| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine.parser; | 4 library engine.parser; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'instrumentation.dart'; | 8 import 'instrumentation.dart'; |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'source.dart'; | 10 import 'source.dart'; |
| (...skipping 3429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3440 * not given | 3440 * not given |
| 3441 * @return the class declaration that was parsed | 3441 * @return the class declaration that was parsed |
| 3442 */ | 3442 */ |
| 3443 CompilationUnitMember parseClassDeclaration(CommentAndMetadata commentAndMetad
ata, Token abstractKeyword) { | 3443 CompilationUnitMember parseClassDeclaration(CommentAndMetadata commentAndMetad
ata, Token abstractKeyword) { |
| 3444 Token keyword = expect(Keyword.CLASS); | 3444 Token keyword = expect(Keyword.CLASS); |
| 3445 if (matchesIdentifier()) { | 3445 if (matchesIdentifier()) { |
| 3446 Token next = peek(); | 3446 Token next = peek(); |
| 3447 if (matches4(next, TokenType.LT)) { | 3447 if (matches4(next, TokenType.LT)) { |
| 3448 next = skipTypeParameterList(next); | 3448 next = skipTypeParameterList(next); |
| 3449 if (next != null && matches4(next, TokenType.EQ)) { | 3449 if (next != null && matches4(next, TokenType.EQ)) { |
| 3450 return parseClassTypeAlias(commentAndMetadata, keyword); | 3450 return parseClassTypeAlias(commentAndMetadata, abstractKeyword, keywor
d); |
| 3451 } | 3451 } |
| 3452 } else if (matches4(next, TokenType.EQ)) { | 3452 } else if (matches4(next, TokenType.EQ)) { |
| 3453 return parseClassTypeAlias(commentAndMetadata, keyword); | 3453 return parseClassTypeAlias(commentAndMetadata, abstractKeyword, keyword)
; |
| 3454 } | 3454 } |
| 3455 } | 3455 } |
| 3456 SimpleIdentifier name = parseSimpleIdentifier(); | 3456 SimpleIdentifier name = parseSimpleIdentifier(); |
| 3457 String className = name.name; | 3457 String className = name.name; |
| 3458 TypeParameterList typeParameters = null; | 3458 TypeParameterList typeParameters = null; |
| 3459 if (matches5(TokenType.LT)) { | 3459 if (matches5(TokenType.LT)) { |
| 3460 typeParameters = parseTypeParameterList(); | 3460 typeParameters = parseTypeParameterList(); |
| 3461 } | 3461 } |
| 3462 ExtendsClause extendsClause = null; | 3462 ExtendsClause extendsClause = null; |
| 3463 WithClause withClause = null; | 3463 WithClause withClause = null; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3561 * | 3561 * |
| 3562 * <pre> | 3562 * <pre> |
| 3563 * classTypeAlias ::= | 3563 * classTypeAlias ::= |
| 3564 * identifier typeParameters? '=' 'abstract'? mixinApplication | 3564 * identifier typeParameters? '=' 'abstract'? mixinApplication |
| 3565 * | 3565 * |
| 3566 * mixinApplication ::= | 3566 * mixinApplication ::= |
| 3567 * type withClause implementsClause? ';' | 3567 * type withClause implementsClause? ';' |
| 3568 * </pre> | 3568 * </pre> |
| 3569 * | 3569 * |
| 3570 * @param commentAndMetadata the metadata to be associated with the member | 3570 * @param commentAndMetadata the metadata to be associated with the member |
| 3571 * @param keyword the token representing the 'typedef' keyword | 3571 * @param abstractKeyword the token representing the 'abstract' keyword |
| 3572 * @param classKeyword the token representing the 'class' keyword |
| 3572 * @return the class type alias that was parsed | 3573 * @return the class type alias that was parsed |
| 3573 */ | 3574 */ |
| 3574 ClassTypeAlias parseClassTypeAlias(CommentAndMetadata commentAndMetadata, Toke
n keyword) { | 3575 ClassTypeAlias parseClassTypeAlias(CommentAndMetadata commentAndMetadata, Toke
n abstractKeyword, Token classKeyword) { |
| 3575 SimpleIdentifier className = parseSimpleIdentifier(); | 3576 SimpleIdentifier className = parseSimpleIdentifier(); |
| 3576 TypeParameterList typeParameters = null; | 3577 TypeParameterList typeParameters = null; |
| 3577 if (matches5(TokenType.LT)) { | 3578 if (matches5(TokenType.LT)) { |
| 3578 typeParameters = parseTypeParameterList(); | 3579 typeParameters = parseTypeParameterList(); |
| 3579 } | 3580 } |
| 3580 Token equals = expect2(TokenType.EQ); | 3581 Token equals = expect2(TokenType.EQ); |
| 3581 Token abstractKeyword = null; | |
| 3582 if (matches(Keyword.ABSTRACT)) { | 3582 if (matches(Keyword.ABSTRACT)) { |
| 3583 abstractKeyword = andAdvance; | 3583 abstractKeyword = andAdvance; |
| 3584 } | 3584 } |
| 3585 TypeName superclass = parseTypeName(); | 3585 TypeName superclass = parseTypeName(); |
| 3586 WithClause withClause = null; | 3586 WithClause withClause = null; |
| 3587 if (matches(Keyword.WITH)) { | 3587 if (matches(Keyword.WITH)) { |
| 3588 withClause = parseWithClause(); | 3588 withClause = parseWithClause(); |
| 3589 } | 3589 } |
| 3590 ImplementsClause implementsClause = null; | 3590 ImplementsClause implementsClause = null; |
| 3591 if (matches(Keyword.IMPLEMENTS)) { | 3591 if (matches(Keyword.IMPLEMENTS)) { |
| 3592 implementsClause = parseImplementsClause(); | 3592 implementsClause = parseImplementsClause(); |
| 3593 } | 3593 } |
| 3594 Token semicolon; | 3594 Token semicolon; |
| 3595 if (matches5(TokenType.SEMICOLON)) { | 3595 if (matches5(TokenType.SEMICOLON)) { |
| 3596 semicolon = andAdvance; | 3596 semicolon = andAdvance; |
| 3597 } else { | 3597 } else { |
| 3598 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { | 3598 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { |
| 3599 reportError10(ParserErrorCode.EXPECTED_TOKEN, [TokenType.SEMICOLON.lexem
e]); | 3599 reportError10(ParserErrorCode.EXPECTED_TOKEN, [TokenType.SEMICOLON.lexem
e]); |
| 3600 Token leftBracket = andAdvance; | 3600 Token leftBracket = andAdvance; |
| 3601 parseClassMembers(className.name, getEndToken(leftBracket)); | 3601 parseClassMembers(className.name, getEndToken(leftBracket)); |
| 3602 expect2(TokenType.CLOSE_CURLY_BRACKET); | 3602 expect2(TokenType.CLOSE_CURLY_BRACKET); |
| 3603 } else { | 3603 } else { |
| 3604 reportError11(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [T
okenType.SEMICOLON.lexeme]); | 3604 reportError11(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [T
okenType.SEMICOLON.lexeme]); |
| 3605 } | 3605 } |
| 3606 semicolon = createSyntheticToken2(TokenType.SEMICOLON); | 3606 semicolon = createSyntheticToken2(TokenType.SEMICOLON); |
| 3607 } | 3607 } |
| 3608 return new ClassTypeAlias(commentAndMetadata.comment, commentAndMetadata.met
adata, keyword, className, typeParameters, equals, abstractKeyword, superclass,
withClause, implementsClause, semicolon); | 3608 return new ClassTypeAlias(commentAndMetadata.comment, commentAndMetadata.met
adata, classKeyword, className, typeParameters, equals, abstractKeyword, supercl
ass, withClause, implementsClause, semicolon); |
| 3609 } | 3609 } |
| 3610 | 3610 |
| 3611 /** | 3611 /** |
| 3612 * Parse a list of combinators in a directive. | 3612 * Parse a list of combinators in a directive. |
| 3613 * | 3613 * |
| 3614 * <pre> | 3614 * <pre> |
| 3615 * combinator ::= | 3615 * combinator ::= |
| 3616 * 'show' identifier (',' identifier)* | 3616 * 'show' identifier (',' identifier)* |
| 3617 * | 'hide' identifier (',' identifier)* | 3617 * | 'hide' identifier (',' identifier)* |
| 3618 * </pre> | 3618 * </pre> |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3786 if (matches(Keyword.CLASS)) { | 3786 if (matches(Keyword.CLASS)) { |
| 3787 return parseClassDeclaration(commentAndMetadata, validateModifiersForClass
(modifiers)); | 3787 return parseClassDeclaration(commentAndMetadata, validateModifiersForClass
(modifiers)); |
| 3788 } else if (matches(Keyword.TYPEDEF) && !matches4(peek(), TokenType.PERIOD) &
& !matches4(peek(), TokenType.LT) && !matches4(peek(), TokenType.OPEN_PAREN)) { | 3788 } else if (matches(Keyword.TYPEDEF) && !matches4(peek(), TokenType.PERIOD) &
& !matches4(peek(), TokenType.LT) && !matches4(peek(), TokenType.OPEN_PAREN)) { |
| 3789 validateModifiersForTypedef(modifiers); | 3789 validateModifiersForTypedef(modifiers); |
| 3790 return parseTypeAlias(commentAndMetadata); | 3790 return parseTypeAlias(commentAndMetadata); |
| 3791 } | 3791 } |
| 3792 if (matches(Keyword.VOID)) { | 3792 if (matches(Keyword.VOID)) { |
| 3793 TypeName returnType = parseReturnType(); | 3793 TypeName returnType = parseReturnType(); |
| 3794 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p
eek())) { | 3794 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p
eek())) { |
| 3795 validateModifiersForTopLevelFunction(modifiers); | 3795 validateModifiersForTopLevelFunction(modifiers); |
| 3796 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null); | 3796 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, returnType); |
| 3797 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { | 3797 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { |
| 3798 reportError11(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []); | 3798 reportError11(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []); |
| 3799 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, mo
difiers.externalKeyword, returnType)); | 3799 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, mo
difiers.externalKeyword, returnType)); |
| 3800 } else if (matchesIdentifier() && matchesAny(peek(), [ | 3800 } else if (matchesIdentifier() && matchesAny(peek(), [ |
| 3801 TokenType.OPEN_PAREN, | 3801 TokenType.OPEN_PAREN, |
| 3802 TokenType.OPEN_CURLY_BRACKET, | 3802 TokenType.OPEN_CURLY_BRACKET, |
| 3803 TokenType.FUNCTION])) { | 3803 TokenType.FUNCTION])) { |
| 3804 validateModifiersForTopLevelFunction(modifiers); | 3804 validateModifiersForTopLevelFunction(modifiers); |
| 3805 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, returnType); | 3805 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, returnType); |
| 3806 } else { | 3806 } else { |
| (...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5835 * @param commentAndMetadata the metadata to be associated with the member | 5835 * @param commentAndMetadata the metadata to be associated with the member |
| 5836 * @return the type alias that was parsed | 5836 * @return the type alias that was parsed |
| 5837 */ | 5837 */ |
| 5838 TypeAlias parseTypeAlias(CommentAndMetadata commentAndMetadata) { | 5838 TypeAlias parseTypeAlias(CommentAndMetadata commentAndMetadata) { |
| 5839 Token keyword = expect(Keyword.TYPEDEF); | 5839 Token keyword = expect(Keyword.TYPEDEF); |
| 5840 if (matchesIdentifier()) { | 5840 if (matchesIdentifier()) { |
| 5841 Token next = peek(); | 5841 Token next = peek(); |
| 5842 if (matches4(next, TokenType.LT)) { | 5842 if (matches4(next, TokenType.LT)) { |
| 5843 next = skipTypeParameterList(next); | 5843 next = skipTypeParameterList(next); |
| 5844 if (next != null && matches4(next, TokenType.EQ)) { | 5844 if (next != null && matches4(next, TokenType.EQ)) { |
| 5845 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword)
; | 5845 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, null, ke
yword); |
| 5846 reportError11(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []
); | 5846 reportError11(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []
); |
| 5847 return typeAlias; | 5847 return typeAlias; |
| 5848 } | 5848 } |
| 5849 } else if (matches4(next, TokenType.EQ)) { | 5849 } else if (matches4(next, TokenType.EQ)) { |
| 5850 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword); | 5850 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, null, keyw
ord); |
| 5851 reportError11(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []); | 5851 reportError11(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []); |
| 5852 return typeAlias; | 5852 return typeAlias; |
| 5853 } | 5853 } |
| 5854 } | 5854 } |
| 5855 return parseFunctionTypeAlias(commentAndMetadata, keyword); | 5855 return parseFunctionTypeAlias(commentAndMetadata, keyword); |
| 5856 } | 5856 } |
| 5857 | 5857 |
| 5858 /** | 5858 /** |
| 5859 * Parse a unary expression. | 5859 * Parse a unary expression. |
| 5860 * | 5860 * |
| (...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7333 | 7333 |
| 7334 /** | 7334 /** |
| 7335 * The template used to create the message to be displayed for this error. | 7335 * The template used to create the message to be displayed for this error. |
| 7336 */ | 7336 */ |
| 7337 String _message; | 7337 String _message; |
| 7338 | 7338 |
| 7339 /** | 7339 /** |
| 7340 * The template used to create the correction to be displayed for this error,
or `null` if | 7340 * The template used to create the correction to be displayed for this error,
or `null` if |
| 7341 * there is no correction information for this error. | 7341 * there is no correction information for this error. |
| 7342 */ | 7342 */ |
| 7343 String correction8; | 7343 String correction9; |
| 7344 | 7344 |
| 7345 /** | 7345 /** |
| 7346 * Initialize a newly created error code to have the given severity and messag
e. | 7346 * Initialize a newly created error code to have the given severity and messag
e. |
| 7347 * | 7347 * |
| 7348 * @param severity the severity of the error | 7348 * @param severity the severity of the error |
| 7349 * @param message the message template used to create the message to be displa
yed for the error | 7349 * @param message the message template used to create the message to be displa
yed for the error |
| 7350 */ | 7350 */ |
| 7351 ParserErrorCode.con1(String name, int ordinal, ErrorSeverity severity, String
message) : super(name, ordinal) { | 7351 ParserErrorCode.con1(String name, int ordinal, ErrorSeverity severity, String
message) : super(name, ordinal) { |
| 7352 this._severity = severity; | 7352 this._severity = severity; |
| 7353 this._message = message; | 7353 this._message = message; |
| 7354 } | 7354 } |
| 7355 | 7355 |
| 7356 /** | 7356 /** |
| 7357 * Initialize a newly created error code to have the given severity, message a
nd correction. | 7357 * Initialize a newly created error code to have the given severity, message a
nd correction. |
| 7358 * | 7358 * |
| 7359 * @param severity the severity of the error | 7359 * @param severity the severity of the error |
| 7360 * @param message the template used to create the message to be displayed for
the error | 7360 * @param message the template used to create the message to be displayed for
the error |
| 7361 * @param correction the template used to create the correction to be displaye
d for the error | 7361 * @param correction the template used to create the correction to be displaye
d for the error |
| 7362 */ | 7362 */ |
| 7363 ParserErrorCode.con2(String name, int ordinal, ErrorSeverity severity, String
message, String correction) : super(name, ordinal) { | 7363 ParserErrorCode.con2(String name, int ordinal, ErrorSeverity severity, String
message, String correction) : super(name, ordinal) { |
| 7364 this._severity = severity; | 7364 this._severity = severity; |
| 7365 this._message = message; | 7365 this._message = message; |
| 7366 this.correction8 = correction; | 7366 this.correction9 = correction; |
| 7367 } | 7367 } |
| 7368 | 7368 |
| 7369 /** | 7369 /** |
| 7370 * Initialize a newly created error code to have the given message and a sever
ity of ERROR. | 7370 * Initialize a newly created error code to have the given message and a sever
ity of ERROR. |
| 7371 * | 7371 * |
| 7372 * @param message the message template used to create the message to be displa
yed for the error | 7372 * @param message the message template used to create the message to be displa
yed for the error |
| 7373 */ | 7373 */ |
| 7374 ParserErrorCode.con3(String name, int ordinal, String message) : this.con1(nam
e, ordinal, ErrorSeverity.ERROR, message); | 7374 ParserErrorCode.con3(String name, int ordinal, String message) : this.con1(nam
e, ordinal, ErrorSeverity.ERROR, message); |
| 7375 | 7375 |
| 7376 String get correction => correction8; | 7376 String get correction => correction9; |
| 7377 | 7377 |
| 7378 ErrorSeverity get errorSeverity => _severity; | 7378 ErrorSeverity get errorSeverity => _severity; |
| 7379 | 7379 |
| 7380 String get message => _message; | 7380 String get message => _message; |
| 7381 | 7381 |
| 7382 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 7382 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 7383 } | 7383 } |
| 7384 | 7384 |
| 7385 /** | 7385 /** |
| 7386 * Instances of the class `ResolutionCopier` copies resolution information from
one AST | 7386 * Instances of the class `ResolutionCopier` copies resolution information from
one AST |
| (...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9296 if ("\n" == separator) { | 9296 if ("\n" == separator) { |
| 9297 _writer.print("\n"); | 9297 _writer.print("\n"); |
| 9298 indent(); | 9298 indent(); |
| 9299 } else if (i > 0) { | 9299 } else if (i > 0) { |
| 9300 _writer.print(separator); | 9300 _writer.print(separator); |
| 9301 } | 9301 } |
| 9302 _writer.print(tokens[i].lexeme); | 9302 _writer.print(tokens[i].lexeme); |
| 9303 } | 9303 } |
| 9304 } | 9304 } |
| 9305 } | 9305 } |
| OLD | NEW |