| 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 'java_engine.dart'; | 8 import 'java_engine.dart'; |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'source.dart'; | 10 import 'source.dart'; |
| 11 import 'scanner.dart'; | 11 import 'scanner.dart'; |
| 12 import 'ast.dart'; | 12 import 'ast.dart'; |
| 13 import 'package:analyzer-experimental/src/generated/utilities_dart.dart'; | 13 import 'package:analyzer-experimental/src/generated/utilities_dart.dart'; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Instances of the class {@code CommentAndMetadata} implement a simple data-hol
der for a method | 16 * Instances of the class {@code CommentAndMetadata} implement a simple data-hol
der for a method |
| 17 * that needs to return multiple values. | 17 * that needs to return multiple values. |
| 18 * @coverage dart.engine.parser |
| 18 */ | 19 */ |
| 19 class CommentAndMetadata { | 20 class CommentAndMetadata { |
| 20 /** | 21 /** |
| 21 * The documentation comment that was parsed, or {@code null} if none was give
n. | 22 * The documentation comment that was parsed, or {@code null} if none was give
n. |
| 22 */ | 23 */ |
| 23 Comment _comment; | 24 Comment _comment; |
| 24 /** | 25 /** |
| 25 * The metadata that was parsed. | 26 * The metadata that was parsed. |
| 26 */ | 27 */ |
| 27 List<Annotation> _metadata; | 28 List<Annotation> _metadata; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 41 Comment get comment => _comment; | 42 Comment get comment => _comment; |
| 42 /** | 43 /** |
| 43 * Return the metadata that was parsed. If there was no metadata, then the lis
t will be empty. | 44 * Return the metadata that was parsed. If there was no metadata, then the lis
t will be empty. |
| 44 * @return the metadata that was parsed | 45 * @return the metadata that was parsed |
| 45 */ | 46 */ |
| 46 List<Annotation> get metadata => _metadata; | 47 List<Annotation> get metadata => _metadata; |
| 47 } | 48 } |
| 48 /** | 49 /** |
| 49 * Instances of the class {@code FinalConstVarOrType} implement a simple data-ho
lder for a method | 50 * Instances of the class {@code FinalConstVarOrType} implement a simple data-ho
lder for a method |
| 50 * that needs to return multiple values. | 51 * that needs to return multiple values. |
| 52 * @coverage dart.engine.parser |
| 51 */ | 53 */ |
| 52 class FinalConstVarOrType { | 54 class FinalConstVarOrType { |
| 53 /** | 55 /** |
| 54 * The 'final', 'const' or 'var' keyword, or {@code null} if none was given. | 56 * The 'final', 'const' or 'var' keyword, or {@code null} if none was given. |
| 55 */ | 57 */ |
| 56 Token _keyword; | 58 Token _keyword; |
| 57 /** | 59 /** |
| 58 * The type, of {@code null} if no type was specified. | 60 * The type, of {@code null} if no type was specified. |
| 59 */ | 61 */ |
| 60 TypeName _type; | 62 TypeName _type; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 74 Token get keyword => _keyword; | 76 Token get keyword => _keyword; |
| 75 /** | 77 /** |
| 76 * Return the type, of {@code null} if no type was specified. | 78 * Return the type, of {@code null} if no type was specified. |
| 77 * @return the type | 79 * @return the type |
| 78 */ | 80 */ |
| 79 TypeName get type => _type; | 81 TypeName get type => _type; |
| 80 } | 82 } |
| 81 /** | 83 /** |
| 82 * Instances of the class {@code Modifiers} implement a simple data-holder for a
method that needs | 84 * Instances of the class {@code Modifiers} implement a simple data-holder for a
method that needs |
| 83 * to return multiple values. | 85 * to return multiple values. |
| 86 * @coverage dart.engine.parser |
| 84 */ | 87 */ |
| 85 class Modifiers { | 88 class Modifiers { |
| 86 /** | 89 /** |
| 87 * The token representing the keyword 'abstract', or {@code null} if the keywo
rd was not found. | 90 * The token representing the keyword 'abstract', or {@code null} if the keywo
rd was not found. |
| 88 */ | 91 */ |
| 89 Token _abstractKeyword; | 92 Token _abstractKeyword; |
| 90 /** | 93 /** |
| 91 * The token representing the keyword 'const', or {@code null} if the keyword
was not found. | 94 * The token representing the keyword 'const', or {@code null} if the keyword
was not found. |
| 92 */ | 95 */ |
| 93 Token _constKeyword; | 96 Token _constKeyword; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 builder.appendChar(0x20); | 234 builder.appendChar(0x20); |
| 232 } | 235 } |
| 233 builder.append(keyword.lexeme); | 236 builder.append(keyword.lexeme); |
| 234 return true; | 237 return true; |
| 235 } | 238 } |
| 236 return needsSpace; | 239 return needsSpace; |
| 237 } | 240 } |
| 238 } | 241 } |
| 239 /** | 242 /** |
| 240 * Instances of the class {@code Parser} are used to parse tokens into an AST st
ructure. | 243 * Instances of the class {@code Parser} are used to parse tokens into an AST st
ructure. |
| 244 * @coverage dart.engine.parser |
| 241 */ | 245 */ |
| 242 class Parser { | 246 class Parser { |
| 243 /** | 247 /** |
| 244 * The source being parsed. | 248 * The source being parsed. |
| 245 */ | 249 */ |
| 246 Source _source; | 250 Source _source; |
| 247 /** | 251 /** |
| 248 * The error listener that will be informed of any errors that are found durin
g the parse. | 252 * The error listener that will be informed of any errors that are found durin
g the parse. |
| 249 */ | 253 */ |
| 250 AnalysisErrorListener _errorListener; | 254 AnalysisErrorListener _errorListener; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return true; | 534 return true; |
| 531 } | 535 } |
| 532 Token token = skipTypeName(_currentToken); | 536 Token token = skipTypeName(_currentToken); |
| 533 if (token == null) { | 537 if (token == null) { |
| 534 return false; | 538 return false; |
| 535 } | 539 } |
| 536 token = skipSimpleIdentifier(token); | 540 token = skipSimpleIdentifier(token); |
| 537 if (token == null) { | 541 if (token == null) { |
| 538 return false; | 542 return false; |
| 539 } | 543 } |
| 540 TokenType type20 = token.type; | 544 TokenType type21 = token.type; |
| 541 return identical(type20, TokenType.EQ) || identical(type20, TokenType.COMMA)
|| identical(type20, TokenType.SEMICOLON) || matches3(token, Keyword.IN); | 545 return identical(type21, TokenType.EQ) || identical(type21, TokenType.COMMA)
|| identical(type21, TokenType.SEMICOLON) || matches3(token, Keyword.IN); |
| 542 } | 546 } |
| 543 /** | 547 /** |
| 544 * Return {@code true} if the current token appears to be the beginning of a s
witch member. | 548 * Return {@code true} if the current token appears to be the beginning of a s
witch member. |
| 545 * @return {@code true} if the current token appears to be the beginning of a
switch member | 549 * @return {@code true} if the current token appears to be the beginning of a
switch member |
| 546 */ | 550 */ |
| 547 bool isSwitchMember() { | 551 bool isSwitchMember() { |
| 548 Token token = _currentToken; | 552 Token token = _currentToken; |
| 549 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy
pe.COLON)) { | 553 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy
pe.COLON)) { |
| 550 token = token.next.next; | 554 token = token.next.next; |
| 551 } | 555 } |
| 552 if (identical(token.type, TokenType.KEYWORD)) { | 556 if (identical(token.type, TokenType.KEYWORD)) { |
| 553 Keyword keyword27 = ((token as KeywordToken)).keyword; | 557 Keyword keyword29 = ((token as KeywordToken)).keyword; |
| 554 return identical(keyword27, Keyword.CASE) || identical(keyword27, Keyword.
DEFAULT); | 558 return identical(keyword29, Keyword.CASE) || identical(keyword29, Keyword.
DEFAULT); |
| 555 } | 559 } |
| 556 return false; | 560 return false; |
| 557 } | 561 } |
| 558 /** | 562 /** |
| 559 * Compare the given tokens to find the token that appears first in the source
being parsed. That | 563 * Compare the given tokens to find the token that appears first in the source
being parsed. That |
| 560 * is, return the left-most of all of the tokens. The arguments are allowed to
be {@code null}. | 564 * is, return the left-most of all of the tokens. The arguments are allowed to
be {@code null}. |
| 561 * Return the token with the smallest offset, or {@code null} if there are no
arguments or if all | 565 * Return the token with the smallest offset, or {@code null} if there are no
arguments or if all |
| 562 * of the arguments are {@code null}. | 566 * of the arguments are {@code null}. |
| 563 * @param tokens the tokens being compared | 567 * @param tokens the tokens being compared |
| 564 * @return the token with the smallest offset | 568 * @return the token with the smallest offset |
| (...skipping 22 matching lines...) Expand all Loading... |
| 587 * @param identifier the identifier that can optionally appear in the current
location | 591 * @param identifier the identifier that can optionally appear in the current
location |
| 588 * @return {@code true} if the current token matches the given identifier | 592 * @return {@code true} if the current token matches the given identifier |
| 589 */ | 593 */ |
| 590 bool matches2(String identifier) => identical(_currentToken.type, TokenType.ID
ENTIFIER) && _currentToken.lexeme == identifier; | 594 bool matches2(String identifier) => identical(_currentToken.type, TokenType.ID
ENTIFIER) && _currentToken.lexeme == identifier; |
| 591 /** | 595 /** |
| 592 * Return {@code true} if the given token matches the given keyword. | 596 * Return {@code true} if the given token matches the given keyword. |
| 593 * @param token the token being tested | 597 * @param token the token being tested |
| 594 * @param keyword the keyword that is being tested for | 598 * @param keyword the keyword that is being tested for |
| 595 * @return {@code true} if the given token matches the given keyword | 599 * @return {@code true} if the given token matches the given keyword |
| 596 */ | 600 */ |
| 597 bool matches3(Token token, Keyword keyword35) => identical(token.type, TokenTy
pe.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword35); | 601 bool matches3(Token token, Keyword keyword37) => identical(token.type, TokenTy
pe.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword37); |
| 598 /** | 602 /** |
| 599 * Return {@code true} if the given token has the given type. | 603 * Return {@code true} if the given token has the given type. |
| 600 * @param token the token being tested | 604 * @param token the token being tested |
| 601 * @param type the type of token that is being tested for | 605 * @param type the type of token that is being tested for |
| 602 * @return {@code true} if the given token has the given type | 606 * @return {@code true} if the given token has the given type |
| 603 */ | 607 */ |
| 604 bool matches4(Token token, TokenType type29) => identical(token.type, type29); | 608 bool matches4(Token token, TokenType type30) => identical(token.type, type30); |
| 605 /** | 609 /** |
| 606 * Return {@code true} if the current token has the given type. Note that this
method, unlike | 610 * Return {@code true} if the current token has the given type. Note that this
method, unlike |
| 607 * other variants, will modify the token stream if possible to match a wider r
ange of tokens. In | 611 * other variants, will modify the token stream if possible to match a wider r
ange of tokens. In |
| 608 * particular, if we are attempting to match a '>' and the next token is eithe
r a '>>' or '>>>', | 612 * particular, if we are attempting to match a '>' and the next token is eithe
r a '>>' or '>>>', |
| 609 * the token stream will be re-written and {@code true} will be returned. | 613 * the token stream will be re-written and {@code true} will be returned. |
| 610 * @param type the type of token that can optionally appear in the current loc
ation | 614 * @param type the type of token that can optionally appear in the current loc
ation |
| 611 * @return {@code true} if the current token has the given type | 615 * @return {@code true} if the current token has the given type |
| 612 */ | 616 */ |
| 613 bool matches5(TokenType type30) { | 617 bool matches5(TokenType type31) { |
| 614 TokenType currentType = _currentToken.type; | 618 TokenType currentType = _currentToken.type; |
| 615 if (currentType != type30) { | 619 if (currentType != type31) { |
| 616 if (identical(type30, TokenType.GT)) { | 620 if (identical(type31, TokenType.GT)) { |
| 617 if (identical(currentType, TokenType.GT_GT)) { | 621 if (identical(currentType, TokenType.GT_GT)) { |
| 618 int offset6 = _currentToken.offset; | 622 int offset6 = _currentToken.offset; |
| 619 Token first = new Token(TokenType.GT, offset6); | 623 Token first = new Token(TokenType.GT, offset6); |
| 620 Token second = new Token(TokenType.GT, offset6 + 1); | 624 Token second = new Token(TokenType.GT, offset6 + 1); |
| 621 second.setNext(_currentToken.next); | 625 second.setNext(_currentToken.next); |
| 622 first.setNext(second); | 626 first.setNext(second); |
| 623 _currentToken.previous.setNext(first); | 627 _currentToken.previous.setNext(first); |
| 624 _currentToken = first; | 628 _currentToken = first; |
| 625 return true; | 629 return true; |
| 626 } else if (identical(currentType, TokenType.GT_EQ)) { | 630 } else if (identical(currentType, TokenType.GT_EQ)) { |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 * comment | 1344 * comment |
| 1341 * @param sourceOffset the offset of the first character of the reference sour
ce | 1345 * @param sourceOffset the offset of the first character of the reference sour
ce |
| 1342 * @return the comment reference that was parsed | 1346 * @return the comment reference that was parsed |
| 1343 */ | 1347 */ |
| 1344 CommentReference parseCommentReference(String referenceSource, int sourceOffse
t) { | 1348 CommentReference parseCommentReference(String referenceSource, int sourceOffse
t) { |
| 1345 if (referenceSource.length == 0) { | 1349 if (referenceSource.length == 0) { |
| 1346 return null; | 1350 return null; |
| 1347 } | 1351 } |
| 1348 try { | 1352 try { |
| 1349 List<bool> errorFound = [false]; | 1353 List<bool> errorFound = [false]; |
| 1350 AnalysisErrorListener listener = new AnalysisErrorListener_6(errorFound); | 1354 AnalysisErrorListener listener = new AnalysisErrorListener_7(errorFound); |
| 1351 StringScanner scanner = new StringScanner(null, referenceSource, listener)
; | 1355 StringScanner scanner = new StringScanner(null, referenceSource, listener)
; |
| 1352 scanner.setSourceStart(1, 1, sourceOffset); | 1356 scanner.setSourceStart(1, 1, sourceOffset); |
| 1353 Token firstToken = scanner.tokenize(); | 1357 Token firstToken = scanner.tokenize(); |
| 1354 if (!errorFound[0]) { | 1358 if (!errorFound[0]) { |
| 1355 Token newKeyword = null; | 1359 Token newKeyword = null; |
| 1356 if (matches3(firstToken, Keyword.NEW)) { | 1360 if (matches3(firstToken, Keyword.NEW)) { |
| 1357 newKeyword = firstToken; | 1361 newKeyword = firstToken; |
| 1358 firstToken = firstToken.next; | 1362 firstToken = firstToken.next; |
| 1359 } | 1363 } |
| 1360 if (matchesIdentifier2(firstToken)) { | 1364 if (matchesIdentifier2(firstToken)) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 * <pre> | 1432 * <pre> |
| 1429 * compilationUnit ::= | 1433 * compilationUnit ::= |
| 1430 * scriptTag? topLevelElement | 1434 * scriptTag? topLevelElement |
| 1431 * topLevelElement ::= | 1435 * topLevelElement ::= |
| 1432 * directive | 1436 * directive |
| 1433 * | topLevelDeclaration | 1437 * | topLevelDeclaration |
| 1434 * </pre> | 1438 * </pre> |
| 1435 * @return the compilation unit that was parsed | 1439 * @return the compilation unit that was parsed |
| 1436 */ | 1440 */ |
| 1437 CompilationUnit parseCompilationUnit2() { | 1441 CompilationUnit parseCompilationUnit2() { |
| 1438 Token firstToken = _currentToken.precedingComments; | 1442 Token firstToken = _currentToken; |
| 1439 if (firstToken == null) { | |
| 1440 firstToken = _currentToken; | |
| 1441 } | |
| 1442 ScriptTag scriptTag = null; | 1443 ScriptTag scriptTag = null; |
| 1443 if (matches5(TokenType.SCRIPT_TAG)) { | 1444 if (matches5(TokenType.SCRIPT_TAG)) { |
| 1444 scriptTag = new ScriptTag.full(andAdvance); | 1445 scriptTag = new ScriptTag.full(andAdvance); |
| 1445 } | 1446 } |
| 1446 bool libraryDirectiveFound = false; | 1447 bool libraryDirectiveFound = false; |
| 1447 bool partOfDirectiveFound = false; | 1448 bool partOfDirectiveFound = false; |
| 1448 bool partDirectiveFound = false; | 1449 bool partDirectiveFound = false; |
| 1449 bool directiveFoundAfterDeclaration = false; | 1450 bool directiveFoundAfterDeclaration = false; |
| 1450 List<Directive> directives = new List<Directive>(); | 1451 List<Directive> directives = new List<Directive>(); |
| 1451 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; | 1452 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 if (matches(Keyword.CLASS)) { | 1531 if (matches(Keyword.CLASS)) { |
| 1531 return parseClassDeclaration(commentAndMetadata, validateModifiersForClass
(modifiers)); | 1532 return parseClassDeclaration(commentAndMetadata, validateModifiersForClass
(modifiers)); |
| 1532 } else if (matches(Keyword.TYPEDEF) && !matches4(peek(), TokenType.PERIOD) &
& !matches4(peek(), TokenType.LT)) { | 1533 } else if (matches(Keyword.TYPEDEF) && !matches4(peek(), TokenType.PERIOD) &
& !matches4(peek(), TokenType.LT)) { |
| 1533 validateModifiersForTypedef(modifiers); | 1534 validateModifiersForTypedef(modifiers); |
| 1534 return parseTypeAlias(commentAndMetadata); | 1535 return parseTypeAlias(commentAndMetadata); |
| 1535 } | 1536 } |
| 1536 if (matches(Keyword.VOID)) { | 1537 if (matches(Keyword.VOID)) { |
| 1537 TypeName returnType = parseReturnType(); | 1538 TypeName returnType = parseReturnType(); |
| 1538 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p
eek())) { | 1539 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p
eek())) { |
| 1539 validateModifiersForTopLevelFunction(modifiers); | 1540 validateModifiersForTopLevelFunction(modifiers); |
| 1540 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null, false); | 1541 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null); |
| 1541 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { | 1542 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { |
| 1542 return null; | 1543 return null; |
| 1543 } else if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN
, TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { | 1544 } else if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN
, TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { |
| 1544 validateModifiersForTopLevelFunction(modifiers); | 1545 validateModifiersForTopLevelFunction(modifiers); |
| 1545 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null, false); | 1546 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null); |
| 1546 } else { | 1547 } else { |
| 1547 if (matchesIdentifier()) { | 1548 if (matchesIdentifier()) { |
| 1548 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { | 1549 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { |
| 1549 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); | 1550 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); |
| 1550 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme
nt, commentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiers
ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); | 1551 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme
nt, commentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiers
ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); |
| 1551 } | 1552 } |
| 1552 } | 1553 } |
| 1553 return null; | 1554 return null; |
| 1554 } | 1555 } |
| 1555 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi
er2(peek())) { | 1556 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi
er2(peek())) { |
| 1556 validateModifiersForTopLevelFunction(modifiers); | 1557 validateModifiersForTopLevelFunction(modifiers); |
| 1557 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null, false); | 1558 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null); |
| 1558 } else if (matches(Keyword.OPERATOR) && peek().isOperator() && matches4(peek
2(2), TokenType.OPEN_PAREN)) { | 1559 } else if (matches(Keyword.OPERATOR) && peek().isOperator() && matches4(peek
2(2), TokenType.OPEN_PAREN)) { |
| 1559 return null; | 1560 return null; |
| 1560 } else if (!matchesIdentifier()) { | 1561 } else if (!matchesIdentifier()) { |
| 1561 return null; | 1562 return null; |
| 1562 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { | 1563 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { |
| 1563 validateModifiersForTopLevelFunction(modifiers); | 1564 validateModifiersForTopLevelFunction(modifiers); |
| 1564 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null, false); | 1565 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null); |
| 1565 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { | 1566 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { |
| 1566 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co
mmentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTop
LevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); | 1567 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co
mmentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTop
LevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); |
| 1567 } | 1568 } |
| 1568 TypeName returnType = parseReturnType(); | 1569 TypeName returnType = parseReturnType(); |
| 1569 if (matches(Keyword.GET) || matches(Keyword.SET)) { | 1570 if (matches(Keyword.GET) || matches(Keyword.SET)) { |
| 1570 validateModifiersForTopLevelFunction(modifiers); | 1571 validateModifiersForTopLevelFunction(modifiers); |
| 1571 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType, false); | 1572 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType); |
| 1572 } else if (!matchesIdentifier()) { | 1573 } else if (!matchesIdentifier()) { |
| 1573 return null; | 1574 return null; |
| 1574 } | 1575 } |
| 1575 if (matchesAny(peek(), [TokenType.OPEN_PAREN, TokenType.FUNCTION, TokenType.
OPEN_CURLY_BRACKET])) { | 1576 if (matchesAny(peek(), [TokenType.OPEN_PAREN, TokenType.FUNCTION, TokenType.
OPEN_CURLY_BRACKET])) { |
| 1576 validateModifiersForTopLevelFunction(modifiers); | 1577 validateModifiersForTopLevelFunction(modifiers); |
| 1577 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType, false); | 1578 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, returnType); |
| 1578 } | 1579 } |
| 1579 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, comm
entAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTopLe
velVariable(modifiers), returnType), expect2(TokenType.SEMICOLON)); | 1580 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, comm
entAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTopLe
velVariable(modifiers), returnType), expect2(TokenType.SEMICOLON)); |
| 1580 } | 1581 } |
| 1581 /** | 1582 /** |
| 1582 * Parse a conditional expression. | 1583 * Parse a conditional expression. |
| 1583 * <pre> | 1584 * <pre> |
| 1584 * conditionalExpression ::= | 1585 * conditionalExpression ::= |
| 1585 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithoutCasc
ade)? | 1586 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithoutCasc
ade)? |
| 1586 * </pre> | 1587 * </pre> |
| 1587 * @return the conditional expression that was parsed | 1588 * @return the conditional expression that was parsed |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2168 List<VariableDeclaration> variables = new List<VariableDeclaration>(); | 2169 List<VariableDeclaration> variables = new List<VariableDeclaration>(); |
| 2169 SimpleIdentifier variableName = parseSimpleIdentifier(); | 2170 SimpleIdentifier variableName = parseSimpleIdentifier(); |
| 2170 variables.add(new VariableDeclaration.full(null, null, variableName, n
ull, null)); | 2171 variables.add(new VariableDeclaration.full(null, null, variableName, n
ull, null)); |
| 2171 variableList = new VariableDeclarationList.full(null, null, variables)
; | 2172 variableList = new VariableDeclarationList.full(null, null, variables)
; |
| 2172 } else if (isInitializedVariableDeclaration()) { | 2173 } else if (isInitializedVariableDeclaration()) { |
| 2173 variableList = parseVariableDeclarationList(); | 2174 variableList = parseVariableDeclarationList(); |
| 2174 } else { | 2175 } else { |
| 2175 initialization = parseExpression2(); | 2176 initialization = parseExpression2(); |
| 2176 } | 2177 } |
| 2177 if (matches(Keyword.IN)) { | 2178 if (matches(Keyword.IN)) { |
| 2178 SimpleFormalParameter loopParameter = null; | 2179 DeclaredIdentifier loopVariable = null; |
| 2179 if (variableList == null) { | 2180 if (variableList == null) { |
| 2180 reportError4(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); | 2181 reportError4(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); |
| 2181 } else { | 2182 } else { |
| 2182 NodeList<VariableDeclaration> variables3 = variableList.variables; | 2183 NodeList<VariableDeclaration> variables3 = variableList.variables; |
| 2183 if (variables3.length > 1) { | 2184 if (variables3.length > 1) { |
| 2184 reportError4(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari
ables3.length.toString()]); | 2185 reportError4(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari
ables3.length.toString()]); |
| 2185 } | 2186 } |
| 2186 VariableDeclaration variable = variables3[0]; | 2187 VariableDeclaration variable = variables3[0]; |
| 2187 if (variable.initializer != null) { | 2188 if (variable.initializer != null) { |
| 2188 reportError4(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, [])
; | 2189 reportError4(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, [])
; |
| 2189 } | 2190 } |
| 2190 loopParameter = new SimpleFormalParameter.full(null, null, variableL
ist.keyword, variableList.type, variable.name); | 2191 loopVariable = new DeclaredIdentifier.full(null, null, variableList.
keyword, variableList.type, variable.name); |
| 2191 } | 2192 } |
| 2192 Token inKeyword = expect(Keyword.IN); | 2193 Token inKeyword = expect(Keyword.IN); |
| 2193 Expression iterator = parseExpression2(); | 2194 Expression iterator = parseExpression2(); |
| 2194 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | 2195 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 2195 Statement body = parseStatement2(); | 2196 Statement body = parseStatement2(); |
| 2196 return new ForEachStatement.full(forKeyword, leftParenthesis, loopPara
meter, inKeyword, iterator, rightParenthesis, body); | 2197 return new ForEachStatement.full(forKeyword, leftParenthesis, loopVari
able, inKeyword, iterator, rightParenthesis, body); |
| 2197 } | 2198 } |
| 2198 } | 2199 } |
| 2199 Token leftSeparator = expect2(TokenType.SEMICOLON); | 2200 Token leftSeparator = expect2(TokenType.SEMICOLON); |
| 2200 Expression condition = null; | 2201 Expression condition = null; |
| 2201 if (!matches5(TokenType.SEMICOLON)) { | 2202 if (!matches5(TokenType.SEMICOLON)) { |
| 2202 condition = parseExpression2(); | 2203 condition = parseExpression2(); |
| 2203 } | 2204 } |
| 2204 Token rightSeparator = expect2(TokenType.SEMICOLON); | 2205 Token rightSeparator = expect2(TokenType.SEMICOLON); |
| 2205 List<Expression> updaters = null; | 2206 List<Expression> updaters = null; |
| 2206 if (!matches5(TokenType.CLOSE_PAREN)) { | 2207 if (!matches5(TokenType.CLOSE_PAREN)) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2269 * functionSignature functionBody | 2270 * functionSignature functionBody |
| 2270 * | returnType? getOrSet identifier formalParameterList functionBody | 2271 * | returnType? getOrSet identifier formalParameterList functionBody |
| 2271 * </pre> | 2272 * </pre> |
| 2272 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 2273 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 2273 * declaration | 2274 * declaration |
| 2274 * @param externalKeyword the 'external' keyword, or {@code null} if the funct
ion is not external | 2275 * @param externalKeyword the 'external' keyword, or {@code null} if the funct
ion is not external |
| 2275 * @param returnType the return type, or {@code null} if there is no return ty
pe | 2276 * @param returnType the return type, or {@code null} if there is no return ty
pe |
| 2276 * @param isStatement {@code true} if the function declaration is being parsed
as a statement | 2277 * @param isStatement {@code true} if the function declaration is being parsed
as a statement |
| 2277 * @return the function declaration that was parsed | 2278 * @return the function declaration that was parsed |
| 2278 */ | 2279 */ |
| 2279 FunctionDeclaration parseFunctionDeclaration(CommentAndMetadata commentAndMeta
data, Token externalKeyword, TypeName returnType, bool isStatement) { | 2280 FunctionDeclaration parseFunctionDeclaration(CommentAndMetadata commentAndMeta
data, Token externalKeyword, TypeName returnType) { |
| 2280 Token keyword = null; | 2281 Token keyword = null; |
| 2281 bool isGetter = false; | 2282 bool isGetter = false; |
| 2282 if (matches(Keyword.GET) && !matches4(peek(), TokenType.OPEN_PAREN)) { | 2283 if (matches(Keyword.GET) && !matches4(peek(), TokenType.OPEN_PAREN)) { |
| 2283 keyword = andAdvance; | 2284 keyword = andAdvance; |
| 2284 isGetter = true; | 2285 isGetter = true; |
| 2285 } else if (matches(Keyword.SET) && !matches4(peek(), TokenType.OPEN_PAREN))
{ | 2286 } else if (matches(Keyword.SET) && !matches4(peek(), TokenType.OPEN_PAREN))
{ |
| 2286 keyword = andAdvance; | 2287 keyword = andAdvance; |
| 2287 } | 2288 } |
| 2288 SimpleIdentifier name = parseSimpleIdentifier(); | 2289 SimpleIdentifier name = parseSimpleIdentifier(); |
| 2289 FormalParameterList parameters = null; | 2290 FormalParameterList parameters = null; |
| 2290 if (!isGetter) { | 2291 if (!isGetter) { |
| 2291 if (matches5(TokenType.OPEN_PAREN)) { | 2292 if (matches5(TokenType.OPEN_PAREN)) { |
| 2292 parameters = parseFormalParameterList(); | 2293 parameters = parseFormalParameterList(); |
| 2293 validateFormalParameterList(parameters); | 2294 validateFormalParameterList(parameters); |
| 2294 } else { | 2295 } else { |
| 2295 reportError4(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, []); | 2296 reportError4(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, []); |
| 2296 } | 2297 } |
| 2297 } else if (matches5(TokenType.OPEN_PAREN)) { | 2298 } else if (matches5(TokenType.OPEN_PAREN)) { |
| 2298 reportError4(ParserErrorCode.GETTER_WITH_PARAMETERS, []); | 2299 reportError4(ParserErrorCode.GETTER_WITH_PARAMETERS, []); |
| 2299 parseFormalParameterList(); | 2300 parseFormalParameterList(); |
| 2300 } | 2301 } |
| 2301 FunctionBody body = null; | 2302 FunctionBody body; |
| 2302 if (externalKeyword == null) { | 2303 if (externalKeyword == null) { |
| 2303 body = parseFunctionBody(false, false); | 2304 body = parseFunctionBody(false, false); |
| 2304 } | 2305 } else { |
| 2305 if (!isStatement && matches5(TokenType.SEMICOLON)) { | 2306 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON)); |
| 2306 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]); | |
| 2307 advance(); | |
| 2308 } | 2307 } |
| 2309 return new FunctionDeclaration.full(commentAndMetadata.comment, commentAndMe
tadata.metadata, externalKeyword, returnType, keyword, name, new FunctionExpress
ion.full(parameters, body)); | 2308 return new FunctionDeclaration.full(commentAndMetadata.comment, commentAndMe
tadata.metadata, externalKeyword, returnType, keyword, name, new FunctionExpress
ion.full(parameters, body)); |
| 2310 } | 2309 } |
| 2311 /** | 2310 /** |
| 2312 * Parse a function declaration statement. | 2311 * Parse a function declaration statement. |
| 2313 * <pre> | 2312 * <pre> |
| 2314 * functionDeclarationStatement ::= | 2313 * functionDeclarationStatement ::= |
| 2315 * functionSignature functionBody | 2314 * functionSignature functionBody |
| 2316 * </pre> | 2315 * </pre> |
| 2317 * @return the function declaration statement that was parsed | 2316 * @return the function declaration statement that was parsed |
| 2318 */ | 2317 */ |
| 2319 Statement parseFunctionDeclarationStatement() => parseFunctionDeclarationState
ment2(parseCommentAndMetadata(), parseOptionalReturnType()); | 2318 Statement parseFunctionDeclarationStatement() => parseFunctionDeclarationState
ment2(parseCommentAndMetadata(), parseOptionalReturnType()); |
| 2320 /** | 2319 /** |
| 2321 * Parse a function declaration statement. | 2320 * Parse a function declaration statement. |
| 2322 * <pre> | 2321 * <pre> |
| 2323 * functionDeclarationStatement ::= | 2322 * functionDeclarationStatement ::= |
| 2324 * functionSignature functionBody | 2323 * functionSignature functionBody |
| 2325 * </pre> | 2324 * </pre> |
| 2326 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 2325 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 2327 * declaration | 2326 * declaration |
| 2328 * @param returnType the return type, or {@code null} if there is no return ty
pe | 2327 * @param returnType the return type, or {@code null} if there is no return ty
pe |
| 2329 * @return the function declaration statement that was parsed | 2328 * @return the function declaration statement that was parsed |
| 2330 */ | 2329 */ |
| 2331 Statement parseFunctionDeclarationStatement2(CommentAndMetadata commentAndMeta
data, TypeName returnType) => new FunctionDeclarationStatement.full(parseFunctio
nDeclaration(commentAndMetadata, null, returnType, true)); | 2330 Statement parseFunctionDeclarationStatement2(CommentAndMetadata commentAndMeta
data, TypeName returnType) => new FunctionDeclarationStatement.full(parseFunctio
nDeclaration(commentAndMetadata, null, returnType)); |
| 2332 /** | 2331 /** |
| 2333 * Parse a function expression. | 2332 * Parse a function expression. |
| 2334 * <pre> | 2333 * <pre> |
| 2335 * functionExpression ::= | 2334 * functionExpression ::= |
| 2336 * (returnType? identifier)? formalParameterList functionExpressionBody | 2335 * (returnType? identifier)? formalParameterList functionExpressionBody |
| 2337 * </pre> | 2336 * </pre> |
| 2338 * @return the function expression that was parsed | 2337 * @return the function expression that was parsed |
| 2339 */ | 2338 */ |
| 2340 FunctionExpression parseFunctionExpression() { | 2339 FunctionExpression parseFunctionExpression() { |
| 2341 FormalParameterList parameters = parseFormalParameterList(); | 2340 FormalParameterList parameters = parseFormalParameterList(); |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2890 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 2889 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 2891 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { | 2890 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { |
| 2892 if (matches4(peek(), TokenType.STRING)) { | 2891 if (matches4(peek(), TokenType.STRING)) { |
| 2893 Token afterString = skipStringLiteral(_currentToken.next); | 2892 Token afterString = skipStringLiteral(_currentToken.next); |
| 2894 if (afterString != null && identical(afterString.type, TokenType.COLON))
{ | 2893 if (afterString != null && identical(afterString.type, TokenType.COLON))
{ |
| 2895 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT
ype.SEMICOLON)); | 2894 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT
ype.SEMICOLON)); |
| 2896 } | 2895 } |
| 2897 } | 2896 } |
| 2898 return parseBlock(); | 2897 return parseBlock(); |
| 2899 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken))
.keyword.isPseudoKeyword()) { | 2898 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken))
.keyword.isPseudoKeyword()) { |
| 2900 Keyword keyword28 = ((_currentToken as KeywordToken)).keyword; | 2899 Keyword keyword30 = ((_currentToken as KeywordToken)).keyword; |
| 2901 if (identical(keyword28, Keyword.ASSERT)) { | 2900 if (identical(keyword30, Keyword.ASSERT)) { |
| 2902 return parseAssertStatement(); | 2901 return parseAssertStatement(); |
| 2903 } else if (identical(keyword28, Keyword.BREAK)) { | 2902 } else if (identical(keyword30, Keyword.BREAK)) { |
| 2904 return parseBreakStatement(); | 2903 return parseBreakStatement(); |
| 2905 } else if (identical(keyword28, Keyword.CONTINUE)) { | 2904 } else if (identical(keyword30, Keyword.CONTINUE)) { |
| 2906 return parseContinueStatement(); | 2905 return parseContinueStatement(); |
| 2907 } else if (identical(keyword28, Keyword.DO)) { | 2906 } else if (identical(keyword30, Keyword.DO)) { |
| 2908 return parseDoStatement(); | 2907 return parseDoStatement(); |
| 2909 } else if (identical(keyword28, Keyword.FOR)) { | 2908 } else if (identical(keyword30, Keyword.FOR)) { |
| 2910 return parseForStatement(); | 2909 return parseForStatement(); |
| 2911 } else if (identical(keyword28, Keyword.IF)) { | 2910 } else if (identical(keyword30, Keyword.IF)) { |
| 2912 return parseIfStatement(); | 2911 return parseIfStatement(); |
| 2913 } else if (identical(keyword28, Keyword.RETURN)) { | 2912 } else if (identical(keyword30, Keyword.RETURN)) { |
| 2914 return parseReturnStatement(); | 2913 return parseReturnStatement(); |
| 2915 } else if (identical(keyword28, Keyword.SWITCH)) { | 2914 } else if (identical(keyword30, Keyword.SWITCH)) { |
| 2916 return parseSwitchStatement(); | 2915 return parseSwitchStatement(); |
| 2917 } else if (identical(keyword28, Keyword.THROW)) { | 2916 } else if (identical(keyword30, Keyword.THROW)) { |
| 2918 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke
nType.SEMICOLON)); | 2917 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke
nType.SEMICOLON)); |
| 2919 } else if (identical(keyword28, Keyword.TRY)) { | 2918 } else if (identical(keyword30, Keyword.TRY)) { |
| 2920 return parseTryStatement(); | 2919 return parseTryStatement(); |
| 2921 } else if (identical(keyword28, Keyword.WHILE)) { | 2920 } else if (identical(keyword30, Keyword.WHILE)) { |
| 2922 return parseWhileStatement(); | 2921 return parseWhileStatement(); |
| 2923 } else if (identical(keyword28, Keyword.VAR) || identical(keyword28, Keywo
rd.FINAL)) { | 2922 } else if (identical(keyword30, Keyword.VAR) || identical(keyword30, Keywo
rd.FINAL)) { |
| 2924 return parseVariableDeclarationStatement(); | 2923 return parseVariableDeclarationStatement(); |
| 2925 } else if (identical(keyword28, Keyword.VOID)) { | 2924 } else if (identical(keyword30, Keyword.VOID)) { |
| 2926 TypeName returnType = parseReturnType(); | 2925 TypeName returnType = parseReturnType(); |
| 2927 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok
enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { | 2926 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok
enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { |
| 2928 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy
pe); | 2927 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy
pe); |
| 2929 } else { | 2928 } else { |
| 2930 if (matchesIdentifier()) { | 2929 if (matchesIdentifier()) { |
| 2931 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM
ICOLON])) { | 2930 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM
ICOLON])) { |
| 2932 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); | 2931 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); |
| 2933 return parseVariableDeclarationStatement(); | 2932 return parseVariableDeclarationStatement(); |
| 2934 } | 2933 } |
| 2935 } | 2934 } |
| 2936 return null; | 2935 return null; |
| 2937 } | 2936 } |
| 2938 } else if (identical(keyword28, Keyword.CONST)) { | 2937 } else if (identical(keyword30, Keyword.CONST)) { |
| 2939 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke
nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) { | 2938 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke
nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) { |
| 2940 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT
ype.SEMICOLON)); | 2939 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT
ype.SEMICOLON)); |
| 2941 } else if (matches4(peek(), TokenType.IDENTIFIER)) { | 2940 } else if (matches4(peek(), TokenType.IDENTIFIER)) { |
| 2942 Token afterType = skipTypeName(peek()); | 2941 Token afterType = skipTypeName(peek()); |
| 2943 if (afterType != null) { | 2942 if (afterType != null) { |
| 2944 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType
, TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches
4(afterType.next.next, TokenType.OPEN_PAREN))) { | 2943 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType
, TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches
4(afterType.next.next, TokenType.OPEN_PAREN))) { |
| 2945 return new ExpressionStatement.full(parseExpression2(), expect2(To
kenType.SEMICOLON)); | 2944 return new ExpressionStatement.full(parseExpression2(), expect2(To
kenType.SEMICOLON)); |
| 2946 } | 2945 } |
| 2947 } | 2946 } |
| 2948 } | 2947 } |
| 2949 return parseVariableDeclarationStatement(); | 2948 return parseVariableDeclarationStatement(); |
| 2950 } else if (identical(keyword28, Keyword.NEW) || identical(keyword28, Keywo
rd.TRUE) || identical(keyword28, Keyword.FALSE) || identical(keyword28, Keyword.
NULL) || identical(keyword28, Keyword.SUPER) || identical(keyword28, Keyword.THI
S)) { | 2949 } else if (identical(keyword30, Keyword.NEW) || identical(keyword30, Keywo
rd.TRUE) || identical(keyword30, Keyword.FALSE) || identical(keyword30, Keyword.
NULL) || identical(keyword30, Keyword.SUPER) || identical(keyword30, Keyword.THI
S)) { |
| 2951 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp
e.SEMICOLON)); | 2950 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp
e.SEMICOLON)); |
| 2952 } else { | 2951 } else { |
| 2953 return null; | 2952 return null; |
| 2954 } | 2953 } |
| 2955 } else if (matches5(TokenType.SEMICOLON)) { | 2954 } else if (matches5(TokenType.SEMICOLON)) { |
| 2956 return parseEmptyStatement(); | 2955 return parseEmptyStatement(); |
| 2957 } else if (isInitializedVariableDeclaration()) { | 2956 } else if (isInitializedVariableDeclaration()) { |
| 2958 return parseVariableDeclarationStatement(); | 2957 return parseVariableDeclarationStatement(); |
| 2959 } else if (isFunctionDeclaration()) { | 2958 } else if (isFunctionDeclaration()) { |
| 2960 return parseFunctionDeclarationStatement(); | 2959 return parseFunctionDeclarationStatement(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2988 thisKeyword = andAdvance; | 2987 thisKeyword = andAdvance; |
| 2989 period = expect2(TokenType.PERIOD); | 2988 period = expect2(TokenType.PERIOD); |
| 2990 } | 2989 } |
| 2991 SimpleIdentifier identifier = parseSimpleIdentifier(); | 2990 SimpleIdentifier identifier = parseSimpleIdentifier(); |
| 2992 if (matches5(TokenType.OPEN_PAREN)) { | 2991 if (matches5(TokenType.OPEN_PAREN)) { |
| 2993 if (thisKeyword != null) { | 2992 if (thisKeyword != null) { |
| 2994 } | 2993 } |
| 2995 FormalParameterList parameters = parseFormalParameterList(); | 2994 FormalParameterList parameters = parseFormalParameterList(); |
| 2996 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c
ommentAndMetadata.metadata, holder.type, identifier, parameters); | 2995 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c
ommentAndMetadata.metadata, holder.type, identifier, parameters); |
| 2997 } | 2996 } |
| 2998 TypeName type21 = holder.type; | 2997 TypeName type22 = holder.type; |
| 2999 if (type21 != null && matches3(type21.name.beginToken, Keyword.VOID)) { | 2998 if (type22 != null && matches3(type22.name.beginToken, Keyword.VOID)) { |
| 3000 reportError5(ParserErrorCode.VOID_PARAMETER, type21.name.beginToken, []); | 2999 reportError5(ParserErrorCode.VOID_PARAMETER, type22.name.beginToken, []); |
| 3001 } | 3000 } |
| 3002 if (thisKeyword != null) { | 3001 if (thisKeyword != null) { |
| 3003 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier
); | 3002 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier
); |
| 3004 } | 3003 } |
| 3005 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd
Metadata.metadata, holder.keyword, holder.type, identifier); | 3004 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd
Metadata.metadata, holder.keyword, holder.type, identifier); |
| 3006 } | 3005 } |
| 3007 /** | 3006 /** |
| 3008 * Parse an operator declaration. | 3007 * Parse an operator declaration. |
| 3009 * <pre> | 3008 * <pre> |
| 3010 * operatorDeclaration ::= | 3009 * operatorDeclaration ::= |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4100 * actually creating a string literal or changing the current token. Return th
e token following | 4099 * actually creating a string literal or changing the current token. Return th
e token following |
| 4101 * the string literal that was parsed, or {@code null} if the given token is n
ot the first token | 4100 * the string literal that was parsed, or {@code null} if the given token is n
ot the first token |
| 4102 * in a valid string literal. | 4101 * in a valid string literal. |
| 4103 * <p> | 4102 * <p> |
| 4104 * This method must be kept in sync with {@link #parseStringInterpolation(Toke
n)}. | 4103 * This method must be kept in sync with {@link #parseStringInterpolation(Toke
n)}. |
| 4105 * @param startToken the token at which parsing is to begin | 4104 * @param startToken the token at which parsing is to begin |
| 4106 * @return the string literal that was parsed | 4105 * @return the string literal that was parsed |
| 4107 */ | 4106 */ |
| 4108 Token skipStringInterpolation(Token startToken) { | 4107 Token skipStringInterpolation(Token startToken) { |
| 4109 Token token = startToken; | 4108 Token token = startToken; |
| 4110 TokenType type22 = token.type; | 4109 TokenType type23 = token.type; |
| 4111 while (identical(type22, TokenType.STRING_INTERPOLATION_EXPRESSION) || ident
ical(type22, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { | 4110 while (identical(type23, TokenType.STRING_INTERPOLATION_EXPRESSION) || ident
ical(type23, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { |
| 4112 if (identical(type22, TokenType.STRING_INTERPOLATION_EXPRESSION)) { | 4111 if (identical(type23, TokenType.STRING_INTERPOLATION_EXPRESSION)) { |
| 4113 token = token.next; | 4112 token = token.next; |
| 4114 type22 = token.type; | 4113 type23 = token.type; |
| 4115 int bracketNestingLevel = 1; | 4114 int bracketNestingLevel = 1; |
| 4116 while (bracketNestingLevel > 0) { | 4115 while (bracketNestingLevel > 0) { |
| 4117 if (identical(type22, TokenType.EOF)) { | 4116 if (identical(type23, TokenType.EOF)) { |
| 4118 return null; | 4117 return null; |
| 4119 } else if (identical(type22, TokenType.OPEN_CURLY_BRACKET)) { | 4118 } else if (identical(type23, TokenType.OPEN_CURLY_BRACKET)) { |
| 4120 bracketNestingLevel++; | 4119 bracketNestingLevel++; |
| 4121 } else if (identical(type22, TokenType.CLOSE_CURLY_BRACKET)) { | 4120 } else if (identical(type23, TokenType.CLOSE_CURLY_BRACKET)) { |
| 4122 bracketNestingLevel--; | 4121 bracketNestingLevel--; |
| 4123 } else if (identical(type22, TokenType.STRING)) { | 4122 } else if (identical(type23, TokenType.STRING)) { |
| 4124 token = skipStringLiteral(token); | 4123 token = skipStringLiteral(token); |
| 4125 if (token == null) { | 4124 if (token == null) { |
| 4126 return null; | 4125 return null; |
| 4127 } | 4126 } |
| 4128 } else { | 4127 } else { |
| 4129 token = token.next; | 4128 token = token.next; |
| 4130 } | 4129 } |
| 4131 type22 = token.type; | 4130 type23 = token.type; |
| 4132 } | 4131 } |
| 4133 token = token.next; | 4132 token = token.next; |
| 4134 type22 = token.type; | 4133 type23 = token.type; |
| 4135 } else { | 4134 } else { |
| 4136 token = token.next; | 4135 token = token.next; |
| 4137 if (token.type != TokenType.IDENTIFIER) { | 4136 if (token.type != TokenType.IDENTIFIER) { |
| 4138 return null; | 4137 return null; |
| 4139 } | 4138 } |
| 4140 token = token.next; | 4139 token = token.next; |
| 4141 } | 4140 } |
| 4142 type22 = token.type; | 4141 type23 = token.type; |
| 4143 if (identical(type22, TokenType.STRING)) { | 4142 if (identical(type23, TokenType.STRING)) { |
| 4144 token = token.next; | 4143 token = token.next; |
| 4145 type22 = token.type; | 4144 type23 = token.type; |
| 4146 } | 4145 } |
| 4147 } | 4146 } |
| 4148 return token; | 4147 return token; |
| 4149 } | 4148 } |
| 4150 /** | 4149 /** |
| 4151 * Parse a string literal, starting at the given token, without actually creat
ing a string literal | 4150 * Parse a string literal, starting at the given token, without actually creat
ing a string literal |
| 4152 * or changing the current token. Return the token following the string litera
l that was parsed, | 4151 * or changing the current token. Return the token following the string litera
l that was parsed, |
| 4153 * or {@code null} if the given token is not the first token in a valid string
literal. | 4152 * or {@code null} if the given token is not the first token in a valid string
literal. |
| 4154 * <p> | 4153 * <p> |
| 4155 * This method must be kept in sync with {@link #parseStringLiteral()}. | 4154 * This method must be kept in sync with {@link #parseStringLiteral()}. |
| 4156 * <pre> | 4155 * <pre> |
| 4157 * stringLiteral ::= | 4156 * stringLiteral ::= |
| 4158 * MULTI_LINE_STRING+ | 4157 * MULTI_LINE_STRING+ |
| 4159 * | SINGLE_LINE_STRING+ | 4158 * | SINGLE_LINE_STRING+ |
| 4160 * </pre> | 4159 * </pre> |
| 4161 * @param startToken the token at which parsing is to begin | 4160 * @param startToken the token at which parsing is to begin |
| 4162 * @return the token following the string literal that was parsed | 4161 * @return the token following the string literal that was parsed |
| 4163 */ | 4162 */ |
| 4164 Token skipStringLiteral(Token startToken) { | 4163 Token skipStringLiteral(Token startToken) { |
| 4165 Token token = startToken; | 4164 Token token = startToken; |
| 4166 while (token != null && matches4(token, TokenType.STRING)) { | 4165 while (token != null && matches4(token, TokenType.STRING)) { |
| 4167 token = token.next; | 4166 token = token.next; |
| 4168 TokenType type23 = token.type; | 4167 TokenType type24 = token.type; |
| 4169 if (identical(type23, TokenType.STRING_INTERPOLATION_EXPRESSION) || identi
cal(type23, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { | 4168 if (identical(type24, TokenType.STRING_INTERPOLATION_EXPRESSION) || identi
cal(type24, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { |
| 4170 token = skipStringInterpolation(token); | 4169 token = skipStringInterpolation(token); |
| 4171 } | 4170 } |
| 4172 } | 4171 } |
| 4173 if (identical(token, startToken)) { | 4172 if (identical(token, startToken)) { |
| 4174 return null; | 4173 return null; |
| 4175 } | 4174 } |
| 4176 return token; | 4175 return token; |
| 4177 } | 4176 } |
| 4178 /** | 4177 /** |
| 4179 * Parse a list of type arguments, starting at the given token, without actual
ly creating a type argument list | 4178 * Parse a list of type arguments, starting at the given token, without actual
ly creating a type argument list |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4624 reportError5(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword,
[]); | 4623 reportError5(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword,
[]); |
| 4625 } | 4624 } |
| 4626 if (modifiers.finalKeyword != null) { | 4625 if (modifiers.finalKeyword != null) { |
| 4627 reportError5(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []); | 4626 reportError5(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []); |
| 4628 } | 4627 } |
| 4629 if (modifiers.varKeyword != null) { | 4628 if (modifiers.varKeyword != null) { |
| 4630 reportError5(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []); | 4629 reportError5(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []); |
| 4631 } | 4630 } |
| 4632 } | 4631 } |
| 4633 } | 4632 } |
| 4634 class AnalysisErrorListener_6 implements AnalysisErrorListener { | 4633 class AnalysisErrorListener_7 implements AnalysisErrorListener { |
| 4635 List<bool> errorFound; | 4634 List<bool> errorFound; |
| 4636 AnalysisErrorListener_6(this.errorFound); | 4635 AnalysisErrorListener_7(this.errorFound); |
| 4637 void onError(AnalysisError error) { | 4636 void onError(AnalysisError error) { |
| 4638 errorFound[0] = true; | 4637 errorFound[0] = true; |
| 4639 } | 4638 } |
| 4640 } | 4639 } |
| 4641 /** | 4640 /** |
| 4642 * The enumeration {@code ParserErrorCode} defines the error codes used for erro
rs detected by the | 4641 * The enumeration {@code ParserErrorCode} defines the error codes used for erro
rs detected by the |
| 4643 * parser. The convention for this class is for the name of the error code to in
dicate the problem | 4642 * parser. The convention for this class is for the name of the error code to in
dicate the problem |
| 4644 * that caused the error to be generated and for the error message to explain wh
at is wrong and, | 4643 * that caused the error to be generated and for the error message to explain wh
at is wrong and, |
| 4645 * when appropriate, how the problem can be corrected. | 4644 * when appropriate, how the problem can be corrected. |
| 4645 * @coverage dart.engine.parser |
| 4646 */ | 4646 */ |
| 4647 class ParserErrorCode implements ErrorCode { | 4647 class ParserErrorCode implements ErrorCode { |
| 4648 static final ParserErrorCode ABSTRACT_CLASS_MEMBER = new ParserErrorCode.con2(
'ABSTRACT_CLASS_MEMBER', 0, "Members of classes cannot be declared to be 'abstra
ct'"); | 4648 static final ParserErrorCode ABSTRACT_CLASS_MEMBER = new ParserErrorCode.con2(
'ABSTRACT_CLASS_MEMBER', 0, "Members of classes cannot be declared to be 'abstra
ct'"); |
| 4649 static final ParserErrorCode ABSTRACT_STATIC_METHOD = new ParserErrorCode.con2
('ABSTRACT_STATIC_METHOD', 1, "Static methods cannot be declared to be 'abstract
'"); | 4649 static final ParserErrorCode ABSTRACT_STATIC_METHOD = new ParserErrorCode.con2
('ABSTRACT_STATIC_METHOD', 1, "Static methods cannot be declared to be 'abstract
'"); |
| 4650 static final ParserErrorCode ABSTRACT_TOP_LEVEL_FUNCTION = new ParserErrorCode
.con2('ABSTRACT_TOP_LEVEL_FUNCTION', 2, "Top-level functions cannot be declared
to be 'abstract'"); | 4650 static final ParserErrorCode ABSTRACT_TOP_LEVEL_FUNCTION = new ParserErrorCode
.con2('ABSTRACT_TOP_LEVEL_FUNCTION', 2, "Top-level functions cannot be declared
to be 'abstract'"); |
| 4651 static final ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE = new ParserErrorCode
.con2('ABSTRACT_TOP_LEVEL_VARIABLE', 3, "Top-level variables cannot be declared
to be 'abstract'"); | 4651 static final ParserErrorCode ABSTRACT_TOP_LEVEL_VARIABLE = new ParserErrorCode
.con2('ABSTRACT_TOP_LEVEL_VARIABLE', 3, "Top-level variables cannot be declared
to be 'abstract'"); |
| 4652 static final ParserErrorCode ABSTRACT_TYPEDEF = new ParserErrorCode.con2('ABST
RACT_TYPEDEF', 4, "Type aliases cannot be declared to be 'abstract'"); | 4652 static final ParserErrorCode ABSTRACT_TYPEDEF = new ParserErrorCode.con2('ABST
RACT_TYPEDEF', 4, "Type aliases cannot be declared to be 'abstract'"); |
| 4653 static final ParserErrorCode BREAK_OUTSIDE_OF_LOOP = new ParserErrorCode.con2(
'BREAK_OUTSIDE_OF_LOOP', 5, "A break statement cannot be used outside of a loop
or switch statement"); | 4653 static final ParserErrorCode BREAK_OUTSIDE_OF_LOOP = new ParserErrorCode.con2(
'BREAK_OUTSIDE_OF_LOOP', 5, "A break statement cannot be used outside of a loop
or switch statement"); |
| 4654 static final ParserErrorCode CONST_AND_FINAL = new ParserErrorCode.con2('CONST
_AND_FINAL', 6, "Members cannot be declared to be both 'const' and 'final'"); | 4654 static final ParserErrorCode CONST_AND_FINAL = new ParserErrorCode.con2('CONST
_AND_FINAL', 6, "Members cannot be declared to be both 'const' and 'final'"); |
| 4655 static final ParserErrorCode CONST_AND_VAR = new ParserErrorCode.con2('CONST_A
ND_VAR', 7, "Members cannot be declared to be both 'const' and 'var'"); | 4655 static final ParserErrorCode CONST_AND_VAR = new ParserErrorCode.con2('CONST_A
ND_VAR', 7, "Members cannot be declared to be both 'const' and 'var'"); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4740 static final ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = new Pa
rserErrorCode.con2('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER', 92, "The default
value of a positional parameter should be preceeded by '='"); | 4740 static final ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = new Pa
rserErrorCode.con2('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER', 92, "The default
value of a positional parameter should be preceeded by '='"); |
| 4741 static final ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = new Parser
ErrorCode.con2('WRONG_TERMINATOR_FOR_PARAMETER_GROUP', 93, "Expected '%s' to clo
se parameter group"); | 4741 static final ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = new Parser
ErrorCode.con2('WRONG_TERMINATOR_FOR_PARAMETER_GROUP', 93, "Expected '%s' to clo
se parameter group"); |
| 4742 static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con2('VAR_CLASS',
94, "Classes cannot be declared to be 'var'"); | 4742 static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con2('VAR_CLASS',
94, "Classes cannot be declared to be 'var'"); |
| 4743 static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con2('VAR_R
ETURN_TYPE', 95, "The return type cannot be 'var'"); | 4743 static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con2('VAR_R
ETURN_TYPE', 95, "The return type cannot be 'var'"); |
| 4744 static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con2('VAR_TYPED
EF', 96, "Type aliases cannot be declared to be 'var'"); | 4744 static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con2('VAR_TYPED
EF', 96, "Type aliases cannot be declared to be 'var'"); |
| 4745 static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con2('VOID_P
ARAMETER', 97, "Parameters cannot have a type of 'void'"); | 4745 static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con2('VOID_P
ARAMETER', 97, "Parameters cannot have a type of 'void'"); |
| 4746 static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con2('VOID_VA
RIABLE', 98, "Variables cannot have a type of 'void'"); | 4746 static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con2('VOID_VA
RIABLE', 98, "Variables cannot have a type of 'void'"); |
| 4747 static final List<ParserErrorCode> values = [ABSTRACT_CLASS_MEMBER, ABSTRACT_S
TATIC_METHOD, ABSTRACT_TOP_LEVEL_FUNCTION, ABSTRACT_TOP_LEVEL_VARIABLE, ABSTRACT
_TYPEDEF, BREAK_OUTSIDE_OF_LOOP, CONST_AND_FINAL, CONST_AND_VAR, CONST_CLASS, CO
NST_METHOD, CONST_TYPEDEF, CONSTRUCTOR_WITH_RETURN_TYPE, CONTINUE_OUTSIDE_OF_LOO
P, CONTINUE_WITHOUT_LABEL_IN_CASE, DIRECTIVE_AFTER_DECLARATION, DUPLICATE_LABEL_
IN_SWITCH_STATEMENT, DUPLICATED_MODIFIER, EXPECTED_CASE_OR_DEFAULT, EXPECTED_LIS
T_OR_MAP_LITERAL, EXPECTED_STRING_LITERAL, EXPECTED_TOKEN, EXPORT_DIRECTIVE_AFTE
R_PART_DIRECTIVE, EXTERNAL_AFTER_CONST, EXTERNAL_AFTER_FACTORY, EXTERNAL_AFTER_S
TATIC, EXTERNAL_CLASS, EXTERNAL_CONSTRUCTOR_WITH_BODY, EXTERNAL_FIELD, EXTERNAL_
GETTER_WITH_BODY, EXTERNAL_METHOD_WITH_BODY, EXTERNAL_OPERATOR_WITH_BODY, EXTERN
AL_SETTER_WITH_BODY, EXTERNAL_TYPEDEF, FACTORY_TOP_LEVEL_DECLARATION, FIELD_INIT
IALIZER_OUTSIDE_CONSTRUCTOR, FINAL_AND_VAR, FINAL_CLASS, FINAL_CONSTRUCTOR, FINA
L_METHOD, FINAL_TYPEDEF, GETTER_WITH_PARAMETERS, ILLEGAL_ASSIGNMENT_TO_NON_ASSIG
NABLE, IMPLEMENTS_BEFORE_EXTENDS, IMPLEMENTS_BEFORE_WITH, IMPORT_DIRECTIVE_AFTER
_PART_DIRECTIVE, INITIALIZED_VARIABLE_IN_FOR_EACH, INVALID_CODE_POINT, INVALID_C
OMMENT_REFERENCE, INVALID_HEX_ESCAPE, INVALID_OPERATOR_FOR_SUPER, INVALID_UNICOD
E_ESCAPE, LIBRARY_DIRECTIVE_NOT_FIRST, MISSING_ASSIGNABLE_SELECTOR, MISSING_CATC
H_OR_FINALLY, MISSING_CLASS_BODY, MISSING_CONST_FINAL_VAR_OR_TYPE, MISSING_FUNCT
ION_BODY, MISSING_FUNCTION_PARAMETERS, MISSING_IDENTIFIER, MISSING_NAME_IN_LIBRA
RY_DIRECTIVE, MISSING_NAME_IN_PART_OF_DIRECTIVE, MISSING_TERMINATOR_FOR_PARAMETE
R_GROUP, MISSING_TYPEDEF_PARAMETERS, MISSING_VARIABLE_IN_FOR_EACH, MIXED_PARAMET
ER_GROUPS, MULTIPLE_EXTENDS_CLAUSES, MULTIPLE_IMPLEMENTS_CLAUSES, MULTIPLE_LIBRA
RY_DIRECTIVES, MULTIPLE_NAMED_PARAMETER_GROUPS, MULTIPLE_PART_OF_DIRECTIVES, MUL
TIPLE_POSITIONAL_PARAMETER_GROUPS, MULTIPLE_VARIABLES_IN_FOR_EACH, MULTIPLE_WITH
_CLAUSES, NAMED_PARAMETER_OUTSIDE_GROUP, NON_CONSTRUCTOR_FACTORY, NON_IDENTIFIER
_LIBRARY_NAME, NON_PART_OF_DIRECTIVE_IN_PART, NON_USER_DEFINABLE_OPERATOR, POSIT
IONAL_AFTER_NAMED_ARGUMENT, POSITIONAL_PARAMETER_OUTSIDE_GROUP, STATIC_AFTER_CON
ST, STATIC_AFTER_FINAL, STATIC_AFTER_VAR, STATIC_CONSTRUCTOR, STATIC_OPERATOR, S
TATIC_TOP_LEVEL_DECLARATION, UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, UNEXPECT
ED_TOKEN, USE_OF_UNARY_PLUS_OPERATOR, WITH_BEFORE_EXTENDS, WITH_WITHOUT_EXTENDS,
WRONG_SEPARATOR_FOR_NAMED_PARAMETER, WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER,
WRONG_TERMINATOR_FOR_PARAMETER_GROUP, VAR_CLASS, VAR_RETURN_TYPE, VAR_TYPEDEF, V
OID_PARAMETER, VOID_VARIABLE]; | 4747 static final List<ParserErrorCode> values = [ABSTRACT_CLASS_MEMBER, ABSTRACT_S
TATIC_METHOD, ABSTRACT_TOP_LEVEL_FUNCTION, ABSTRACT_TOP_LEVEL_VARIABLE, ABSTRACT
_TYPEDEF, BREAK_OUTSIDE_OF_LOOP, CONST_AND_FINAL, CONST_AND_VAR, CONST_CLASS, CO
NST_METHOD, CONST_TYPEDEF, CONSTRUCTOR_WITH_RETURN_TYPE, CONTINUE_OUTSIDE_OF_LOO
P, CONTINUE_WITHOUT_LABEL_IN_CASE, DIRECTIVE_AFTER_DECLARATION, DUPLICATE_LABEL_
IN_SWITCH_STATEMENT, DUPLICATED_MODIFIER, EXPECTED_CASE_OR_DEFAULT, EXPECTED_LIS
T_OR_MAP_LITERAL, EXPECTED_STRING_LITERAL, EXPECTED_TOKEN, EXPORT_DIRECTIVE_AFTE
R_PART_DIRECTIVE, EXTERNAL_AFTER_CONST, EXTERNAL_AFTER_FACTORY, EXTERNAL_AFTER_S
TATIC, EXTERNAL_CLASS, EXTERNAL_CONSTRUCTOR_WITH_BODY, EXTERNAL_FIELD, EXTERNAL_
GETTER_WITH_BODY, EXTERNAL_METHOD_WITH_BODY, EXTERNAL_OPERATOR_WITH_BODY, EXTERN
AL_SETTER_WITH_BODY, EXTERNAL_TYPEDEF, FACTORY_TOP_LEVEL_DECLARATION, FIELD_INIT
IALIZER_OUTSIDE_CONSTRUCTOR, FINAL_AND_VAR, FINAL_CLASS, FINAL_CONSTRUCTOR, FINA
L_METHOD, FINAL_TYPEDEF, GETTER_WITH_PARAMETERS, ILLEGAL_ASSIGNMENT_TO_NON_ASSIG
NABLE, IMPLEMENTS_BEFORE_EXTENDS, IMPLEMENTS_BEFORE_WITH, IMPORT_DIRECTIVE_AFTER
_PART_DIRECTIVE, INITIALIZED_VARIABLE_IN_FOR_EACH, INVALID_CODE_POINT, INVALID_C
OMMENT_REFERENCE, INVALID_HEX_ESCAPE, INVALID_OPERATOR_FOR_SUPER, INVALID_UNICOD
E_ESCAPE, LIBRARY_DIRECTIVE_NOT_FIRST, MISSING_ASSIGNABLE_SELECTOR, MISSING_CATC
H_OR_FINALLY, MISSING_CLASS_BODY, MISSING_CONST_FINAL_VAR_OR_TYPE, MISSING_FUNCT
ION_BODY, MISSING_FUNCTION_PARAMETERS, MISSING_IDENTIFIER, MISSING_NAME_IN_LIBRA
RY_DIRECTIVE, MISSING_NAME_IN_PART_OF_DIRECTIVE, MISSING_TERMINATOR_FOR_PARAMETE
R_GROUP, MISSING_TYPEDEF_PARAMETERS, MISSING_VARIABLE_IN_FOR_EACH, MIXED_PARAMET
ER_GROUPS, MULTIPLE_EXTENDS_CLAUSES, MULTIPLE_IMPLEMENTS_CLAUSES, MULTIPLE_LIBRA
RY_DIRECTIVES, MULTIPLE_NAMED_PARAMETER_GROUPS, MULTIPLE_PART_OF_DIRECTIVES, MUL
TIPLE_POSITIONAL_PARAMETER_GROUPS, MULTIPLE_VARIABLES_IN_FOR_EACH, MULTIPLE_WITH
_CLAUSES, NAMED_PARAMETER_OUTSIDE_GROUP, NON_CONSTRUCTOR_FACTORY, NON_IDENTIFIER
_LIBRARY_NAME, NON_PART_OF_DIRECTIVE_IN_PART, NON_USER_DEFINABLE_OPERATOR, POSIT
IONAL_AFTER_NAMED_ARGUMENT, POSITIONAL_PARAMETER_OUTSIDE_GROUP, STATIC_AFTER_CON
ST, STATIC_AFTER_FINAL, STATIC_AFTER_VAR, STATIC_CONSTRUCTOR, STATIC_OPERATOR, S
TATIC_TOP_LEVEL_DECLARATION, UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP, UNEXPECT
ED_TOKEN, USE_OF_UNARY_PLUS_OPERATOR, WITH_BEFORE_EXTENDS, WITH_WITHOUT_EXTENDS,
WRONG_SEPARATOR_FOR_NAMED_PARAMETER, WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER,
WRONG_TERMINATOR_FOR_PARAMETER_GROUP, VAR_CLASS, VAR_RETURN_TYPE, VAR_TYPEDEF, V
OID_PARAMETER, VOID_VARIABLE]; |
| 4748 String __name; | 4748 String __name; |
| 4749 int __ordinal = 0; | 4749 int __ordinal = 0; |
| 4750 int get ordinal => __ordinal; |
| 4750 /** | 4751 /** |
| 4751 * The severity of this error. | 4752 * The severity of this error. |
| 4752 */ | 4753 */ |
| 4753 ErrorSeverity _severity; | 4754 ErrorSeverity _severity; |
| 4754 /** | 4755 /** |
| 4755 * The message template used to create the message to be displayed for this er
ror. | 4756 * The message template used to create the message to be displayed for this er
ror. |
| 4756 */ | 4757 */ |
| 4757 String _message; | 4758 String _message; |
| 4758 /** | 4759 /** |
| 4759 * Initialize a newly created error code to have the given severity and messag
e. | 4760 * Initialize a newly created error code to have the given severity and messag
e. |
| 4760 * @param severity the severity of the error | 4761 * @param severity the severity of the error |
| 4761 * @param message the message template used to create the message to be displa
yed for the error | 4762 * @param message the message template used to create the message to be displa
yed for the error |
| 4762 */ | 4763 */ |
| 4763 ParserErrorCode.con1(String ___name, int ___ordinal, ErrorSeverity severity2,
String message2) { | 4764 ParserErrorCode.con1(String ___name, int ___ordinal, ErrorSeverity severity2,
String message2) { |
| 4764 _jtd_constructor_252_impl(___name, ___ordinal, severity2, message2); | 4765 _jtd_constructor_258_impl(___name, ___ordinal, severity2, message2); |
| 4765 } | 4766 } |
| 4766 _jtd_constructor_252_impl(String ___name, int ___ordinal, ErrorSeverity severi
ty2, String message2) { | 4767 _jtd_constructor_258_impl(String ___name, int ___ordinal, ErrorSeverity severi
ty2, String message2) { |
| 4767 __name = ___name; | 4768 __name = ___name; |
| 4768 __ordinal = ___ordinal; | 4769 __ordinal = ___ordinal; |
| 4769 this._severity = severity2; | 4770 this._severity = severity2; |
| 4770 this._message = message2; | 4771 this._message = message2; |
| 4771 } | 4772 } |
| 4772 /** | 4773 /** |
| 4773 * Initialize a newly created error code to have the given message and a sever
ity of ERROR. | 4774 * Initialize a newly created error code to have the given message and a sever
ity of ERROR. |
| 4774 * @param message the message template used to create the message to be displa
yed for the error | 4775 * @param message the message template used to create the message to be displa
yed for the error |
| 4775 */ | 4776 */ |
| 4776 ParserErrorCode.con2(String ___name, int ___ordinal, String message) { | 4777 ParserErrorCode.con2(String ___name, int ___ordinal, String message) { |
| 4777 _jtd_constructor_253_impl(___name, ___ordinal, message); | 4778 _jtd_constructor_259_impl(___name, ___ordinal, message); |
| 4778 } | 4779 } |
| 4779 _jtd_constructor_253_impl(String ___name, int ___ordinal, String message) { | 4780 _jtd_constructor_259_impl(String ___name, int ___ordinal, String message) { |
| 4780 _jtd_constructor_252_impl(___name, ___ordinal, ErrorSeverity.ERROR, message)
; | 4781 _jtd_constructor_258_impl(___name, ___ordinal, ErrorSeverity.ERROR, message)
; |
| 4781 } | 4782 } |
| 4782 ErrorSeverity get errorSeverity => _severity; | 4783 ErrorSeverity get errorSeverity => _severity; |
| 4783 String get message => _message; | 4784 String get message => _message; |
| 4784 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 4785 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 4785 bool needsRecompilation() => true; | 4786 bool needsRecompilation() => true; |
| 4786 String toString() => __name; | 4787 String toString() => __name; |
| 4787 } | 4788 } |
| 4788 /** | 4789 /** |
| 4789 * Instances of the class {link ToFormattedSourceVisitor} write a source represe
ntation of a visited | 4790 * Instances of the class {link ToFormattedSourceVisitor} write a source represe
ntation of a visited |
| 4790 * AST node (and all of it's children) to a writer. | 4791 * AST node (and all of it's children) to a writer. |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4999 visit(node.type); | 5000 visit(node.type); |
| 5000 visit7(".", node.name); | 5001 visit7(".", node.name); |
| 5001 return null; | 5002 return null; |
| 5002 } | 5003 } |
| 5003 Object visitContinueStatement(ContinueStatement node) { | 5004 Object visitContinueStatement(ContinueStatement node) { |
| 5004 _writer.print("continue"); | 5005 _writer.print("continue"); |
| 5005 visit7(" ", node.label); | 5006 visit7(" ", node.label); |
| 5006 _writer.print(";"); | 5007 _writer.print(";"); |
| 5007 return null; | 5008 return null; |
| 5008 } | 5009 } |
| 5010 Object visitDeclaredIdentifier(DeclaredIdentifier node) { |
| 5011 visit8(node.keyword, " "); |
| 5012 visit6(node.type, " "); |
| 5013 visit(node.identifier); |
| 5014 return null; |
| 5015 } |
| 5009 Object visitDefaultFormalParameter(DefaultFormalParameter node) { | 5016 Object visitDefaultFormalParameter(DefaultFormalParameter node) { |
| 5010 visit(node.parameter); | 5017 visit(node.parameter); |
| 5011 if (node.separator != null) { | 5018 if (node.separator != null) { |
| 5012 _writer.print(" "); | 5019 _writer.print(" "); |
| 5013 _writer.print(node.separator.lexeme); | 5020 _writer.print(node.separator.lexeme); |
| 5014 visit7(" ", node.defaultValue); | 5021 visit7(" ", node.defaultValue); |
| 5015 } | 5022 } |
| 5016 return null; | 5023 return null; |
| 5017 } | 5024 } |
| 5018 Object visitDoStatement(DoStatement node) { | 5025 Object visitDoStatement(DoStatement node) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5069 } | 5076 } |
| 5070 Object visitFieldFormalParameter(FieldFormalParameter node) { | 5077 Object visitFieldFormalParameter(FieldFormalParameter node) { |
| 5071 visit8(node.keyword, " "); | 5078 visit8(node.keyword, " "); |
| 5072 visit6(node.type, " "); | 5079 visit6(node.type, " "); |
| 5073 _writer.print("this."); | 5080 _writer.print("this."); |
| 5074 visit(node.identifier); | 5081 visit(node.identifier); |
| 5075 return null; | 5082 return null; |
| 5076 } | 5083 } |
| 5077 Object visitForEachStatement(ForEachStatement node) { | 5084 Object visitForEachStatement(ForEachStatement node) { |
| 5078 _writer.print("for ("); | 5085 _writer.print("for ("); |
| 5079 visit(node.loopParameter); | 5086 visit(node.loopVariable); |
| 5080 _writer.print(" in "); | 5087 _writer.print(" in "); |
| 5081 visit(node.iterator); | 5088 visit(node.iterator); |
| 5082 _writer.print(") "); | 5089 _writer.print(") "); |
| 5083 visit(node.body); | 5090 visit(node.body); |
| 5084 return null; | 5091 return null; |
| 5085 } | 5092 } |
| 5086 Object visitFormalParameterList(FormalParameterList node) { | 5093 Object visitFormalParameterList(FormalParameterList node) { |
| 5087 String groupEnd = null; | 5094 String groupEnd = null; |
| 5088 _writer.print('('); | 5095 _writer.print('('); |
| 5089 NodeList<FormalParameter> parameters13 = node.parameters; | 5096 NodeList<FormalParameter> parameters13 = node.parameters; |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5645 for (int i = 0; i < size10; i++) { | 5652 for (int i = 0; i < size10; i++) { |
| 5646 if (i > 0) { | 5653 if (i > 0) { |
| 5647 _writer.print(separator); | 5654 _writer.print(separator); |
| 5648 } | 5655 } |
| 5649 nodes[i].accept(this); | 5656 nodes[i].accept(this); |
| 5650 } | 5657 } |
| 5651 } | 5658 } |
| 5652 } | 5659 } |
| 5653 } | 5660 } |
| 5654 } | 5661 } |
| OLD | NEW |