| 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'; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 * If the given keyword is not {@code null}, append it to the given builder, p
refixing it with a | 221 * If the given keyword is not {@code null}, append it to the given builder, p
refixing it with a |
| 222 * space if needed. | 222 * space if needed. |
| 223 * @param builder the builder to which the keyword will be appended | 223 * @param builder the builder to which the keyword will be appended |
| 224 * @param needsSpace {@code true} if the keyword needs to be prefixed with a s
pace | 224 * @param needsSpace {@code true} if the keyword needs to be prefixed with a s
pace |
| 225 * @param keyword the keyword to be appended | 225 * @param keyword the keyword to be appended |
| 226 * @return {@code true} if subsequent keywords need to be prefixed with a spac
e | 226 * @return {@code true} if subsequent keywords need to be prefixed with a spac
e |
| 227 */ | 227 */ |
| 228 bool appendKeyword(StringBuffer builder, bool needsSpace, Token keyword) { | 228 bool appendKeyword(StringBuffer builder, bool needsSpace, Token keyword) { |
| 229 if (keyword != null) { | 229 if (keyword != null) { |
| 230 if (needsSpace) { | 230 if (needsSpace) { |
| 231 builder.addCharCode(0x20); | 231 builder.writeCharCode(0x20); |
| 232 } | 232 } |
| 233 builder.add(keyword.lexeme); | 233 builder.write(keyword.lexeme); |
| 234 return true; | 234 return true; |
| 235 } | 235 } |
| 236 return needsSpace; | 236 return needsSpace; |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 /** | 239 /** |
| 240 * Instances of the class {@code Parser} are used to parse tokens into an AST st
ructure. | 240 * Instances of the class {@code Parser} are used to parse tokens into an AST st
ructure. |
| 241 */ | 241 */ |
| 242 class Parser { | 242 class Parser { |
| 243 /** | 243 /** |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 * and end indices to report an error, and don't append anything to the builde
r, if the scalar | 327 * and end indices to report an error, and don't append anything to the builde
r, if the scalar |
| 328 * value is invalid. | 328 * value is invalid. |
| 329 * @param builder the builder to which the scalar value is to be appended | 329 * @param builder the builder to which the scalar value is to be appended |
| 330 * @param escapeSequence the escape sequence that was parsed to produce the sc
alar value | 330 * @param escapeSequence the escape sequence that was parsed to produce the sc
alar value |
| 331 * @param scalarValue the value to be appended | 331 * @param scalarValue the value to be appended |
| 332 * @param startIndex the index of the first character representing the scalar
value | 332 * @param startIndex the index of the first character representing the scalar
value |
| 333 * @param endIndex the index of the last character representing the scalar val
ue | 333 * @param endIndex the index of the last character representing the scalar val
ue |
| 334 */ | 334 */ |
| 335 void appendScalarValue(StringBuffer builder, String escapeSequence, int scalar
Value, int startIndex, int endIndex) { | 335 void appendScalarValue(StringBuffer builder, String escapeSequence, int scalar
Value, int startIndex, int endIndex) { |
| 336 if (scalarValue < 0 || scalarValue > Character.MAX_CODE_POINT || (scalarValu
e >= 0xD800 && scalarValue <= 0xDFFF)) { | 336 if (scalarValue < 0 || scalarValue > Character.MAX_CODE_POINT || (scalarValu
e >= 0xD800 && scalarValue <= 0xDFFF)) { |
| 337 reportError3(ParserErrorCode.INVALID_CODE_POINT, [escapeSequence]); | 337 reportError4(ParserErrorCode.INVALID_CODE_POINT, [escapeSequence]); |
| 338 return; | 338 return; |
| 339 } | 339 } |
| 340 if (scalarValue < Character.MAX_VALUE) { | 340 if (scalarValue < Character.MAX_VALUE) { |
| 341 builder.addCharCode((scalarValue as int)); | 341 builder.writeCharCode((scalarValue as int)); |
| 342 } else { | 342 } else { |
| 343 builder.add(Character.toChars(scalarValue)); | 343 builder.write(Character.toChars(scalarValue)); |
| 344 } | 344 } |
| 345 } | 345 } |
| 346 /** | 346 /** |
| 347 * Compute the content of a string with the given literal representation. | 347 * Compute the content of a string with the given literal representation. |
| 348 * @param lexeme the literal representation of the string | 348 * @param lexeme the literal representation of the string |
| 349 * @return the actual value of the string | 349 * @return the actual value of the string |
| 350 */ | 350 */ |
| 351 String computeStringValue(String lexeme) { | 351 String computeStringValue(String lexeme) { |
| 352 if (lexeme.startsWith("r\"\"\"") || lexeme.startsWith("r'''")) { | 352 if (lexeme.startsWith("r\"\"\"") || lexeme.startsWith("r'''")) { |
| 353 if (lexeme.length > 4) { | 353 if (lexeme.length > 4) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 * | 'super' assignableSelector | 400 * | 'super' assignableSelector |
| 401 * | identifier | 401 * | identifier |
| 402 * assignableSelector ::= | 402 * assignableSelector ::= |
| 403 * '[' expression ']' | 403 * '[' expression ']' |
| 404 * | '.' identifier | 404 * | '.' identifier |
| 405 * </pre> | 405 * </pre> |
| 406 * @param expression the expression being checked | 406 * @param expression the expression being checked |
| 407 */ | 407 */ |
| 408 void ensureAssignable(Expression expression) { | 408 void ensureAssignable(Expression expression) { |
| 409 if (expression != null && !expression.isAssignable()) { | 409 if (expression != null && !expression.isAssignable()) { |
| 410 reportError3(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, []); | 410 reportError4(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, []); |
| 411 } | 411 } |
| 412 } | 412 } |
| 413 /** | 413 /** |
| 414 * If the current token is a keyword matching the given string, return it afte
r advancing to the | 414 * If the current token is a keyword matching the given string, return it afte
r advancing to the |
| 415 * next token. Otherwise report an error and return the current token without
advancing. | 415 * next token. Otherwise report an error and return the current token without
advancing. |
| 416 * @param keyword the keyword that is expected | 416 * @param keyword the keyword that is expected |
| 417 * @return the token that matched the given type | 417 * @return the token that matched the given type |
| 418 */ | 418 */ |
| 419 Token expect(Keyword keyword) { | 419 Token expect(Keyword keyword) { |
| 420 if (matches(keyword)) { | 420 if (matches(keyword)) { |
| 421 return andAdvance; | 421 return andAdvance; |
| 422 } | 422 } |
| 423 reportError3(ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax]); | 423 reportError4(ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax]); |
| 424 return _currentToken; | 424 return _currentToken; |
| 425 } | 425 } |
| 426 /** | 426 /** |
| 427 * If the current token has the expected type, return it after advancing to th
e next token. | 427 * If the current token has the expected type, return it after advancing to th
e next token. |
| 428 * Otherwise report an error and return the current token without advancing. | 428 * Otherwise report an error and return the current token without advancing. |
| 429 * @param type the type of token that is expected | 429 * @param type the type of token that is expected |
| 430 * @return the token that matched the given type | 430 * @return the token that matched the given type |
| 431 */ | 431 */ |
| 432 Token expect2(TokenType type) { | 432 Token expect2(TokenType type) { |
| 433 if (matches5(type)) { | 433 if (matches5(type)) { |
| 434 return andAdvance; | 434 return andAdvance; |
| 435 } | 435 } |
| 436 if (identical(type, TokenType.SEMICOLON)) { | 436 if (identical(type, TokenType.SEMICOLON)) { |
| 437 reportError4(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [type
.lexeme]); | 437 reportError5(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [type
.lexeme]); |
| 438 } else { | 438 } else { |
| 439 reportError3(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme]); | 439 reportError4(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme]); |
| 440 } | 440 } |
| 441 return _currentToken; | 441 return _currentToken; |
| 442 } | 442 } |
| 443 /** | 443 /** |
| 444 * Advance to the next token in the token stream, making it the new current to
ken. | 444 * Advance to the next token in the token stream, making it the new current to
ken. |
| 445 * @return the token that was current before this method was invoked | 445 * @return the token that was current before this method was invoked |
| 446 */ | 446 */ |
| 447 Token get andAdvance { | 447 Token get andAdvance { |
| 448 Token token = _currentToken; | 448 Token token = _currentToken; |
| 449 advance(); | 449 advance(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 return true; | 530 return true; |
| 531 } | 531 } |
| 532 Token token = skipTypeName(_currentToken); | 532 Token token = skipTypeName(_currentToken); |
| 533 if (token == null) { | 533 if (token == null) { |
| 534 return false; | 534 return false; |
| 535 } | 535 } |
| 536 token = skipSimpleIdentifier(token); | 536 token = skipSimpleIdentifier(token); |
| 537 if (token == null) { | 537 if (token == null) { |
| 538 return false; | 538 return false; |
| 539 } | 539 } |
| 540 TokenType type15 = token.type; | 540 TokenType type20 = token.type; |
| 541 return identical(type15, TokenType.EQ) || identical(type15, TokenType.COMMA)
|| identical(type15, TokenType.SEMICOLON) || matches3(token, Keyword.IN); | 541 return identical(type20, TokenType.EQ) || identical(type20, TokenType.COMMA)
|| identical(type20, TokenType.SEMICOLON) || matches3(token, Keyword.IN); |
| 542 } | 542 } |
| 543 /** | 543 /** |
| 544 * Return {@code true} if the current token appears to be the beginning of a s
witch member. | 544 * 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 | 545 * @return {@code true} if the current token appears to be the beginning of a
switch member |
| 546 */ | 546 */ |
| 547 bool isSwitchMember() { | 547 bool isSwitchMember() { |
| 548 Token token = _currentToken; | 548 Token token = _currentToken; |
| 549 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy
pe.COLON)) { | 549 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy
pe.COLON)) { |
| 550 token = token.next.next; | 550 token = token.next.next; |
| 551 } | 551 } |
| 552 if (identical(token.type, TokenType.KEYWORD)) { | 552 if (identical(token.type, TokenType.KEYWORD)) { |
| 553 Keyword keyword27 = ((token as KeywordToken)).keyword; | 553 Keyword keyword27 = ((token as KeywordToken)).keyword; |
| 554 return identical(keyword27, Keyword.CASE) || identical(keyword27, Keyword.
DEFAULT); | 554 return identical(keyword27, Keyword.CASE) || identical(keyword27, Keyword.
DEFAULT); |
| 555 } | 555 } |
| 556 return false; | 556 return false; |
| 557 } | 557 } |
| 558 /** | 558 /** |
| 559 * Compare the given tokens to find the token that appears first in the source
being parsed. That | 559 * 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}. | 560 * 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 | 561 * 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}. | 562 * of the arguments are {@code null}. |
| 563 * @param tokens the tokens being compared | 563 * @param tokens the tokens being compared |
| 564 * @return the token with the smallest offset | 564 * @return the token with the smallest offset |
| 565 */ | 565 */ |
| 566 Token lexicallyFirst(List<Token> tokens) { | 566 Token lexicallyFirst(List<Token> tokens) { |
| 567 Token first = null; | 567 Token first = null; |
| 568 int firstOffset = 2147483647; | 568 int firstOffset = 2147483647; |
| 569 for (Token token in tokens) { | 569 for (Token token in tokens) { |
| 570 if (token != null) { | 570 if (token != null) { |
| 571 int offset4 = token.offset; | 571 int offset5 = token.offset; |
| 572 if (offset4 < firstOffset) { | 572 if (offset5 < firstOffset) { |
| 573 first = token; | 573 first = token; |
| 574 } | 574 } |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 return first; | 577 return first; |
| 578 } | 578 } |
| 579 /** | 579 /** |
| 580 * Return {@code true} if the current token matches the given keyword. | 580 * Return {@code true} if the current token matches the given keyword. |
| 581 * @param keyword the keyword that can optionally appear in the current locati
on | 581 * @param keyword the keyword that can optionally appear in the current locati
on |
| 582 * @return {@code true} if the current token matches the given keyword | 582 * @return {@code true} if the current token matches the given keyword |
| (...skipping 11 matching lines...) Expand all Loading... |
| 594 * @param keyword the keyword that is being tested for | 594 * @param keyword the keyword that is being tested for |
| 595 * @return {@code true} if the given token matches the given keyword | 595 * @return {@code true} if the given token matches the given keyword |
| 596 */ | 596 */ |
| 597 bool matches3(Token token, Keyword keyword35) => identical(token.type, TokenTy
pe.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword35); | 597 bool matches3(Token token, Keyword keyword35) => identical(token.type, TokenTy
pe.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword35); |
| 598 /** | 598 /** |
| 599 * Return {@code true} if the given token has the given type. | 599 * Return {@code true} if the given token has the given type. |
| 600 * @param token the token being tested | 600 * @param token the token being tested |
| 601 * @param type the type of token that is being tested for | 601 * @param type the type of token that is being tested for |
| 602 * @return {@code true} if the given token has the given type | 602 * @return {@code true} if the given token has the given type |
| 603 */ | 603 */ |
| 604 bool matches4(Token token, TokenType type24) => identical(token.type, type24); | 604 bool matches4(Token token, TokenType type29) => identical(token.type, type29); |
| 605 /** | 605 /** |
| 606 * Return {@code true} if the current token has the given type. Note that this
method, unlike | 606 * 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 | 607 * 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 '>>>', | 608 * 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. | 609 * 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 | 610 * @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 | 611 * @return {@code true} if the current token has the given type |
| 612 */ | 612 */ |
| 613 bool matches5(TokenType type25) { | 613 bool matches5(TokenType type30) { |
| 614 TokenType currentType = _currentToken.type; | 614 TokenType currentType = _currentToken.type; |
| 615 if (currentType != type25) { | 615 if (currentType != type30) { |
| 616 if (identical(type25, TokenType.GT)) { | 616 if (identical(type30, TokenType.GT)) { |
| 617 if (identical(currentType, TokenType.GT_GT)) { | 617 if (identical(currentType, TokenType.GT_GT)) { |
| 618 int offset5 = _currentToken.offset; | 618 int offset6 = _currentToken.offset; |
| 619 Token first = new Token(TokenType.GT, offset5); | 619 Token first = new Token(TokenType.GT, offset6); |
| 620 Token second = new Token(TokenType.GT, offset5 + 1); | 620 Token second = new Token(TokenType.GT, offset6 + 1); |
| 621 second.setNext(_currentToken.next); | 621 second.setNext(_currentToken.next); |
| 622 first.setNext(second); | 622 first.setNext(second); |
| 623 _currentToken.previous.setNext(first); | 623 _currentToken.previous.setNext(first); |
| 624 _currentToken = first; | 624 _currentToken = first; |
| 625 return true; | 625 return true; |
| 626 } else if (identical(currentType, TokenType.GT_EQ)) { | 626 } else if (identical(currentType, TokenType.GT_EQ)) { |
| 627 int offset6 = _currentToken.offset; | 627 int offset7 = _currentToken.offset; |
| 628 Token first = new Token(TokenType.GT, offset6); | 628 Token first = new Token(TokenType.GT, offset7); |
| 629 Token second = new Token(TokenType.EQ, offset6 + 1); | 629 Token second = new Token(TokenType.EQ, offset7 + 1); |
| 630 second.setNext(_currentToken.next); | 630 second.setNext(_currentToken.next); |
| 631 first.setNext(second); | 631 first.setNext(second); |
| 632 _currentToken.previous.setNext(first); | 632 _currentToken.previous.setNext(first); |
| 633 _currentToken = first; | 633 _currentToken = first; |
| 634 return true; | 634 return true; |
| 635 } else if (identical(currentType, TokenType.GT_GT_EQ)) { | 635 } else if (identical(currentType, TokenType.GT_GT_EQ)) { |
| 636 int offset7 = _currentToken.offset; | 636 int offset8 = _currentToken.offset; |
| 637 Token first = new Token(TokenType.GT, offset7); | 637 Token first = new Token(TokenType.GT, offset8); |
| 638 Token second = new Token(TokenType.GT, offset7 + 1); | 638 Token second = new Token(TokenType.GT, offset8 + 1); |
| 639 Token third = new Token(TokenType.EQ, offset7 + 2); | 639 Token third = new Token(TokenType.EQ, offset8 + 2); |
| 640 third.setNext(_currentToken.next); | 640 third.setNext(_currentToken.next); |
| 641 second.setNext(third); | 641 second.setNext(third); |
| 642 first.setNext(second); | 642 first.setNext(second); |
| 643 _currentToken.previous.setNext(first); | 643 _currentToken.previous.setNext(first); |
| 644 _currentToken = first; | 644 _currentToken = first; |
| 645 return true; | 645 return true; |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 return false; | 648 return false; |
| 649 } | 649 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 } | 785 } |
| 786 Expression argument = parseArgument(); | 786 Expression argument = parseArgument(); |
| 787 arguments.add(argument); | 787 arguments.add(argument); |
| 788 bool foundNamedArgument = argument is NamedExpression; | 788 bool foundNamedArgument = argument is NamedExpression; |
| 789 bool generatedError = false; | 789 bool generatedError = false; |
| 790 while (optional(TokenType.COMMA)) { | 790 while (optional(TokenType.COMMA)) { |
| 791 argument = parseArgument(); | 791 argument = parseArgument(); |
| 792 arguments.add(argument); | 792 arguments.add(argument); |
| 793 if (foundNamedArgument) { | 793 if (foundNamedArgument) { |
| 794 if (!generatedError && argument is! NamedExpression) { | 794 if (!generatedError && argument is! NamedExpression) { |
| 795 reportError3(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, []); | 795 reportError4(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, []); |
| 796 generatedError = true; | 796 generatedError = true; |
| 797 } | 797 } |
| 798 } else if (argument is NamedExpression) { | 798 } else if (argument is NamedExpression) { |
| 799 foundNamedArgument = true; | 799 foundNamedArgument = true; |
| 800 } | 800 } |
| 801 } | 801 } |
| 802 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | 802 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 803 return new ArgumentList.full(leftParenthesis, arguments, rightParenthesis); | 803 return new ArgumentList.full(leftParenthesis, arguments, rightParenthesis); |
| 804 } | 804 } |
| 805 /** | 805 /** |
| (...skipping 29 matching lines...) Expand all Loading... |
| 835 return parseAssignableSelector(new SuperExpression.full(andAdvance), false
); | 835 return parseAssignableSelector(new SuperExpression.full(andAdvance), false
); |
| 836 } | 836 } |
| 837 Expression expression = parsePrimaryExpression(); | 837 Expression expression = parsePrimaryExpression(); |
| 838 bool isOptional = primaryAllowed || expression is SimpleIdentifier; | 838 bool isOptional = primaryAllowed || expression is SimpleIdentifier; |
| 839 while (true) { | 839 while (true) { |
| 840 while (matches5(TokenType.OPEN_PAREN)) { | 840 while (matches5(TokenType.OPEN_PAREN)) { |
| 841 ArgumentList argumentList = parseArgumentList(); | 841 ArgumentList argumentList = parseArgumentList(); |
| 842 if (expression is SimpleIdentifier) { | 842 if (expression is SimpleIdentifier) { |
| 843 expression = new MethodInvocation.full(null, null, (expression as Simp
leIdentifier), argumentList); | 843 expression = new MethodInvocation.full(null, null, (expression as Simp
leIdentifier), argumentList); |
| 844 } else if (expression is PrefixedIdentifier) { | 844 } else if (expression is PrefixedIdentifier) { |
| 845 PrefixedIdentifier identifier = (expression as PrefixedIdentifier); | 845 PrefixedIdentifier identifier = expression as PrefixedIdentifier; |
| 846 expression = new MethodInvocation.full(identifier.prefix, identifier.p
eriod, identifier.identifier, argumentList); | 846 expression = new MethodInvocation.full(identifier.prefix, identifier.p
eriod, identifier.identifier, argumentList); |
| 847 } else if (expression is PropertyAccess) { | 847 } else if (expression is PropertyAccess) { |
| 848 PropertyAccess access = (expression as PropertyAccess); | 848 PropertyAccess access = expression as PropertyAccess; |
| 849 expression = new MethodInvocation.full(access.target, access.operator,
access.propertyName, argumentList); | 849 expression = new MethodInvocation.full(access.target, access.operator,
access.propertyName, argumentList); |
| 850 } else { | 850 } else { |
| 851 expression = new FunctionExpressionInvocation.full(expression, argumen
tList); | 851 expression = new FunctionExpressionInvocation.full(expression, argumen
tList); |
| 852 } | 852 } |
| 853 if (!primaryAllowed) { | 853 if (!primaryAllowed) { |
| 854 isOptional = false; | 854 isOptional = false; |
| 855 } | 855 } |
| 856 } | 856 } |
| 857 Expression selectorExpression = parseAssignableSelector(expression, isOpti
onal || (expression is PrefixedIdentifier)); | 857 Expression selectorExpression = parseAssignableSelector(expression, isOpti
onal || (expression is PrefixedIdentifier)); |
| 858 if (identical(selectorExpression, expression)) { | 858 if (identical(selectorExpression, expression)) { |
| 859 if (!isOptional && (expression is PrefixedIdentifier)) { | 859 if (!isOptional && (expression is PrefixedIdentifier)) { |
| 860 PrefixedIdentifier identifier = (expression as PrefixedIdentifier); | 860 PrefixedIdentifier identifier = expression as PrefixedIdentifier; |
| 861 expression = new PropertyAccess.full(identifier.prefix, identifier.per
iod, identifier.identifier); | 861 expression = new PropertyAccess.full(identifier.prefix, identifier.per
iod, identifier.identifier); |
| 862 } | 862 } |
| 863 return expression; | 863 return expression; |
| 864 } | 864 } |
| 865 expression = selectorExpression; | 865 expression = selectorExpression; |
| 866 isOptional = true; | 866 isOptional = true; |
| 867 } | 867 } |
| 868 } | 868 } |
| 869 /** | 869 /** |
| 870 * Parse an assignable selector. | 870 * Parse an assignable selector. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 881 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { | 881 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { |
| 882 Token leftBracket = andAdvance; | 882 Token leftBracket = andAdvance; |
| 883 Expression index = parseExpression2(); | 883 Expression index = parseExpression2(); |
| 884 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); | 884 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); |
| 885 return new IndexExpression.forTarget_full(prefix, leftBracket, index, righ
tBracket); | 885 return new IndexExpression.forTarget_full(prefix, leftBracket, index, righ
tBracket); |
| 886 } else if (matches5(TokenType.PERIOD)) { | 886 } else if (matches5(TokenType.PERIOD)) { |
| 887 Token period = andAdvance; | 887 Token period = andAdvance; |
| 888 return new PropertyAccess.full(prefix, period, parseSimpleIdentifier()); | 888 return new PropertyAccess.full(prefix, period, parseSimpleIdentifier()); |
| 889 } else { | 889 } else { |
| 890 if (!optional) { | 890 if (!optional) { |
| 891 reportError3(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); | 891 reportError4(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); |
| 892 } | 892 } |
| 893 return prefix; | 893 return prefix; |
| 894 } | 894 } |
| 895 } | 895 } |
| 896 /** | 896 /** |
| 897 * Parse a bitwise and expression. | 897 * Parse a bitwise and expression. |
| 898 * <pre> | 898 * <pre> |
| 899 * bitwiseAndExpression ::= | 899 * bitwiseAndExpression ::= |
| 900 * equalityExpression ('&' equalityExpression) | 900 * equalityExpression ('&' equalityExpression) |
| 901 * | 'super' ('&' equalityExpression)+ | 901 * | 'super' ('&' equalityExpression)+ |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 Block parseBlock() { | 970 Block parseBlock() { |
| 971 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); | 971 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); |
| 972 List<Statement> statements = new List<Statement>(); | 972 List<Statement> statements = new List<Statement>(); |
| 973 Token statementStart = _currentToken; | 973 Token statementStart = _currentToken; |
| 974 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET))
{ | 974 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET))
{ |
| 975 Statement statement = parseStatement2(); | 975 Statement statement = parseStatement2(); |
| 976 if (statement != null) { | 976 if (statement != null) { |
| 977 statements.add(statement); | 977 statements.add(statement); |
| 978 } | 978 } |
| 979 if (identical(_currentToken, statementStart)) { | 979 if (identical(_currentToken, statementStart)) { |
| 980 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | 980 reportError5(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 981 advance(); | 981 advance(); |
| 982 } | 982 } |
| 983 statementStart = _currentToken; | 983 statementStart = _currentToken; |
| 984 } | 984 } |
| 985 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); | 985 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); |
| 986 return new Block.full(leftBracket, statements, rightBracket); | 986 return new Block.full(leftBracket, statements, rightBracket); |
| 987 } | 987 } |
| 988 /** | 988 /** |
| 989 * Parse a break statement. | 989 * Parse a break statement. |
| 990 * <pre> | 990 * <pre> |
| 991 * breakStatement ::= | 991 * breakStatement ::= |
| 992 * 'break' identifier? ';' | 992 * 'break' identifier? ';' |
| 993 * </pre> | 993 * </pre> |
| 994 * @return the break statement that was parsed | 994 * @return the break statement that was parsed |
| 995 */ | 995 */ |
| 996 Statement parseBreakStatement() { | 996 Statement parseBreakStatement() { |
| 997 Token breakKeyword = expect(Keyword.BREAK); | 997 Token breakKeyword = expect(Keyword.BREAK); |
| 998 SimpleIdentifier label = null; | 998 SimpleIdentifier label = null; |
| 999 if (matchesIdentifier()) { | 999 if (matchesIdentifier()) { |
| 1000 label = parseSimpleIdentifier(); | 1000 label = parseSimpleIdentifier(); |
| 1001 } | 1001 } |
| 1002 if (!_inLoop && !_inSwitch && label == null) { | 1002 if (!_inLoop && !_inSwitch && label == null) { |
| 1003 reportError4(ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, breakKeyword, []); | 1003 reportError5(ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, breakKeyword, []); |
| 1004 } | 1004 } |
| 1005 Token semicolon = expect2(TokenType.SEMICOLON); | 1005 Token semicolon = expect2(TokenType.SEMICOLON); |
| 1006 return new BreakStatement.full(breakKeyword, label, semicolon); | 1006 return new BreakStatement.full(breakKeyword, label, semicolon); |
| 1007 } | 1007 } |
| 1008 /** | 1008 /** |
| 1009 * Parse a cascade section. | 1009 * Parse a cascade section. |
| 1010 * <pre> | 1010 * <pre> |
| 1011 * cascadeSection ::= | 1011 * cascadeSection ::= |
| 1012 * '..' cascadeSelector arguments* (assignableSelector arguments*)* cascadeAss
ignment? | 1012 * '..' (cascadeSelector arguments*) (assignableSelector arguments*)* cascadeA
ssignment? |
| 1013 * cascadeSelector ::= | 1013 * cascadeSelector ::= |
| 1014 * '[' expression ']' | 1014 * '[' expression ']' |
| 1015 * | identifier | 1015 * | identifier |
| 1016 * cascadeAssignment ::= | 1016 * cascadeAssignment ::= |
| 1017 * assignmentOperator expressionWithoutCascade | 1017 * assignmentOperator expressionWithoutCascade |
| 1018 * </pre> | 1018 * </pre> |
| 1019 * @return the expression representing the cascaded method invocation | 1019 * @return the expression representing the cascaded method invocation |
| 1020 */ | 1020 */ |
| 1021 Expression parseCascadeSection() { | 1021 Expression parseCascadeSection() { |
| 1022 Token period = expect2(TokenType.PERIOD_PERIOD); | 1022 Token period = expect2(TokenType.PERIOD_PERIOD); |
| 1023 Expression expression = null; | 1023 Expression expression = null; |
| 1024 SimpleIdentifier functionName = null; | 1024 SimpleIdentifier functionName = null; |
| 1025 if (matchesIdentifier()) { | 1025 if (matchesIdentifier()) { |
| 1026 functionName = parseSimpleIdentifier(); | 1026 functionName = parseSimpleIdentifier(); |
| 1027 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) { | 1027 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) { |
| 1028 Token leftBracket = andAdvance; | 1028 Token leftBracket = andAdvance; |
| 1029 Expression index = parseExpression2(); | 1029 Expression index = parseExpression2(); |
| 1030 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); | 1030 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); |
| 1031 expression = new IndexExpression.forCascade_full(period, leftBracket, inde
x, rightBracket); | 1031 expression = new IndexExpression.forCascade_full(period, leftBracket, inde
x, rightBracket); |
| 1032 period = null; | 1032 period = null; |
| 1033 } else { | 1033 } else { |
| 1034 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentTok
en.lexeme]); | 1034 reportError5(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentTok
en.lexeme]); |
| 1035 return expression; | 1035 return expression; |
| 1036 } | 1036 } |
| 1037 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) { | 1037 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) { |
| 1038 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { | 1038 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { |
| 1039 if (functionName != null) { | 1039 if (functionName != null) { |
| 1040 expression = new MethodInvocation.full(expression, period, functionNam
e, parseArgumentList()); | 1040 expression = new MethodInvocation.full(expression, period, functionNam
e, parseArgumentList()); |
| 1041 period = null; | 1041 period = null; |
| 1042 functionName = null; | 1042 functionName = null; |
| 1043 } else if (expression == null) { | 1043 } else if (expression == null) { |
| 1044 return null; | 1044 return null; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1058 expression = selector; | 1058 expression = selector; |
| 1059 progress = true; | 1059 progress = true; |
| 1060 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { | 1060 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { |
| 1061 expression = new FunctionExpressionInvocation.full(expression, parseAr
gumentList()); | 1061 expression = new FunctionExpressionInvocation.full(expression, parseAr
gumentList()); |
| 1062 } | 1062 } |
| 1063 } | 1063 } |
| 1064 } | 1064 } |
| 1065 if (_currentToken.type.isAssignmentOperator()) { | 1065 if (_currentToken.type.isAssignmentOperator()) { |
| 1066 Token operator = andAdvance; | 1066 Token operator = andAdvance; |
| 1067 ensureAssignable(expression); | 1067 ensureAssignable(expression); |
| 1068 expression = new AssignmentExpression.full(expression, operator, parseExpr
ession2()); | 1068 expression = new AssignmentExpression.full(expression, operator, parseExpr
essionWithoutCascade()); |
| 1069 } | 1069 } |
| 1070 return expression; | 1070 return expression; |
| 1071 } | 1071 } |
| 1072 /** | 1072 /** |
| 1073 * Parse a class declaration. | 1073 * Parse a class declaration. |
| 1074 * <pre> | 1074 * <pre> |
| 1075 * classDeclaration ::= | 1075 * classDeclaration ::= |
| 1076 * metadata 'abstract'? 'class' name typeParameterList? (extendsClause withCla
use?)? implementsClause? '{' classMembers '}' | 1076 * metadata 'abstract'? 'class' name typeParameterList? (extendsClause withCla
use?)? implementsClause? '{' classMembers '}' |
| 1077 * </pre> | 1077 * </pre> |
| 1078 * @param commentAndMetadata the metadata to be associated with the member | 1078 * @param commentAndMetadata the metadata to be associated with the member |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1090 } | 1090 } |
| 1091 ExtendsClause extendsClause = null; | 1091 ExtendsClause extendsClause = null; |
| 1092 WithClause withClause = null; | 1092 WithClause withClause = null; |
| 1093 ImplementsClause implementsClause = null; | 1093 ImplementsClause implementsClause = null; |
| 1094 bool foundClause = true; | 1094 bool foundClause = true; |
| 1095 while (foundClause) { | 1095 while (foundClause) { |
| 1096 if (matches(Keyword.EXTENDS)) { | 1096 if (matches(Keyword.EXTENDS)) { |
| 1097 if (extendsClause == null) { | 1097 if (extendsClause == null) { |
| 1098 extendsClause = parseExtendsClause(); | 1098 extendsClause = parseExtendsClause(); |
| 1099 if (withClause != null) { | 1099 if (withClause != null) { |
| 1100 reportError4(ParserErrorCode.WITH_BEFORE_EXTENDS, withClause.withKey
word, []); | 1100 reportError5(ParserErrorCode.WITH_BEFORE_EXTENDS, withClause.withKey
word, []); |
| 1101 } else if (implementsClause != null) { | 1101 } else if (implementsClause != null) { |
| 1102 reportError4(ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, implementsCl
ause.keyword, []); | 1102 reportError5(ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, implementsCl
ause.keyword, []); |
| 1103 } | 1103 } |
| 1104 } else { | 1104 } else { |
| 1105 reportError4(ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, extendsClause.k
eyword, []); | 1105 reportError5(ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, extendsClause.k
eyword, []); |
| 1106 parseExtendsClause(); | 1106 parseExtendsClause(); |
| 1107 } | 1107 } |
| 1108 } else if (matches(Keyword.WITH)) { | 1108 } else if (matches(Keyword.WITH)) { |
| 1109 if (withClause == null) { | 1109 if (withClause == null) { |
| 1110 withClause = parseWithClause(); | 1110 withClause = parseWithClause(); |
| 1111 if (implementsClause != null) { | 1111 if (implementsClause != null) { |
| 1112 reportError4(ParserErrorCode.IMPLEMENTS_BEFORE_WITH, implementsClaus
e.keyword, []); | 1112 reportError5(ParserErrorCode.IMPLEMENTS_BEFORE_WITH, implementsClaus
e.keyword, []); |
| 1113 } | 1113 } |
| 1114 } else { | 1114 } else { |
| 1115 reportError4(ParserErrorCode.MULTIPLE_WITH_CLAUSES, withClause.withKey
word, []); | 1115 reportError5(ParserErrorCode.MULTIPLE_WITH_CLAUSES, withClause.withKey
word, []); |
| 1116 parseWithClause(); | 1116 parseWithClause(); |
| 1117 } | 1117 } |
| 1118 } else if (matches(Keyword.IMPLEMENTS)) { | 1118 } else if (matches(Keyword.IMPLEMENTS)) { |
| 1119 if (implementsClause == null) { | 1119 if (implementsClause == null) { |
| 1120 implementsClause = parseImplementsClause(); | 1120 implementsClause = parseImplementsClause(); |
| 1121 } else { | 1121 } else { |
| 1122 reportError4(ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, implementsCl
ause.keyword, []); | 1122 reportError5(ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, implementsCl
ause.keyword, []); |
| 1123 parseImplementsClause(); | 1123 parseImplementsClause(); |
| 1124 } | 1124 } |
| 1125 } else { | 1125 } else { |
| 1126 foundClause = false; | 1126 foundClause = false; |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 if (withClause != null && extendsClause == null) { | 1129 if (withClause != null && extendsClause == null) { |
| 1130 reportError4(ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.withKeyword,
[]); | 1130 reportError5(ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.withKeyword,
[]); |
| 1131 } | 1131 } |
| 1132 Token leftBracket = null; | 1132 Token leftBracket = null; |
| 1133 List<ClassMember> members = null; | 1133 List<ClassMember> members = null; |
| 1134 Token rightBracket = null; | 1134 Token rightBracket = null; |
| 1135 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { | 1135 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { |
| 1136 leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); | 1136 leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); |
| 1137 members = parseClassMembers(className); | 1137 members = parseClassMembers(className, ((leftBracket as BeginToken)).endTo
ken != null); |
| 1138 rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); | 1138 rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); |
| 1139 } else { | 1139 } else { |
| 1140 leftBracket = createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); | 1140 leftBracket = createSyntheticToken(TokenType.OPEN_CURLY_BRACKET); |
| 1141 rightBracket = createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); | 1141 rightBracket = createSyntheticToken(TokenType.CLOSE_CURLY_BRACKET); |
| 1142 reportError3(ParserErrorCode.MISSING_CLASS_BODY, []); | 1142 reportError4(ParserErrorCode.MISSING_CLASS_BODY, []); |
| 1143 } | 1143 } |
| 1144 return new ClassDeclaration.full(commentAndMetadata.comment, commentAndMetad
ata.metadata, abstractKeyword, keyword, name, typeParameters, extendsClause, wit
hClause, implementsClause, leftBracket, members, rightBracket); | 1144 return new ClassDeclaration.full(commentAndMetadata.comment, commentAndMetad
ata.metadata, abstractKeyword, keyword, name, typeParameters, extendsClause, wit
hClause, implementsClause, leftBracket, members, rightBracket); |
| 1145 } | 1145 } |
| 1146 /** | 1146 /** |
| 1147 * Parse a class member. | 1147 * Parse a class member. |
| 1148 * <pre> | 1148 * <pre> |
| 1149 * classMemberDefinition ::= | 1149 * classMemberDefinition ::= |
| 1150 * declaration ';' | 1150 * declaration ';' |
| 1151 * | methodSignature functionBody | 1151 * | methodSignature functionBody |
| 1152 * </pre> | 1152 * </pre> |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1178 } | 1178 } |
| 1179 } | 1179 } |
| 1180 return null; | 1180 return null; |
| 1181 } | 1181 } |
| 1182 } else if (matches(Keyword.GET) && matchesIdentifier2(peek())) { | 1182 } else if (matches(Keyword.GET) && matchesIdentifier2(peek())) { |
| 1183 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1183 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1184 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); | 1184 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); |
| 1185 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { | 1185 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { |
| 1186 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1186 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1187 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); | 1187 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, null); |
| 1188 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { | 1188 } else if (matches(Keyword.OPERATOR) && peek().isOperator() && matches4(peek
2(2), TokenType.OPEN_PAREN)) { |
| 1189 validateModifiersForOperator(modifiers); | 1189 validateModifiersForOperator(modifiers); |
| 1190 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null); | 1190 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null); |
| 1191 } else if (!matchesIdentifier()) { | 1191 } else if (!matchesIdentifier()) { |
| 1192 return null; | 1192 return null; |
| 1193 } else if (matches4(peek(), TokenType.PERIOD) && matchesIdentifier2(peek2(2)
) && matches4(peek2(3), TokenType.OPEN_PAREN)) { | 1193 } else if (matches4(peek(), TokenType.PERIOD) && matchesIdentifier2(peek2(2)
) && matches4(peek2(3), TokenType.OPEN_PAREN)) { |
| 1194 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val
idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId
entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); | 1194 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val
idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId
entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); |
| 1195 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { | 1195 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { |
| 1196 SimpleIdentifier methodName = parseSimpleIdentifier(); | 1196 SimpleIdentifier methodName = parseSimpleIdentifier(); |
| 1197 FormalParameterList parameters = parseFormalParameterList(); | 1197 FormalParameterList parameters = parseFormalParameterList(); |
| 1198 if (matches5(TokenType.COLON) || modifiers.factoryKeyword != null || metho
dName.name == className) { | 1198 if (matches5(TokenType.COLON) || modifiers.factoryKeyword != null || metho
dName.name == className) { |
| 1199 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); | 1199 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v
alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName,
null, null, parameters); |
| 1200 } | 1200 } |
| 1201 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1201 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1202 validateFormalParameterList(parameters); | 1202 validateFormalParameterList(parameters); |
| 1203 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo
rd, modifiers.staticKeyword, null, methodName, parameters); | 1203 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo
rd, modifiers.staticKeyword, null, methodName, parameters); |
| 1204 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { | 1204 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { |
| 1205 return parseInitializedIdentifierList(commentAndMetadata, modifiers.static
Keyword, validateModifiersForField(modifiers), null); | 1205 return parseInitializedIdentifierList(commentAndMetadata, modifiers.static
Keyword, validateModifiersForField(modifiers), null); |
| 1206 } | 1206 } |
| 1207 TypeName type = parseTypeName(); | 1207 TypeName type = parseTypeName(); |
| 1208 if (matches(Keyword.GET) && matchesIdentifier2(peek())) { | 1208 if (matches(Keyword.GET) && matchesIdentifier2(peek())) { |
| 1209 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1209 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1210 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); | 1210 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); |
| 1211 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { | 1211 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { |
| 1212 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1212 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1213 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); | 1213 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier
s.staticKeyword, type); |
| 1214 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { | 1214 } else if (matches(Keyword.OPERATOR) && peek().isOperator() && matches4(peek
2(2), TokenType.OPEN_PAREN)) { |
| 1215 validateModifiersForOperator(modifiers); | 1215 validateModifiersForOperator(modifiers); |
| 1216 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type); | 1216 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type); |
| 1217 } else if (!matchesIdentifier()) { | 1217 } else if (!matchesIdentifier()) { |
| 1218 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { | 1218 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { |
| 1219 validateModifiersForGetterOrSetterOrMethod(modifiers); | 1219 validateModifiersForGetterOrSetterOrMethod(modifiers); |
| 1220 return parseMethodDeclaration(commentAndMetadata, modifiers.externalKeywor
d, modifiers.staticKeyword, type); | 1220 return parseMethodDeclaration(commentAndMetadata, modifiers.externalKeywor
d, modifiers.staticKeyword, type); |
| 1221 } | 1221 } |
| 1222 return parseInitializedIdentifierList(commentAndMetadata, modifiers.staticKe
yword, validateModifiersForField(modifiers), type); | 1222 return parseInitializedIdentifierList(commentAndMetadata, modifiers.staticKe
yword, validateModifiersForField(modifiers), type); |
| 1223 } | 1223 } |
| 1224 /** | 1224 /** |
| 1225 * Parse a list of class members. | 1225 * Parse a list of class members. |
| 1226 * <pre> | 1226 * <pre> |
| 1227 * classMembers ::= | 1227 * classMembers ::= |
| 1228 * (metadata memberDefinition) | 1228 * (metadata memberDefinition) |
| 1229 * </pre> | 1229 * </pre> |
| 1230 * @param className the name of the class whose members are being parsed |
| 1231 * @param balancedBrackets {@code true} if the opening and closing brackets fo
r the class are |
| 1232 * balanced |
| 1230 * @return the list of class members that were parsed | 1233 * @return the list of class members that were parsed |
| 1231 */ | 1234 */ |
| 1232 List<ClassMember> parseClassMembers(String className) { | 1235 List<ClassMember> parseClassMembers(String className, bool balancedBrackets) { |
| 1233 List<ClassMember> members = new List<ClassMember>(); | 1236 List<ClassMember> members = new List<ClassMember>(); |
| 1234 Token memberStart = _currentToken; | 1237 Token memberStart = _currentToken; |
| 1235 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)
&& !matches(Keyword.CLASS) && !matches(Keyword.TYPEDEF)) { | 1238 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)
&& (balancedBrackets || (!matches(Keyword.CLASS) && !matches(Keyword.TYPEDEF))))
{ |
| 1236 if (matches5(TokenType.SEMICOLON)) { | 1239 if (matches5(TokenType.SEMICOLON)) { |
| 1237 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | 1240 reportError5(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 1238 advance(); | 1241 advance(); |
| 1239 } else { | 1242 } else { |
| 1240 ClassMember member = parseClassMember(className); | 1243 ClassMember member = parseClassMember(className); |
| 1241 if (member != null) { | 1244 if (member != null) { |
| 1242 members.add(member); | 1245 members.add(member); |
| 1243 } | 1246 } |
| 1244 } | 1247 } |
| 1245 if (identical(_currentToken, memberStart)) { | 1248 if (identical(_currentToken, memberStart)) { |
| 1246 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | 1249 reportError5(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 1247 advance(); | 1250 advance(); |
| 1248 } | 1251 } |
| 1249 memberStart = _currentToken; | 1252 memberStart = _currentToken; |
| 1250 } | 1253 } |
| 1251 return members; | 1254 return members; |
| 1252 } | 1255 } |
| 1253 /** | 1256 /** |
| 1254 * Parse a class type alias. | 1257 * Parse a class type alias. |
| 1255 * <pre> | 1258 * <pre> |
| 1256 * classTypeAlias ::= | 1259 * classTypeAlias ::= |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 * comment | 1340 * comment |
| 1338 * @param sourceOffset the offset of the first character of the reference sour
ce | 1341 * @param sourceOffset the offset of the first character of the reference sour
ce |
| 1339 * @return the comment reference that was parsed | 1342 * @return the comment reference that was parsed |
| 1340 */ | 1343 */ |
| 1341 CommentReference parseCommentReference(String referenceSource, int sourceOffse
t) { | 1344 CommentReference parseCommentReference(String referenceSource, int sourceOffse
t) { |
| 1342 if (referenceSource.length == 0) { | 1345 if (referenceSource.length == 0) { |
| 1343 return null; | 1346 return null; |
| 1344 } | 1347 } |
| 1345 try { | 1348 try { |
| 1346 List<bool> errorFound = [false]; | 1349 List<bool> errorFound = [false]; |
| 1347 AnalysisErrorListener listener = new AnalysisErrorListener_4(errorFound); | 1350 AnalysisErrorListener listener = new AnalysisErrorListener_6(errorFound); |
| 1348 StringScanner scanner = new StringScanner(null, referenceSource, listener)
; | 1351 StringScanner scanner = new StringScanner(null, referenceSource, listener)
; |
| 1349 scanner.setSourceStart(1, 1, sourceOffset); | 1352 scanner.setSourceStart(1, 1, sourceOffset); |
| 1350 Token firstToken = scanner.tokenize(); | 1353 Token firstToken = scanner.tokenize(); |
| 1351 if (!errorFound[0]) { | 1354 if (!errorFound[0]) { |
| 1352 Token newKeyword = null; | 1355 Token newKeyword = null; |
| 1353 if (matches3(firstToken, Keyword.NEW)) { | 1356 if (matches3(firstToken, Keyword.NEW)) { |
| 1354 newKeyword = firstToken; | 1357 newKeyword = firstToken; |
| 1355 firstToken = firstToken.next; | 1358 firstToken = firstToken.next; |
| 1356 } | 1359 } |
| 1357 if (matchesIdentifier2(firstToken)) { | 1360 if (matchesIdentifier2(firstToken)) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 } | 1445 } |
| 1443 bool libraryDirectiveFound = false; | 1446 bool libraryDirectiveFound = false; |
| 1444 bool partOfDirectiveFound = false; | 1447 bool partOfDirectiveFound = false; |
| 1445 bool partDirectiveFound = false; | 1448 bool partDirectiveFound = false; |
| 1446 bool directiveFoundAfterDeclaration = false; | 1449 bool directiveFoundAfterDeclaration = false; |
| 1447 List<Directive> directives = new List<Directive>(); | 1450 List<Directive> directives = new List<Directive>(); |
| 1448 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; | 1451 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>()
; |
| 1449 Token memberStart = _currentToken; | 1452 Token memberStart = _currentToken; |
| 1450 while (!matches5(TokenType.EOF)) { | 1453 while (!matches5(TokenType.EOF)) { |
| 1451 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); | 1454 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); |
| 1452 if (matches(Keyword.IMPORT) || matches(Keyword.EXPORT) || matches(Keyword.
LIBRARY) || matches(Keyword.PART)) { | 1455 if ((matches(Keyword.IMPORT) || matches(Keyword.EXPORT) || matches(Keyword
.LIBRARY) || matches(Keyword.PART)) && !matches4(peek(), TokenType.PERIOD) && !m
atches4(peek(), TokenType.LT)) { |
| 1453 Directive directive = parseDirective(commentAndMetadata); | 1456 Directive directive = parseDirective(commentAndMetadata); |
| 1454 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { | 1457 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { |
| 1455 reportError3(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, []); | 1458 reportError4(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, []); |
| 1456 directiveFoundAfterDeclaration = true; | 1459 directiveFoundAfterDeclaration = true; |
| 1457 } | 1460 } |
| 1458 if (directive is LibraryDirective) { | 1461 if (directive is LibraryDirective) { |
| 1459 if (libraryDirectiveFound) { | 1462 if (libraryDirectiveFound) { |
| 1460 reportError3(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, []); | 1463 reportError4(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, []); |
| 1461 } else { | 1464 } else { |
| 1462 if (directives.length > 0) { | 1465 if (directives.length > 0) { |
| 1463 reportError3(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, []); | 1466 reportError4(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, []); |
| 1464 } | 1467 } |
| 1465 libraryDirectiveFound = true; | 1468 libraryDirectiveFound = true; |
| 1466 } | 1469 } |
| 1467 } else if (directive is PartDirective) { | 1470 } else if (directive is PartDirective) { |
| 1468 partDirectiveFound = true; | 1471 partDirectiveFound = true; |
| 1469 } else if (partDirectiveFound) { | 1472 } else if (partDirectiveFound) { |
| 1470 if (directive is ExportDirective) { | 1473 if (directive is ExportDirective) { |
| 1471 reportError3(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
[]); | 1474 reportError4(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
[]); |
| 1472 } else if (directive is ImportDirective) { | 1475 } else if (directive is ImportDirective) { |
| 1473 reportError3(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
[]); | 1476 reportError4(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE,
[]); |
| 1474 } | 1477 } |
| 1475 } | 1478 } |
| 1476 if (directive is PartOfDirective) { | 1479 if (directive is PartOfDirective) { |
| 1477 if (partOfDirectiveFound) { | 1480 if (partOfDirectiveFound) { |
| 1478 reportError3(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []); | 1481 reportError4(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []); |
| 1479 } else { | 1482 } else { |
| 1480 for (Directive preceedingDirective in directives) { | 1483 for (Directive preceedingDirective in directives) { |
| 1481 reportError4(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, precee
dingDirective.keyword, []); | 1484 reportError5(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, precee
dingDirective.keyword, []); |
| 1482 } | 1485 } |
| 1483 partOfDirectiveFound = true; | 1486 partOfDirectiveFound = true; |
| 1484 } | 1487 } |
| 1485 } else { | 1488 } else { |
| 1486 if (partOfDirectiveFound) { | 1489 if (partOfDirectiveFound) { |
| 1487 reportError4(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directiv
e.keyword, []); | 1490 reportError5(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directiv
e.keyword, []); |
| 1488 } | 1491 } |
| 1489 } | 1492 } |
| 1490 directives.add(directive); | 1493 directives.add(directive); |
| 1491 } else if (matches5(TokenType.SEMICOLON)) { | 1494 } else if (matches5(TokenType.SEMICOLON)) { |
| 1492 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | 1495 reportError5(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 1493 advance(); | 1496 advance(); |
| 1494 } else { | 1497 } else { |
| 1495 CompilationUnitMember member = parseCompilationUnitMember(commentAndMeta
data); | 1498 CompilationUnitMember member = parseCompilationUnitMember(commentAndMeta
data); |
| 1496 if (member != null) { | 1499 if (member != null) { |
| 1497 declarations.add(member); | 1500 declarations.add(member); |
| 1498 } | 1501 } |
| 1499 } | 1502 } |
| 1500 if (identical(_currentToken, memberStart)) { | 1503 if (identical(_currentToken, memberStart)) { |
| 1501 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | 1504 reportError5(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 1502 advance(); | 1505 advance(); |
| 1503 } | 1506 } |
| 1504 memberStart = _currentToken; | 1507 memberStart = _currentToken; |
| 1505 } | 1508 } |
| 1506 return new CompilationUnit.full(firstToken, scriptTag, directives, declarati
ons, _currentToken); | 1509 return new CompilationUnit.full(firstToken, scriptTag, directives, declarati
ons, _currentToken); |
| 1507 } | 1510 } |
| 1508 /** | 1511 /** |
| 1509 * Parse a compilation unit member. | 1512 * Parse a compilation unit member. |
| 1510 * <pre> | 1513 * <pre> |
| 1511 * compilationUnitMember ::= | 1514 * compilationUnitMember ::= |
| 1512 * classDefinition | 1515 * classDefinition |
| 1513 * | functionTypeAlias | 1516 * | functionTypeAlias |
| 1514 * | external functionSignature | 1517 * | external functionSignature |
| 1515 * | external getterSignature | 1518 * | external getterSignature |
| 1516 * | external setterSignature | 1519 * | external setterSignature |
| 1517 * | functionSignature functionBody | 1520 * | functionSignature functionBody |
| 1518 * | returnType? getOrSet identifier formalParameterList functionBody | 1521 * | returnType? getOrSet identifier formalParameterList functionBody |
| 1519 * | (final | const) type? staticFinalDeclarationList ';' | 1522 * | (final | const) type? staticFinalDeclarationList ';' |
| 1520 * | variableDeclaration ';' | 1523 * | variableDeclaration ';' |
| 1521 * </pre> | 1524 * </pre> |
| 1522 * @param commentAndMetadata the metadata to be associated with the member | 1525 * @param commentAndMetadata the metadata to be associated with the member |
| 1523 * @return the compilation unit member that was parsed | 1526 * @return the compilation unit member that was parsed |
| 1524 */ | 1527 */ |
| 1525 CompilationUnitMember parseCompilationUnitMember(CommentAndMetadata commentAnd
Metadata) { | 1528 CompilationUnitMember parseCompilationUnitMember(CommentAndMetadata commentAnd
Metadata) { |
| 1526 Modifiers modifiers = parseModifiers(); | 1529 Modifiers modifiers = parseModifiers(); |
| 1527 if (matches(Keyword.CLASS)) { | 1530 if (matches(Keyword.CLASS)) { |
| 1528 return parseClassDeclaration(commentAndMetadata, validateModifiersForClass
(modifiers)); | 1531 return parseClassDeclaration(commentAndMetadata, validateModifiersForClass
(modifiers)); |
| 1529 } else if (matches(Keyword.TYPEDEF)) { | 1532 } else if (matches(Keyword.TYPEDEF) && !matches4(peek(), TokenType.PERIOD) &
& !matches4(peek(), TokenType.LT)) { |
| 1530 validateModifiersForTypedef(modifiers); | 1533 validateModifiersForTypedef(modifiers); |
| 1531 return parseTypeAlias(commentAndMetadata); | 1534 return parseTypeAlias(commentAndMetadata); |
| 1532 } | 1535 } |
| 1533 if (matches(Keyword.VOID)) { | 1536 if (matches(Keyword.VOID)) { |
| 1534 TypeName returnType = parseReturnType(); | 1537 TypeName returnType = parseReturnType(); |
| 1535 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p
eek())) { | 1538 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p
eek())) { |
| 1536 validateModifiersForTopLevelFunction(modifiers); | 1539 validateModifiersForTopLevelFunction(modifiers); |
| 1537 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null, false); | 1540 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null, false); |
| 1538 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { | 1541 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { |
| 1539 return null; | 1542 return null; |
| 1540 } else if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN
, TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { | 1543 } else if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN
, TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { |
| 1541 validateModifiersForTopLevelFunction(modifiers); | 1544 validateModifiersForTopLevelFunction(modifiers); |
| 1542 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null, false); | 1545 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe
yword, null, false); |
| 1543 } else { | 1546 } else { |
| 1544 if (matchesIdentifier()) { | 1547 if (matchesIdentifier()) { |
| 1545 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { | 1548 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC
OLON])) { |
| 1546 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); | 1549 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); |
| 1547 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme
nt, commentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiers
ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); | 1550 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme
nt, commentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiers
ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); |
| 1548 } | 1551 } |
| 1549 } | 1552 } |
| 1550 return null; | 1553 return null; |
| 1551 } | 1554 } |
| 1552 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi
er2(peek())) { | 1555 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi
er2(peek())) { |
| 1553 validateModifiersForTopLevelFunction(modifiers); | 1556 validateModifiersForTopLevelFunction(modifiers); |
| 1554 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null, false); | 1557 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null, false); |
| 1555 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { | 1558 } else if (matches(Keyword.OPERATOR) && peek().isOperator() && matches4(peek
2(2), TokenType.OPEN_PAREN)) { |
| 1556 return null; | 1559 return null; |
| 1557 } else if (!matchesIdentifier()) { | 1560 } else if (!matchesIdentifier()) { |
| 1558 return null; | 1561 return null; |
| 1559 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { | 1562 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { |
| 1560 validateModifiersForTopLevelFunction(modifiers); | 1563 validateModifiersForTopLevelFunction(modifiers); |
| 1561 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null, false); | 1564 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw
ord, null, false); |
| 1562 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { | 1565 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI
COLON])) { |
| 1563 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co
mmentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTop
LevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); | 1566 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co
mmentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTop
LevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); |
| 1564 } | 1567 } |
| 1565 TypeName returnType = parseReturnType(); | 1568 TypeName returnType = parseReturnType(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 } | 1645 } |
| 1643 ConstructorName redirectedConstructor = null; | 1646 ConstructorName redirectedConstructor = null; |
| 1644 FunctionBody body; | 1647 FunctionBody body; |
| 1645 if (matches5(TokenType.EQ)) { | 1648 if (matches5(TokenType.EQ)) { |
| 1646 separator = andAdvance; | 1649 separator = andAdvance; |
| 1647 redirectedConstructor = parseConstructorName(); | 1650 redirectedConstructor = parseConstructorName(); |
| 1648 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON)); | 1651 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON)); |
| 1649 } else { | 1652 } else { |
| 1650 body = parseFunctionBody(true, false); | 1653 body = parseFunctionBody(true, false); |
| 1651 if (!bodyAllowed && body is! EmptyFunctionBody) { | 1654 if (!bodyAllowed && body is! EmptyFunctionBody) { |
| 1652 reportError3(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, []); | 1655 reportError4(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, []); |
| 1653 } | 1656 } |
| 1654 } | 1657 } |
| 1655 return new ConstructorDeclaration.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, externalKeyword, constKeyword, factoryKeyword, returnType, p
eriod, name, parameters, separator, initializers, redirectedConstructor, body); | 1658 return new ConstructorDeclaration.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, externalKeyword, constKeyword, factoryKeyword, returnType, p
eriod, name, parameters, separator, initializers, redirectedConstructor, body); |
| 1656 } | 1659 } |
| 1657 /** | 1660 /** |
| 1658 * Parse a field initializer within a constructor. | 1661 * Parse a field initializer within a constructor. |
| 1659 * <pre> | 1662 * <pre> |
| 1660 * fieldInitializer: | 1663 * fieldInitializer: |
| 1661 * ('this' '.')? identifier '=' conditionalExpression cascadeSection | 1664 * ('this' '.')? identifier '=' conditionalExpression cascadeSection |
| 1662 * </pre> | 1665 * </pre> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 * Parse a continue statement. | 1711 * Parse a continue statement. |
| 1709 * <pre> | 1712 * <pre> |
| 1710 * continueStatement ::= | 1713 * continueStatement ::= |
| 1711 * 'continue' identifier? ';' | 1714 * 'continue' identifier? ';' |
| 1712 * </pre> | 1715 * </pre> |
| 1713 * @return the continue statement that was parsed | 1716 * @return the continue statement that was parsed |
| 1714 */ | 1717 */ |
| 1715 Statement parseContinueStatement() { | 1718 Statement parseContinueStatement() { |
| 1716 Token continueKeyword = expect(Keyword.CONTINUE); | 1719 Token continueKeyword = expect(Keyword.CONTINUE); |
| 1717 if (!_inLoop && !_inSwitch) { | 1720 if (!_inLoop && !_inSwitch) { |
| 1718 reportError4(ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, continueKeyword, []
); | 1721 reportError5(ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, continueKeyword, []
); |
| 1719 } | 1722 } |
| 1720 SimpleIdentifier label = null; | 1723 SimpleIdentifier label = null; |
| 1721 if (matchesIdentifier()) { | 1724 if (matchesIdentifier()) { |
| 1722 label = parseSimpleIdentifier(); | 1725 label = parseSimpleIdentifier(); |
| 1723 } | 1726 } |
| 1724 if (_inSwitch && !_inLoop && label == null) { | 1727 if (_inSwitch && !_inLoop && label == null) { |
| 1725 reportError4(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, continueKeywo
rd, []); | 1728 reportError5(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, continueKeywo
rd, []); |
| 1726 } | 1729 } |
| 1727 Token semicolon = expect2(TokenType.SEMICOLON); | 1730 Token semicolon = expect2(TokenType.SEMICOLON); |
| 1728 return new ContinueStatement.full(continueKeyword, label, semicolon); | 1731 return new ContinueStatement.full(continueKeyword, label, semicolon); |
| 1729 } | 1732 } |
| 1730 /** | 1733 /** |
| 1731 * Parse a directive. | 1734 * Parse a directive. |
| 1732 * <pre> | 1735 * <pre> |
| 1733 * directive ::= | 1736 * directive ::= |
| 1734 * exportDirective | 1737 * exportDirective |
| 1735 * | libraryDirective | 1738 * | libraryDirective |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 keyword = andAdvance; | 1964 keyword = andAdvance; |
| 1962 if (matchesIdentifier2(peek()) || matches4(peek(), TokenType.LT) || matche
s3(peek(), Keyword.THIS)) { | 1965 if (matchesIdentifier2(peek()) || matches4(peek(), TokenType.LT) || matche
s3(peek(), Keyword.THIS)) { |
| 1963 type = parseTypeName(); | 1966 type = parseTypeName(); |
| 1964 } | 1967 } |
| 1965 } else if (matches(Keyword.VAR)) { | 1968 } else if (matches(Keyword.VAR)) { |
| 1966 keyword = andAdvance; | 1969 keyword = andAdvance; |
| 1967 } else { | 1970 } else { |
| 1968 if (matchesIdentifier2(peek()) || matches4(peek(), TokenType.LT) || matche
s3(peek(), Keyword.THIS) || (matches4(peek(), TokenType.PERIOD) && matchesIdenti
fier2(peek2(2)) && (matchesIdentifier2(peek2(3)) || matches4(peek2(3), TokenType
.LT) || matches3(peek2(3), Keyword.THIS)))) { | 1971 if (matchesIdentifier2(peek()) || matches4(peek(), TokenType.LT) || matche
s3(peek(), Keyword.THIS) || (matches4(peek(), TokenType.PERIOD) && matchesIdenti
fier2(peek2(2)) && (matchesIdentifier2(peek2(3)) || matches4(peek2(3), TokenType
.LT) || matches3(peek2(3), Keyword.THIS)))) { |
| 1969 type = parseReturnType(); | 1972 type = parseReturnType(); |
| 1970 } else if (!optional) { | 1973 } else if (!optional) { |
| 1971 reportError3(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []); | 1974 reportError4(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []); |
| 1972 } | 1975 } |
| 1973 } | 1976 } |
| 1974 return new FinalConstVarOrType(keyword, type); | 1977 return new FinalConstVarOrType(keyword, type); |
| 1975 } | 1978 } |
| 1976 /** | 1979 /** |
| 1977 * Parse a formal parameter. At most one of {@code isOptional} and {@code isNa
med} can be{@code true}. | 1980 * Parse a formal parameter. At most one of {@code isOptional} and {@code isNa
med} can be{@code true}. |
| 1978 * <pre> | 1981 * <pre> |
| 1979 * defaultFormalParameter ::= | 1982 * defaultFormalParameter ::= |
| 1980 * normalFormalParameter ('=' expression)? | 1983 * normalFormalParameter ('=' expression)? |
| 1981 * defaultNamedParameter ::= | 1984 * defaultNamedParameter ::= |
| 1982 * normalFormalParameter (':' expression)? | 1985 * normalFormalParameter (':' expression)? |
| 1983 * </pre> | 1986 * </pre> |
| 1984 * @param kind the kind of parameter being expected based on the presence or a
bsence of group | 1987 * @param kind the kind of parameter being expected based on the presence or a
bsence of group |
| 1985 * delimiters | 1988 * delimiters |
| 1986 * @return the formal parameter that was parsed | 1989 * @return the formal parameter that was parsed |
| 1987 */ | 1990 */ |
| 1988 FormalParameter parseFormalParameter(ParameterKind kind) { | 1991 FormalParameter parseFormalParameter(ParameterKind kind) { |
| 1989 NormalFormalParameter parameter = parseNormalFormalParameter(); | 1992 NormalFormalParameter parameter = parseNormalFormalParameter(); |
| 1990 if (matches5(TokenType.EQ)) { | 1993 if (matches5(TokenType.EQ)) { |
| 1991 Token seperator = andAdvance; | 1994 Token seperator = andAdvance; |
| 1992 Expression defaultValue = parseExpression2(); | 1995 Expression defaultValue = parseExpression2(); |
| 1993 if (identical(kind, ParameterKind.NAMED)) { | 1996 if (identical(kind, ParameterKind.NAMED)) { |
| 1994 reportError4(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, sepera
tor, []); | 1997 reportError5(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, sepera
tor, []); |
| 1995 } else if (identical(kind, ParameterKind.REQUIRED)) { | 1998 } else if (identical(kind, ParameterKind.REQUIRED)) { |
| 1996 reportError(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, paramete
r, []); | 1999 reportError(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, paramete
r, []); |
| 1997 } | 2000 } |
| 1998 return new DefaultFormalParameter.full(parameter, kind, seperator, default
Value); | 2001 return new DefaultFormalParameter.full(parameter, kind, seperator, default
Value); |
| 1999 } else if (matches5(TokenType.COLON)) { | 2002 } else if (matches5(TokenType.COLON)) { |
| 2000 Token seperator = andAdvance; | 2003 Token seperator = andAdvance; |
| 2001 Expression defaultValue = parseExpression2(); | 2004 Expression defaultValue = parseExpression2(); |
| 2002 if (identical(kind, ParameterKind.POSITIONAL)) { | 2005 if (identical(kind, ParameterKind.POSITIONAL)) { |
| 2003 reportError4(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, s
eperator, []); | 2006 reportError5(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, s
eperator, []); |
| 2004 } else if (identical(kind, ParameterKind.REQUIRED)) { | 2007 } else if (identical(kind, ParameterKind.REQUIRED)) { |
| 2005 reportError(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, []
); | 2008 reportError(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, []
); |
| 2006 } | 2009 } |
| 2007 return new DefaultFormalParameter.full(parameter, kind, seperator, default
Value); | 2010 return new DefaultFormalParameter.full(parameter, kind, seperator, default
Value); |
| 2008 } else if (kind != ParameterKind.REQUIRED) { | 2011 } else if (kind != ParameterKind.REQUIRED) { |
| 2009 return new DefaultFormalParameter.full(parameter, kind, null, null); | 2012 return new DefaultFormalParameter.full(parameter, kind, null, null); |
| 2010 } | 2013 } |
| 2011 return parameter; | 2014 return parameter; |
| 2012 } | 2015 } |
| 2013 /** | 2016 /** |
| 2014 * Parse a list of formal parameters. | 2017 * Parse a list of formal parameters. |
| 2015 * <pre> | 2018 * <pre> |
| 2016 * formalParameterList ::= | 2019 * formalParameterList ::= |
| 2017 * '(' ')' | 2020 * '(' ')' |
| 2018 * | '(' normalFormalParameters (',' optionalFormalParameters)? ')' | 2021 * | '(' normalFormalParameters (',' optionalFormalParameters)? ')' |
| 2019 * | '(' optionalFormalParameters ')' | 2022 * | '(' optionalFormalParameters ')' |
| 2020 * normalFormalParameters ::= | 2023 * normalFormalParameters ::= |
| 2021 * normalFormalParameter (',' normalFormalParameter) | 2024 * normalFormalParameter (',' normalFormalParameter) |
| 2022 * optionalFormalParameters ::= | 2025 * optionalFormalParameters ::= |
| 2023 * optionalPositionalFormalParameters | 2026 * optionalPositionalFormalParameters |
| 2024 * | namedFormalParameters | 2027 * | namedFormalParameters |
| 2025 * optionalPositionalFormalParameters ::= | 2028 * optionalPositionalFormalParameters ::= |
| 2026 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' | 2029 * '[' defaultFormalParameter (',' defaultFormalParameter)* ']' |
| 2027 * namedFormalParameters ::= | 2030 * namedFormalParameters ::= |
| 2028 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' | 2031 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' |
| 2029 * </pre> | 2032 * </pre> |
| 2030 * @return the formal parameters that were parsed | 2033 * @return the formal parameters that were parsed |
| 2031 */ | 2034 */ |
| 2032 FormalParameterList parseFormalParameterList() { | 2035 FormalParameterList parseFormalParameterList() { |
| 2036 if (matches5(TokenType.EQ) && matches4(peek(), TokenType.OPEN_PAREN)) { |
| 2037 Token previous4 = _currentToken.previous; |
| 2038 if ((matches4(previous4, TokenType.EQ_EQ) || matches4(previous4, TokenType
.BANG_EQ)) && _currentToken.offset == previous4.offset + 2) { |
| 2039 advance(); |
| 2040 } |
| 2041 } |
| 2033 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); | 2042 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); |
| 2034 if (matches5(TokenType.CLOSE_PAREN)) { | 2043 if (matches5(TokenType.CLOSE_PAREN)) { |
| 2035 return new FormalParameterList.full(leftParenthesis, null, null, null, and
Advance); | 2044 return new FormalParameterList.full(leftParenthesis, null, null, null, and
Advance); |
| 2036 } | 2045 } |
| 2037 List<FormalParameter> parameters = new List<FormalParameter>(); | 2046 List<FormalParameter> parameters = new List<FormalParameter>(); |
| 2038 List<FormalParameter> normalParameters = new List<FormalParameter>(); | 2047 List<FormalParameter> normalParameters = new List<FormalParameter>(); |
| 2039 List<FormalParameter> positionalParameters = new List<FormalParameter>(); | 2048 List<FormalParameter> positionalParameters = new List<FormalParameter>(); |
| 2040 List<FormalParameter> namedParameters = new List<FormalParameter>(); | 2049 List<FormalParameter> namedParameters = new List<FormalParameter>(); |
| 2041 List<FormalParameter> currentParameters = normalParameters; | 2050 List<FormalParameter> currentParameters = normalParameters; |
| 2042 Token leftSquareBracket = null; | 2051 Token leftSquareBracket = null; |
| 2043 Token rightSquareBracket = null; | 2052 Token rightSquareBracket = null; |
| 2044 Token leftCurlyBracket = null; | 2053 Token leftCurlyBracket = null; |
| 2045 Token rightCurlyBracket = null; | 2054 Token rightCurlyBracket = null; |
| 2046 ParameterKind kind = ParameterKind.REQUIRED; | 2055 ParameterKind kind = ParameterKind.REQUIRED; |
| 2047 bool firstParameter = true; | 2056 bool firstParameter = true; |
| 2048 bool reportedMuliplePositionalGroups = false; | 2057 bool reportedMuliplePositionalGroups = false; |
| 2049 bool reportedMulipleNamedGroups = false; | 2058 bool reportedMulipleNamedGroups = false; |
| 2050 bool reportedMixedGroups = false; | 2059 bool reportedMixedGroups = false; |
| 2051 Token initialToken = null; | 2060 Token initialToken = null; |
| 2052 do { | 2061 do { |
| 2053 if (firstParameter) { | 2062 if (firstParameter) { |
| 2054 firstParameter = false; | 2063 firstParameter = false; |
| 2055 } else if (!optional(TokenType.COMMA)) { | 2064 } else if (!optional(TokenType.COMMA)) { |
| 2056 if (((leftParenthesis as BeginToken)).endToken != null) { | 2065 if (((leftParenthesis as BeginToken)).endToken != null) { |
| 2057 reportError3(ParserErrorCode.EXPECTED_TOKEN, [TokenType.COMMA.lexeme])
; | 2066 reportError4(ParserErrorCode.EXPECTED_TOKEN, [TokenType.COMMA.lexeme])
; |
| 2058 } else { | 2067 } else { |
| 2059 break; | 2068 break; |
| 2060 } | 2069 } |
| 2061 } | 2070 } |
| 2062 initialToken = _currentToken; | 2071 initialToken = _currentToken; |
| 2063 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { | 2072 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { |
| 2064 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) { | 2073 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) { |
| 2065 reportError3(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, [])
; | 2074 reportError4(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, [])
; |
| 2066 reportedMuliplePositionalGroups = true; | 2075 reportedMuliplePositionalGroups = true; |
| 2067 } | 2076 } |
| 2068 if (leftCurlyBracket != null && !reportedMixedGroups) { | 2077 if (leftCurlyBracket != null && !reportedMixedGroups) { |
| 2069 reportError3(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); | 2078 reportError4(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); |
| 2070 reportedMixedGroups = true; | 2079 reportedMixedGroups = true; |
| 2071 } | 2080 } |
| 2072 leftSquareBracket = andAdvance; | 2081 leftSquareBracket = andAdvance; |
| 2073 currentParameters = positionalParameters; | 2082 currentParameters = positionalParameters; |
| 2074 kind = ParameterKind.POSITIONAL; | 2083 kind = ParameterKind.POSITIONAL; |
| 2075 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { | 2084 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { |
| 2076 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) { | 2085 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) { |
| 2077 reportError3(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, []); | 2086 reportError4(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, []); |
| 2078 reportedMulipleNamedGroups = true; | 2087 reportedMulipleNamedGroups = true; |
| 2079 } | 2088 } |
| 2080 if (leftSquareBracket != null && !reportedMixedGroups) { | 2089 if (leftSquareBracket != null && !reportedMixedGroups) { |
| 2081 reportError3(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); | 2090 reportError4(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); |
| 2082 reportedMixedGroups = true; | 2091 reportedMixedGroups = true; |
| 2083 } | 2092 } |
| 2084 leftCurlyBracket = andAdvance; | 2093 leftCurlyBracket = andAdvance; |
| 2085 currentParameters = namedParameters; | 2094 currentParameters = namedParameters; |
| 2086 kind = ParameterKind.NAMED; | 2095 kind = ParameterKind.NAMED; |
| 2087 } | 2096 } |
| 2088 FormalParameter parameter = parseFormalParameter(kind); | 2097 FormalParameter parameter = parseFormalParameter(kind); |
| 2089 parameters.add(parameter); | 2098 parameters.add(parameter); |
| 2090 currentParameters.add(parameter); | 2099 currentParameters.add(parameter); |
| 2091 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) { | 2100 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) { |
| 2092 rightSquareBracket = andAdvance; | 2101 rightSquareBracket = andAdvance; |
| 2093 currentParameters = normalParameters; | 2102 currentParameters = normalParameters; |
| 2094 if (leftSquareBracket == null) { | 2103 if (leftSquareBracket == null) { |
| 2104 if (leftCurlyBracket != null) { |
| 2105 reportError4(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [
"}"]); |
| 2106 rightCurlyBracket = rightSquareBracket; |
| 2107 rightSquareBracket = null; |
| 2108 } else { |
| 2109 reportError4(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO
UP, ["["]); |
| 2110 } |
| 2095 } | 2111 } |
| 2096 kind = ParameterKind.REQUIRED; | 2112 kind = ParameterKind.REQUIRED; |
| 2097 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { | 2113 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { |
| 2098 rightCurlyBracket = andAdvance; | 2114 rightCurlyBracket = andAdvance; |
| 2099 currentParameters = normalParameters; | 2115 currentParameters = normalParameters; |
| 2100 if (leftCurlyBracket == null) { | 2116 if (leftCurlyBracket == null) { |
| 2117 if (leftSquareBracket != null) { |
| 2118 reportError4(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [
"]"]); |
| 2119 rightSquareBracket = rightCurlyBracket; |
| 2120 rightCurlyBracket = null; |
| 2121 } else { |
| 2122 reportError4(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO
UP, ["{"]); |
| 2123 } |
| 2101 } | 2124 } |
| 2102 kind = ParameterKind.REQUIRED; | 2125 kind = ParameterKind.REQUIRED; |
| 2103 } | 2126 } |
| 2104 } while (!matches5(TokenType.CLOSE_PAREN) && initialToken != _currentToken); | 2127 } while (!matches5(TokenType.CLOSE_PAREN) && initialToken != _currentToken); |
| 2105 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | 2128 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 2106 if (leftSquareBracket != null && rightSquareBracket == null) { | 2129 if (leftSquareBracket != null && rightSquareBracket == null) { |
| 2130 reportError4(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]
); |
| 2107 } | 2131 } |
| 2108 if (leftCurlyBracket != null && rightCurlyBracket == null) { | 2132 if (leftCurlyBracket != null && rightCurlyBracket == null) { |
| 2133 reportError4(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]
); |
| 2109 } | 2134 } |
| 2110 if (leftSquareBracket == null) { | 2135 if (leftSquareBracket == null) { |
| 2111 leftSquareBracket = leftCurlyBracket; | 2136 leftSquareBracket = leftCurlyBracket; |
| 2112 } | 2137 } |
| 2113 if (rightSquareBracket == null) { | 2138 if (rightSquareBracket == null) { |
| 2114 rightSquareBracket = rightCurlyBracket; | 2139 rightSquareBracket = rightCurlyBracket; |
| 2115 } | 2140 } |
| 2116 return new FormalParameterList.full(leftParenthesis, parameters, leftSquareB
racket, rightSquareBracket, rightParenthesis); | 2141 return new FormalParameterList.full(leftParenthesis, parameters, leftSquareB
racket, rightSquareBracket, rightParenthesis); |
| 2117 } | 2142 } |
| 2118 /** | 2143 /** |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2145 variables.add(new VariableDeclaration.full(null, null, variableName, n
ull, null)); | 2170 variables.add(new VariableDeclaration.full(null, null, variableName, n
ull, null)); |
| 2146 variableList = new VariableDeclarationList.full(null, null, variables)
; | 2171 variableList = new VariableDeclarationList.full(null, null, variables)
; |
| 2147 } else if (isInitializedVariableDeclaration()) { | 2172 } else if (isInitializedVariableDeclaration()) { |
| 2148 variableList = parseVariableDeclarationList(); | 2173 variableList = parseVariableDeclarationList(); |
| 2149 } else { | 2174 } else { |
| 2150 initialization = parseExpression2(); | 2175 initialization = parseExpression2(); |
| 2151 } | 2176 } |
| 2152 if (matches(Keyword.IN)) { | 2177 if (matches(Keyword.IN)) { |
| 2153 SimpleFormalParameter loopParameter = null; | 2178 SimpleFormalParameter loopParameter = null; |
| 2154 if (variableList == null) { | 2179 if (variableList == null) { |
| 2155 reportError3(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); | 2180 reportError4(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); |
| 2156 } else { | 2181 } else { |
| 2157 NodeList<VariableDeclaration> variables3 = variableList.variables; | 2182 NodeList<VariableDeclaration> variables3 = variableList.variables; |
| 2158 if (variables3.length > 1) { | 2183 if (variables3.length > 1) { |
| 2159 reportError3(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari
ables3.length.toString()]); | 2184 reportError4(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari
ables3.length.toString()]); |
| 2160 } | 2185 } |
| 2161 VariableDeclaration variable = variables3[0]; | 2186 VariableDeclaration variable = variables3[0]; |
| 2162 if (variable.initializer != null) { | 2187 if (variable.initializer != null) { |
| 2163 reportError3(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, [])
; | 2188 reportError4(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, [])
; |
| 2164 } | 2189 } |
| 2165 loopParameter = new SimpleFormalParameter.full(null, null, variableL
ist.keyword, variableList.type, variable.name); | 2190 loopParameter = new SimpleFormalParameter.full(null, null, variableL
ist.keyword, variableList.type, variable.name); |
| 2166 } | 2191 } |
| 2167 Token inKeyword = expect(Keyword.IN); | 2192 Token inKeyword = expect(Keyword.IN); |
| 2168 Expression iterator = parseExpression2(); | 2193 Expression iterator = parseExpression2(); |
| 2169 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | 2194 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 2170 Statement body = parseStatement2(); | 2195 Statement body = parseStatement2(); |
| 2171 return new ForEachStatement.full(forKeyword, leftParenthesis, loopPara
meter, inKeyword, iterator, rightParenthesis, body); | 2196 return new ForEachStatement.full(forKeyword, leftParenthesis, loopPara
meter, inKeyword, iterator, rightParenthesis, body); |
| 2172 } | 2197 } |
| 2173 } | 2198 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2204 * @return the function body that was parsed | 2229 * @return the function body that was parsed |
| 2205 */ | 2230 */ |
| 2206 FunctionBody parseFunctionBody(bool mayBeEmpty, bool inExpression) { | 2231 FunctionBody parseFunctionBody(bool mayBeEmpty, bool inExpression) { |
| 2207 bool wasInLoop = _inLoop; | 2232 bool wasInLoop = _inLoop; |
| 2208 bool wasInSwitch = _inSwitch; | 2233 bool wasInSwitch = _inSwitch; |
| 2209 _inLoop = false; | 2234 _inLoop = false; |
| 2210 _inSwitch = false; | 2235 _inSwitch = false; |
| 2211 try { | 2236 try { |
| 2212 if (matches5(TokenType.SEMICOLON)) { | 2237 if (matches5(TokenType.SEMICOLON)) { |
| 2213 if (!mayBeEmpty) { | 2238 if (!mayBeEmpty) { |
| 2214 reportError3(ParserErrorCode.MISSING_FUNCTION_BODY, []); | 2239 reportError4(ParserErrorCode.MISSING_FUNCTION_BODY, []); |
| 2215 } | 2240 } |
| 2216 return new EmptyFunctionBody.full(andAdvance); | 2241 return new EmptyFunctionBody.full(andAdvance); |
| 2217 } else if (matches5(TokenType.FUNCTION)) { | 2242 } else if (matches5(TokenType.FUNCTION)) { |
| 2218 Token functionDefinition = andAdvance; | 2243 Token functionDefinition = andAdvance; |
| 2219 Expression expression = parseExpression2(); | 2244 Expression expression = parseExpression2(); |
| 2220 Token semicolon = null; | 2245 Token semicolon = null; |
| 2221 if (!inExpression) { | 2246 if (!inExpression) { |
| 2222 semicolon = expect2(TokenType.SEMICOLON); | 2247 semicolon = expect2(TokenType.SEMICOLON); |
| 2223 } | 2248 } |
| 2224 return new ExpressionFunctionBody.full(functionDefinition, expression, s
emicolon); | 2249 return new ExpressionFunctionBody.full(functionDefinition, expression, s
emicolon); |
| 2225 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { | 2250 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { |
| 2226 return new BlockFunctionBody.full(parseBlock()); | 2251 return new BlockFunctionBody.full(parseBlock()); |
| 2227 } else if (matches2("native")) { | 2252 } else if (matches2("native")) { |
| 2228 advance(); | 2253 advance(); |
| 2229 parseStringLiteral(); | 2254 parseStringLiteral(); |
| 2230 return new EmptyFunctionBody.full(andAdvance); | 2255 return new EmptyFunctionBody.full(andAdvance); |
| 2231 } else { | 2256 } else { |
| 2232 reportError3(ParserErrorCode.MISSING_FUNCTION_BODY, []); | 2257 reportError4(ParserErrorCode.MISSING_FUNCTION_BODY, []); |
| 2233 return new EmptyFunctionBody.full(createSyntheticToken(TokenType.SEMICOL
ON)); | 2258 return new EmptyFunctionBody.full(createSyntheticToken(TokenType.SEMICOL
ON)); |
| 2234 } | 2259 } |
| 2235 } finally { | 2260 } finally { |
| 2236 _inLoop = wasInLoop; | 2261 _inLoop = wasInLoop; |
| 2237 _inSwitch = wasInSwitch; | 2262 _inSwitch = wasInSwitch; |
| 2238 } | 2263 } |
| 2239 } | 2264 } |
| 2240 /** | 2265 /** |
| 2241 * Parse a function declaration. | 2266 * Parse a function declaration. |
| 2242 * <pre> | 2267 * <pre> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2260 } else if (matches(Keyword.SET) && !matches4(peek(), TokenType.OPEN_PAREN))
{ | 2285 } else if (matches(Keyword.SET) && !matches4(peek(), TokenType.OPEN_PAREN))
{ |
| 2261 keyword = andAdvance; | 2286 keyword = andAdvance; |
| 2262 } | 2287 } |
| 2263 SimpleIdentifier name = parseSimpleIdentifier(); | 2288 SimpleIdentifier name = parseSimpleIdentifier(); |
| 2264 FormalParameterList parameters = null; | 2289 FormalParameterList parameters = null; |
| 2265 if (!isGetter) { | 2290 if (!isGetter) { |
| 2266 if (matches5(TokenType.OPEN_PAREN)) { | 2291 if (matches5(TokenType.OPEN_PAREN)) { |
| 2267 parameters = parseFormalParameterList(); | 2292 parameters = parseFormalParameterList(); |
| 2268 validateFormalParameterList(parameters); | 2293 validateFormalParameterList(parameters); |
| 2269 } else { | 2294 } else { |
| 2270 reportError3(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, []); | 2295 reportError4(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, []); |
| 2271 } | 2296 } |
| 2272 } else if (matches5(TokenType.OPEN_PAREN)) { | 2297 } else if (matches5(TokenType.OPEN_PAREN)) { |
| 2273 reportError3(ParserErrorCode.GETTER_WITH_PARAMETERS, []); | 2298 reportError4(ParserErrorCode.GETTER_WITH_PARAMETERS, []); |
| 2274 parseFormalParameterList(); | 2299 parseFormalParameterList(); |
| 2275 } | 2300 } |
| 2276 FunctionBody body = null; | 2301 FunctionBody body = null; |
| 2277 if (externalKeyword == null) { | 2302 if (externalKeyword == null) { |
| 2278 body = parseFunctionBody(false, false); | 2303 body = parseFunctionBody(false, false); |
| 2279 } | 2304 } |
| 2280 if (!isStatement && matches5(TokenType.SEMICOLON)) { | 2305 if (!isStatement && matches5(TokenType.SEMICOLON)) { |
| 2281 reportError3(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]); | 2306 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]); |
| 2282 advance(); | 2307 advance(); |
| 2283 } | 2308 } |
| 2284 return new FunctionDeclaration.full(commentAndMetadata.comment, commentAndMe
tadata.metadata, externalKeyword, returnType, keyword, name, new FunctionExpress
ion.full(parameters, body)); | 2309 return new FunctionDeclaration.full(commentAndMetadata.comment, commentAndMe
tadata.metadata, externalKeyword, returnType, keyword, name, new FunctionExpress
ion.full(parameters, body)); |
| 2285 } | 2310 } |
| 2286 /** | 2311 /** |
| 2287 * Parse a function declaration statement. | 2312 * Parse a function declaration statement. |
| 2288 * <pre> | 2313 * <pre> |
| 2289 * functionDeclarationStatement ::= | 2314 * functionDeclarationStatement ::= |
| 2290 * functionSignature functionBody | 2315 * functionSignature functionBody |
| 2291 * </pre> | 2316 * </pre> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2333 FunctionTypeAlias parseFunctionTypeAlias(CommentAndMetadata commentAndMetadata
, Token keyword) { | 2358 FunctionTypeAlias parseFunctionTypeAlias(CommentAndMetadata commentAndMetadata
, Token keyword) { |
| 2334 TypeName returnType = null; | 2359 TypeName returnType = null; |
| 2335 if (hasReturnTypeInTypeAlias()) { | 2360 if (hasReturnTypeInTypeAlias()) { |
| 2336 returnType = parseReturnType(); | 2361 returnType = parseReturnType(); |
| 2337 } | 2362 } |
| 2338 SimpleIdentifier name = parseSimpleIdentifier2(ParserErrorCode.BUILT_IN_IDEN
TIFIER_AS_TYPEDEF_NAME); | 2363 SimpleIdentifier name = parseSimpleIdentifier2(ParserErrorCode.BUILT_IN_IDEN
TIFIER_AS_TYPEDEF_NAME); |
| 2339 TypeParameterList typeParameters = null; | 2364 TypeParameterList typeParameters = null; |
| 2340 if (matches5(TokenType.LT)) { | 2365 if (matches5(TokenType.LT)) { |
| 2341 typeParameters = parseTypeParameterList(); | 2366 typeParameters = parseTypeParameterList(); |
| 2342 } | 2367 } |
| 2343 if (matches5(TokenType.SEMICOLON)) { | 2368 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.EOF)) { |
| 2344 reportError3(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []); | 2369 reportError4(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []); |
| 2345 FormalParameterList parameters = new FormalParameterList.full(createSynthe
ticToken(TokenType.OPEN_PAREN), null, null, null, createSyntheticToken(TokenType
.CLOSE_PAREN)); | 2370 FormalParameterList parameters = new FormalParameterList.full(createSynthe
ticToken(TokenType.OPEN_PAREN), null, null, null, createSyntheticToken(TokenType
.CLOSE_PAREN)); |
| 2346 Token semicolon = expect2(TokenType.SEMICOLON); | 2371 Token semicolon = expect2(TokenType.SEMICOLON); |
| 2347 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMe
tadata.metadata, keyword, returnType, name, typeParameters, parameters, semicolo
n); | 2372 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMe
tadata.metadata, keyword, returnType, name, typeParameters, parameters, semicolo
n); |
| 2348 } else if (!matches5(TokenType.OPEN_PAREN)) { | 2373 } else if (!matches5(TokenType.OPEN_PAREN)) { |
| 2349 return null; | 2374 return null; |
| 2350 } | 2375 } |
| 2351 FormalParameterList parameters = parseFormalParameterList(); | 2376 FormalParameterList parameters = parseFormalParameterList(); |
| 2352 validateFormalParameterList(parameters); | 2377 validateFormalParameterList(parameters); |
| 2353 Token semicolon = expect2(TokenType.SEMICOLON); | 2378 Token semicolon = expect2(TokenType.SEMICOLON); |
| 2354 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMeta
data.metadata, keyword, returnType, name, typeParameters, parameters, semicolon)
; | 2379 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMeta
data.metadata, keyword, returnType, name, typeParameters, parameters, semicolon)
; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2366 * @param externalKeyword the 'external' token | 2391 * @param externalKeyword the 'external' token |
| 2367 * @param staticKeyword the static keyword, or {@code null} if the getter is n
ot static | 2392 * @param staticKeyword the static keyword, or {@code null} if the getter is n
ot static |
| 2368 * @param the return type that has already been parsed, or {@code null} if the
re was no return | 2393 * @param the return type that has already been parsed, or {@code null} if the
re was no return |
| 2369 * type | 2394 * type |
| 2370 * @return the getter that was parsed | 2395 * @return the getter that was parsed |
| 2371 */ | 2396 */ |
| 2372 MethodDeclaration parseGetter(CommentAndMetadata commentAndMetadata, Token ext
ernalKeyword, Token staticKeyword, TypeName returnType) { | 2397 MethodDeclaration parseGetter(CommentAndMetadata commentAndMetadata, Token ext
ernalKeyword, Token staticKeyword, TypeName returnType) { |
| 2373 Token propertyKeyword = expect(Keyword.GET); | 2398 Token propertyKeyword = expect(Keyword.GET); |
| 2374 SimpleIdentifier name = parseSimpleIdentifier(); | 2399 SimpleIdentifier name = parseSimpleIdentifier(); |
| 2375 if (matches5(TokenType.OPEN_PAREN) && matches4(peek(), TokenType.CLOSE_PAREN
)) { | 2400 if (matches5(TokenType.OPEN_PAREN) && matches4(peek(), TokenType.CLOSE_PAREN
)) { |
| 2376 reportError3(ParserErrorCode.GETTER_WITH_PARAMETERS, []); | 2401 reportError4(ParserErrorCode.GETTER_WITH_PARAMETERS, []); |
| 2377 advance(); | 2402 advance(); |
| 2378 advance(); | 2403 advance(); |
| 2379 } | 2404 } |
| 2380 FunctionBody body = parseFunctionBody(true, false); | 2405 FunctionBody body = parseFunctionBody(true, false); |
| 2381 if (externalKeyword != null && body is! EmptyFunctionBody) { | 2406 if (externalKeyword != null && body is! EmptyFunctionBody) { |
| 2382 reportError3(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, []); | 2407 reportError4(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, []); |
| 2383 } | 2408 } |
| 2384 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null
, name, null, body); | 2409 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null
, name, null, body); |
| 2385 } | 2410 } |
| 2386 /** | 2411 /** |
| 2387 * Parse a list of identifiers. | 2412 * Parse a list of identifiers. |
| 2388 * <pre> | 2413 * <pre> |
| 2389 * identifierList ::= | 2414 * identifierList ::= |
| 2390 * identifier (',' identifier) | 2415 * identifier (',' identifier) |
| 2391 * </pre> | 2416 * </pre> |
| 2392 * @return the list of identifiers that were parsed | 2417 * @return the list of identifiers that were parsed |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2541 * missing | 2566 * missing |
| 2542 * @return the library name that was parsed | 2567 * @return the library name that was parsed |
| 2543 */ | 2568 */ |
| 2544 LibraryIdentifier parseLibraryName(ParserErrorCode missingNameError, Token mis
singNameToken) { | 2569 LibraryIdentifier parseLibraryName(ParserErrorCode missingNameError, Token mis
singNameToken) { |
| 2545 if (matchesIdentifier()) { | 2570 if (matchesIdentifier()) { |
| 2546 return parseLibraryIdentifier(); | 2571 return parseLibraryIdentifier(); |
| 2547 } else if (matches5(TokenType.STRING)) { | 2572 } else if (matches5(TokenType.STRING)) { |
| 2548 StringLiteral string = parseStringLiteral(); | 2573 StringLiteral string = parseStringLiteral(); |
| 2549 reportError(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string, []); | 2574 reportError(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string, []); |
| 2550 } else { | 2575 } else { |
| 2551 reportError4(missingNameError, missingNameToken, []); | 2576 reportError5(missingNameError, missingNameToken, []); |
| 2552 } | 2577 } |
| 2553 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); | 2578 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); |
| 2554 components.add(createSyntheticIdentifier()); | 2579 components.add(createSyntheticIdentifier()); |
| 2555 return new LibraryIdentifier.full(components); | 2580 return new LibraryIdentifier.full(components); |
| 2556 } | 2581 } |
| 2557 /** | 2582 /** |
| 2558 * Parse a list literal. | 2583 * Parse a list literal. |
| 2559 * <pre> | 2584 * <pre> |
| 2560 * listLiteral ::= | 2585 * listLiteral ::= |
| 2561 * 'const'? typeArguments? '[' (expressionList ','?)? ']' | 2586 * 'const'? typeArguments? '[' (expressionList ','?)? ']' |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2606 TypedLiteral parseListOrMapLiteral(Token modifier) { | 2631 TypedLiteral parseListOrMapLiteral(Token modifier) { |
| 2607 TypeArgumentList typeArguments = null; | 2632 TypeArgumentList typeArguments = null; |
| 2608 if (matches5(TokenType.LT)) { | 2633 if (matches5(TokenType.LT)) { |
| 2609 typeArguments = parseTypeArgumentList(); | 2634 typeArguments = parseTypeArgumentList(); |
| 2610 } | 2635 } |
| 2611 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { | 2636 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { |
| 2612 return parseMapLiteral(modifier, typeArguments); | 2637 return parseMapLiteral(modifier, typeArguments); |
| 2613 } else if (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.IND
EX)) { | 2638 } else if (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.IND
EX)) { |
| 2614 return parseListLiteral(modifier, typeArguments); | 2639 return parseListLiteral(modifier, typeArguments); |
| 2615 } | 2640 } |
| 2616 reportError3(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, []); | 2641 reportError4(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, []); |
| 2617 return new ListLiteral.full(modifier, typeArguments, createSyntheticToken(To
kenType.OPEN_SQUARE_BRACKET), null, createSyntheticToken(TokenType.CLOSE_SQUARE_
BRACKET)); | 2642 return new ListLiteral.full(modifier, typeArguments, createSyntheticToken(To
kenType.OPEN_SQUARE_BRACKET), null, createSyntheticToken(TokenType.CLOSE_SQUARE_
BRACKET)); |
| 2618 } | 2643 } |
| 2619 /** | 2644 /** |
| 2620 * Parse a logical and expression. | 2645 * Parse a logical and expression. |
| 2621 * <pre> | 2646 * <pre> |
| 2622 * logicalAndExpression ::= | 2647 * logicalAndExpression ::= |
| 2623 * bitwiseOrExpression ('&&' bitwiseOrExpression) | 2648 * bitwiseOrExpression ('&&' bitwiseOrExpression) |
| 2624 * </pre> | 2649 * </pre> |
| 2625 * @return the logical and expression that was parsed | 2650 * @return the logical and expression that was parsed |
| 2626 */ | 2651 */ |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2747 * <pre> | 2772 * <pre> |
| 2748 * modifiers ::= | 2773 * modifiers ::= |
| 2749 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | 'var'
) | 2774 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | 'var'
) |
| 2750 * </pre> | 2775 * </pre> |
| 2751 * @return the modifiers that were parsed | 2776 * @return the modifiers that were parsed |
| 2752 */ | 2777 */ |
| 2753 Modifiers parseModifiers() { | 2778 Modifiers parseModifiers() { |
| 2754 Modifiers modifiers = new Modifiers(); | 2779 Modifiers modifiers = new Modifiers(); |
| 2755 bool progress = true; | 2780 bool progress = true; |
| 2756 while (progress) { | 2781 while (progress) { |
| 2757 if (matches(Keyword.ABSTRACT)) { | 2782 if (matches(Keyword.ABSTRACT) && !matches4(peek(), TokenType.PERIOD) && !m
atches4(peek(), TokenType.LT)) { |
| 2758 if (modifiers.abstractKeyword != null) { | 2783 if (modifiers.abstractKeyword != null) { |
| 2759 reportError3(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); | 2784 reportError4(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); |
| 2760 advance(); | 2785 advance(); |
| 2761 } else { | 2786 } else { |
| 2762 modifiers.abstractKeyword = andAdvance; | 2787 modifiers.abstractKeyword = andAdvance; |
| 2763 } | 2788 } |
| 2764 } else if (matches(Keyword.CONST)) { | 2789 } else if (matches(Keyword.CONST)) { |
| 2765 if (modifiers.constKeyword != null) { | 2790 if (modifiers.constKeyword != null) { |
| 2766 reportError3(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); | 2791 reportError4(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); |
| 2767 advance(); | 2792 advance(); |
| 2768 } else { | 2793 } else { |
| 2769 modifiers.constKeyword = andAdvance; | 2794 modifiers.constKeyword = andAdvance; |
| 2770 } | 2795 } |
| 2771 } else if (matches(Keyword.EXTERNAL)) { | 2796 } else if (matches(Keyword.EXTERNAL) && !matches4(peek(), TokenType.PERIOD
) && !matches4(peek(), TokenType.LT)) { |
| 2772 if (modifiers.externalKeyword != null) { | 2797 if (modifiers.externalKeyword != null) { |
| 2773 reportError3(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); | 2798 reportError4(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); |
| 2774 advance(); | 2799 advance(); |
| 2775 } else { | 2800 } else { |
| 2776 modifiers.externalKeyword = andAdvance; | 2801 modifiers.externalKeyword = andAdvance; |
| 2777 } | 2802 } |
| 2778 } else if (matches(Keyword.FACTORY)) { | 2803 } else if (matches(Keyword.FACTORY) && !matches4(peek(), TokenType.PERIOD)
&& !matches4(peek(), TokenType.LT)) { |
| 2779 if (modifiers.factoryKeyword != null) { | 2804 if (modifiers.factoryKeyword != null) { |
| 2780 reportError3(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); | 2805 reportError4(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); |
| 2781 advance(); | 2806 advance(); |
| 2782 } else { | 2807 } else { |
| 2783 modifiers.factoryKeyword = andAdvance; | 2808 modifiers.factoryKeyword = andAdvance; |
| 2784 } | 2809 } |
| 2785 } else if (matches(Keyword.FINAL)) { | 2810 } else if (matches(Keyword.FINAL)) { |
| 2786 if (modifiers.finalKeyword != null) { | 2811 if (modifiers.finalKeyword != null) { |
| 2787 reportError3(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); | 2812 reportError4(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); |
| 2788 advance(); | 2813 advance(); |
| 2789 } else { | 2814 } else { |
| 2790 modifiers.finalKeyword = andAdvance; | 2815 modifiers.finalKeyword = andAdvance; |
| 2791 } | 2816 } |
| 2792 } else if (matches(Keyword.STATIC)) { | 2817 } else if (matches(Keyword.STATIC) && !matches4(peek(), TokenType.PERIOD)
&& !matches4(peek(), TokenType.LT)) { |
| 2793 if (modifiers.staticKeyword != null) { | 2818 if (modifiers.staticKeyword != null) { |
| 2794 reportError3(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); | 2819 reportError4(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); |
| 2795 advance(); | 2820 advance(); |
| 2796 } else { | 2821 } else { |
| 2797 modifiers.staticKeyword = andAdvance; | 2822 modifiers.staticKeyword = andAdvance; |
| 2798 } | 2823 } |
| 2799 } else if (matches(Keyword.VAR)) { | 2824 } else if (matches(Keyword.VAR)) { |
| 2800 if (modifiers.varKeyword != null) { | 2825 if (modifiers.varKeyword != null) { |
| 2801 reportError3(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); | 2826 reportError4(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem
e]); |
| 2802 advance(); | 2827 advance(); |
| 2803 } else { | 2828 } else { |
| 2804 modifiers.varKeyword = andAdvance; | 2829 modifiers.varKeyword = andAdvance; |
| 2805 } | 2830 } |
| 2806 } else { | 2831 } else { |
| 2807 progress = false; | 2832 progress = false; |
| 2808 } | 2833 } |
| 2809 } | 2834 } |
| 2810 return modifiers; | 2835 return modifiers; |
| 2811 } | 2836 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2963 thisKeyword = andAdvance; | 2988 thisKeyword = andAdvance; |
| 2964 period = expect2(TokenType.PERIOD); | 2989 period = expect2(TokenType.PERIOD); |
| 2965 } | 2990 } |
| 2966 SimpleIdentifier identifier = parseSimpleIdentifier(); | 2991 SimpleIdentifier identifier = parseSimpleIdentifier(); |
| 2967 if (matches5(TokenType.OPEN_PAREN)) { | 2992 if (matches5(TokenType.OPEN_PAREN)) { |
| 2968 if (thisKeyword != null) { | 2993 if (thisKeyword != null) { |
| 2969 } | 2994 } |
| 2970 FormalParameterList parameters = parseFormalParameterList(); | 2995 FormalParameterList parameters = parseFormalParameterList(); |
| 2971 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c
ommentAndMetadata.metadata, holder.type, identifier, parameters); | 2996 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c
ommentAndMetadata.metadata, holder.type, identifier, parameters); |
| 2972 } | 2997 } |
| 2973 TypeName type16 = holder.type; | 2998 TypeName type21 = holder.type; |
| 2974 if (type16 != null && matches3(type16.name.beginToken, Keyword.VOID)) { | 2999 if (type21 != null && matches3(type21.name.beginToken, Keyword.VOID)) { |
| 2975 reportError4(ParserErrorCode.VOID_PARAMETER, type16.name.beginToken, []); | 3000 reportError5(ParserErrorCode.VOID_PARAMETER, type21.name.beginToken, []); |
| 2976 } | 3001 } |
| 2977 if (thisKeyword != null) { | 3002 if (thisKeyword != null) { |
| 2978 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier
); | 3003 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn
dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier
); |
| 2979 } | 3004 } |
| 2980 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd
Metadata.metadata, holder.keyword, holder.type, identifier); | 3005 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd
Metadata.metadata, holder.keyword, holder.type, identifier); |
| 2981 } | 3006 } |
| 2982 /** | 3007 /** |
| 2983 * Parse an operator declaration. | 3008 * Parse an operator declaration. |
| 2984 * <pre> | 3009 * <pre> |
| 2985 * operatorDeclaration ::= | 3010 * operatorDeclaration ::= |
| 2986 * operatorSignature (';' | functionBody) | 3011 * operatorSignature (';' | functionBody) |
| 2987 * operatorSignature ::= | 3012 * operatorSignature ::= |
| 2988 * 'external'? returnType? 'operator' operator formalParameterList | 3013 * 'external'? returnType? 'operator' operator formalParameterList |
| 2989 * </pre> | 3014 * </pre> |
| 2990 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the | 3015 * @param commentAndMetadata the documentation comment and metadata to be asso
ciated with the |
| 2991 * declaration | 3016 * declaration |
| 2992 * @param externalKeyword the 'external' token | 3017 * @param externalKeyword the 'external' token |
| 2993 * @param the return type that has already been parsed, or {@code null} if the
re was no return | 3018 * @param the return type that has already been parsed, or {@code null} if the
re was no return |
| 2994 * type | 3019 * type |
| 2995 * @return the operator declaration that was parsed | 3020 * @return the operator declaration that was parsed |
| 2996 */ | 3021 */ |
| 2997 MethodDeclaration parseOperator(CommentAndMetadata commentAndMetadata, Token e
xternalKeyword, TypeName returnType) { | 3022 MethodDeclaration parseOperator(CommentAndMetadata commentAndMetadata, Token e
xternalKeyword, TypeName returnType) { |
| 2998 Token operatorKeyword = expect(Keyword.OPERATOR); | 3023 Token operatorKeyword = expect(Keyword.OPERATOR); |
| 2999 if (!_currentToken.isUserDefinableOperator()) { | 3024 if (!_currentToken.isUserDefinableOperator()) { |
| 3000 reportError3(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.l
exeme]); | 3025 reportError4(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.l
exeme]); |
| 3001 } | 3026 } |
| 3002 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance); | 3027 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance); |
| 3003 FormalParameterList parameters = parseFormalParameterList(); | 3028 FormalParameterList parameters = parseFormalParameterList(); |
| 3004 validateFormalParameterList(parameters); | 3029 validateFormalParameterList(parameters); |
| 3005 FunctionBody body = parseFunctionBody(true, false); | 3030 FunctionBody body = parseFunctionBody(true, false); |
| 3006 if (externalKeyword != null && body is! EmptyFunctionBody) { | 3031 if (externalKeyword != null && body is! EmptyFunctionBody) { |
| 3007 reportError3(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []); | 3032 reportError4(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []); |
| 3008 } | 3033 } |
| 3009 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p
arameters, body); | 3034 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p
arameters, body); |
| 3010 } | 3035 } |
| 3011 /** | 3036 /** |
| 3012 * Parse a return type if one is given, otherwise return {@code null} without
advancing. | 3037 * Parse a return type if one is given, otherwise return {@code null} without
advancing. |
| 3013 * @return the return type that was parsed | 3038 * @return the return type that was parsed |
| 3014 */ | 3039 */ |
| 3015 TypeName parseOptionalReturnType() { | 3040 TypeName parseOptionalReturnType() { |
| 3016 if (matches(Keyword.VOID)) { | 3041 if (matches(Keyword.VOID)) { |
| 3017 return parseReturnType(); | 3042 return parseReturnType(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3057 * </pre> | 3082 * </pre> |
| 3058 * @return the postfix expression that was parsed | 3083 * @return the postfix expression that was parsed |
| 3059 */ | 3084 */ |
| 3060 Expression parsePostfixExpression() { | 3085 Expression parsePostfixExpression() { |
| 3061 Expression operand = parseAssignableExpression(true); | 3086 Expression operand = parseAssignableExpression(true); |
| 3062 if (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.PERIOD) ||
matches5(TokenType.OPEN_PAREN)) { | 3087 if (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.PERIOD) ||
matches5(TokenType.OPEN_PAREN)) { |
| 3063 do { | 3088 do { |
| 3064 if (matches5(TokenType.OPEN_PAREN)) { | 3089 if (matches5(TokenType.OPEN_PAREN)) { |
| 3065 ArgumentList argumentList = parseArgumentList(); | 3090 ArgumentList argumentList = parseArgumentList(); |
| 3066 if (operand is PropertyAccess) { | 3091 if (operand is PropertyAccess) { |
| 3067 PropertyAccess access = (operand as PropertyAccess); | 3092 PropertyAccess access = operand as PropertyAccess; |
| 3068 operand = new MethodInvocation.full(access.target, access.operator,
access.propertyName, argumentList); | 3093 operand = new MethodInvocation.full(access.target, access.operator,
access.propertyName, argumentList); |
| 3069 } else { | 3094 } else { |
| 3070 operand = new FunctionExpressionInvocation.full(operand, argumentLis
t); | 3095 operand = new FunctionExpressionInvocation.full(operand, argumentLis
t); |
| 3071 } | 3096 } |
| 3072 } else { | 3097 } else { |
| 3073 operand = parseAssignableSelector(operand, true); | 3098 operand = parseAssignableSelector(operand, true); |
| 3074 } | 3099 } |
| 3075 } while (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.PER
IOD) || matches5(TokenType.OPEN_PAREN)); | 3100 } while (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.PER
IOD) || matches5(TokenType.OPEN_PAREN)); |
| 3076 return operand; | 3101 return operand; |
| 3077 } | 3102 } |
| 3078 if (!_currentToken.type.isIncrementOperator()) { | 3103 if (!_currentToken.type.isIncrementOperator()) { |
| 3079 return operand; | 3104 return operand; |
| 3080 } | 3105 } |
| 3081 if (operand is FunctionExpressionInvocation) { | 3106 if (operand is FunctionExpressionInvocation) { |
| 3082 reportError3(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); | 3107 reportError4(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); |
| 3083 } | 3108 } |
| 3084 Token operator = andAdvance; | 3109 Token operator = andAdvance; |
| 3085 return new PostfixExpression.full(operand, operator); | 3110 return new PostfixExpression.full(operand, operator); |
| 3086 } | 3111 } |
| 3087 /** | 3112 /** |
| 3088 * Parse a prefixed identifier. | 3113 * Parse a prefixed identifier. |
| 3089 * <pre> | 3114 * <pre> |
| 3090 * prefixedIdentifier ::= | 3115 * prefixedIdentifier ::= |
| 3091 * identifier ('.' identifier)? | 3116 * identifier ('.' identifier)? |
| 3092 * </pre> | 3117 * </pre> |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3177 } | 3202 } |
| 3178 Token leftParenthesis = andAdvance; | 3203 Token leftParenthesis = andAdvance; |
| 3179 Expression expression = parseExpression2(); | 3204 Expression expression = parseExpression2(); |
| 3180 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | 3205 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 3181 return new ParenthesizedExpression.full(leftParenthesis, expression, right
Parenthesis); | 3206 return new ParenthesizedExpression.full(leftParenthesis, expression, right
Parenthesis); |
| 3182 } else if (matches5(TokenType.LT)) { | 3207 } else if (matches5(TokenType.LT)) { |
| 3183 return parseListOrMapLiteral(null); | 3208 return parseListOrMapLiteral(null); |
| 3184 } else if (matches5(TokenType.QUESTION)) { | 3209 } else if (matches5(TokenType.QUESTION)) { |
| 3185 return parseArgumentDefinitionTest(); | 3210 return parseArgumentDefinitionTest(); |
| 3186 } else if (matches(Keyword.VOID)) { | 3211 } else if (matches(Keyword.VOID)) { |
| 3187 reportError3(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]); | 3212 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]); |
| 3188 advance(); | 3213 advance(); |
| 3189 return parsePrimaryExpression(); | 3214 return parsePrimaryExpression(); |
| 3190 } else { | 3215 } else { |
| 3191 return createSyntheticIdentifier(); | 3216 return createSyntheticIdentifier(); |
| 3192 } | 3217 } |
| 3193 } | 3218 } |
| 3194 /** | 3219 /** |
| 3195 * Parse a redirecting constructor invocation. | 3220 * Parse a redirecting constructor invocation. |
| 3196 * <pre> | 3221 * <pre> |
| 3197 * redirectingConstructorInvocation ::= | 3222 * redirectingConstructorInvocation ::= |
| (...skipping 23 matching lines...) Expand all Loading... |
| 3221 */ | 3246 */ |
| 3222 Expression parseRelationalExpression() { | 3247 Expression parseRelationalExpression() { |
| 3223 if (matches(Keyword.SUPER) && _currentToken.next.type.isRelationalOperator()
) { | 3248 if (matches(Keyword.SUPER) && _currentToken.next.type.isRelationalOperator()
) { |
| 3224 Expression expression = new SuperExpression.full(andAdvance); | 3249 Expression expression = new SuperExpression.full(andAdvance); |
| 3225 Token operator = andAdvance; | 3250 Token operator = andAdvance; |
| 3226 expression = new BinaryExpression.full(expression, operator, parseShiftExp
ression()); | 3251 expression = new BinaryExpression.full(expression, operator, parseShiftExp
ression()); |
| 3227 return expression; | 3252 return expression; |
| 3228 } | 3253 } |
| 3229 Expression expression = parseShiftExpression(); | 3254 Expression expression = parseShiftExpression(); |
| 3230 if (matches(Keyword.AS)) { | 3255 if (matches(Keyword.AS)) { |
| 3231 Token isOperator = andAdvance; | 3256 Token asOperator = andAdvance; |
| 3232 expression = new AsExpression.full(expression, isOperator, parseTypeName()
); | 3257 expression = new AsExpression.full(expression, asOperator, parseTypeName()
); |
| 3233 } else if (matches(Keyword.IS)) { | 3258 } else if (matches(Keyword.IS)) { |
| 3234 Token isOperator = andAdvance; | 3259 Token isOperator = andAdvance; |
| 3235 Token notOperator = null; | 3260 Token notOperator = null; |
| 3236 if (matches5(TokenType.BANG)) { | 3261 if (matches5(TokenType.BANG)) { |
| 3237 notOperator = andAdvance; | 3262 notOperator = andAdvance; |
| 3238 } | 3263 } |
| 3239 expression = new IsExpression.full(expression, isOperator, notOperator, pa
rseTypeName()); | 3264 expression = new IsExpression.full(expression, isOperator, notOperator, pa
rseTypeName()); |
| 3240 } else if (_currentToken.type.isRelationalOperator()) { | 3265 } else if (_currentToken.type.isRelationalOperator()) { |
| 3241 Token operator = andAdvance; | 3266 Token operator = andAdvance; |
| 3242 expression = new BinaryExpression.full(expression, operator, parseShiftExp
ression()); | 3267 expression = new BinaryExpression.full(expression, operator, parseShiftExp
ression()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3292 * type | 3317 * type |
| 3293 * @return the setter that was parsed | 3318 * @return the setter that was parsed |
| 3294 */ | 3319 */ |
| 3295 MethodDeclaration parseSetter(CommentAndMetadata commentAndMetadata, Token ext
ernalKeyword, Token staticKeyword, TypeName returnType) { | 3320 MethodDeclaration parseSetter(CommentAndMetadata commentAndMetadata, Token ext
ernalKeyword, Token staticKeyword, TypeName returnType) { |
| 3296 Token propertyKeyword = expect(Keyword.SET); | 3321 Token propertyKeyword = expect(Keyword.SET); |
| 3297 SimpleIdentifier name = parseSimpleIdentifier(); | 3322 SimpleIdentifier name = parseSimpleIdentifier(); |
| 3298 FormalParameterList parameters = parseFormalParameterList(); | 3323 FormalParameterList parameters = parseFormalParameterList(); |
| 3299 validateFormalParameterList(parameters); | 3324 validateFormalParameterList(parameters); |
| 3300 FunctionBody body = parseFunctionBody(true, false); | 3325 FunctionBody body = parseFunctionBody(true, false); |
| 3301 if (externalKeyword != null && body is! EmptyFunctionBody) { | 3326 if (externalKeyword != null && body is! EmptyFunctionBody) { |
| 3302 reportError3(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, []); | 3327 reportError4(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, []); |
| 3303 } | 3328 } |
| 3304 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null
, name, parameters, body); | 3329 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta
data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null
, name, parameters, body); |
| 3305 } | 3330 } |
| 3306 /** | 3331 /** |
| 3307 * Parse a shift expression. | 3332 * Parse a shift expression. |
| 3308 * <pre> | 3333 * <pre> |
| 3309 * shiftExpression ::= | 3334 * shiftExpression ::= |
| 3310 * additiveExpression (shiftOperator additiveExpression) | 3335 * additiveExpression (shiftOperator additiveExpression) |
| 3311 * | 'super' (shiftOperator additiveExpression)+ | 3336 * | 'super' (shiftOperator additiveExpression)+ |
| 3312 * </pre> | 3337 * </pre> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3330 * <pre> | 3355 * <pre> |
| 3331 * identifier ::= | 3356 * identifier ::= |
| 3332 * IDENTIFIER | 3357 * IDENTIFIER |
| 3333 * </pre> | 3358 * </pre> |
| 3334 * @return the simple identifier that was parsed | 3359 * @return the simple identifier that was parsed |
| 3335 */ | 3360 */ |
| 3336 SimpleIdentifier parseSimpleIdentifier() { | 3361 SimpleIdentifier parseSimpleIdentifier() { |
| 3337 if (matchesIdentifier()) { | 3362 if (matchesIdentifier()) { |
| 3338 return new SimpleIdentifier.full(andAdvance); | 3363 return new SimpleIdentifier.full(andAdvance); |
| 3339 } | 3364 } |
| 3340 reportError3(ParserErrorCode.MISSING_IDENTIFIER, []); | 3365 reportError4(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 3341 return createSyntheticIdentifier(); | 3366 return createSyntheticIdentifier(); |
| 3342 } | 3367 } |
| 3343 /** | 3368 /** |
| 3344 * Parse a simple identifier and validate that it is not a built-in identifier
. | 3369 * Parse a simple identifier and validate that it is not a built-in identifier
. |
| 3345 * <pre> | 3370 * <pre> |
| 3346 * identifier ::= | 3371 * identifier ::= |
| 3347 * IDENTIFIER | 3372 * IDENTIFIER |
| 3348 * </pre> | 3373 * </pre> |
| 3349 * @param errorCode the error code to be used to report a built-in identifier
if one is found | 3374 * @param errorCode the error code to be used to report a built-in identifier
if one is found |
| 3350 * @return the simple identifier that was parsed | 3375 * @return the simple identifier that was parsed |
| 3351 */ | 3376 */ |
| 3352 SimpleIdentifier parseSimpleIdentifier2(ParserErrorCode errorCode) { | 3377 SimpleIdentifier parseSimpleIdentifier2(ParserErrorCode errorCode) { |
| 3353 if (matchesIdentifier()) { | 3378 if (matchesIdentifier()) { |
| 3354 Token token = andAdvance; | 3379 Token token = andAdvance; |
| 3355 if (identical(token.type, TokenType.KEYWORD)) { | 3380 if (identical(token.type, TokenType.KEYWORD)) { |
| 3356 reportError4(errorCode, token, [token.lexeme]); | 3381 reportError5(errorCode, token, [token.lexeme]); |
| 3357 } | 3382 } |
| 3358 return new SimpleIdentifier.full(token); | 3383 return new SimpleIdentifier.full(token); |
| 3359 } | 3384 } |
| 3360 reportError3(ParserErrorCode.MISSING_IDENTIFIER, []); | 3385 reportError4(ParserErrorCode.MISSING_IDENTIFIER, []); |
| 3361 return createSyntheticIdentifier(); | 3386 return createSyntheticIdentifier(); |
| 3362 } | 3387 } |
| 3363 /** | 3388 /** |
| 3364 * Parse a statement. | 3389 * Parse a statement. |
| 3365 * <pre> | 3390 * <pre> |
| 3366 * statement ::= | 3391 * statement ::= |
| 3367 * label* nonLabeledStatement | 3392 * label* nonLabeledStatement |
| 3368 * </pre> | 3393 * </pre> |
| 3369 * @return the statement that was parsed | 3394 * @return the statement that was parsed |
| 3370 */ | 3395 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3388 * statement | 3413 * statement |
| 3389 * </pre> | 3414 * </pre> |
| 3390 * @return the statements that were parsed | 3415 * @return the statements that were parsed |
| 3391 */ | 3416 */ |
| 3392 List<Statement> parseStatements2() { | 3417 List<Statement> parseStatements2() { |
| 3393 List<Statement> statements = new List<Statement>(); | 3418 List<Statement> statements = new List<Statement>(); |
| 3394 Token statementStart = _currentToken; | 3419 Token statementStart = _currentToken; |
| 3395 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)
&& !isSwitchMember()) { | 3420 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)
&& !isSwitchMember()) { |
| 3396 statements.add(parseStatement2()); | 3421 statements.add(parseStatement2()); |
| 3397 if (identical(_currentToken, statementStart)) { | 3422 if (identical(_currentToken, statementStart)) { |
| 3398 reportError4(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); | 3423 reportError5(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_currentT
oken.lexeme]); |
| 3399 advance(); | 3424 advance(); |
| 3400 } | 3425 } |
| 3401 statementStart = _currentToken; | 3426 statementStart = _currentToken; |
| 3402 } | 3427 } |
| 3403 return statements; | 3428 return statements; |
| 3404 } | 3429 } |
| 3405 /** | 3430 /** |
| 3406 * Parse a string literal that contains interpolations. | 3431 * Parse a string literal that contains interpolations. |
| 3407 * @return the string literal that was parsed | 3432 * @return the string literal that was parsed |
| 3408 */ | 3433 */ |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3445 List<StringLiteral> strings = new List<StringLiteral>(); | 3470 List<StringLiteral> strings = new List<StringLiteral>(); |
| 3446 while (matches5(TokenType.STRING)) { | 3471 while (matches5(TokenType.STRING)) { |
| 3447 Token string = andAdvance; | 3472 Token string = andAdvance; |
| 3448 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches5(TokenT
ype.STRING_INTERPOLATION_IDENTIFIER)) { | 3473 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches5(TokenT
ype.STRING_INTERPOLATION_IDENTIFIER)) { |
| 3449 strings.add(parseStringInterpolation(string)); | 3474 strings.add(parseStringInterpolation(string)); |
| 3450 } else { | 3475 } else { |
| 3451 strings.add(new SimpleStringLiteral.full(string, computeStringValue(stri
ng.lexeme))); | 3476 strings.add(new SimpleStringLiteral.full(string, computeStringValue(stri
ng.lexeme))); |
| 3452 } | 3477 } |
| 3453 } | 3478 } |
| 3454 if (strings.length < 1) { | 3479 if (strings.length < 1) { |
| 3455 reportError3(ParserErrorCode.EXPECTED_STRING_LITERAL, []); | 3480 reportError4(ParserErrorCode.EXPECTED_STRING_LITERAL, []); |
| 3456 return createSyntheticStringLiteral(); | 3481 return createSyntheticStringLiteral(); |
| 3457 } else if (strings.length == 1) { | 3482 } else if (strings.length == 1) { |
| 3458 return strings[0]; | 3483 return strings[0]; |
| 3459 } else { | 3484 } else { |
| 3460 return new AdjacentStrings.full(strings); | 3485 return new AdjacentStrings.full(strings); |
| 3461 } | 3486 } |
| 3462 } | 3487 } |
| 3463 /** | 3488 /** |
| 3464 * Parse a super constructor invocation. | 3489 * Parse a super constructor invocation. |
| 3465 * <pre> | 3490 * <pre> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3501 Expression expression = parseExpression2(); | 3526 Expression expression = parseExpression2(); |
| 3502 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); | 3527 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); |
| 3503 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); | 3528 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); |
| 3504 List<SwitchMember> members = new List<SwitchMember>(); | 3529 List<SwitchMember> members = new List<SwitchMember>(); |
| 3505 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET
)) { | 3530 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET
)) { |
| 3506 List<Label> labels = new List<Label>(); | 3531 List<Label> labels = new List<Label>(); |
| 3507 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { | 3532 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { |
| 3508 SimpleIdentifier identifier = parseSimpleIdentifier(); | 3533 SimpleIdentifier identifier = parseSimpleIdentifier(); |
| 3509 String label = identifier.token.lexeme; | 3534 String label = identifier.token.lexeme; |
| 3510 if (definedLabels.contains(label)) { | 3535 if (definedLabels.contains(label)) { |
| 3511 reportError4(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, id
entifier.token, [label]); | 3536 reportError5(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, id
entifier.token, [label]); |
| 3512 } else { | 3537 } else { |
| 3513 javaSetAdd(definedLabels, label); | 3538 javaSetAdd(definedLabels, label); |
| 3514 } | 3539 } |
| 3515 Token colon = expect2(TokenType.COLON); | 3540 Token colon = expect2(TokenType.COLON); |
| 3516 labels.add(new Label.full(identifier, colon)); | 3541 labels.add(new Label.full(identifier, colon)); |
| 3517 } | 3542 } |
| 3518 if (matches(Keyword.CASE)) { | 3543 if (matches(Keyword.CASE)) { |
| 3519 Token caseKeyword = andAdvance; | 3544 Token caseKeyword = andAdvance; |
| 3520 Expression caseExpression = parseExpression2(); | 3545 Expression caseExpression = parseExpression2(); |
| 3521 Token colon = expect2(TokenType.COLON); | 3546 Token colon = expect2(TokenType.COLON); |
| 3522 members.add(new SwitchCase.full(labels, caseKeyword, caseExpression, c
olon, parseStatements2())); | 3547 members.add(new SwitchCase.full(labels, caseKeyword, caseExpression, c
olon, parseStatements2())); |
| 3523 } else if (matches(Keyword.DEFAULT)) { | 3548 } else if (matches(Keyword.DEFAULT)) { |
| 3524 Token defaultKeyword = andAdvance; | 3549 Token defaultKeyword = andAdvance; |
| 3525 Token colon = expect2(TokenType.COLON); | 3550 Token colon = expect2(TokenType.COLON); |
| 3526 members.add(new SwitchDefault.full(labels, defaultKeyword, colon, pars
eStatements2())); | 3551 members.add(new SwitchDefault.full(labels, defaultKeyword, colon, pars
eStatements2())); |
| 3527 } else { | 3552 } else { |
| 3528 reportError3(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, []); | 3553 reportError4(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, []); |
| 3529 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRA
CKET) && !matches(Keyword.CASE) && !matches(Keyword.DEFAULT)) { | 3554 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRA
CKET) && !matches(Keyword.CASE) && !matches(Keyword.DEFAULT)) { |
| 3530 advance(); | 3555 advance(); |
| 3531 } | 3556 } |
| 3532 } | 3557 } |
| 3533 } | 3558 } |
| 3534 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); | 3559 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); |
| 3535 return new SwitchStatement.full(keyword, leftParenthesis, expression, righ
tParenthesis, leftBracket, members, rightBracket); | 3560 return new SwitchStatement.full(keyword, leftParenthesis, expression, righ
tParenthesis, leftBracket, members, rightBracket); |
| 3536 } finally { | 3561 } finally { |
| 3537 _inSwitch = wasInSwitch; | 3562 _inSwitch = wasInSwitch; |
| 3538 } | 3563 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3614 } | 3639 } |
| 3615 Block catchBody = parseBlock(); | 3640 Block catchBody = parseBlock(); |
| 3616 catchClauses.add(new CatchClause.full(onKeyword, exceptionType, catchKeywo
rd, leftParenthesis, exceptionParameter, comma, stackTraceParameter, rightParent
hesis, catchBody)); | 3641 catchClauses.add(new CatchClause.full(onKeyword, exceptionType, catchKeywo
rd, leftParenthesis, exceptionParameter, comma, stackTraceParameter, rightParent
hesis, catchBody)); |
| 3617 } | 3642 } |
| 3618 Token finallyKeyword = null; | 3643 Token finallyKeyword = null; |
| 3619 if (matches(Keyword.FINALLY)) { | 3644 if (matches(Keyword.FINALLY)) { |
| 3620 finallyKeyword = andAdvance; | 3645 finallyKeyword = andAdvance; |
| 3621 finallyClause = parseBlock(); | 3646 finallyClause = parseBlock(); |
| 3622 } else { | 3647 } else { |
| 3623 if (catchClauses.isEmpty) { | 3648 if (catchClauses.isEmpty) { |
| 3624 reportError3(ParserErrorCode.MISSING_CATCH_OR_FINALLY, []); | 3649 reportError4(ParserErrorCode.MISSING_CATCH_OR_FINALLY, []); |
| 3625 } | 3650 } |
| 3626 } | 3651 } |
| 3627 return new TryStatement.full(tryKeyword, body, catchClauses, finallyKeyword,
finallyClause); | 3652 return new TryStatement.full(tryKeyword, body, catchClauses, finallyKeyword,
finallyClause); |
| 3628 } | 3653 } |
| 3629 /** | 3654 /** |
| 3630 * Parse a type alias. | 3655 * Parse a type alias. |
| 3631 * <pre> | 3656 * <pre> |
| 3632 * typeAlias ::= | 3657 * typeAlias ::= |
| 3633 * 'typedef' typeAliasBody | 3658 * 'typedef' typeAliasBody |
| 3634 * typeAliasBody ::= | 3659 * typeAliasBody ::= |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3752 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(),
TokenType.PERIOD)) { | 3777 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(),
TokenType.PERIOD)) { |
| 3753 return new PrefixExpression.full(operator, parseUnaryExpression()); | 3778 return new PrefixExpression.full(operator, parseUnaryExpression()); |
| 3754 } | 3779 } |
| 3755 return new PrefixExpression.full(operator, new SuperExpression.full(andA
dvance)); | 3780 return new PrefixExpression.full(operator, new SuperExpression.full(andA
dvance)); |
| 3756 } | 3781 } |
| 3757 return new PrefixExpression.full(operator, parseUnaryExpression()); | 3782 return new PrefixExpression.full(operator, parseUnaryExpression()); |
| 3758 } else if (_currentToken.type.isIncrementOperator()) { | 3783 } else if (_currentToken.type.isIncrementOperator()) { |
| 3759 Token operator = andAdvance; | 3784 Token operator = andAdvance; |
| 3760 if (matches(Keyword.SUPER)) { | 3785 if (matches(Keyword.SUPER)) { |
| 3761 if (identical(operator.type, TokenType.MINUS_MINUS)) { | 3786 if (identical(operator.type, TokenType.MINUS_MINUS)) { |
| 3762 int offset8 = operator.offset; | 3787 int offset9 = operator.offset; |
| 3763 Token firstOperator = new Token(TokenType.MINUS, offset8); | 3788 Token firstOperator = new Token(TokenType.MINUS, offset9); |
| 3764 Token secondOperator = new Token(TokenType.MINUS, offset8 + 1); | 3789 Token secondOperator = new Token(TokenType.MINUS, offset9 + 1); |
| 3765 secondOperator.setNext(_currentToken); | 3790 secondOperator.setNext(_currentToken); |
| 3766 firstOperator.setNext(secondOperator); | 3791 firstOperator.setNext(secondOperator); |
| 3767 operator.previous.setNext(firstOperator); | 3792 operator.previous.setNext(firstOperator); |
| 3768 return new PrefixExpression.full(firstOperator, new PrefixExpression.f
ull(secondOperator, new SuperExpression.full(andAdvance))); | 3793 return new PrefixExpression.full(firstOperator, new PrefixExpression.f
ull(secondOperator, new SuperExpression.full(andAdvance))); |
| 3769 } else { | 3794 } else { |
| 3770 reportError3(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex
eme]); | 3795 reportError4(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex
eme]); |
| 3771 return new PrefixExpression.full(operator, new SuperExpression.full(an
dAdvance)); | 3796 return new PrefixExpression.full(operator, new SuperExpression.full(an
dAdvance)); |
| 3772 } | 3797 } |
| 3773 } | 3798 } |
| 3774 return new PrefixExpression.full(operator, parseAssignableExpression(false
)); | 3799 return new PrefixExpression.full(operator, parseAssignableExpression(false
)); |
| 3775 } else if (matches5(TokenType.PLUS)) { | 3800 } else if (matches5(TokenType.PLUS)) { |
| 3776 reportError3(ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR, []); | 3801 reportError4(ParserErrorCode.USE_OF_UNARY_PLUS_OPERATOR, []); |
| 3777 } | 3802 } |
| 3778 return parsePostfixExpression(); | 3803 return parsePostfixExpression(); |
| 3779 } | 3804 } |
| 3780 /** | 3805 /** |
| 3781 * Parse a variable declaration. | 3806 * Parse a variable declaration. |
| 3782 * <pre> | 3807 * <pre> |
| 3783 * variableDeclaration ::= | 3808 * variableDeclaration ::= |
| 3784 * identifier ('=' expression)? | 3809 * identifier ('=' expression)? |
| 3785 * </pre> | 3810 * </pre> |
| 3786 * @return the variable declaration that was parsed | 3811 * @return the variable declaration that was parsed |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3865 } | 3890 } |
| 3866 /** | 3891 /** |
| 3867 * Parse a with clause. | 3892 * Parse a with clause. |
| 3868 * <pre> | 3893 * <pre> |
| 3869 * withClause ::= | 3894 * withClause ::= |
| 3870 * 'with' typeName (',' typeName) | 3895 * 'with' typeName (',' typeName) |
| 3871 * </pre> | 3896 * </pre> |
| 3872 * @return the with clause that was parsed | 3897 * @return the with clause that was parsed |
| 3873 */ | 3898 */ |
| 3874 WithClause parseWithClause() { | 3899 WithClause parseWithClause() { |
| 3875 Token with6 = expect(Keyword.WITH); | 3900 Token with2 = expect(Keyword.WITH); |
| 3876 List<TypeName> types = new List<TypeName>(); | 3901 List<TypeName> types = new List<TypeName>(); |
| 3877 types.add(parseTypeName()); | 3902 types.add(parseTypeName()); |
| 3878 while (optional(TokenType.COMMA)) { | 3903 while (optional(TokenType.COMMA)) { |
| 3879 types.add(parseTypeName()); | 3904 types.add(parseTypeName()); |
| 3880 } | 3905 } |
| 3881 return new WithClause.full(with6, types); | 3906 return new WithClause.full(with2, types); |
| 3882 } | 3907 } |
| 3883 /** | 3908 /** |
| 3884 * Return the token that is immediately after the current token. This is equiv
alent to{@link #peek(int) peek(1)}. | 3909 * Return the token that is immediately after the current token. This is equiv
alent to{@link #peek(int) peek(1)}. |
| 3885 * @return the token that is immediately after the current token | 3910 * @return the token that is immediately after the current token |
| 3886 */ | 3911 */ |
| 3887 Token peek() => _currentToken.next; | 3912 Token peek() => _currentToken.next; |
| 3888 /** | 3913 /** |
| 3889 * Return the token that is the given distance after the current token. | 3914 * Return the token that is the given distance after the current token. |
| 3890 * @param distance the number of tokens to look ahead, where {@code 0} is the
current token,{@code 1} is the next token, etc. | 3915 * @param distance the number of tokens to look ahead, where {@code 0} is the
current token,{@code 1} is the next token, etc. |
| 3891 * @return the token that is the given distance after the current token | 3916 * @return the token that is the given distance after the current token |
| (...skipping 12 matching lines...) Expand all Loading... |
| 3904 * @param arguments the arguments to the error, used to compose the error mess
age | 3929 * @param arguments the arguments to the error, used to compose the error mess
age |
| 3905 */ | 3930 */ |
| 3906 void reportError(ParserErrorCode errorCode, ASTNode node, List<Object> argumen
ts) { | 3931 void reportError(ParserErrorCode errorCode, ASTNode node, List<Object> argumen
ts) { |
| 3907 _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.len
gth, errorCode, [arguments])); | 3932 _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.len
gth, errorCode, [arguments])); |
| 3908 } | 3933 } |
| 3909 /** | 3934 /** |
| 3910 * Report an error with the given error code and arguments. | 3935 * Report an error with the given error code and arguments. |
| 3911 * @param errorCode the error code of the error to be reported | 3936 * @param errorCode the error code of the error to be reported |
| 3912 * @param arguments the arguments to the error, used to compose the error mess
age | 3937 * @param arguments the arguments to the error, used to compose the error mess
age |
| 3913 */ | 3938 */ |
| 3914 void reportError3(ParserErrorCode errorCode, List<Object> arguments) { | 3939 void reportError4(ParserErrorCode errorCode, List<Object> arguments) { |
| 3915 reportError4(errorCode, _currentToken, arguments); | 3940 reportError5(errorCode, _currentToken, arguments); |
| 3916 } | 3941 } |
| 3917 /** | 3942 /** |
| 3918 * Report an error with the given error code and arguments. | 3943 * Report an error with the given error code and arguments. |
| 3919 * @param errorCode the error code of the error to be reported | 3944 * @param errorCode the error code of the error to be reported |
| 3920 * @param token the token specifying the location of the error | 3945 * @param token the token specifying the location of the error |
| 3921 * @param arguments the arguments to the error, used to compose the error mess
age | 3946 * @param arguments the arguments to the error, used to compose the error mess
age |
| 3922 */ | 3947 */ |
| 3923 void reportError4(ParserErrorCode errorCode, Token token, List<Object> argumen
ts) { | 3948 void reportError5(ParserErrorCode errorCode, Token token, List<Object> argumen
ts) { |
| 3924 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l
ength, errorCode, [arguments])); | 3949 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l
ength, errorCode, [arguments])); |
| 3925 } | 3950 } |
| 3926 /** | 3951 /** |
| 3927 * Parse the 'final', 'const', 'var' or type preceding a variable declaration,
starting at the | 3952 * Parse the 'final', 'const', 'var' or type preceding a variable declaration,
starting at the |
| 3928 * given token, without actually creating a type or changing the current token
. Return the token | 3953 * given token, without actually creating a type or changing the current token
. Return the token |
| 3929 * following the type that was parsed, or {@code null} if the given token is n
ot the first token | 3954 * following the type that was parsed, or {@code null} if the given token is n
ot the first token |
| 3930 * in a valid type. | 3955 * in a valid type. |
| 3931 * <pre> | 3956 * <pre> |
| 3932 * finalConstVarOrType ::= | 3957 * finalConstVarOrType ::= |
| 3933 * | 'final' type? | 3958 * | 'final' type? |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4095 * actually creating a string literal or changing the current token. Return th
e token following | 4120 * actually creating a string literal or changing the current token. Return th
e token following |
| 4096 * the string literal that was parsed, or {@code null} if the given token is n
ot the first token | 4121 * the string literal that was parsed, or {@code null} if the given token is n
ot the first token |
| 4097 * in a valid string literal. | 4122 * in a valid string literal. |
| 4098 * <p> | 4123 * <p> |
| 4099 * This method must be kept in sync with {@link #parseStringInterpolation(Toke
n)}. | 4124 * This method must be kept in sync with {@link #parseStringInterpolation(Toke
n)}. |
| 4100 * @param startToken the token at which parsing is to begin | 4125 * @param startToken the token at which parsing is to begin |
| 4101 * @return the string literal that was parsed | 4126 * @return the string literal that was parsed |
| 4102 */ | 4127 */ |
| 4103 Token skipStringInterpolation(Token startToken) { | 4128 Token skipStringInterpolation(Token startToken) { |
| 4104 Token token = startToken; | 4129 Token token = startToken; |
| 4105 TokenType type17 = token.type; | 4130 TokenType type22 = token.type; |
| 4106 while (identical(type17, TokenType.STRING_INTERPOLATION_EXPRESSION) || ident
ical(type17, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { | 4131 while (identical(type22, TokenType.STRING_INTERPOLATION_EXPRESSION) || ident
ical(type22, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { |
| 4107 if (identical(type17, TokenType.STRING_INTERPOLATION_EXPRESSION)) { | 4132 if (identical(type22, TokenType.STRING_INTERPOLATION_EXPRESSION)) { |
| 4108 token = token.next; | 4133 token = token.next; |
| 4109 type17 = token.type; | 4134 type22 = token.type; |
| 4110 int bracketNestingLevel = 1; | 4135 int bracketNestingLevel = 1; |
| 4111 while (bracketNestingLevel > 0) { | 4136 while (bracketNestingLevel > 0) { |
| 4112 if (identical(type17, TokenType.EOF)) { | 4137 if (identical(type22, TokenType.EOF)) { |
| 4113 return null; | 4138 return null; |
| 4114 } else if (identical(type17, TokenType.OPEN_CURLY_BRACKET)) { | 4139 } else if (identical(type22, TokenType.OPEN_CURLY_BRACKET)) { |
| 4115 bracketNestingLevel++; | 4140 bracketNestingLevel++; |
| 4116 } else if (identical(type17, TokenType.CLOSE_CURLY_BRACKET)) { | 4141 } else if (identical(type22, TokenType.CLOSE_CURLY_BRACKET)) { |
| 4117 bracketNestingLevel--; | 4142 bracketNestingLevel--; |
| 4118 } else if (identical(type17, TokenType.STRING)) { | 4143 } else if (identical(type22, TokenType.STRING)) { |
| 4119 token = skipStringLiteral(token); | 4144 token = skipStringLiteral(token); |
| 4120 if (token == null) { | 4145 if (token == null) { |
| 4121 return null; | 4146 return null; |
| 4122 } | 4147 } |
| 4123 } else { | 4148 } else { |
| 4124 token = token.next; | 4149 token = token.next; |
| 4125 } | 4150 } |
| 4126 type17 = token.type; | 4151 type22 = token.type; |
| 4127 } | 4152 } |
| 4128 token = token.next; | 4153 token = token.next; |
| 4129 type17 = token.type; | 4154 type22 = token.type; |
| 4130 } else { | 4155 } else { |
| 4131 token = token.next; | 4156 token = token.next; |
| 4132 if (token.type != TokenType.IDENTIFIER) { | 4157 if (token.type != TokenType.IDENTIFIER) { |
| 4133 return null; | 4158 return null; |
| 4134 } | 4159 } |
| 4135 token = token.next; | 4160 token = token.next; |
| 4136 } | 4161 } |
| 4137 type17 = token.type; | 4162 type22 = token.type; |
| 4138 if (identical(type17, TokenType.STRING)) { | 4163 if (identical(type22, TokenType.STRING)) { |
| 4139 token = token.next; | 4164 token = token.next; |
| 4140 type17 = token.type; | 4165 type22 = token.type; |
| 4141 } | 4166 } |
| 4142 } | 4167 } |
| 4143 return token; | 4168 return token; |
| 4144 } | 4169 } |
| 4145 /** | 4170 /** |
| 4146 * Parse a string literal, starting at the given token, without actually creat
ing a string literal | 4171 * Parse a string literal, starting at the given token, without actually creat
ing a string literal |
| 4147 * or changing the current token. Return the token following the string litera
l that was parsed, | 4172 * or changing the current token. Return the token following the string litera
l that was parsed, |
| 4148 * or {@code null} if the given token is not the first token in a valid string
literal. | 4173 * or {@code null} if the given token is not the first token in a valid string
literal. |
| 4149 * <p> | 4174 * <p> |
| 4150 * This method must be kept in sync with {@link #parseStringLiteral()}. | 4175 * This method must be kept in sync with {@link #parseStringLiteral()}. |
| 4151 * <pre> | 4176 * <pre> |
| 4152 * stringLiteral ::= | 4177 * stringLiteral ::= |
| 4153 * MULTI_LINE_STRING+ | 4178 * MULTI_LINE_STRING+ |
| 4154 * | SINGLE_LINE_STRING+ | 4179 * | SINGLE_LINE_STRING+ |
| 4155 * </pre> | 4180 * </pre> |
| 4156 * @param startToken the token at which parsing is to begin | 4181 * @param startToken the token at which parsing is to begin |
| 4157 * @return the token following the string literal that was parsed | 4182 * @return the token following the string literal that was parsed |
| 4158 */ | 4183 */ |
| 4159 Token skipStringLiteral(Token startToken) { | 4184 Token skipStringLiteral(Token startToken) { |
| 4160 Token token = startToken; | 4185 Token token = startToken; |
| 4161 while (token != null && matches4(token, TokenType.STRING)) { | 4186 while (token != null && matches4(token, TokenType.STRING)) { |
| 4162 token = token.next; | 4187 token = token.next; |
| 4163 TokenType type18 = token.type; | 4188 TokenType type23 = token.type; |
| 4164 if (identical(type18, TokenType.STRING_INTERPOLATION_EXPRESSION) || identi
cal(type18, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { | 4189 if (identical(type23, TokenType.STRING_INTERPOLATION_EXPRESSION) || identi
cal(type23, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { |
| 4165 token = skipStringInterpolation(token); | 4190 token = skipStringInterpolation(token); |
| 4166 } | 4191 } |
| 4167 } | 4192 } |
| 4168 if (identical(token, startToken)) { | 4193 if (identical(token, startToken)) { |
| 4169 return null; | 4194 return null; |
| 4170 } | 4195 } |
| 4171 return token; | 4196 return token; |
| 4172 } | 4197 } |
| 4173 /** | 4198 /** |
| 4174 * Parse a list of type arguments, starting at the given token, without actual
ly creating a type argument list | 4199 * Parse a list of type arguments, starting at the given token, without actual
ly creating a type argument list |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4285 * Translate the characters at the given index in the given string, appending
the translated | 4310 * Translate the characters at the given index in the given string, appending
the translated |
| 4286 * character to the given builder. The index is assumed to be valid. | 4311 * character to the given builder. The index is assumed to be valid. |
| 4287 * @param builder the builder to which the translated character is to be appen
ded | 4312 * @param builder the builder to which the translated character is to be appen
ded |
| 4288 * @param lexeme the string containing the character(s) to be translated | 4313 * @param lexeme the string containing the character(s) to be translated |
| 4289 * @param index the index of the character to be translated | 4314 * @param index the index of the character to be translated |
| 4290 * @return the index of the next character to be translated | 4315 * @return the index of the next character to be translated |
| 4291 */ | 4316 */ |
| 4292 int translateCharacter(StringBuffer builder, String lexeme, int index) { | 4317 int translateCharacter(StringBuffer builder, String lexeme, int index) { |
| 4293 int currentChar = lexeme.codeUnitAt(index); | 4318 int currentChar = lexeme.codeUnitAt(index); |
| 4294 if (currentChar != 0x5C) { | 4319 if (currentChar != 0x5C) { |
| 4295 builder.addCharCode(currentChar); | 4320 builder.writeCharCode(currentChar); |
| 4296 return index + 1; | 4321 return index + 1; |
| 4297 } | 4322 } |
| 4298 int length8 = lexeme.length; | 4323 int length8 = lexeme.length; |
| 4299 int currentIndex = index + 1; | 4324 int currentIndex = index + 1; |
| 4300 if (currentIndex >= length8) { | 4325 if (currentIndex >= length8) { |
| 4301 return length8; | 4326 return length8; |
| 4302 } | 4327 } |
| 4303 currentChar = lexeme.codeUnitAt(currentIndex); | 4328 currentChar = lexeme.codeUnitAt(currentIndex); |
| 4304 if (currentChar == 0x6E) { | 4329 if (currentChar == 0x6E) { |
| 4305 builder.addCharCode(0xA); | 4330 builder.writeCharCode(0xA); |
| 4306 } else if (currentChar == 0x72) { | 4331 } else if (currentChar == 0x72) { |
| 4307 builder.addCharCode(0xD); | 4332 builder.writeCharCode(0xD); |
| 4308 } else if (currentChar == 0x66) { | 4333 } else if (currentChar == 0x66) { |
| 4309 builder.addCharCode(0xC); | 4334 builder.writeCharCode(0xC); |
| 4310 } else if (currentChar == 0x62) { | 4335 } else if (currentChar == 0x62) { |
| 4311 builder.addCharCode(0x8); | 4336 builder.writeCharCode(0x8); |
| 4312 } else if (currentChar == 0x74) { | 4337 } else if (currentChar == 0x74) { |
| 4313 builder.addCharCode(0x9); | 4338 builder.writeCharCode(0x9); |
| 4314 } else if (currentChar == 0x76) { | 4339 } else if (currentChar == 0x76) { |
| 4315 builder.addCharCode(0xB); | 4340 builder.writeCharCode(0xB); |
| 4316 } else if (currentChar == 0x78) { | 4341 } else if (currentChar == 0x78) { |
| 4317 if (currentIndex + 2 >= length8) { | 4342 if (currentIndex + 2 >= length8) { |
| 4318 reportError3(ParserErrorCode.INVALID_HEX_ESCAPE, []); | 4343 reportError4(ParserErrorCode.INVALID_HEX_ESCAPE, []); |
| 4319 return length8; | 4344 return length8; |
| 4320 } | 4345 } |
| 4321 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); | 4346 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); |
| 4322 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); | 4347 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); |
| 4323 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) { | 4348 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) { |
| 4324 reportError3(ParserErrorCode.INVALID_HEX_ESCAPE, []); | 4349 reportError4(ParserErrorCode.INVALID_HEX_ESCAPE, []); |
| 4325 } else { | 4350 } else { |
| 4326 builder.addCharCode((((Character.digit(firstDigit, 16) << 4) + Character
.digit(secondDigit, 16)) as int)); | 4351 builder.writeCharCode((((Character.digit(firstDigit, 16) << 4) + Charact
er.digit(secondDigit, 16)) as int)); |
| 4327 } | 4352 } |
| 4328 return currentIndex + 3; | 4353 return currentIndex + 3; |
| 4329 } else if (currentChar == 0x75) { | 4354 } else if (currentChar == 0x75) { |
| 4330 currentIndex++; | 4355 currentIndex++; |
| 4331 if (currentIndex >= length8) { | 4356 if (currentIndex >= length8) { |
| 4332 reportError3(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 4357 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 4333 return length8; | 4358 return length8; |
| 4334 } | 4359 } |
| 4335 currentChar = lexeme.codeUnitAt(currentIndex); | 4360 currentChar = lexeme.codeUnitAt(currentIndex); |
| 4336 if (currentChar == 0x7B) { | 4361 if (currentChar == 0x7B) { |
| 4337 currentIndex++; | 4362 currentIndex++; |
| 4338 if (currentIndex >= length8) { | 4363 if (currentIndex >= length8) { |
| 4339 reportError3(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 4364 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 4340 return length8; | 4365 return length8; |
| 4341 } | 4366 } |
| 4342 currentChar = lexeme.codeUnitAt(currentIndex); | 4367 currentChar = lexeme.codeUnitAt(currentIndex); |
| 4343 int digitCount = 0; | 4368 int digitCount = 0; |
| 4344 int value = 0; | 4369 int value = 0; |
| 4345 while (currentChar != 0x7D) { | 4370 while (currentChar != 0x7D) { |
| 4346 if (!isHexDigit(currentChar)) { | 4371 if (!isHexDigit(currentChar)) { |
| 4347 reportError3(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 4372 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 4348 currentIndex++; | 4373 currentIndex++; |
| 4349 while (currentIndex < length8 && lexeme.codeUnitAt(currentIndex) !=
0x7D) { | 4374 while (currentIndex < length8 && lexeme.codeUnitAt(currentIndex) !=
0x7D) { |
| 4350 currentIndex++; | 4375 currentIndex++; |
| 4351 } | 4376 } |
| 4352 return currentIndex + 1; | 4377 return currentIndex + 1; |
| 4353 } | 4378 } |
| 4354 digitCount++; | 4379 digitCount++; |
| 4355 value = (value << 4) + Character.digit(currentChar, 16); | 4380 value = (value << 4) + Character.digit(currentChar, 16); |
| 4356 currentIndex++; | 4381 currentIndex++; |
| 4357 if (currentIndex >= length8) { | 4382 if (currentIndex >= length8) { |
| 4358 reportError3(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 4383 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 4359 return length8; | 4384 return length8; |
| 4360 } | 4385 } |
| 4361 currentChar = lexeme.codeUnitAt(currentIndex); | 4386 currentChar = lexeme.codeUnitAt(currentIndex); |
| 4362 } | 4387 } |
| 4363 if (digitCount < 1 || digitCount > 6) { | 4388 if (digitCount < 1 || digitCount > 6) { |
| 4364 reportError3(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 4389 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 4365 } | 4390 } |
| 4366 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va
lue, index, currentIndex); | 4391 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va
lue, index, currentIndex); |
| 4367 return currentIndex + 1; | 4392 return currentIndex + 1; |
| 4368 } else { | 4393 } else { |
| 4369 if (currentIndex + 3 >= length8) { | 4394 if (currentIndex + 3 >= length8) { |
| 4370 reportError3(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 4395 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 4371 return length8; | 4396 return length8; |
| 4372 } | 4397 } |
| 4373 int firstDigit = currentChar; | 4398 int firstDigit = currentChar; |
| 4374 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); | 4399 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); |
| 4375 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); | 4400 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); |
| 4376 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); | 4401 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); |
| 4377 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t
hirdDigit) || !isHexDigit(fourthDigit)) { | 4402 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t
hirdDigit) || !isHexDigit(fourthDigit)) { |
| 4378 reportError3(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); | 4403 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); |
| 4379 } else { | 4404 } else { |
| 4380 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1),
((((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16))
<< 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16
)), index, currentIndex + 3); | 4405 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1),
((((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16))
<< 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16
)), index, currentIndex + 3); |
| 4381 } | 4406 } |
| 4382 return currentIndex + 4; | 4407 return currentIndex + 4; |
| 4383 } | 4408 } |
| 4384 } else { | 4409 } else { |
| 4385 builder.addCharCode(currentChar); | 4410 builder.writeCharCode(currentChar); |
| 4386 } | 4411 } |
| 4387 return currentIndex + 1; | 4412 return currentIndex + 1; |
| 4388 } | 4413 } |
| 4389 /** | 4414 /** |
| 4390 * Validate that the given parameter list does not contain any field initializ
ers. | 4415 * Validate that the given parameter list does not contain any field initializ
ers. |
| 4391 * @param parameterList the parameter list to be validated | 4416 * @param parameterList the parameter list to be validated |
| 4392 */ | 4417 */ |
| 4393 void validateFormalParameterList(FormalParameterList parameterList) { | 4418 void validateFormalParameterList(FormalParameterList parameterList) { |
| 4394 for (FormalParameter parameter in parameterList.parameters) { | 4419 for (FormalParameter parameter in parameterList.parameters) { |
| 4395 if (parameter is FieldFormalParameter) { | 4420 if (parameter is FieldFormalParameter) { |
| 4396 reportError(ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, ((par
ameter as FieldFormalParameter)).identifier, []); | 4421 reportError(ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, ((par
ameter as FieldFormalParameter)).identifier, []); |
| 4397 } | 4422 } |
| 4398 } | 4423 } |
| 4399 } | 4424 } |
| 4400 /** | 4425 /** |
| 4401 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' | 4426 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' |
| 4402 * keyword if there is one. | 4427 * keyword if there is one. |
| 4403 * @param modifiers the modifiers being validated | 4428 * @param modifiers the modifiers being validated |
| 4404 */ | 4429 */ |
| 4405 Token validateModifiersForClass(Modifiers modifiers) { | 4430 Token validateModifiersForClass(Modifiers modifiers) { |
| 4406 validateModifiersForTopLevelDeclaration(modifiers); | 4431 validateModifiersForTopLevelDeclaration(modifiers); |
| 4407 if (modifiers.constKeyword != null) { | 4432 if (modifiers.constKeyword != null) { |
| 4408 reportError4(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []); | 4433 reportError5(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []); |
| 4409 } | 4434 } |
| 4410 if (modifiers.externalKeyword != null) { | 4435 if (modifiers.externalKeyword != null) { |
| 4411 reportError4(ParserErrorCode.EXTERNAL_CLASS, modifiers.externalKeyword, []
); | 4436 reportError5(ParserErrorCode.EXTERNAL_CLASS, modifiers.externalKeyword, []
); |
| 4412 } | 4437 } |
| 4413 if (modifiers.finalKeyword != null) { | 4438 if (modifiers.finalKeyword != null) { |
| 4414 reportError4(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []); | 4439 reportError5(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []); |
| 4415 } | 4440 } |
| 4416 if (modifiers.varKeyword != null) { | 4441 if (modifiers.varKeyword != null) { |
| 4417 reportError4(ParserErrorCode.VAR_CLASS, modifiers.varKeyword, []); | 4442 reportError5(ParserErrorCode.VAR_CLASS, modifiers.varKeyword, []); |
| 4418 } | 4443 } |
| 4419 return modifiers.abstractKeyword; | 4444 return modifiers.abstractKeyword; |
| 4420 } | 4445 } |
| 4421 /** | 4446 /** |
| 4422 * Validate that the given set of modifiers is appropriate for a constructor a
nd return the | 4447 * Validate that the given set of modifiers is appropriate for a constructor a
nd return the |
| 4423 * 'const' keyword if there is one. | 4448 * 'const' keyword if there is one. |
| 4424 * @param modifiers the modifiers being validated | 4449 * @param modifiers the modifiers being validated |
| 4425 * @return the 'const' or 'final' keyword associated with the constructor | 4450 * @return the 'const' or 'final' keyword associated with the constructor |
| 4426 */ | 4451 */ |
| 4427 Token validateModifiersForConstructor(Modifiers modifiers) { | 4452 Token validateModifiersForConstructor(Modifiers modifiers) { |
| 4428 if (modifiers.abstractKeyword != null) { | 4453 if (modifiers.abstractKeyword != null) { |
| 4429 reportError3(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); | 4454 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); |
| 4430 } | 4455 } |
| 4431 if (modifiers.finalKeyword != null) { | 4456 if (modifiers.finalKeyword != null) { |
| 4432 reportError4(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, []
); | 4457 reportError5(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, []
); |
| 4433 } | 4458 } |
| 4434 if (modifiers.staticKeyword != null) { | 4459 if (modifiers.staticKeyword != null) { |
| 4435 reportError4(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword,
[]); | 4460 reportError5(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword,
[]); |
| 4436 } | 4461 } |
| 4437 if (modifiers.varKeyword != null) { | 4462 if (modifiers.varKeyword != null) { |
| 4438 reportError4(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varKe
yword, []); | 4463 reportError5(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varKe
yword, []); |
| 4439 } | 4464 } |
| 4440 Token externalKeyword6 = modifiers.externalKeyword; | 4465 Token externalKeyword6 = modifiers.externalKeyword; |
| 4441 Token constKeyword4 = modifiers.constKeyword; | 4466 Token constKeyword4 = modifiers.constKeyword; |
| 4442 Token factoryKeyword4 = modifiers.factoryKeyword; | 4467 Token factoryKeyword4 = modifiers.factoryKeyword; |
| 4443 if (externalKeyword6 != null && constKeyword4 != null && constKeyword4.offse
t < externalKeyword6.offset) { | 4468 if (externalKeyword6 != null && constKeyword4 != null && constKeyword4.offse
t < externalKeyword6.offset) { |
| 4444 reportError4(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword6, []); | 4469 reportError5(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword6, []); |
| 4445 } | 4470 } |
| 4446 if (externalKeyword6 != null && factoryKeyword4 != null && factoryKeyword4.o
ffset < externalKeyword6.offset) { | 4471 if (externalKeyword6 != null && factoryKeyword4 != null && factoryKeyword4.o
ffset < externalKeyword6.offset) { |
| 4447 reportError4(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword6, [])
; | 4472 reportError5(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword6, [])
; |
| 4448 } | 4473 } |
| 4449 return constKeyword4; | 4474 return constKeyword4; |
| 4450 } | 4475 } |
| 4451 /** | 4476 /** |
| 4452 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', | 4477 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', |
| 4453 * 'const' or 'var' keyword if there is one. | 4478 * 'const' or 'var' keyword if there is one. |
| 4454 * @param modifiers the modifiers being validated | 4479 * @param modifiers the modifiers being validated |
| 4455 * @return the 'final', 'const' or 'var' keyword associated with the field | 4480 * @return the 'final', 'const' or 'var' keyword associated with the field |
| 4456 */ | 4481 */ |
| 4457 Token validateModifiersForField(Modifiers modifiers) { | 4482 Token validateModifiersForField(Modifiers modifiers) { |
| 4458 if (modifiers.abstractKeyword != null) { | 4483 if (modifiers.abstractKeyword != null) { |
| 4459 reportError3(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); | 4484 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); |
| 4460 } | 4485 } |
| 4461 if (modifiers.externalKeyword != null) { | 4486 if (modifiers.externalKeyword != null) { |
| 4462 reportError4(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, []
); | 4487 reportError5(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, []
); |
| 4463 } | 4488 } |
| 4464 if (modifiers.factoryKeyword != null) { | 4489 if (modifiers.factoryKeyword != null) { |
| 4465 reportError4(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey
word, []); | 4490 reportError5(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey
word, []); |
| 4466 } | 4491 } |
| 4467 Token staticKeyword3 = modifiers.staticKeyword; | 4492 Token staticKeyword3 = modifiers.staticKeyword; |
| 4468 Token constKeyword5 = modifiers.constKeyword; | 4493 Token constKeyword5 = modifiers.constKeyword; |
| 4469 Token finalKeyword3 = modifiers.finalKeyword; | 4494 Token finalKeyword3 = modifiers.finalKeyword; |
| 4470 Token varKeyword3 = modifiers.varKeyword; | 4495 Token varKeyword3 = modifiers.varKeyword; |
| 4471 if (constKeyword5 != null) { | 4496 if (constKeyword5 != null) { |
| 4472 if (finalKeyword3 != null) { | 4497 if (finalKeyword3 != null) { |
| 4473 reportError4(ParserErrorCode.CONST_AND_FINAL, finalKeyword3, []); | 4498 reportError5(ParserErrorCode.CONST_AND_FINAL, finalKeyword3, []); |
| 4474 } | 4499 } |
| 4475 if (varKeyword3 != null) { | 4500 if (varKeyword3 != null) { |
| 4476 reportError4(ParserErrorCode.CONST_AND_VAR, varKeyword3, []); | 4501 reportError5(ParserErrorCode.CONST_AND_VAR, varKeyword3, []); |
| 4477 } | 4502 } |
| 4478 if (staticKeyword3 != null && constKeyword5.offset < staticKeyword3.offset
) { | 4503 if (staticKeyword3 != null && constKeyword5.offset < staticKeyword3.offset
) { |
| 4479 reportError4(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword3, []); | 4504 reportError5(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword3, []); |
| 4480 } | 4505 } |
| 4481 } else if (finalKeyword3 != null) { | 4506 } else if (finalKeyword3 != null) { |
| 4482 if (varKeyword3 != null) { | 4507 if (varKeyword3 != null) { |
| 4483 reportError4(ParserErrorCode.FINAL_AND_VAR, varKeyword3, []); | 4508 reportError5(ParserErrorCode.FINAL_AND_VAR, varKeyword3, []); |
| 4484 } | 4509 } |
| 4485 if (staticKeyword3 != null && finalKeyword3.offset < staticKeyword3.offset
) { | 4510 if (staticKeyword3 != null && finalKeyword3.offset < staticKeyword3.offset
) { |
| 4486 reportError4(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword3, []); | 4511 reportError5(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword3, []); |
| 4487 } | 4512 } |
| 4488 } else if (varKeyword3 != null && staticKeyword3 != null && varKeyword3.offs
et < staticKeyword3.offset) { | 4513 } else if (varKeyword3 != null && staticKeyword3 != null && varKeyword3.offs
et < staticKeyword3.offset) { |
| 4489 reportError4(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword3, []); | 4514 reportError5(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword3, []); |
| 4490 } | 4515 } |
| 4491 return lexicallyFirst([constKeyword5, finalKeyword3, varKeyword3]); | 4516 return lexicallyFirst([constKeyword5, finalKeyword3, varKeyword3]); |
| 4492 } | 4517 } |
| 4493 /** | 4518 /** |
| 4494 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. | 4519 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. |
| 4495 * @param modifiers the modifiers being validated | 4520 * @param modifiers the modifiers being validated |
| 4496 */ | 4521 */ |
| 4497 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { | 4522 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { |
| 4498 if (modifiers.abstractKeyword != null) { | 4523 if (modifiers.abstractKeyword != null) { |
| 4499 reportError3(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); | 4524 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); |
| 4500 } | 4525 } |
| 4501 if (modifiers.constKeyword != null) { | 4526 if (modifiers.constKeyword != null) { |
| 4502 reportError4(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); | 4527 reportError5(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); |
| 4503 } | 4528 } |
| 4504 if (modifiers.factoryKeyword != null) { | 4529 if (modifiers.factoryKeyword != null) { |
| 4505 reportError4(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey
word, []); | 4530 reportError5(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey
word, []); |
| 4506 } | 4531 } |
| 4507 if (modifiers.finalKeyword != null) { | 4532 if (modifiers.finalKeyword != null) { |
| 4508 reportError4(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); | 4533 reportError5(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); |
| 4509 } | 4534 } |
| 4510 if (modifiers.varKeyword != null) { | 4535 if (modifiers.varKeyword != null) { |
| 4511 reportError4(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); | 4536 reportError5(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); |
| 4512 } | 4537 } |
| 4513 Token externalKeyword7 = modifiers.externalKeyword; | 4538 Token externalKeyword7 = modifiers.externalKeyword; |
| 4514 Token staticKeyword4 = modifiers.staticKeyword; | 4539 Token staticKeyword4 = modifiers.staticKeyword; |
| 4515 if (externalKeyword7 != null && staticKeyword4 != null && staticKeyword4.off
set < externalKeyword7.offset) { | 4540 if (externalKeyword7 != null && staticKeyword4 != null && staticKeyword4.off
set < externalKeyword7.offset) { |
| 4516 reportError4(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword7, []); | 4541 reportError5(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword7, []); |
| 4517 } | 4542 } |
| 4518 } | 4543 } |
| 4519 /** | 4544 /** |
| 4520 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. | 4545 * Validate that the given set of modifiers is appropriate for a getter, sette
r, or method. |
| 4521 * @param modifiers the modifiers being validated | 4546 * @param modifiers the modifiers being validated |
| 4522 */ | 4547 */ |
| 4523 void validateModifiersForOperator(Modifiers modifiers) { | 4548 void validateModifiersForOperator(Modifiers modifiers) { |
| 4524 if (modifiers.abstractKeyword != null) { | 4549 if (modifiers.abstractKeyword != null) { |
| 4525 reportError3(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); | 4550 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); |
| 4526 } | 4551 } |
| 4527 if (modifiers.constKeyword != null) { | 4552 if (modifiers.constKeyword != null) { |
| 4528 reportError4(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); | 4553 reportError5(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); |
| 4529 } | 4554 } |
| 4530 if (modifiers.factoryKeyword != null) { | 4555 if (modifiers.factoryKeyword != null) { |
| 4531 reportError4(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey
word, []); | 4556 reportError5(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey
word, []); |
| 4532 } | 4557 } |
| 4533 if (modifiers.finalKeyword != null) { | 4558 if (modifiers.finalKeyword != null) { |
| 4534 reportError4(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); | 4559 reportError5(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); |
| 4535 } | 4560 } |
| 4536 if (modifiers.staticKeyword != null) { | 4561 if (modifiers.staticKeyword != null) { |
| 4537 reportError4(ParserErrorCode.STATIC_OPERATOR, modifiers.staticKeyword, [])
; | 4562 reportError5(ParserErrorCode.STATIC_OPERATOR, modifiers.staticKeyword, [])
; |
| 4538 } | 4563 } |
| 4539 if (modifiers.varKeyword != null) { | 4564 if (modifiers.varKeyword != null) { |
| 4540 reportError4(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); | 4565 reportError5(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); |
| 4541 } | 4566 } |
| 4542 } | 4567 } |
| 4543 /** | 4568 /** |
| 4544 * Validate that the given set of modifiers is appropriate for a top-level dec
laration. | 4569 * Validate that the given set of modifiers is appropriate for a top-level dec
laration. |
| 4545 * @param modifiers the modifiers being validated | 4570 * @param modifiers the modifiers being validated |
| 4546 */ | 4571 */ |
| 4547 void validateModifiersForTopLevelDeclaration(Modifiers modifiers) { | 4572 void validateModifiersForTopLevelDeclaration(Modifiers modifiers) { |
| 4548 if (modifiers.factoryKeyword != null) { | 4573 if (modifiers.factoryKeyword != null) { |
| 4549 reportError4(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, modifiers.fact
oryKeyword, []); | 4574 reportError5(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, modifiers.fact
oryKeyword, []); |
| 4550 } | 4575 } |
| 4551 if (modifiers.staticKeyword != null) { | 4576 if (modifiers.staticKeyword != null) { |
| 4552 reportError4(ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, modifiers.stati
cKeyword, []); | 4577 reportError5(ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, modifiers.stati
cKeyword, []); |
| 4553 } | 4578 } |
| 4554 } | 4579 } |
| 4555 /** | 4580 /** |
| 4556 * Validate that the given set of modifiers is appropriate for a top-level fun
ction. | 4581 * Validate that the given set of modifiers is appropriate for a top-level fun
ction. |
| 4557 * @param modifiers the modifiers being validated | 4582 * @param modifiers the modifiers being validated |
| 4558 */ | 4583 */ |
| 4559 void validateModifiersForTopLevelFunction(Modifiers modifiers) { | 4584 void validateModifiersForTopLevelFunction(Modifiers modifiers) { |
| 4560 validateModifiersForTopLevelDeclaration(modifiers); | 4585 validateModifiersForTopLevelDeclaration(modifiers); |
| 4561 if (modifiers.abstractKeyword != null) { | 4586 if (modifiers.abstractKeyword != null) { |
| 4562 reportError3(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, []); | 4587 reportError4(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, []); |
| 4563 } | 4588 } |
| 4564 if (modifiers.constKeyword != null) { | 4589 if (modifiers.constKeyword != null) { |
| 4565 reportError4(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []); | 4590 reportError5(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []); |
| 4566 } | 4591 } |
| 4567 if (modifiers.finalKeyword != null) { | 4592 if (modifiers.finalKeyword != null) { |
| 4568 reportError4(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []); | 4593 reportError5(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []); |
| 4569 } | 4594 } |
| 4570 if (modifiers.varKeyword != null) { | 4595 if (modifiers.varKeyword != null) { |
| 4571 reportError4(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); | 4596 reportError5(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); |
| 4572 } | 4597 } |
| 4573 } | 4598 } |
| 4574 /** | 4599 /** |
| 4575 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', | 4600 * Validate that the given set of modifiers is appropriate for a field and ret
urn the 'final', |
| 4576 * 'const' or 'var' keyword if there is one. | 4601 * 'const' or 'var' keyword if there is one. |
| 4577 * @param modifiers the modifiers being validated | 4602 * @param modifiers the modifiers being validated |
| 4578 * @return the 'final', 'const' or 'var' keyword associated with the field | 4603 * @return the 'final', 'const' or 'var' keyword associated with the field |
| 4579 */ | 4604 */ |
| 4580 Token validateModifiersForTopLevelVariable(Modifiers modifiers) { | 4605 Token validateModifiersForTopLevelVariable(Modifiers modifiers) { |
| 4581 validateModifiersForTopLevelDeclaration(modifiers); | 4606 validateModifiersForTopLevelDeclaration(modifiers); |
| 4582 if (modifiers.abstractKeyword != null) { | 4607 if (modifiers.abstractKeyword != null) { |
| 4583 reportError3(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []); | 4608 reportError4(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []); |
| 4584 } | 4609 } |
| 4585 if (modifiers.externalKeyword != null) { | 4610 if (modifiers.externalKeyword != null) { |
| 4586 reportError4(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, []
); | 4611 reportError5(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, []
); |
| 4587 } | 4612 } |
| 4588 Token constKeyword6 = modifiers.constKeyword; | 4613 Token constKeyword6 = modifiers.constKeyword; |
| 4589 Token finalKeyword4 = modifiers.finalKeyword; | 4614 Token finalKeyword4 = modifiers.finalKeyword; |
| 4590 Token varKeyword4 = modifiers.varKeyword; | 4615 Token varKeyword4 = modifiers.varKeyword; |
| 4591 if (constKeyword6 != null) { | 4616 if (constKeyword6 != null) { |
| 4592 if (finalKeyword4 != null) { | 4617 if (finalKeyword4 != null) { |
| 4593 reportError4(ParserErrorCode.CONST_AND_FINAL, finalKeyword4, []); | 4618 reportError5(ParserErrorCode.CONST_AND_FINAL, finalKeyword4, []); |
| 4594 } | 4619 } |
| 4595 if (varKeyword4 != null) { | 4620 if (varKeyword4 != null) { |
| 4596 reportError4(ParserErrorCode.CONST_AND_VAR, varKeyword4, []); | 4621 reportError5(ParserErrorCode.CONST_AND_VAR, varKeyword4, []); |
| 4597 } | 4622 } |
| 4598 } else if (finalKeyword4 != null) { | 4623 } else if (finalKeyword4 != null) { |
| 4599 if (varKeyword4 != null) { | 4624 if (varKeyword4 != null) { |
| 4600 reportError4(ParserErrorCode.FINAL_AND_VAR, varKeyword4, []); | 4625 reportError5(ParserErrorCode.FINAL_AND_VAR, varKeyword4, []); |
| 4601 } | 4626 } |
| 4602 } | 4627 } |
| 4603 return lexicallyFirst([constKeyword6, finalKeyword4, varKeyword4]); | 4628 return lexicallyFirst([constKeyword6, finalKeyword4, varKeyword4]); |
| 4604 } | 4629 } |
| 4605 /** | 4630 /** |
| 4606 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' | 4631 * Validate that the given set of modifiers is appropriate for a class and ret
urn the 'abstract' |
| 4607 * keyword if there is one. | 4632 * keyword if there is one. |
| 4608 * @param modifiers the modifiers being validated | 4633 * @param modifiers the modifiers being validated |
| 4609 */ | 4634 */ |
| 4610 void validateModifiersForTypedef(Modifiers modifiers) { | 4635 void validateModifiersForTypedef(Modifiers modifiers) { |
| 4611 validateModifiersForTopLevelDeclaration(modifiers); | 4636 validateModifiersForTopLevelDeclaration(modifiers); |
| 4612 if (modifiers.abstractKeyword != null) { | 4637 if (modifiers.abstractKeyword != null) { |
| 4613 reportError4(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKeyword,
[]); | 4638 reportError5(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKeyword,
[]); |
| 4614 } | 4639 } |
| 4615 if (modifiers.constKeyword != null) { | 4640 if (modifiers.constKeyword != null) { |
| 4616 reportError4(ParserErrorCode.CONST_TYPEDEF, modifiers.constKeyword, []); | 4641 reportError5(ParserErrorCode.CONST_TYPEDEF, modifiers.constKeyword, []); |
| 4617 } | 4642 } |
| 4618 if (modifiers.externalKeyword != null) { | 4643 if (modifiers.externalKeyword != null) { |
| 4619 reportError4(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword,
[]); | 4644 reportError5(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword,
[]); |
| 4620 } | 4645 } |
| 4621 if (modifiers.finalKeyword != null) { | 4646 if (modifiers.finalKeyword != null) { |
| 4622 reportError4(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []); | 4647 reportError5(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []); |
| 4623 } | 4648 } |
| 4624 if (modifiers.varKeyword != null) { | 4649 if (modifiers.varKeyword != null) { |
| 4625 reportError4(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []); | 4650 reportError5(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []); |
| 4626 } | 4651 } |
| 4627 } | 4652 } |
| 4628 } | 4653 } |
| 4629 class AnalysisErrorListener_4 implements AnalysisErrorListener { | 4654 class AnalysisErrorListener_6 implements AnalysisErrorListener { |
| 4630 List<bool> errorFound; | 4655 List<bool> errorFound; |
| 4631 AnalysisErrorListener_4(this.errorFound); | 4656 AnalysisErrorListener_6(this.errorFound); |
| 4632 void onError(AnalysisError error) { | 4657 void onError(AnalysisError error) { |
| 4633 errorFound[0] = true; | 4658 errorFound[0] = true; |
| 4634 } | 4659 } |
| 4635 } | 4660 } |
| 4636 /** | 4661 /** |
| 4637 * The enumeration {@code ParserErrorCode} defines the error codes used for erro
rs detected by the | 4662 * The enumeration {@code ParserErrorCode} defines the error codes used for erro
rs detected by the |
| 4638 * parser. The convention for this class is for the name of the error code to in
dicate the problem | 4663 * parser. The convention for this class is for the name of the error code to in
dicate the problem |
| 4639 * that caused the error to be generated and for the error message to explain wh
at is wrong and, | 4664 * that caused the error to be generated and for the error message to explain wh
at is wrong and, |
| 4640 * when appropriate, how the problem can be corrected. | 4665 * when appropriate, how the problem can be corrected. |
| 4641 */ | 4666 */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4697 static final ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = new ParserErrorCode
.con2('LIBRARY_DIRECTIVE_NOT_FIRST', 54, "The library directive must appear befo
re all other directives"); | 4722 static final ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = new ParserErrorCode
.con2('LIBRARY_DIRECTIVE_NOT_FIRST', 54, "The library directive must appear befo
re all other directives"); |
| 4698 static final ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = new ParserErrorCode
.con2('MISSING_ASSIGNABLE_SELECTOR', 55, "Missing selector such as \".<identifie
r>\" or \"[0]\""); | 4723 static final ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = new ParserErrorCode
.con2('MISSING_ASSIGNABLE_SELECTOR', 55, "Missing selector such as \".<identifie
r>\" or \"[0]\""); |
| 4699 static final ParserErrorCode MISSING_CATCH_OR_FINALLY = new ParserErrorCode.co
n2('MISSING_CATCH_OR_FINALLY', 56, "A try statement must have either a catch or
finally clause"); | 4724 static final ParserErrorCode MISSING_CATCH_OR_FINALLY = new ParserErrorCode.co
n2('MISSING_CATCH_OR_FINALLY', 56, "A try statement must have either a catch or
finally clause"); |
| 4700 static final ParserErrorCode MISSING_CLASS_BODY = new ParserErrorCode.con2('MI
SSING_CLASS_BODY', 57, "A class definition must have a body, even if it is empty
"); | 4725 static final ParserErrorCode MISSING_CLASS_BODY = new ParserErrorCode.con2('MI
SSING_CLASS_BODY', 57, "A class definition must have a body, even if it is empty
"); |
| 4701 static final ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE = new ParserError
Code.con2('MISSING_CONST_FINAL_VAR_OR_TYPE', 58, "Variables must be declared usi
ng the keywords 'const', 'final', 'var' or a type name"); | 4726 static final ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE = new ParserError
Code.con2('MISSING_CONST_FINAL_VAR_OR_TYPE', 58, "Variables must be declared usi
ng the keywords 'const', 'final', 'var' or a type name"); |
| 4702 static final ParserErrorCode MISSING_FUNCTION_BODY = new ParserErrorCode.con2(
'MISSING_FUNCTION_BODY', 59, "A function body must be provided"); | 4727 static final ParserErrorCode MISSING_FUNCTION_BODY = new ParserErrorCode.con2(
'MISSING_FUNCTION_BODY', 59, "A function body must be provided"); |
| 4703 static final ParserErrorCode MISSING_FUNCTION_PARAMETERS = new ParserErrorCode
.con2('MISSING_FUNCTION_PARAMETERS', 60, "Functions must have an explicit list o
f parameters"); | 4728 static final ParserErrorCode MISSING_FUNCTION_PARAMETERS = new ParserErrorCode
.con2('MISSING_FUNCTION_PARAMETERS', 60, "Functions must have an explicit list o
f parameters"); |
| 4704 static final ParserErrorCode MISSING_IDENTIFIER = new ParserErrorCode.con2('MI
SSING_IDENTIFIER', 61, "Expected an identifier"); | 4729 static final ParserErrorCode MISSING_IDENTIFIER = new ParserErrorCode.con2('MI
SSING_IDENTIFIER', 61, "Expected an identifier"); |
| 4705 static final ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = new ParserErr
orCode.con2('MISSING_NAME_IN_LIBRARY_DIRECTIVE', 62, "Library directives must in
clude a library name"); | 4730 static final ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = new ParserErr
orCode.con2('MISSING_NAME_IN_LIBRARY_DIRECTIVE', 62, "Library directives must in
clude a library name"); |
| 4706 static final ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE = new ParserErr
orCode.con2('MISSING_NAME_IN_PART_OF_DIRECTIVE', 63, "Library directives must in
clude a library name"); | 4731 static final ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE = new ParserErr
orCode.con2('MISSING_NAME_IN_PART_OF_DIRECTIVE', 63, "Library directives must in
clude a library name"); |
| 4707 static final ParserErrorCode MISSING_TYPEDEF_PARAMETERS = new ParserErrorCode.
con2('MISSING_TYPEDEF_PARAMETERS', 64, "Type aliases for functions must have an
explicit list of parameters"); | 4732 static final ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP = new Pars
erErrorCode.con2('MISSING_TERMINATOR_FOR_PARAMETER_GROUP', 64, "There is no '%s'
to close the parameter group"); |
| 4708 static final ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = new ParserErrorCod
e.con2('MISSING_VARIABLE_IN_FOR_EACH', 65, "A loop variable must be declared in
a for-each loop before the 'in', but none were found"); | 4733 static final ParserErrorCode MISSING_TYPEDEF_PARAMETERS = new ParserErrorCode.
con2('MISSING_TYPEDEF_PARAMETERS', 65, "Type aliases for functions must have an
explicit list of parameters"); |
| 4709 static final ParserErrorCode MIXED_PARAMETER_GROUPS = new ParserErrorCode.con2
('MIXED_PARAMETER_GROUPS', 66, "Cannot have both positional and named parameters
in a single parameter list"); | 4734 static final ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = new ParserErrorCod
e.con2('MISSING_VARIABLE_IN_FOR_EACH', 66, "A loop variable must be declared in
a for-each loop before the 'in', but none were found"); |
| 4710 static final ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = new ParserErrorCode.co
n2('MULTIPLE_EXTENDS_CLAUSES', 67, "Each class definition can have at most one e
xtends clause"); | 4735 static final ParserErrorCode MIXED_PARAMETER_GROUPS = new ParserErrorCode.con2
('MIXED_PARAMETER_GROUPS', 67, "Cannot have both positional and named parameters
in a single parameter list"); |
| 4711 static final ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = new ParserErrorCode
.con2('MULTIPLE_IMPLEMENTS_CLAUSES', 68, "Each class definition can have at most
one implements clause"); | 4736 static final ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = new ParserErrorCode.co
n2('MULTIPLE_EXTENDS_CLAUSES', 68, "Each class definition can have at most one e
xtends clause"); |
| 4712 static final ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES = new ParserErrorCode
.con2('MULTIPLE_LIBRARY_DIRECTIVES', 69, "Only one library directive may be decl
ared in a file"); | 4737 static final ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = new ParserErrorCode
.con2('MULTIPLE_IMPLEMENTS_CLAUSES', 69, "Each class definition can have at most
one implements clause"); |
| 4713 static final ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS = new ParserError
Code.con2('MULTIPLE_NAMED_PARAMETER_GROUPS', 70, "Cannot have multiple groups of
named parameters in a single parameter list"); | 4738 static final ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES = new ParserErrorCode
.con2('MULTIPLE_LIBRARY_DIRECTIVES', 70, "Only one library directive may be decl
ared in a file"); |
| 4714 static final ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES = new ParserErrorCode
.con2('MULTIPLE_PART_OF_DIRECTIVES', 71, "Only one part-of directive may be decl
ared in a file"); | 4739 static final ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS = new ParserError
Code.con2('MULTIPLE_NAMED_PARAMETER_GROUPS', 71, "Cannot have multiple groups of
named parameters in a single parameter list"); |
| 4715 static final ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS = new Parser
ErrorCode.con2('MULTIPLE_POSITIONAL_PARAMETER_GROUPS', 72, "Cannot have multiple
groups of positional parameters in a single parameter list"); | 4740 static final ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES = new ParserErrorCode
.con2('MULTIPLE_PART_OF_DIRECTIVES', 72, "Only one part-of directive may be decl
ared in a file"); |
| 4716 static final ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = new ParserErrorC
ode.con2('MULTIPLE_VARIABLES_IN_FOR_EACH', 73, "A single loop variable must be d
eclared in a for-each loop before the 'in', but %s were found"); | 4741 static final ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS = new Parser
ErrorCode.con2('MULTIPLE_POSITIONAL_PARAMETER_GROUPS', 73, "Cannot have multiple
groups of positional parameters in a single parameter list"); |
| 4717 static final ParserErrorCode MULTIPLE_WITH_CLAUSES = new ParserErrorCode.con2(
'MULTIPLE_WITH_CLAUSES', 74, "Each class definition can have at most one with cl
ause"); | 4742 static final ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = new ParserErrorC
ode.con2('MULTIPLE_VARIABLES_IN_FOR_EACH', 74, "A single loop variable must be d
eclared in a for-each loop before the 'in', but %s were found"); |
| 4718 static final ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = new ParserErrorCo
de.con2('NAMED_PARAMETER_OUTSIDE_GROUP', 75, "Named parameters must be enclosed
in curly braces ('{' and '}')"); | 4743 static final ParserErrorCode MULTIPLE_WITH_CLAUSES = new ParserErrorCode.con2(
'MULTIPLE_WITH_CLAUSES', 75, "Each class definition can have at most one with cl
ause"); |
| 4719 static final ParserErrorCode NON_CONSTRUCTOR_FACTORY = new ParserErrorCode.con
2('NON_CONSTRUCTOR_FACTORY', 76, "Only constructors can be declared to be a 'fac
tory'"); | 4744 static final ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = new ParserErrorCo
de.con2('NAMED_PARAMETER_OUTSIDE_GROUP', 76, "Named parameters must be enclosed
in curly braces ('{' and '}')"); |
| 4720 static final ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = new ParserErrorCode
.con2('NON_IDENTIFIER_LIBRARY_NAME', 77, "The name of a library must be an ident
ifier"); | 4745 static final ParserErrorCode NON_CONSTRUCTOR_FACTORY = new ParserErrorCode.con
2('NON_CONSTRUCTOR_FACTORY', 77, "Only constructors can be declared to be a 'fac
tory'"); |
| 4721 static final ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = new ParserErrorCo
de.con2('NON_PART_OF_DIRECTIVE_IN_PART', 78, "The part-of directive must be the
only directive in a part"); | 4746 static final ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = new ParserErrorCode
.con2('NON_IDENTIFIER_LIBRARY_NAME', 78, "The name of a library must be an ident
ifier"); |
| 4722 static final ParserErrorCode NON_USER_DEFINABLE_OPERATOR = new ParserErrorCode
.con2('NON_USER_DEFINABLE_OPERATOR', 79, "The operator '%s' is not user definabl
e"); | 4747 static final ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = new ParserErrorCo
de.con2('NON_PART_OF_DIRECTIVE_IN_PART', 79, "The part-of directive must be the
only directive in a part"); |
| 4723 static final ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = new ParserError
Code.con2('POSITIONAL_AFTER_NAMED_ARGUMENT', 80, "Positional arguments must occu
r before named arguments"); | 4748 static final ParserErrorCode NON_USER_DEFINABLE_OPERATOR = new ParserErrorCode
.con2('NON_USER_DEFINABLE_OPERATOR', 80, "The operator '%s' is not user definabl
e"); |
| 4724 static final ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP = new ParserEr
rorCode.con2('POSITIONAL_PARAMETER_OUTSIDE_GROUP', 81, "Positional parameters mu
st be enclosed in square brackets ('[' and ']')"); | 4749 static final ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = new ParserError
Code.con2('POSITIONAL_AFTER_NAMED_ARGUMENT', 81, "Positional arguments must occu
r before named arguments"); |
| 4725 static final ParserErrorCode STATIC_AFTER_CONST = new ParserErrorCode.con2('ST
ATIC_AFTER_CONST', 82, "The modifier 'static' should be before the modifier 'con
st'"); | 4750 static final ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP = new ParserEr
rorCode.con2('POSITIONAL_PARAMETER_OUTSIDE_GROUP', 82, "Positional parameters mu
st be enclosed in square brackets ('[' and ']')"); |
| 4726 static final ParserErrorCode STATIC_AFTER_FINAL = new ParserErrorCode.con2('ST
ATIC_AFTER_FINAL', 83, "The modifier 'static' should be before the modifier 'fin
al'"); | 4751 static final ParserErrorCode STATIC_AFTER_CONST = new ParserErrorCode.con2('ST
ATIC_AFTER_CONST', 83, "The modifier 'static' should be before the modifier 'con
st'"); |
| 4727 static final ParserErrorCode STATIC_AFTER_VAR = new ParserErrorCode.con2('STAT
IC_AFTER_VAR', 84, "The modifier 'static' should be before the modifier 'var'"); | 4752 static final ParserErrorCode STATIC_AFTER_FINAL = new ParserErrorCode.con2('ST
ATIC_AFTER_FINAL', 84, "The modifier 'static' should be before the modifier 'fin
al'"); |
| 4728 static final ParserErrorCode STATIC_CONSTRUCTOR = new ParserErrorCode.con2('ST
ATIC_CONSTRUCTOR', 85, "Constructors cannot be static"); | 4753 static final ParserErrorCode STATIC_AFTER_VAR = new ParserErrorCode.con2('STAT
IC_AFTER_VAR', 85, "The modifier 'static' should be before the modifier 'var'"); |
| 4729 static final ParserErrorCode STATIC_OPERATOR = new ParserErrorCode.con2('STATI
C_OPERATOR', 86, "Operators cannot be static"); | 4754 static final ParserErrorCode STATIC_CONSTRUCTOR = new ParserErrorCode.con2('ST
ATIC_CONSTRUCTOR', 86, "Constructors cannot be static"); |
| 4730 static final ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = new ParserErrorCod
e.con2('STATIC_TOP_LEVEL_DECLARATION', 87, "Top-level declarations cannot be dec
lared to be 'static'"); | 4755 static final ParserErrorCode STATIC_OPERATOR = new ParserErrorCode.con2('STATI
C_OPERATOR', 87, "Operators cannot be static"); |
| 4731 static final ParserErrorCode UNEXPECTED_TOKEN = new ParserErrorCode.con2('UNEX
PECTED_TOKEN', 88, "Unexpected token '%s'"); | 4756 static final ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = new ParserErrorCod
e.con2('STATIC_TOP_LEVEL_DECLARATION', 88, "Top-level declarations cannot be dec
lared to be 'static'"); |
| 4732 static final ParserErrorCode USE_OF_UNARY_PLUS_OPERATOR = new ParserErrorCode.
con2('USE_OF_UNARY_PLUS_OPERATOR', 89, "There is no unary plus operator in Dart"
); | 4757 static final ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP = new P
arserErrorCode.con2('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP', 89, "There is n
o '%s' to open a parameter group"); |
| 4733 static final ParserErrorCode WITH_BEFORE_EXTENDS = new ParserErrorCode.con2('W
ITH_BEFORE_EXTENDS', 90, "The extends clause must be before the with clause"); | 4758 static final ParserErrorCode UNEXPECTED_TOKEN = new ParserErrorCode.con2('UNEX
PECTED_TOKEN', 90, "Unexpected token '%s'"); |
| 4734 static final ParserErrorCode WITH_WITHOUT_EXTENDS = new ParserErrorCode.con2('
WITH_WITHOUT_EXTENDS', 91, "The with clause cannot be used without an extends cl
ause"); | 4759 static final ParserErrorCode USE_OF_UNARY_PLUS_OPERATOR = new ParserErrorCode.
con2('USE_OF_UNARY_PLUS_OPERATOR', 91, "There is no unary plus operator in Dart"
); |
| 4735 static final ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER = new ParserE
rrorCode.con2('WRONG_SEPARATOR_FOR_NAMED_PARAMETER', 92, "The default value of a
named parameter should be preceeded by ':'"); | 4760 static final ParserErrorCode WITH_BEFORE_EXTENDS = new ParserErrorCode.con2('W
ITH_BEFORE_EXTENDS', 92, "The extends clause must be before the with clause"); |
| 4736 static final ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = new Pa
rserErrorCode.con2('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER', 93, "The default
value of a positional parameter should be preceeded by '='"); | 4761 static final ParserErrorCode WITH_WITHOUT_EXTENDS = new ParserErrorCode.con2('
WITH_WITHOUT_EXTENDS', 93, "The with clause cannot be used without an extends cl
ause"); |
| 4737 static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con2('VAR_CLASS',
94, "Classes cannot be declared to be 'var'"); | 4762 static final ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER = new ParserE
rrorCode.con2('WRONG_SEPARATOR_FOR_NAMED_PARAMETER', 94, "The default value of a
named parameter should be preceeded by ':'"); |
| 4738 static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con2('VAR_R
ETURN_TYPE', 95, "The return type cannot be 'var'"); | 4763 static final ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = new Pa
rserErrorCode.con2('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER', 95, "The default
value of a positional parameter should be preceeded by '='"); |
| 4739 static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con2('VAR_TYPED
EF', 96, "Type aliases cannot be declared to be 'var'"); | 4764 static final ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = new Parser
ErrorCode.con2('WRONG_TERMINATOR_FOR_PARAMETER_GROUP', 96, "Expected '%s' to clo
se parameter group"); |
| 4740 static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con2('VOID_P
ARAMETER', 97, "Parameters cannot have a type of 'void'"); | 4765 static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con2('VAR_CLASS',
97, "Classes cannot be declared to be 'var'"); |
| 4741 static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con2('VOID_VA
RIABLE', 98, "Variables cannot have a type of 'void'"); | 4766 static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con2('VAR_R
ETURN_TYPE', 98, "The return type cannot be 'var'"); |
| 4742 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, BUILT_IN_IDENTIFIER_AS_TYPE_NAME, BUILT_IN_IDEN
TIFIER_AS_TYPEDEF_NAME, BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME, CONST_AND_FIN
AL, CONST_AND_VAR, CONST_CLASS, CONST_METHOD, CONST_TYPEDEF, CONSTRUCTOR_WITH_RE
TURN_TYPE, CONTINUE_OUTSIDE_OF_LOOP, CONTINUE_WITHOUT_LABEL_IN_CASE, DIRECTIVE_A
FTER_DECLARATION, DUPLICATE_LABEL_IN_SWITCH_STATEMENT, DUPLICATED_MODIFIER, EXPE
CTED_CASE_OR_DEFAULT, EXPECTED_LIST_OR_MAP_LITERAL, EXPECTED_STRING_LITERAL, EXP
ECTED_TOKEN, EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, EXTERNAL_AFTER_CONST, EXTERN
AL_AFTER_FACTORY, EXTERNAL_AFTER_STATIC, EXTERNAL_CLASS, EXTERNAL_CONSTRUCTOR_WI
TH_BODY, EXTERNAL_FIELD, EXTERNAL_GETTER_WITH_BODY, EXTERNAL_METHOD_WITH_BODY, E
XTERNAL_OPERATOR_WITH_BODY, EXTERNAL_SETTER_WITH_BODY, EXTERNAL_TYPEDEF, FACTORY
_TOP_LEVEL_DECLARATION, FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, FINAL_AND_VAR, FI
NAL_CLASS, FINAL_CONSTRUCTOR, FINAL_METHOD, FINAL_TYPEDEF, GETTER_WITH_PARAMETER
S, ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, IMPLEMENTS_BEFORE_EXTENDS, IMPLEMENTS_B
EFORE_WITH, IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, INITIALIZED_VARIABLE_IN_FOR_E
ACH, INVALID_CODE_POINT, INVALID_COMMENT_REFERENCE, INVALID_HEX_ESCAPE, INVALID_
OPERATOR_FOR_SUPER, INVALID_UNICODE_ESCAPE, LIBRARY_DIRECTIVE_NOT_FIRST, MISSING
_ASSIGNABLE_SELECTOR, MISSING_CATCH_OR_FINALLY, MISSING_CLASS_BODY, MISSING_CONS
T_FINAL_VAR_OR_TYPE, MISSING_FUNCTION_BODY, MISSING_FUNCTION_PARAMETERS, MISSING
_IDENTIFIER, MISSING_NAME_IN_LIBRARY_DIRECTIVE, MISSING_NAME_IN_PART_OF_DIRECTIV
E, MISSING_TYPEDEF_PARAMETERS, MISSING_VARIABLE_IN_FOR_EACH, MIXED_PARAMETER_GRO
UPS, MULTIPLE_EXTENDS_CLAUSES, MULTIPLE_IMPLEMENTS_CLAUSES, MULTIPLE_LIBRARY_DIR
ECTIVES, MULTIPLE_NAMED_PARAMETER_GROUPS, MULTIPLE_PART_OF_DIRECTIVES, MULTIPLE_
POSITIONAL_PARAMETER_GROUPS, MULTIPLE_VARIABLES_IN_FOR_EACH, MULTIPLE_WITH_CLAUS
ES, NAMED_PARAMETER_OUTSIDE_GROUP, NON_CONSTRUCTOR_FACTORY, NON_IDENTIFIER_LIBRA
RY_NAME, NON_PART_OF_DIRECTIVE_IN_PART, NON_USER_DEFINABLE_OPERATOR, POSITIONAL_
AFTER_NAMED_ARGUMENT, POSITIONAL_PARAMETER_OUTSIDE_GROUP, STATIC_AFTER_CONST, ST
ATIC_AFTER_FINAL, STATIC_AFTER_VAR, STATIC_CONSTRUCTOR, STATIC_OPERATOR, STATIC_
TOP_LEVEL_DECLARATION, UNEXPECTED_TOKEN, USE_OF_UNARY_PLUS_OPERATOR, WITH_BEFORE
_EXTENDS, WITH_WITHOUT_EXTENDS, WRONG_SEPARATOR_FOR_NAMED_PARAMETER, WRONG_SEPAR
ATOR_FOR_POSITIONAL_PARAMETER, VAR_CLASS, VAR_RETURN_TYPE, VAR_TYPEDEF, VOID_PAR
AMETER, VOID_VARIABLE]; | 4767 static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con2('VAR_TYPED
EF', 99, "Type aliases cannot be declared to be 'var'"); |
| 4768 static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con2('VOID_P
ARAMETER', 100, "Parameters cannot have a type of 'void'"); |
| 4769 static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con2('VOID_VA
RIABLE', 101, "Variables cannot have a type of 'void'"); |
| 4770 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, BUILT_IN_IDENTIFIER_AS_TYPE_NAME, BUILT_IN_IDEN
TIFIER_AS_TYPEDEF_NAME, BUILT_IN_IDENTIFIER_AS_TYPE_VARIABLE_NAME, CONST_AND_FIN
AL, CONST_AND_VAR, CONST_CLASS, CONST_METHOD, CONST_TYPEDEF, CONSTRUCTOR_WITH_RE
TURN_TYPE, CONTINUE_OUTSIDE_OF_LOOP, CONTINUE_WITHOUT_LABEL_IN_CASE, DIRECTIVE_A
FTER_DECLARATION, DUPLICATE_LABEL_IN_SWITCH_STATEMENT, DUPLICATED_MODIFIER, EXPE
CTED_CASE_OR_DEFAULT, EXPECTED_LIST_OR_MAP_LITERAL, EXPECTED_STRING_LITERAL, EXP
ECTED_TOKEN, EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, EXTERNAL_AFTER_CONST, EXTERN
AL_AFTER_FACTORY, EXTERNAL_AFTER_STATIC, EXTERNAL_CLASS, EXTERNAL_CONSTRUCTOR_WI
TH_BODY, EXTERNAL_FIELD, EXTERNAL_GETTER_WITH_BODY, EXTERNAL_METHOD_WITH_BODY, E
XTERNAL_OPERATOR_WITH_BODY, EXTERNAL_SETTER_WITH_BODY, EXTERNAL_TYPEDEF, FACTORY
_TOP_LEVEL_DECLARATION, FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, FINAL_AND_VAR, FI
NAL_CLASS, FINAL_CONSTRUCTOR, FINAL_METHOD, FINAL_TYPEDEF, GETTER_WITH_PARAMETER
S, ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, IMPLEMENTS_BEFORE_EXTENDS, IMPLEMENTS_B
EFORE_WITH, IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, INITIALIZED_VARIABLE_IN_FOR_E
ACH, INVALID_CODE_POINT, INVALID_COMMENT_REFERENCE, INVALID_HEX_ESCAPE, INVALID_
OPERATOR_FOR_SUPER, INVALID_UNICODE_ESCAPE, LIBRARY_DIRECTIVE_NOT_FIRST, MISSING
_ASSIGNABLE_SELECTOR, MISSING_CATCH_OR_FINALLY, MISSING_CLASS_BODY, MISSING_CONS
T_FINAL_VAR_OR_TYPE, MISSING_FUNCTION_BODY, MISSING_FUNCTION_PARAMETERS, MISSING
_IDENTIFIER, MISSING_NAME_IN_LIBRARY_DIRECTIVE, MISSING_NAME_IN_PART_OF_DIRECTIV
E, MISSING_TERMINATOR_FOR_PARAMETER_GROUP, MISSING_TYPEDEF_PARAMETERS, MISSING_V
ARIABLE_IN_FOR_EACH, MIXED_PARAMETER_GROUPS, MULTIPLE_EXTENDS_CLAUSES, MULTIPLE_
IMPLEMENTS_CLAUSES, MULTIPLE_LIBRARY_DIRECTIVES, MULTIPLE_NAMED_PARAMETER_GROUPS
, MULTIPLE_PART_OF_DIRECTIVES, MULTIPLE_POSITIONAL_PARAMETER_GROUPS, MULTIPLE_VA
RIABLES_IN_FOR_EACH, MULTIPLE_WITH_CLAUSES, NAMED_PARAMETER_OUTSIDE_GROUP, NON_C
ONSTRUCTOR_FACTORY, NON_IDENTIFIER_LIBRARY_NAME, NON_PART_OF_DIRECTIVE_IN_PART,
NON_USER_DEFINABLE_OPERATOR, POSITIONAL_AFTER_NAMED_ARGUMENT, POSITIONAL_PARAMET
ER_OUTSIDE_GROUP, STATIC_AFTER_CONST, STATIC_AFTER_FINAL, STATIC_AFTER_VAR, STAT
IC_CONSTRUCTOR, STATIC_OPERATOR, STATIC_TOP_LEVEL_DECLARATION, UNEXPECTED_TERMIN
ATOR_FOR_PARAMETER_GROUP, UNEXPECTED_TOKEN, USE_OF_UNARY_PLUS_OPERATOR, WITH_BEF
ORE_EXTENDS, WITH_WITHOUT_EXTENDS, WRONG_SEPARATOR_FOR_NAMED_PARAMETER, WRONG_SE
PARATOR_FOR_POSITIONAL_PARAMETER, WRONG_TERMINATOR_FOR_PARAMETER_GROUP, VAR_CLAS
S, VAR_RETURN_TYPE, VAR_TYPEDEF, VOID_PARAMETER, VOID_VARIABLE]; |
| 4743 String __name; | 4771 String __name; |
| 4744 int __ordinal = 0; | 4772 int __ordinal = 0; |
| 4745 /** | 4773 /** |
| 4746 * The severity of this error. | 4774 * The severity of this error. |
| 4747 */ | 4775 */ |
| 4748 ErrorSeverity _severity; | 4776 ErrorSeverity _severity; |
| 4749 /** | 4777 /** |
| 4750 * The message template used to create the message to be displayed for this er
ror. | 4778 * The message template used to create the message to be displayed for this er
ror. |
| 4751 */ | 4779 */ |
| 4752 String _message; | 4780 String _message; |
| 4753 /** | 4781 /** |
| 4754 * Initialize a newly created error code to have the given severity and messag
e. | 4782 * Initialize a newly created error code to have the given severity and messag
e. |
| 4755 * @param severity the severity of the error | 4783 * @param severity the severity of the error |
| 4756 * @param message the message template used to create the message to be displa
yed for the error | 4784 * @param message the message template used to create the message to be displa
yed for the error |
| 4757 */ | 4785 */ |
| 4758 ParserErrorCode.con1(String ___name, int ___ordinal, ErrorSeverity severity2,
String message2) { | 4786 ParserErrorCode.con1(String ___name, int ___ordinal, ErrorSeverity severity2,
String message2) { |
| 4759 _jtd_constructor_217_impl(___name, ___ordinal, severity2, message2); | 4787 _jtd_constructor_252_impl(___name, ___ordinal, severity2, message2); |
| 4760 } | 4788 } |
| 4761 _jtd_constructor_217_impl(String ___name, int ___ordinal, ErrorSeverity severi
ty2, String message2) { | 4789 _jtd_constructor_252_impl(String ___name, int ___ordinal, ErrorSeverity severi
ty2, String message2) { |
| 4762 __name = ___name; | 4790 __name = ___name; |
| 4763 __ordinal = ___ordinal; | 4791 __ordinal = ___ordinal; |
| 4764 this._severity = severity2; | 4792 this._severity = severity2; |
| 4765 this._message = message2; | 4793 this._message = message2; |
| 4766 } | 4794 } |
| 4767 /** | 4795 /** |
| 4768 * Initialize a newly created error code to have the given message and a sever
ity of ERROR. | 4796 * Initialize a newly created error code to have the given message and a sever
ity of ERROR. |
| 4769 * @param message the message template used to create the message to be displa
yed for the error | 4797 * @param message the message template used to create the message to be displa
yed for the error |
| 4770 */ | 4798 */ |
| 4771 ParserErrorCode.con2(String ___name, int ___ordinal, String message) { | 4799 ParserErrorCode.con2(String ___name, int ___ordinal, String message) { |
| 4772 _jtd_constructor_218_impl(___name, ___ordinal, message); | 4800 _jtd_constructor_253_impl(___name, ___ordinal, message); |
| 4773 } | 4801 } |
| 4774 _jtd_constructor_218_impl(String ___name, int ___ordinal, String message) { | 4802 _jtd_constructor_253_impl(String ___name, int ___ordinal, String message) { |
| 4775 _jtd_constructor_217_impl(___name, ___ordinal, ErrorSeverity.ERROR, message)
; | 4803 _jtd_constructor_252_impl(___name, ___ordinal, ErrorSeverity.ERROR, message)
; |
| 4776 } | 4804 } |
| 4777 ErrorSeverity get errorSeverity => _severity; | 4805 ErrorSeverity get errorSeverity => _severity; |
| 4778 String get message => _message; | 4806 String get message => _message; |
| 4779 ErrorType get type => ErrorType.SYNTACTIC_ERROR; | 4807 ErrorType get type => ErrorType.SYNTACTIC_ERROR; |
| 4780 bool needsRecompilation() => true; | 4808 bool needsRecompilation() => true; |
| 4781 String toString() => __name; | 4809 String toString() => __name; |
| 4782 } | 4810 } |
| 4783 /** | 4811 /** |
| 4784 * Instances of the class {link ToFormattedSourceVisitor} write a source represe
ntation of a visited | 4812 * Instances of the class {link ToFormattedSourceVisitor} write a source represe
ntation of a visited |
| 4785 * AST node (and all of it's children) to a writer. | 4813 * AST node (and all of it's children) to a writer. |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5074 visit(node.loopParameter); | 5102 visit(node.loopParameter); |
| 5075 _writer.print(" in "); | 5103 _writer.print(" in "); |
| 5076 visit(node.iterator); | 5104 visit(node.iterator); |
| 5077 _writer.print(") "); | 5105 _writer.print(") "); |
| 5078 visit(node.body); | 5106 visit(node.body); |
| 5079 return null; | 5107 return null; |
| 5080 } | 5108 } |
| 5081 Object visitFormalParameterList(FormalParameterList node) { | 5109 Object visitFormalParameterList(FormalParameterList node) { |
| 5082 String groupEnd = null; | 5110 String groupEnd = null; |
| 5083 _writer.print('('); | 5111 _writer.print('('); |
| 5084 NodeList<FormalParameter> parameters11 = node.parameters; | 5112 NodeList<FormalParameter> parameters13 = node.parameters; |
| 5085 int size7 = parameters11.length; | 5113 int size7 = parameters13.length; |
| 5086 for (int i = 0; i < size7; i++) { | 5114 for (int i = 0; i < size7; i++) { |
| 5087 FormalParameter parameter = parameters11[i]; | 5115 FormalParameter parameter = parameters13[i]; |
| 5088 if (i > 0) { | 5116 if (i > 0) { |
| 5089 _writer.print(", "); | 5117 _writer.print(", "); |
| 5090 } | 5118 } |
| 5091 if (groupEnd == null && parameter is DefaultFormalParameter) { | 5119 if (groupEnd == null && parameter is DefaultFormalParameter) { |
| 5092 if (identical(parameter.kind, ParameterKind.NAMED)) { | 5120 if (identical(parameter.kind, ParameterKind.NAMED)) { |
| 5093 groupEnd = "}"; | 5121 groupEnd = "}"; |
| 5094 _writer.print('{'); | 5122 _writer.print('{'); |
| 5095 } else { | 5123 } else { |
| 5096 groupEnd = "]"; | 5124 groupEnd = "]"; |
| 5097 _writer.print('['); | 5125 _writer.print('['); |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5640 for (int i = 0; i < size10; i++) { | 5668 for (int i = 0; i < size10; i++) { |
| 5641 if (i > 0) { | 5669 if (i > 0) { |
| 5642 _writer.print(separator); | 5670 _writer.print(separator); |
| 5643 } | 5671 } |
| 5644 nodes[i].accept(this); | 5672 nodes[i].accept(this); |
| 5645 } | 5673 } |
| 5646 } | 5674 } |
| 5647 } | 5675 } |
| 5648 } | 5676 } |
| 5649 } | 5677 } |
| OLD | NEW |