| 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 library engine.parser; | 3 library engine.parser; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
| 6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
| 7 import 'instrumentation.dart'; | 7 import 'instrumentation.dart'; |
| 8 import 'error.dart'; | 8 import 'error.dart'; |
| 9 import 'source.dart'; | 9 import 'source.dart'; |
| 10 import 'scanner.dart'; | 10 import 'scanner.dart'; |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 if (next == null) { | 650 if (next == null) { |
| 651 return false; | 651 return false; |
| 652 } | 652 } |
| 653 return matchesIdentifier2(next); | 653 return matchesIdentifier2(next); |
| 654 } | 654 } |
| 655 | 655 |
| 656 /** | 656 /** |
| 657 * Return `true` if the current token appears to be the beginning of a functio
n declaration. | 657 * Return `true` if the current token appears to be the beginning of a functio
n declaration. |
| 658 * @return `true` if the current token appears to be the beginning of a functi
on declaration | 658 * @return `true` if the current token appears to be the beginning of a functi
on declaration |
| 659 */ | 659 */ |
| 660 bool get isFunctionDeclaration { | 660 bool isFunctionDeclaration() { |
| 661 if (matches(Keyword.VOID)) { | 661 if (matches(Keyword.VOID)) { |
| 662 return true; | 662 return true; |
| 663 } | 663 } |
| 664 Token afterReturnType = skipTypeName(_currentToken); | 664 Token afterReturnType = skipTypeName(_currentToken); |
| 665 if (afterReturnType == null) { | 665 if (afterReturnType == null) { |
| 666 afterReturnType = _currentToken; | 666 afterReturnType = _currentToken; |
| 667 } | 667 } |
| 668 Token afterIdentifier = skipSimpleIdentifier(afterReturnType); | 668 Token afterIdentifier = skipSimpleIdentifier(afterReturnType); |
| 669 if (afterIdentifier == null) { | 669 if (afterIdentifier == null) { |
| 670 afterIdentifier = skipSimpleIdentifier(_currentToken); | 670 afterIdentifier = skipSimpleIdentifier(_currentToken); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 * | 'var' | 710 * | 'var' |
| 711 * | type | 711 * | type |
| 712 * type ::= | 712 * type ::= |
| 713 * qualified typeArguments? | 713 * qualified typeArguments? |
| 714 * initializedIdentifier ::= | 714 * initializedIdentifier ::= |
| 715 * identifier ('=' expression)? | 715 * identifier ('=' expression)? |
| 716 * </pre> | 716 * </pre> |
| 717 * @return `true` if the current token is the first token in an initialized va
riable | 717 * @return `true` if the current token is the first token in an initialized va
riable |
| 718 * declaration | 718 * declaration |
| 719 */ | 719 */ |
| 720 bool get isInitializedVariableDeclaration { | 720 bool isInitializedVariableDeclaration() { |
| 721 if (matches(Keyword.FINAL) || matches(Keyword.VAR)) { | 721 if (matches(Keyword.FINAL) || matches(Keyword.VAR)) { |
| 722 return true; | 722 return true; |
| 723 } | 723 } |
| 724 if (matches(Keyword.CONST)) { | 724 if (matches(Keyword.CONST)) { |
| 725 return !matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, To
kenType.OPEN_SQUARE_BRACKET, TokenType.INDEX]); | 725 return !matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, To
kenType.OPEN_SQUARE_BRACKET, TokenType.INDEX]); |
| 726 } | 726 } |
| 727 Token token = skipTypeName(_currentToken); | 727 Token token = skipTypeName(_currentToken); |
| 728 if (token == null) { | 728 if (token == null) { |
| 729 return false; | 729 return false; |
| 730 } | 730 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 } | 780 } |
| 781 return matches4(token, TokenType.OPEN_PAREN); | 781 return matches4(token, TokenType.OPEN_PAREN); |
| 782 } | 782 } |
| 783 return false; | 783 return false; |
| 784 } | 784 } |
| 785 | 785 |
| 786 /** | 786 /** |
| 787 * Return `true` if the current token appears to be the beginning of a switch
member. | 787 * Return `true` if the current token appears to be the beginning of a switch
member. |
| 788 * @return `true` if the current token appears to be the beginning of a switch
member | 788 * @return `true` if the current token appears to be the beginning of a switch
member |
| 789 */ | 789 */ |
| 790 bool get isSwitchMember { | 790 bool isSwitchMember() { |
| 791 Token token = _currentToken; | 791 Token token = _currentToken; |
| 792 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy
pe.COLON)) { | 792 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy
pe.COLON)) { |
| 793 token = token.next.next; | 793 token = token.next.next; |
| 794 } | 794 } |
| 795 if (identical(token.type, TokenType.KEYWORD)) { | 795 if (identical(token.type, TokenType.KEYWORD)) { |
| 796 Keyword keyword = ((token as KeywordToken)).keyword; | 796 Keyword keyword = ((token as KeywordToken)).keyword; |
| 797 return identical(keyword, Keyword.CASE) || identical(keyword, Keyword.DEFA
ULT); | 797 return identical(keyword, Keyword.CASE) || identical(keyword, Keyword.DEFA
ULT); |
| 798 } | 798 } |
| 799 return false; | 799 return false; |
| 800 } | 800 } |
| (...skipping 1740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2541 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); | 2541 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); |
| 2542 VariableDeclarationList variableList = null; | 2542 VariableDeclarationList variableList = null; |
| 2543 Expression initialization = null; | 2543 Expression initialization = null; |
| 2544 if (!matches5(TokenType.SEMICOLON)) { | 2544 if (!matches5(TokenType.SEMICOLON)) { |
| 2545 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 2545 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 2546 if (matchesIdentifier() && matches3(peek(), Keyword.IN)) { | 2546 if (matchesIdentifier() && matches3(peek(), Keyword.IN)) { |
| 2547 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 2547 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
| 2548 SimpleIdentifier variableName = parseSimpleIdentifier(); | 2548 SimpleIdentifier variableName = parseSimpleIdentifier(); |
| 2549 variables.add(new VariableDeclaration.full(null, null, variableName, n
ull, null)); | 2549 variables.add(new VariableDeclaration.full(null, null, variableName, n
ull, null)); |
| 2550 variableList = new VariableDeclarationList.full(commentAndMetadata.com
ment, commentAndMetadata.metadata, null, null, variables); | 2550 variableList = new VariableDeclarationList.full(commentAndMetadata.com
ment, commentAndMetadata.metadata, null, null, variables); |
| 2551 } else if (isInitializedVariableDeclaration) { | 2551 } else if (isInitializedVariableDeclaration()) { |
| 2552 variableList = parseVariableDeclarationList(commentAndMetadata); | 2552 variableList = parseVariableDeclarationList(commentAndMetadata); |
| 2553 } else { | 2553 } else { |
| 2554 initialization = parseExpression2(); | 2554 initialization = parseExpression2(); |
| 2555 } | 2555 } |
| 2556 if (matches(Keyword.IN)) { | 2556 if (matches(Keyword.IN)) { |
| 2557 DeclaredIdentifier loopVariable = null; | 2557 DeclaredIdentifier loopVariable = null; |
| 2558 if (variableList == null) { | 2558 if (variableList == null) { |
| 2559 reportError7(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); | 2559 reportError7(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); |
| 2560 } else { | 2560 } else { |
| 2561 NodeList<VariableDeclaration> variables = variableList.variables; | 2561 NodeList<VariableDeclaration> variables = variableList.variables; |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3369 } | 3369 } |
| 3370 return parseVariableDeclarationStatement(commentAndMetadata); | 3370 return parseVariableDeclarationStatement(commentAndMetadata); |
| 3371 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T
RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) ||
identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) { | 3371 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T
RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) ||
identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) { |
| 3372 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp
e.SEMICOLON)); | 3372 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp
e.SEMICOLON)); |
| 3373 } else { | 3373 } else { |
| 3374 reportError7(ParserErrorCode.MISSING_STATEMENT, []); | 3374 reportError7(ParserErrorCode.MISSING_STATEMENT, []); |
| 3375 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON
)); | 3375 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON
)); |
| 3376 } | 3376 } |
| 3377 } else if (matches5(TokenType.SEMICOLON)) { | 3377 } else if (matches5(TokenType.SEMICOLON)) { |
| 3378 return parseEmptyStatement(); | 3378 return parseEmptyStatement(); |
| 3379 } else if (isInitializedVariableDeclaration) { | 3379 } else if (isInitializedVariableDeclaration()) { |
| 3380 return parseVariableDeclarationStatement(commentAndMetadata); | 3380 return parseVariableDeclarationStatement(commentAndMetadata); |
| 3381 } else if (isFunctionDeclaration) { | 3381 } else if (isFunctionDeclaration()) { |
| 3382 return parseFunctionDeclarationStatement(); | 3382 return parseFunctionDeclarationStatement(); |
| 3383 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { | 3383 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { |
| 3384 reportError7(ParserErrorCode.MISSING_STATEMENT, []); | 3384 reportError7(ParserErrorCode.MISSING_STATEMENT, []); |
| 3385 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON))
; | 3385 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON))
; |
| 3386 } else { | 3386 } else { |
| 3387 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType.
SEMICOLON)); | 3387 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType.
SEMICOLON)); |
| 3388 } | 3388 } |
| 3389 } | 3389 } |
| 3390 | 3390 |
| 3391 /** | 3391 /** |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3855 * Parse a list of statements within a switch statement. | 3855 * Parse a list of statements within a switch statement. |
| 3856 * <pre> | 3856 * <pre> |
| 3857 * statements ::= | 3857 * statements ::= |
| 3858 * statement | 3858 * statement |
| 3859 * </pre> | 3859 * </pre> |
| 3860 * @return the statements that were parsed | 3860 * @return the statements that were parsed |
| 3861 */ | 3861 */ |
| 3862 List<Statement> parseStatements2() { | 3862 List<Statement> parseStatements2() { |
| 3863 List<Statement> statements = new List<Statement>(); | 3863 List<Statement> statements = new List<Statement>(); |
| 3864 Token statementStart = _currentToken; | 3864 Token statementStart = _currentToken; |
| 3865 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)
&& !isSwitchMember) { | 3865 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)
&& !isSwitchMember()) { |
| 3866 statements.add(parseStatement2()); | 3866 statements.add(parseStatement2()); |
| 3867 if (identical(_currentToken, statementStart)) { | 3867 if (identical(_currentToken, statementStart)) { |
| 3868 reportError8(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | 3868 reportError8(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 3869 advance(); | 3869 advance(); |
| 3870 } | 3870 } |
| 3871 statementStart = _currentToken; | 3871 statementStart = _currentToken; |
| 3872 } | 3872 } |
| 3873 return statements; | 3873 return statements; |
| 3874 } | 3874 } |
| 3875 | 3875 |
| (...skipping 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6262 for (int i = 0; i < size; i++) { | 6262 for (int i = 0; i < size; i++) { |
| 6263 if (i > 0) { | 6263 if (i > 0) { |
| 6264 _writer.print(separator); | 6264 _writer.print(separator); |
| 6265 } | 6265 } |
| 6266 nodes[i].accept(this); | 6266 nodes[i].accept(this); |
| 6267 } | 6267 } |
| 6268 } | 6268 } |
| 6269 } | 6269 } |
| 6270 } | 6270 } |
| 6271 } | 6271 } |
| OLD | NEW |