| 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 analyzer.src.generated.parser; | 5 library analyzer.src.generated.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 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 4339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4350 return new ArgumentList(_createSyntheticToken(TokenType.OPEN_PAREN), null, | 4350 return new ArgumentList(_createSyntheticToken(TokenType.OPEN_PAREN), null, |
| 4351 _createSyntheticToken(TokenType.CLOSE_PAREN)); | 4351 _createSyntheticToken(TokenType.CLOSE_PAREN)); |
| 4352 } | 4352 } |
| 4353 | 4353 |
| 4354 /** | 4354 /** |
| 4355 * Parse an assert statement. Return the assert statement. | 4355 * Parse an assert statement. Return the assert statement. |
| 4356 * | 4356 * |
| 4357 * This method assumes that the current token matches `Keyword.ASSERT`. | 4357 * This method assumes that the current token matches `Keyword.ASSERT`. |
| 4358 * | 4358 * |
| 4359 * assertStatement ::= | 4359 * assertStatement ::= |
| 4360 * 'assert' '(' conditionalExpression ')' ';' | 4360 * 'assert' '(' expression [',' expression] ')' ';' |
| 4361 */ | 4361 */ |
| 4362 AssertStatement _parseAssertStatement() { | 4362 AssertStatement _parseAssertStatement() { |
| 4363 Token keyword = getAndAdvance(); | 4363 Token keyword = getAndAdvance(); |
| 4364 Token leftParen = _expect(TokenType.OPEN_PAREN); | 4364 Token leftParen = _expect(TokenType.OPEN_PAREN); |
| 4365 Expression expression = parseExpression2(); | 4365 Expression expression = parseExpression2(); |
| 4366 if (expression is AssignmentExpression) { | |
| 4367 _reportErrorForNode( | |
| 4368 ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expression); | |
| 4369 } else if (expression is CascadeExpression) { | |
| 4370 _reportErrorForNode( | |
| 4371 ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression); | |
| 4372 } else if (expression is ThrowExpression) { | |
| 4373 _reportErrorForNode( | |
| 4374 ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression); | |
| 4375 } else if (expression is RethrowExpression) { | |
| 4376 _reportErrorForNode( | |
| 4377 ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression); | |
| 4378 } | |
| 4379 Token comma; | 4366 Token comma; |
| 4380 Expression message; | 4367 Expression message; |
| 4381 if (_matches(TokenType.COMMA)) { | 4368 if (_matches(TokenType.COMMA)) { |
| 4382 comma = getAndAdvance(); | 4369 comma = getAndAdvance(); |
| 4383 message = parseExpression2(); | 4370 message = parseExpression2(); |
| 4384 } | 4371 } |
| 4385 Token rightParen = _expect(TokenType.CLOSE_PAREN); | 4372 Token rightParen = _expect(TokenType.CLOSE_PAREN); |
| 4386 Token semicolon = _expect(TokenType.SEMICOLON); | 4373 Token semicolon = _expect(TokenType.SEMICOLON); |
| 4387 return new AssertStatement( | 4374 return new AssertStatement( |
| 4388 keyword, leftParen, expression, comma, message, rightParen, semicolon); | 4375 keyword, leftParen, expression, comma, message, rightParen, semicolon); |
| (...skipping 5500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9889 const ParserErrorCode('ABSTRACT_TOP_LEVEL_VARIABLE', | 9876 const ParserErrorCode('ABSTRACT_TOP_LEVEL_VARIABLE', |
| 9890 "Top-level variables cannot be declared to be 'abstract'"); | 9877 "Top-level variables cannot be declared to be 'abstract'"); |
| 9891 | 9878 |
| 9892 static const ParserErrorCode ABSTRACT_TYPEDEF = const ParserErrorCode( | 9879 static const ParserErrorCode ABSTRACT_TYPEDEF = const ParserErrorCode( |
| 9893 'ABSTRACT_TYPEDEF', "Type aliases cannot be declared to be 'abstract'"); | 9880 'ABSTRACT_TYPEDEF', "Type aliases cannot be declared to be 'abstract'"); |
| 9894 | 9881 |
| 9895 static const ParserErrorCode ANNOTATION_ON_ENUM_CONSTANT = | 9882 static const ParserErrorCode ANNOTATION_ON_ENUM_CONSTANT = |
| 9896 const ParserErrorCode('ANNOTATION_ON_ENUM_CONSTANT', | 9883 const ParserErrorCode('ANNOTATION_ON_ENUM_CONSTANT', |
| 9897 "Enum constants cannot have annotations"); | 9884 "Enum constants cannot have annotations"); |
| 9898 | 9885 |
| 9899 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_ASSIGNMENT = | |
| 9900 const ParserErrorCode('ASSERT_DOES_NOT_TAKE_ASSIGNMENT', | |
| 9901 "Assert cannot be called on an assignment"); | |
| 9902 | |
| 9903 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_CASCADE = | |
| 9904 const ParserErrorCode( | |
| 9905 'ASSERT_DOES_NOT_TAKE_CASCADE', "Assert cannot be called on cascade"); | |
| 9906 | |
| 9907 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_THROW = | |
| 9908 const ParserErrorCode( | |
| 9909 'ASSERT_DOES_NOT_TAKE_THROW', "Assert cannot be called on throws"); | |
| 9910 | |
| 9911 static const ParserErrorCode ASSERT_DOES_NOT_TAKE_RETHROW = | |
| 9912 const ParserErrorCode('ASSERT_DOES_NOT_TAKE_RETHROW', | |
| 9913 "Assert cannot be called on rethrows"); | |
| 9914 | |
| 9915 /** | 9886 /** |
| 9916 * 16.32 Identifier Reference: It is a compile-time error if any of the | 9887 * 16.32 Identifier Reference: It is a compile-time error if any of the |
| 9917 * identifiers async, await, or yield is used as an identifier in a function | 9888 * identifiers async, await, or yield is used as an identifier in a function |
| 9918 * body marked with either async, async*, or sync*. | 9889 * body marked with either async, async*, or sync*. |
| 9919 */ | 9890 */ |
| 9920 static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER = | 9891 static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER = |
| 9921 const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER', | 9892 const ParserErrorCode('ASYNC_KEYWORD_USED_AS_IDENTIFIER', |
| 9922 "The keywords 'async', 'await', and 'yield' may not be used as identif
iers in an asynchronous or generator function."); | 9893 "The keywords 'async', 'await', and 'yield' may not be used as identif
iers in an asynchronous or generator function."); |
| 9923 | 9894 |
| 9924 /** | 9895 /** |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10478 */ | 10449 */ |
| 10479 const ParserErrorCode(String name, String message, [String correction]) | 10450 const ParserErrorCode(String name, String message, [String correction]) |
| 10480 : super(name, message, correction); | 10451 : super(name, message, correction); |
| 10481 | 10452 |
| 10482 @override | 10453 @override |
| 10483 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; | 10454 ErrorSeverity get errorSeverity => ErrorSeverity.ERROR; |
| 10484 | 10455 |
| 10485 @override | 10456 @override |
| 10486 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 10457 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 10487 } | 10458 } |
| OLD | NEW |