| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library engine.parser; | 5 library engine.parser; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import "dart:math" as math; | 8 import "dart:math" as math; |
| 9 | 9 |
| 10 import 'ast.dart'; | 10 import 'ast.dart'; |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 return _parser.parseTypeName(); | 567 return _parser.parseTypeName(); |
| 568 } | 568 } |
| 569 return _notAChild(node); | 569 return _notAChild(node); |
| 570 } | 570 } |
| 571 | 571 |
| 572 @override | 572 @override |
| 573 AstNode visitAssertStatement(AssertStatement node) { | 573 AstNode visitAssertStatement(AssertStatement node) { |
| 574 if (identical(_oldNode, node.condition)) { | 574 if (identical(_oldNode, node.condition)) { |
| 575 return _parser.parseExpression2(); | 575 return _parser.parseExpression2(); |
| 576 } | 576 } |
| 577 if (identical(_oldNode, node.message)) { |
| 578 return _parser.parseExpression2(); |
| 579 } |
| 577 return _notAChild(node); | 580 return _notAChild(node); |
| 578 } | 581 } |
| 579 | 582 |
| 580 @override | 583 @override |
| 581 AstNode visitAssignmentExpression(AssignmentExpression node) { | 584 AstNode visitAssignmentExpression(AssignmentExpression node) { |
| 582 if (identical(_oldNode, node.leftHandSide)) { | 585 if (identical(_oldNode, node.leftHandSide)) { |
| 583 // TODO(brianwilkerson) If the assignment is part of a cascade section, | 586 // TODO(brianwilkerson) If the assignment is part of a cascade section, |
| 584 // then we don't have a single parse method that will work. | 587 // then we don't have a single parse method that will work. |
| 585 // Otherwise, we can parse a conditional expression, but need to ensure | 588 // Otherwise, we can parse a conditional expression, but need to ensure |
| 586 // that the resulting expression is assignable. | 589 // that the resulting expression is assignable. |
| (...skipping 3784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4371 } else if (expression is CascadeExpression) { | 4374 } else if (expression is CascadeExpression) { |
| 4372 _reportErrorForNode( | 4375 _reportErrorForNode( |
| 4373 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression); | 4376 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression); |
| 4374 } else if (expression is ThrowExpression) { | 4377 } else if (expression is ThrowExpression) { |
| 4375 _reportErrorForNode( | 4378 _reportErrorForNode( |
| 4376 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression); | 4379 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression); |
| 4377 } else if (expression is RethrowExpression) { | 4380 } else if (expression is RethrowExpression) { |
| 4378 _reportErrorForNode( | 4381 _reportErrorForNode( |
| 4379 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression); | 4382 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression); |
| 4380 } | 4383 } |
| 4384 Token comma; |
| 4385 Expression message; |
| 4386 if (_matches(TokenType.COMMA)) { |
| 4387 comma = getAndAdvance(); |
| 4388 message = parseExpression2(); |
| 4389 } |
| 4381 Token rightParen = _expect(TokenType.CLOSE_PAREN); | 4390 Token rightParen = _expect(TokenType.CLOSE_PAREN); |
| 4382 Token semicolon = _expect(TokenType.SEMICOLON); | 4391 Token semicolon = _expect(TokenType.SEMICOLON); |
| 4383 return new AssertStatement( | 4392 return new AssertStatement( |
| 4384 keyword, leftParen, expression, rightParen, semicolon); | 4393 keyword, leftParen, expression, comma, message, rightParen, semicolon); |
| 4385 } | 4394 } |
| 4386 | 4395 |
| 4387 /** | 4396 /** |
| 4388 * Parse an assignable expression. The [primaryAllowed] is `true` if the | 4397 * Parse an assignable expression. The [primaryAllowed] is `true` if the |
| 4389 * expression is allowed to be a primary without any assignable selector. | 4398 * expression is allowed to be a primary without any assignable selector. |
| 4390 * Return the assignable expression that was parsed. | 4399 * Return the assignable expression that was parsed. |
| 4391 * | 4400 * |
| 4392 * assignableExpression ::= | 4401 * assignableExpression ::= |
| 4393 * primary (arguments* assignableSelector)+ | 4402 * primary (arguments* assignableSelector)+ |
| 4394 * | 'super' unconditionalAssignableSelector | 4403 * | 'super' unconditionalAssignableSelector |
| (...skipping 5460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9855 return false; | 9864 return false; |
| 9856 } | 9865 } |
| 9857 | 9866 |
| 9858 @override | 9867 @override |
| 9859 bool visitAssertStatement(AssertStatement node) { | 9868 bool visitAssertStatement(AssertStatement node) { |
| 9860 AssertStatement toNode = this._toNode as AssertStatement; | 9869 AssertStatement toNode = this._toNode as AssertStatement; |
| 9861 return _and( | 9870 return _and( |
| 9862 _isEqualTokens(node.assertKeyword, toNode.assertKeyword), | 9871 _isEqualTokens(node.assertKeyword, toNode.assertKeyword), |
| 9863 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), | 9872 _isEqualTokens(node.leftParenthesis, toNode.leftParenthesis), |
| 9864 _isEqualNodes(node.condition, toNode.condition), | 9873 _isEqualNodes(node.condition, toNode.condition), |
| 9874 _isEqualTokens(node.comma, toNode.comma), |
| 9875 _isEqualNodes(node.message, toNode.message), |
| 9865 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), | 9876 _isEqualTokens(node.rightParenthesis, toNode.rightParenthesis), |
| 9866 _isEqualTokens(node.semicolon, toNode.semicolon)); | 9877 _isEqualTokens(node.semicolon, toNode.semicolon)); |
| 9867 } | 9878 } |
| 9868 | 9879 |
| 9869 @override | 9880 @override |
| 9870 bool visitAssignmentExpression(AssignmentExpression node) { | 9881 bool visitAssignmentExpression(AssignmentExpression node) { |
| 9871 AssignmentExpression toNode = this._toNode as AssignmentExpression; | 9882 AssignmentExpression toNode = this._toNode as AssignmentExpression; |
| 9872 if (_and( | 9883 if (_and( |
| 9873 _isEqualNodes(node.leftHandSide, toNode.leftHandSide), | 9884 _isEqualNodes(node.leftHandSide, toNode.leftHandSide), |
| 9874 _isEqualTokens(node.operator, toNode.operator), | 9885 _isEqualTokens(node.operator, toNode.operator), |
| (...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11177 } | 11188 } |
| 11178 | 11189 |
| 11179 /** | 11190 /** |
| 11180 * Copy resolution data from the [fromNode] to the [toNode]. | 11191 * Copy resolution data from the [fromNode] to the [toNode]. |
| 11181 */ | 11192 */ |
| 11182 static void copyResolutionData(AstNode fromNode, AstNode toNode) { | 11193 static void copyResolutionData(AstNode fromNode, AstNode toNode) { |
| 11183 ResolutionCopier copier = new ResolutionCopier(); | 11194 ResolutionCopier copier = new ResolutionCopier(); |
| 11184 copier._isEqualNodes(fromNode, toNode); | 11195 copier._isEqualNodes(fromNode, toNode); |
| 11185 } | 11196 } |
| 11186 } | 11197 } |
| OLD | NEW |