Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/parser.dart

Issue 14161021: Generate unique names less aggressively. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'instrumentation.dart'; 9 import 'instrumentation.dart';
10 import 'error.dart'; 10 import 'error.dart';
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 Token get staticKeyword => _staticKeyword; 158 Token get staticKeyword => _staticKeyword;
159 /** 159 /**
160 * Return the token representing the keyword 'var', or {@code null} if the key word was not found. 160 * Return the token representing the keyword 'var', or {@code null} if the key word was not found.
161 * @return the token representing the keyword 'var' 161 * @return the token representing the keyword 'var'
162 */ 162 */
163 Token get varKeyword => _varKeyword; 163 Token get varKeyword => _varKeyword;
164 /** 164 /**
165 * Set the token representing the keyword 'abstract' to the given token. 165 * Set the token representing the keyword 'abstract' to the given token.
166 * @param abstractKeyword the token representing the keyword 'abstract' 166 * @param abstractKeyword the token representing the keyword 'abstract'
167 */ 167 */
168 void set abstractKeyword(Token abstractKeyword4) { 168 void set abstractKeyword(Token abstractKeyword2) {
169 this._abstractKeyword = abstractKeyword4; 169 this._abstractKeyword = abstractKeyword2;
170 } 170 }
171 /** 171 /**
172 * Set the token representing the keyword 'const' to the given token. 172 * Set the token representing the keyword 'const' to the given token.
173 * @param constKeyword the token representing the keyword 'const' 173 * @param constKeyword the token representing the keyword 'const'
174 */ 174 */
175 void set constKeyword(Token constKeyword3) { 175 void set constKeyword(Token constKeyword2) {
176 this._constKeyword = constKeyword3; 176 this._constKeyword = constKeyword2;
177 } 177 }
178 /** 178 /**
179 * Set the token representing the keyword 'external' to the given token. 179 * Set the token representing the keyword 'external' to the given token.
180 * @param externalKeyword the token representing the keyword 'external' 180 * @param externalKeyword the token representing the keyword 'external'
181 */ 181 */
182 void set externalKeyword(Token externalKeyword5) { 182 void set externalKeyword(Token externalKeyword2) {
183 this._externalKeyword = externalKeyword5; 183 this._externalKeyword = externalKeyword2;
184 } 184 }
185 /** 185 /**
186 * Set the token representing the keyword 'factory' to the given token. 186 * Set the token representing the keyword 'factory' to the given token.
187 * @param factoryKeyword the token representing the keyword 'factory' 187 * @param factoryKeyword the token representing the keyword 'factory'
188 */ 188 */
189 void set factoryKeyword(Token factoryKeyword3) { 189 void set factoryKeyword(Token factoryKeyword2) {
190 this._factoryKeyword = factoryKeyword3; 190 this._factoryKeyword = factoryKeyword2;
191 } 191 }
192 /** 192 /**
193 * Set the token representing the keyword 'final' to the given token. 193 * Set the token representing the keyword 'final' to the given token.
194 * @param finalKeyword the token representing the keyword 'final' 194 * @param finalKeyword the token representing the keyword 'final'
195 */ 195 */
196 void set finalKeyword(Token finalKeyword2) { 196 void set finalKeyword(Token finalKeyword2) {
197 this._finalKeyword = finalKeyword2; 197 this._finalKeyword = finalKeyword2;
198 } 198 }
199 /** 199 /**
200 * Set the token representing the keyword 'static' to the given token. 200 * Set the token representing the keyword 'static' to the given token.
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 return true; 561 return true;
562 } 562 }
563 Token token = skipTypeName(_currentToken); 563 Token token = skipTypeName(_currentToken);
564 if (token == null) { 564 if (token == null) {
565 return false; 565 return false;
566 } 566 }
567 token = skipSimpleIdentifier(token); 567 token = skipSimpleIdentifier(token);
568 if (token == null) { 568 if (token == null) {
569 return false; 569 return false;
570 } 570 }
571 TokenType type26 = token.type; 571 TokenType type2 = token.type;
572 return identical(type26, TokenType.EQ) || identical(type26, TokenType.COMMA) || identical(type26, TokenType.SEMICOLON) || matches3(token, Keyword.IN); 572 return identical(type2, TokenType.EQ) || identical(type2, TokenType.COMMA) | | identical(type2, TokenType.SEMICOLON) || matches3(token, Keyword.IN);
573 } 573 }
574 /** 574 /**
575 * Return {@code true} if the given token appears to be the beginning of an op erator declaration. 575 * Return {@code true} if the given token appears to be the beginning of an op erator declaration.
576 * @param startToken the token that might be the start of an operator declarat ion 576 * @param startToken the token that might be the start of an operator declarat ion
577 * @return {@code true} if the given token appears to be the beginning of an o perator declaration 577 * @return {@code true} if the given token appears to be the beginning of an o perator declaration
578 */ 578 */
579 bool isOperator(Token startToken) { 579 bool isOperator(Token startToken) {
580 if (startToken.isOperator()) { 580 if (startToken.isOperator()) {
581 Token token = startToken.next; 581 Token token = startToken.next;
582 while (token.isOperator()) { 582 while (token.isOperator()) {
583 token = token.next; 583 token = token.next;
584 } 584 }
585 return matches4(token, TokenType.OPEN_PAREN); 585 return matches4(token, TokenType.OPEN_PAREN);
586 } 586 }
587 return false; 587 return false;
588 } 588 }
589 /** 589 /**
590 * Return {@code true} if the current token appears to be the beginning of a s witch member. 590 * Return {@code true} if the current token appears to be the beginning of a s witch member.
591 * @return {@code true} if the current token appears to be the beginning of a switch member 591 * @return {@code true} if the current token appears to be the beginning of a switch member
592 */ 592 */
593 bool isSwitchMember() { 593 bool isSwitchMember() {
594 Token token = _currentToken; 594 Token token = _currentToken;
595 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy pe.COLON)) { 595 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy pe.COLON)) {
596 token = token.next.next; 596 token = token.next.next;
597 } 597 }
598 if (identical(token.type, TokenType.KEYWORD)) { 598 if (identical(token.type, TokenType.KEYWORD)) {
599 Keyword keyword30 = ((token as KeywordToken)).keyword; 599 Keyword keyword2 = ((token as KeywordToken)).keyword;
600 return identical(keyword30, Keyword.CASE) || identical(keyword30, Keyword. DEFAULT); 600 return identical(keyword2, Keyword.CASE) || identical(keyword2, Keyword.DE FAULT);
601 } 601 }
602 return false; 602 return false;
603 } 603 }
604 /** 604 /**
605 * Compare the given tokens to find the token that appears first in the source being parsed. That 605 * Compare the given tokens to find the token that appears first in the source being parsed. That
606 * is, return the left-most of all of the tokens. The arguments are allowed to be {@code null}. 606 * is, return the left-most of all of the tokens. The arguments are allowed to be {@code null}.
607 * Return the token with the smallest offset, or {@code null} if there are no arguments or if all 607 * Return the token with the smallest offset, or {@code null} if there are no arguments or if all
608 * of the arguments are {@code null}. 608 * of the arguments are {@code null}.
609 * @param tokens the tokens being compared 609 * @param tokens the tokens being compared
610 * @return the token with the smallest offset 610 * @return the token with the smallest offset
611 */ 611 */
612 Token lexicallyFirst(List<Token> tokens) { 612 Token lexicallyFirst(List<Token> tokens) {
613 Token first = null; 613 Token first = null;
614 int firstOffset = 2147483647; 614 int firstOffset = 2147483647;
615 for (Token token in tokens) { 615 for (Token token in tokens) {
616 if (token != null) { 616 if (token != null) {
617 int offset5 = token.offset; 617 int offset2 = token.offset;
618 if (offset5 < firstOffset) { 618 if (offset2 < firstOffset) {
619 first = token; 619 first = token;
620 } 620 }
621 } 621 }
622 } 622 }
623 return first; 623 return first;
624 } 624 }
625 /** 625 /**
626 * Return {@code true} if the current token matches the given keyword. 626 * Return {@code true} if the current token matches the given keyword.
627 * @param keyword the keyword that can optionally appear in the current locati on 627 * @param keyword the keyword that can optionally appear in the current locati on
628 * @return {@code true} if the current token matches the given keyword 628 * @return {@code true} if the current token matches the given keyword
629 */ 629 */
630 bool matches(Keyword keyword) => matches3(_currentToken, keyword); 630 bool matches(Keyword keyword) => matches3(_currentToken, keyword);
631 /** 631 /**
632 * Return {@code true} if the current token matches the given identifier. 632 * Return {@code true} if the current token matches the given identifier.
633 * @param identifier the identifier that can optionally appear in the current location 633 * @param identifier the identifier that can optionally appear in the current location
634 * @return {@code true} if the current token matches the given identifier 634 * @return {@code true} if the current token matches the given identifier
635 */ 635 */
636 bool matches2(String identifier) => identical(_currentToken.type, TokenType.ID ENTIFIER) && _currentToken.lexeme == identifier; 636 bool matches2(String identifier) => identical(_currentToken.type, TokenType.ID ENTIFIER) && _currentToken.lexeme == identifier;
637 /** 637 /**
638 * Return {@code true} if the given token matches the given keyword. 638 * Return {@code true} if the given token matches the given keyword.
639 * @param token the token being tested 639 * @param token the token being tested
640 * @param keyword the keyword that is being tested for 640 * @param keyword the keyword that is being tested for
641 * @return {@code true} if the given token matches the given keyword 641 * @return {@code true} if the given token matches the given keyword
642 */ 642 */
643 bool matches3(Token token, Keyword keyword38) => identical(token.type, TokenTy pe.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword38); 643 bool matches3(Token token, Keyword keyword2) => identical(token.type, TokenTyp e.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword2);
644 /** 644 /**
645 * Return {@code true} if the given token has the given type. 645 * Return {@code true} if the given token has the given type.
646 * @param token the token being tested 646 * @param token the token being tested
647 * @param type the type of token that is being tested for 647 * @param type the type of token that is being tested for
648 * @return {@code true} if the given token has the given type 648 * @return {@code true} if the given token has the given type
649 */ 649 */
650 bool matches4(Token token, TokenType type40) => identical(token.type, type40); 650 bool matches4(Token token, TokenType type2) => identical(token.type, type2);
651 /** 651 /**
652 * Return {@code true} if the current token has the given type. Note that this method, unlike 652 * Return {@code true} if the current token has the given type. Note that this method, unlike
653 * other variants, will modify the token stream if possible to match a wider r ange of tokens. In 653 * other variants, will modify the token stream if possible to match a wider r ange of tokens. In
654 * particular, if we are attempting to match a '>' and the next token is eithe r a '>>' or '>>>', 654 * particular, if we are attempting to match a '>' and the next token is eithe r a '>>' or '>>>',
655 * the token stream will be re-written and {@code true} will be returned. 655 * the token stream will be re-written and {@code true} will be returned.
656 * @param type the type of token that can optionally appear in the current loc ation 656 * @param type the type of token that can optionally appear in the current loc ation
657 * @return {@code true} if the current token has the given type 657 * @return {@code true} if the current token has the given type
658 */ 658 */
659 bool matches5(TokenType type41) { 659 bool matches5(TokenType type2) {
660 TokenType currentType = _currentToken.type; 660 TokenType currentType = _currentToken.type;
661 if (currentType != type41) { 661 if (currentType != type2) {
662 if (identical(type41, TokenType.GT)) { 662 if (identical(type2, TokenType.GT)) {
663 if (identical(currentType, TokenType.GT_GT)) { 663 if (identical(currentType, TokenType.GT_GT)) {
664 int offset6 = _currentToken.offset; 664 int offset2 = _currentToken.offset;
665 Token first = new Token(TokenType.GT, offset6); 665 Token first = new Token(TokenType.GT, offset2);
666 Token second = new Token(TokenType.GT, offset6 + 1); 666 Token second = new Token(TokenType.GT, offset2 + 1);
667 second.setNext(_currentToken.next); 667 second.setNext(_currentToken.next);
668 first.setNext(second); 668 first.setNext(second);
669 _currentToken.previous.setNext(first); 669 _currentToken.previous.setNext(first);
670 _currentToken = first; 670 _currentToken = first;
671 return true; 671 return true;
672 } else if (identical(currentType, TokenType.GT_EQ)) { 672 } else if (identical(currentType, TokenType.GT_EQ)) {
673 int offset7 = _currentToken.offset; 673 int offset3 = _currentToken.offset;
674 Token first = new Token(TokenType.GT, offset7); 674 Token first = new Token(TokenType.GT, offset3);
675 Token second = new Token(TokenType.EQ, offset7 + 1); 675 Token second = new Token(TokenType.EQ, offset3 + 1);
676 second.setNext(_currentToken.next); 676 second.setNext(_currentToken.next);
677 first.setNext(second); 677 first.setNext(second);
678 _currentToken.previous.setNext(first); 678 _currentToken.previous.setNext(first);
679 _currentToken = first; 679 _currentToken = first;
680 return true; 680 return true;
681 } else if (identical(currentType, TokenType.GT_GT_EQ)) { 681 } else if (identical(currentType, TokenType.GT_GT_EQ)) {
682 int offset8 = _currentToken.offset; 682 int offset4 = _currentToken.offset;
683 Token first = new Token(TokenType.GT, offset8); 683 Token first = new Token(TokenType.GT, offset4);
684 Token second = new Token(TokenType.GT, offset8 + 1); 684 Token second = new Token(TokenType.GT, offset4 + 1);
685 Token third = new Token(TokenType.EQ, offset8 + 2); 685 Token third = new Token(TokenType.EQ, offset4 + 2);
686 third.setNext(_currentToken.next); 686 third.setNext(_currentToken.next);
687 second.setNext(third); 687 second.setNext(third);
688 first.setNext(second); 688 first.setNext(second);
689 _currentToken.previous.setNext(first); 689 _currentToken.previous.setNext(first);
690 _currentToken = first; 690 _currentToken = first;
691 return true; 691 return true;
692 } 692 }
693 } 693 }
694 return false; 694 return false;
695 } 695 }
(...skipping 1549 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 } else if (isInitializedVariableDeclaration()) { 2245 } else if (isInitializedVariableDeclaration()) {
2246 variableList = parseVariableDeclarationList(commentAndMetadata); 2246 variableList = parseVariableDeclarationList(commentAndMetadata);
2247 } else { 2247 } else {
2248 initialization = parseExpression2(); 2248 initialization = parseExpression2();
2249 } 2249 }
2250 if (matches(Keyword.IN)) { 2250 if (matches(Keyword.IN)) {
2251 DeclaredIdentifier loopVariable = null; 2251 DeclaredIdentifier loopVariable = null;
2252 if (variableList == null) { 2252 if (variableList == null) {
2253 reportError4(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); 2253 reportError4(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []);
2254 } else { 2254 } else {
2255 NodeList<VariableDeclaration> variables4 = variableList.variables; 2255 NodeList<VariableDeclaration> variables2 = variableList.variables;
2256 if (variables4.length > 1) { 2256 if (variables2.length > 1) {
2257 reportError4(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari ables4.length.toString()]); 2257 reportError4(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari ables2.length.toString()]);
2258 } 2258 }
2259 VariableDeclaration variable = variables4[0]; 2259 VariableDeclaration variable = variables2[0];
2260 if (variable.initializer != null) { 2260 if (variable.initializer != null) {
2261 reportError4(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, []) ; 2261 reportError4(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, []) ;
2262 } 2262 }
2263 loopVariable = new DeclaredIdentifier.full(commentAndMetadata.commen t, commentAndMetadata.metadata, variableList.keyword, variableList.type, variabl e.name); 2263 loopVariable = new DeclaredIdentifier.full(commentAndMetadata.commen t, commentAndMetadata.metadata, variableList.keyword, variableList.type, variabl e.name);
2264 } 2264 }
2265 Token inKeyword = expect(Keyword.IN); 2265 Token inKeyword = expect(Keyword.IN);
2266 Expression iterator = parseExpression2(); 2266 Expression iterator = parseExpression2();
2267 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 2267 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
2268 Statement body = parseStatement2(); 2268 Statement body = parseStatement2();
2269 return new ForEachStatement.full(forKeyword, leftParenthesis, loopVari able, inKeyword, iterator, rightParenthesis, body); 2269 return new ForEachStatement.full(forKeyword, leftParenthesis, loopVari able, inKeyword, iterator, rightParenthesis, body);
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 2962 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
2963 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 2963 if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
2964 if (matches4(peek(), TokenType.STRING)) { 2964 if (matches4(peek(), TokenType.STRING)) {
2965 Token afterString = skipStringLiteral(_currentToken.next); 2965 Token afterString = skipStringLiteral(_currentToken.next);
2966 if (afterString != null && identical(afterString.type, TokenType.COLON)) { 2966 if (afterString != null && identical(afterString.type, TokenType.COLON)) {
2967 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON)); 2967 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON));
2968 } 2968 }
2969 } 2969 }
2970 return parseBlock(); 2970 return parseBlock();
2971 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken)) .keyword.isPseudoKeyword()) { 2971 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken)) .keyword.isPseudoKeyword()) {
2972 Keyword keyword31 = ((_currentToken as KeywordToken)).keyword; 2972 Keyword keyword2 = ((_currentToken as KeywordToken)).keyword;
2973 if (identical(keyword31, Keyword.ASSERT)) { 2973 if (identical(keyword2, Keyword.ASSERT)) {
2974 return parseAssertStatement(); 2974 return parseAssertStatement();
2975 } else if (identical(keyword31, Keyword.BREAK)) { 2975 } else if (identical(keyword2, Keyword.BREAK)) {
2976 return parseBreakStatement(); 2976 return parseBreakStatement();
2977 } else if (identical(keyword31, Keyword.CONTINUE)) { 2977 } else if (identical(keyword2, Keyword.CONTINUE)) {
2978 return parseContinueStatement(); 2978 return parseContinueStatement();
2979 } else if (identical(keyword31, Keyword.DO)) { 2979 } else if (identical(keyword2, Keyword.DO)) {
2980 return parseDoStatement(); 2980 return parseDoStatement();
2981 } else if (identical(keyword31, Keyword.FOR)) { 2981 } else if (identical(keyword2, Keyword.FOR)) {
2982 return parseForStatement(); 2982 return parseForStatement();
2983 } else if (identical(keyword31, Keyword.IF)) { 2983 } else if (identical(keyword2, Keyword.IF)) {
2984 return parseIfStatement(); 2984 return parseIfStatement();
2985 } else if (identical(keyword31, Keyword.RETHROW)) { 2985 } else if (identical(keyword2, Keyword.RETHROW)) {
2986 return new ExpressionStatement.full(parseRethrowExpression(), expect2(To kenType.SEMICOLON)); 2986 return new ExpressionStatement.full(parseRethrowExpression(), expect2(To kenType.SEMICOLON));
2987 } else if (identical(keyword31, Keyword.RETURN)) { 2987 } else if (identical(keyword2, Keyword.RETURN)) {
2988 return parseReturnStatement(); 2988 return parseReturnStatement();
2989 } else if (identical(keyword31, Keyword.SWITCH)) { 2989 } else if (identical(keyword2, Keyword.SWITCH)) {
2990 return parseSwitchStatement(); 2990 return parseSwitchStatement();
2991 } else if (identical(keyword31, Keyword.THROW)) { 2991 } else if (identical(keyword2, Keyword.THROW)) {
2992 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke nType.SEMICOLON)); 2992 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke nType.SEMICOLON));
2993 } else if (identical(keyword31, Keyword.TRY)) { 2993 } else if (identical(keyword2, Keyword.TRY)) {
2994 return parseTryStatement(); 2994 return parseTryStatement();
2995 } else if (identical(keyword31, Keyword.WHILE)) { 2995 } else if (identical(keyword2, Keyword.WHILE)) {
2996 return parseWhileStatement(); 2996 return parseWhileStatement();
2997 } else if (identical(keyword31, Keyword.VAR) || identical(keyword31, Keywo rd.FINAL)) { 2997 } else if (identical(keyword2, Keyword.VAR) || identical(keyword2, Keyword .FINAL)) {
2998 return parseVariableDeclarationStatement(commentAndMetadata); 2998 return parseVariableDeclarationStatement(commentAndMetadata);
2999 } else if (identical(keyword31, Keyword.VOID)) { 2999 } else if (identical(keyword2, Keyword.VOID)) {
3000 TypeName returnType = parseReturnType(); 3000 TypeName returnType = parseReturnType();
3001 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { 3001 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) {
3002 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe); 3002 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe);
3003 } else { 3003 } else {
3004 if (matchesIdentifier()) { 3004 if (matchesIdentifier()) {
3005 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) { 3005 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) {
3006 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); 3006 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []);
3007 return parseVariableDeclarationStatement(commentAndMetadata); 3007 return parseVariableDeclarationStatement(commentAndMetadata);
3008 } 3008 }
3009 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 3009 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
3010 return parseVariableDeclarationStatement2(commentAndMetadata, null, returnType); 3010 return parseVariableDeclarationStatement2(commentAndMetadata, null, returnType);
3011 } 3011 }
3012 reportError4(ParserErrorCode.MISSING_STATEMENT, []); 3012 reportError4(ParserErrorCode.MISSING_STATEMENT, []);
3013 return null; 3013 return null;
3014 } 3014 }
3015 } else if (identical(keyword31, Keyword.CONST)) { 3015 } else if (identical(keyword2, Keyword.CONST)) {
3016 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) { 3016 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) {
3017 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON)); 3017 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON));
3018 } else if (matches4(peek(), TokenType.IDENTIFIER)) { 3018 } else if (matches4(peek(), TokenType.IDENTIFIER)) {
3019 Token afterType = skipTypeName(peek()); 3019 Token afterType = skipTypeName(peek());
3020 if (afterType != null) { 3020 if (afterType != null) {
3021 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) { 3021 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) {
3022 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON)); 3022 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON));
3023 } 3023 }
3024 } 3024 }
3025 } 3025 }
3026 return parseVariableDeclarationStatement(commentAndMetadata); 3026 return parseVariableDeclarationStatement(commentAndMetadata);
3027 } else if (identical(keyword31, Keyword.NEW) || identical(keyword31, Keywo rd.TRUE) || identical(keyword31, Keyword.FALSE) || identical(keyword31, Keyword. NULL) || identical(keyword31, Keyword.SUPER) || identical(keyword31, Keyword.THI S)) { 3027 } else if (identical(keyword2, Keyword.NEW) || identical(keyword2, Keyword .TRUE) || identical(keyword2, Keyword.FALSE) || identical(keyword2, Keyword.NULL ) || identical(keyword2, Keyword.SUPER) || identical(keyword2, Keyword.THIS)) {
3028 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON)); 3028 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON));
3029 } else { 3029 } else {
3030 reportError4(ParserErrorCode.MISSING_STATEMENT, []); 3030 reportError4(ParserErrorCode.MISSING_STATEMENT, []);
3031 return null; 3031 return null;
3032 } 3032 }
3033 } else if (matches5(TokenType.SEMICOLON)) { 3033 } else if (matches5(TokenType.SEMICOLON)) {
3034 return parseEmptyStatement(); 3034 return parseEmptyStatement();
3035 } else if (isInitializedVariableDeclaration()) { 3035 } else if (isInitializedVariableDeclaration()) {
3036 return parseVariableDeclarationStatement(commentAndMetadata); 3036 return parseVariableDeclarationStatement(commentAndMetadata);
3037 } else if (isFunctionDeclaration()) { 3037 } else if (isFunctionDeclaration()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3069 thisKeyword = andAdvance; 3069 thisKeyword = andAdvance;
3070 period = expect2(TokenType.PERIOD); 3070 period = expect2(TokenType.PERIOD);
3071 } 3071 }
3072 SimpleIdentifier identifier = parseSimpleIdentifier(); 3072 SimpleIdentifier identifier = parseSimpleIdentifier();
3073 if (matches5(TokenType.OPEN_PAREN)) { 3073 if (matches5(TokenType.OPEN_PAREN)) {
3074 if (thisKeyword != null) { 3074 if (thisKeyword != null) {
3075 } 3075 }
3076 FormalParameterList parameters = parseFormalParameterList(); 3076 FormalParameterList parameters = parseFormalParameterList();
3077 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c ommentAndMetadata.metadata, holder.type, identifier, parameters); 3077 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, c ommentAndMetadata.metadata, holder.type, identifier, parameters);
3078 } 3078 }
3079 TypeName type27 = holder.type; 3079 TypeName type2 = holder.type;
3080 if (type27 != null && matches3(type27.name.beginToken, Keyword.VOID)) { 3080 if (type2 != null && matches3(type2.name.beginToken, Keyword.VOID)) {
3081 reportError5(ParserErrorCode.VOID_PARAMETER, type27.name.beginToken, []); 3081 reportError5(ParserErrorCode.VOID_PARAMETER, type2.name.beginToken, []);
3082 } 3082 }
3083 if (thisKeyword != null) { 3083 if (thisKeyword != null) {
3084 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier ); 3084 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier );
3085 } 3085 }
3086 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd Metadata.metadata, holder.keyword, holder.type, identifier); 3086 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd Metadata.metadata, holder.keyword, holder.type, identifier);
3087 } 3087 }
3088 /** 3088 /**
3089 * Parse an operator declaration. 3089 * Parse an operator declaration.
3090 * <pre> 3090 * <pre>
3091 * operatorDeclaration ::= 3091 * operatorDeclaration ::=
(...skipping 14 matching lines...) Expand all
3106 operatorKeyword = andAdvance; 3106 operatorKeyword = andAdvance;
3107 } else { 3107 } else {
3108 reportError5(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToken, []); 3108 reportError5(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToken, []);
3109 operatorKeyword = createSyntheticToken(Keyword.OPERATOR); 3109 operatorKeyword = createSyntheticToken(Keyword.OPERATOR);
3110 } 3110 }
3111 if (!_currentToken.isUserDefinableOperator()) { 3111 if (!_currentToken.isUserDefinableOperator()) {
3112 reportError4(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.l exeme]); 3112 reportError4(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.l exeme]);
3113 } 3113 }
3114 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance); 3114 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance);
3115 if (matches5(TokenType.EQ)) { 3115 if (matches5(TokenType.EQ)) {
3116 Token previous4 = _currentToken.previous; 3116 Token previous2 = _currentToken.previous;
3117 if ((matches4(previous4, TokenType.EQ_EQ) || matches4(previous4, TokenType .BANG_EQ)) && _currentToken.offset == previous4.offset + 2) { 3117 if ((matches4(previous2, TokenType.EQ_EQ) || matches4(previous2, TokenType .BANG_EQ)) && _currentToken.offset == previous2.offset + 2) {
3118 reportError4(ParserErrorCode.INVALID_OPERATOR, ["${previous4.lexeme}${_c urrentToken.lexeme}"]); 3118 reportError4(ParserErrorCode.INVALID_OPERATOR, ["${previous2.lexeme}${_c urrentToken.lexeme}"]);
3119 advance(); 3119 advance();
3120 } 3120 }
3121 } 3121 }
3122 FormalParameterList parameters = parseFormalParameterList(); 3122 FormalParameterList parameters = parseFormalParameterList();
3123 validateFormalParameterList(parameters); 3123 validateFormalParameterList(parameters);
3124 FunctionBody body = parseFunctionBody(true, false); 3124 FunctionBody body = parseFunctionBody(true, false);
3125 if (externalKeyword != null && body is! EmptyFunctionBody) { 3125 if (externalKeyword != null && body is! EmptyFunctionBody) {
3126 reportError4(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []); 3126 reportError4(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []);
3127 } 3127 }
3128 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p arameters, body); 3128 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p arameters, body);
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
3870 return new PrefixExpression.full(operator, new SuperExpression.full(andA dvance)); 3870 return new PrefixExpression.full(operator, new SuperExpression.full(andA dvance));
3871 } 3871 }
3872 return new PrefixExpression.full(operator, parseUnaryExpression()); 3872 return new PrefixExpression.full(operator, parseUnaryExpression());
3873 } else if (_currentToken.type.isIncrementOperator()) { 3873 } else if (_currentToken.type.isIncrementOperator()) {
3874 Token operator = andAdvance; 3874 Token operator = andAdvance;
3875 if (matches(Keyword.SUPER)) { 3875 if (matches(Keyword.SUPER)) {
3876 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(), TokenType.PERIOD)) { 3876 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(), TokenType.PERIOD)) {
3877 return new PrefixExpression.full(operator, parseUnaryExpression()); 3877 return new PrefixExpression.full(operator, parseUnaryExpression());
3878 } 3878 }
3879 if (identical(operator.type, TokenType.MINUS_MINUS)) { 3879 if (identical(operator.type, TokenType.MINUS_MINUS)) {
3880 int offset9 = operator.offset; 3880 int offset2 = operator.offset;
3881 Token firstOperator = new Token(TokenType.MINUS, offset9); 3881 Token firstOperator = new Token(TokenType.MINUS, offset2);
3882 Token secondOperator = new Token(TokenType.MINUS, offset9 + 1); 3882 Token secondOperator = new Token(TokenType.MINUS, offset2 + 1);
3883 secondOperator.setNext(_currentToken); 3883 secondOperator.setNext(_currentToken);
3884 firstOperator.setNext(secondOperator); 3884 firstOperator.setNext(secondOperator);
3885 operator.previous.setNext(firstOperator); 3885 operator.previous.setNext(firstOperator);
3886 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance))); 3886 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance)));
3887 } else { 3887 } else {
3888 reportError4(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex eme]); 3888 reportError4(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex eme]);
3889 return new PrefixExpression.full(operator, new SuperExpression.full(an dAdvance)); 3889 return new PrefixExpression.full(operator, new SuperExpression.full(an dAdvance));
3890 } 3890 }
3891 } 3891 }
3892 return new PrefixExpression.full(operator, parseAssignableExpression(false )); 3892 return new PrefixExpression.full(operator, parseAssignableExpression(false ));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
4073 * | 'final' type? 4073 * | 'final' type?
4074 * | 'const' type? 4074 * | 'const' type?
4075 * | 'var' 4075 * | 'var'
4076 * | type 4076 * | type
4077 * </pre> 4077 * </pre>
4078 * @param startToken the token at which parsing is to begin 4078 * @param startToken the token at which parsing is to begin
4079 * @return the token following the type that was parsed 4079 * @return the token following the type that was parsed
4080 */ 4080 */
4081 Token skipFinalConstVarOrType(Token startToken) { 4081 Token skipFinalConstVarOrType(Token startToken) {
4082 if (matches3(startToken, Keyword.FINAL) || matches3(startToken, Keyword.CONS T)) { 4082 if (matches3(startToken, Keyword.FINAL) || matches3(startToken, Keyword.CONS T)) {
4083 Token next3 = startToken.next; 4083 Token next2 = startToken.next;
4084 if (matchesIdentifier2(next3.next) || matches4(next3.next, TokenType.LT) | | matches3(next3.next, Keyword.THIS)) { 4084 if (matchesIdentifier2(next2.next) || matches4(next2.next, TokenType.LT) | | matches3(next2.next, Keyword.THIS)) {
4085 return skipTypeName(next3); 4085 return skipTypeName(next2);
4086 } 4086 }
4087 } else if (matches3(startToken, Keyword.VAR)) { 4087 } else if (matches3(startToken, Keyword.VAR)) {
4088 return startToken.next; 4088 return startToken.next;
4089 } else if (matchesIdentifier2(startToken)) { 4089 } else if (matchesIdentifier2(startToken)) {
4090 Token next4 = startToken.next; 4090 Token next3 = startToken.next;
4091 if (matchesIdentifier2(next4) || matches4(next4, TokenType.LT) || matches3 (next4, Keyword.THIS) || (matches4(next4, TokenType.PERIOD) && matchesIdentifier 2(next4.next) && (matchesIdentifier2(next4.next.next) || matches4(next4.next.nex t, TokenType.LT) || matches3(next4.next.next, Keyword.THIS)))) { 4091 if (matchesIdentifier2(next3) || matches4(next3, TokenType.LT) || matches3 (next3, Keyword.THIS) || (matches4(next3, TokenType.PERIOD) && matchesIdentifier 2(next3.next) && (matchesIdentifier2(next3.next.next) || matches4(next3.next.nex t, TokenType.LT) || matches3(next3.next.next, Keyword.THIS)))) {
4092 return skipReturnType(startToken); 4092 return skipReturnType(startToken);
4093 } 4093 }
4094 } 4094 }
4095 return null; 4095 return null;
4096 } 4096 }
4097 /** 4097 /**
4098 * Parse a list of formal parameters, starting at the given token, without act ually creating a 4098 * Parse a list of formal parameters, starting at the given token, without act ually creating a
4099 * formal parameter list or changing the current token. Return the token follo wing the formal 4099 * formal parameter list or changing the current token. Return the token follo wing the formal
4100 * parameter list that was parsed, or {@code null} if the given token is not t he first token in a 4100 * parameter list that was parsed, or {@code null} if the given token is not t he first token in a
4101 * valid list of formal parameter. 4101 * valid list of formal parameter.
(...skipping 20 matching lines...) Expand all
4122 * namedFormalParameters ::= 4122 * namedFormalParameters ::=
4123 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}' 4123 * '{' defaultNamedParameter (',' defaultNamedParameter)* '}'
4124 * </pre> 4124 * </pre>
4125 * @param startToken the token at which parsing is to begin 4125 * @param startToken the token at which parsing is to begin
4126 * @return the token following the formal parameter list that was parsed 4126 * @return the token following the formal parameter list that was parsed
4127 */ 4127 */
4128 Token skipFormalParameterList(Token startToken) { 4128 Token skipFormalParameterList(Token startToken) {
4129 if (!matches4(startToken, TokenType.OPEN_PAREN)) { 4129 if (!matches4(startToken, TokenType.OPEN_PAREN)) {
4130 return null; 4130 return null;
4131 } 4131 }
4132 Token next5 = startToken.next; 4132 Token next2 = startToken.next;
4133 if (matches4(next5, TokenType.CLOSE_PAREN)) { 4133 if (matches4(next2, TokenType.CLOSE_PAREN)) {
4134 return next5.next; 4134 return next2.next;
4135 } 4135 }
4136 if (matchesAny(next5, [TokenType.AT, TokenType.OPEN_SQUARE_BRACKET, TokenTyp e.OPEN_CURLY_BRACKET]) || matches3(next5, Keyword.VOID) || (matchesIdentifier2(n ext5) && (matchesAny(next5.next, [TokenType.COMMA, TokenType.CLOSE_PAREN])))) { 4136 if (matchesAny(next2, [TokenType.AT, TokenType.OPEN_SQUARE_BRACKET, TokenTyp e.OPEN_CURLY_BRACKET]) || matches3(next2, Keyword.VOID) || (matchesIdentifier2(n ext2) && (matchesAny(next2.next, [TokenType.COMMA, TokenType.CLOSE_PAREN])))) {
4137 return skipPastMatchingToken(startToken); 4137 return skipPastMatchingToken(startToken);
4138 } 4138 }
4139 if (matchesIdentifier2(next5) && matches4(next5.next, TokenType.OPEN_PAREN)) { 4139 if (matchesIdentifier2(next2) && matches4(next2.next, TokenType.OPEN_PAREN)) {
4140 Token afterParameters = skipFormalParameterList(next5.next); 4140 Token afterParameters = skipFormalParameterList(next2.next);
4141 if (afterParameters != null && (matchesAny(afterParameters, [TokenType.COM MA, TokenType.CLOSE_PAREN]))) { 4141 if (afterParameters != null && (matchesAny(afterParameters, [TokenType.COM MA, TokenType.CLOSE_PAREN]))) {
4142 return skipPastMatchingToken(startToken); 4142 return skipPastMatchingToken(startToken);
4143 } 4143 }
4144 } 4144 }
4145 Token afterType = skipFinalConstVarOrType(next5); 4145 Token afterType = skipFinalConstVarOrType(next2);
4146 if (afterType == null) { 4146 if (afterType == null) {
4147 return null; 4147 return null;
4148 } 4148 }
4149 if (skipSimpleIdentifier(afterType) == null) { 4149 if (skipSimpleIdentifier(afterType) == null) {
4150 return null; 4150 return null;
4151 } 4151 }
4152 return skipPastMatchingToken(startToken); 4152 return skipPastMatchingToken(startToken);
4153 } 4153 }
4154 /** 4154 /**
4155 * If the given token is a begin token with an associated end token, then retu rn the token 4155 * If the given token is a begin token with an associated end token, then retu rn the token
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
4235 * actually creating a string literal or changing the current token. Return th e token following 4235 * actually creating a string literal or changing the current token. Return th e token following
4236 * the string literal that was parsed, or {@code null} if the given token is n ot the first token 4236 * the string literal that was parsed, or {@code null} if the given token is n ot the first token
4237 * in a valid string literal. 4237 * in a valid string literal.
4238 * <p> 4238 * <p>
4239 * This method must be kept in sync with {@link #parseStringInterpolation(Toke n)}. 4239 * This method must be kept in sync with {@link #parseStringInterpolation(Toke n)}.
4240 * @param startToken the token at which parsing is to begin 4240 * @param startToken the token at which parsing is to begin
4241 * @return the string literal that was parsed 4241 * @return the string literal that was parsed
4242 */ 4242 */
4243 Token skipStringInterpolation(Token startToken) { 4243 Token skipStringInterpolation(Token startToken) {
4244 Token token = startToken; 4244 Token token = startToken;
4245 TokenType type28 = token.type; 4245 TokenType type2 = token.type;
4246 while (identical(type28, TokenType.STRING_INTERPOLATION_EXPRESSION) || ident ical(type28, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { 4246 while (identical(type2, TokenType.STRING_INTERPOLATION_EXPRESSION) || identi cal(type2, TokenType.STRING_INTERPOLATION_IDENTIFIER)) {
4247 if (identical(type28, TokenType.STRING_INTERPOLATION_EXPRESSION)) { 4247 if (identical(type2, TokenType.STRING_INTERPOLATION_EXPRESSION)) {
4248 token = token.next; 4248 token = token.next;
4249 type28 = token.type; 4249 type2 = token.type;
4250 int bracketNestingLevel = 1; 4250 int bracketNestingLevel = 1;
4251 while (bracketNestingLevel > 0) { 4251 while (bracketNestingLevel > 0) {
4252 if (identical(type28, TokenType.EOF)) { 4252 if (identical(type2, TokenType.EOF)) {
4253 return null; 4253 return null;
4254 } else if (identical(type28, TokenType.OPEN_CURLY_BRACKET)) { 4254 } else if (identical(type2, TokenType.OPEN_CURLY_BRACKET)) {
4255 bracketNestingLevel++; 4255 bracketNestingLevel++;
4256 } else if (identical(type28, TokenType.CLOSE_CURLY_BRACKET)) { 4256 } else if (identical(type2, TokenType.CLOSE_CURLY_BRACKET)) {
4257 bracketNestingLevel--; 4257 bracketNestingLevel--;
4258 } else if (identical(type28, TokenType.STRING)) { 4258 } else if (identical(type2, TokenType.STRING)) {
4259 token = skipStringLiteral(token); 4259 token = skipStringLiteral(token);
4260 if (token == null) { 4260 if (token == null) {
4261 return null; 4261 return null;
4262 } 4262 }
4263 } else { 4263 } else {
4264 token = token.next; 4264 token = token.next;
4265 } 4265 }
4266 type28 = token.type; 4266 type2 = token.type;
4267 } 4267 }
4268 token = token.next; 4268 token = token.next;
4269 type28 = token.type; 4269 type2 = token.type;
4270 } else { 4270 } else {
4271 token = token.next; 4271 token = token.next;
4272 if (token.type != TokenType.IDENTIFIER) { 4272 if (token.type != TokenType.IDENTIFIER) {
4273 return null; 4273 return null;
4274 } 4274 }
4275 token = token.next; 4275 token = token.next;
4276 } 4276 }
4277 type28 = token.type; 4277 type2 = token.type;
4278 if (identical(type28, TokenType.STRING)) { 4278 if (identical(type2, TokenType.STRING)) {
4279 token = token.next; 4279 token = token.next;
4280 type28 = token.type; 4280 type2 = token.type;
4281 } 4281 }
4282 } 4282 }
4283 return token; 4283 return token;
4284 } 4284 }
4285 /** 4285 /**
4286 * Parse a string literal, starting at the given token, without actually creat ing a string literal 4286 * Parse a string literal, starting at the given token, without actually creat ing a string literal
4287 * or changing the current token. Return the token following the string litera l that was parsed, 4287 * or changing the current token. Return the token following the string litera l that was parsed,
4288 * or {@code null} if the given token is not the first token in a valid string literal. 4288 * or {@code null} if the given token is not the first token in a valid string literal.
4289 * <p> 4289 * <p>
4290 * This method must be kept in sync with {@link #parseStringLiteral()}. 4290 * This method must be kept in sync with {@link #parseStringLiteral()}.
4291 * <pre> 4291 * <pre>
4292 * stringLiteral ::= 4292 * stringLiteral ::=
4293 * MULTI_LINE_STRING+ 4293 * MULTI_LINE_STRING+
4294 * | SINGLE_LINE_STRING+ 4294 * | SINGLE_LINE_STRING+
4295 * </pre> 4295 * </pre>
4296 * @param startToken the token at which parsing is to begin 4296 * @param startToken the token at which parsing is to begin
4297 * @return the token following the string literal that was parsed 4297 * @return the token following the string literal that was parsed
4298 */ 4298 */
4299 Token skipStringLiteral(Token startToken) { 4299 Token skipStringLiteral(Token startToken) {
4300 Token token = startToken; 4300 Token token = startToken;
4301 while (token != null && matches4(token, TokenType.STRING)) { 4301 while (token != null && matches4(token, TokenType.STRING)) {
4302 token = token.next; 4302 token = token.next;
4303 TokenType type29 = token.type; 4303 TokenType type2 = token.type;
4304 if (identical(type29, TokenType.STRING_INTERPOLATION_EXPRESSION) || identi cal(type29, TokenType.STRING_INTERPOLATION_IDENTIFIER)) { 4304 if (identical(type2, TokenType.STRING_INTERPOLATION_EXPRESSION) || identic al(type2, TokenType.STRING_INTERPOLATION_IDENTIFIER)) {
4305 token = skipStringInterpolation(token); 4305 token = skipStringInterpolation(token);
4306 } 4306 }
4307 } 4307 }
4308 if (identical(token, startToken)) { 4308 if (identical(token, startToken)) {
4309 return null; 4309 return null;
4310 } 4310 }
4311 return token; 4311 return token;
4312 } 4312 }
4313 /** 4313 /**
4314 * Parse a list of type arguments, starting at the given token, without actual ly creating a type argument list 4314 * Parse a list of type arguments, starting at the given token, without actual ly creating a type argument list
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
4383 * '<' typeParameter (',' typeParameter)* '>' 4383 * '<' typeParameter (',' typeParameter)* '>'
4384 * </pre> 4384 * </pre>
4385 * @param startToken the token at which parsing is to begin 4385 * @param startToken the token at which parsing is to begin
4386 * @return the token following the type parameter list that was parsed 4386 * @return the token following the type parameter list that was parsed
4387 */ 4387 */
4388 Token skipTypeParameterList(Token startToken) { 4388 Token skipTypeParameterList(Token startToken) {
4389 if (!matches4(startToken, TokenType.LT)) { 4389 if (!matches4(startToken, TokenType.LT)) {
4390 return null; 4390 return null;
4391 } 4391 }
4392 int depth = 1; 4392 int depth = 1;
4393 Token next6 = startToken.next; 4393 Token next2 = startToken.next;
4394 while (depth > 0) { 4394 while (depth > 0) {
4395 if (matches4(next6, TokenType.EOF)) { 4395 if (matches4(next2, TokenType.EOF)) {
4396 return null; 4396 return null;
4397 } else if (matches4(next6, TokenType.LT)) { 4397 } else if (matches4(next2, TokenType.LT)) {
4398 depth++; 4398 depth++;
4399 } else if (matches4(next6, TokenType.GT)) { 4399 } else if (matches4(next2, TokenType.GT)) {
4400 depth--; 4400 depth--;
4401 } else if (matches4(next6, TokenType.GT_EQ)) { 4401 } else if (matches4(next2, TokenType.GT_EQ)) {
4402 if (depth == 1) { 4402 if (depth == 1) {
4403 Token fakeEquals = new Token(TokenType.EQ, next6.offset + 2); 4403 Token fakeEquals = new Token(TokenType.EQ, next2.offset + 2);
4404 fakeEquals.setNextWithoutSettingPrevious(next6.next); 4404 fakeEquals.setNextWithoutSettingPrevious(next2.next);
4405 return fakeEquals; 4405 return fakeEquals;
4406 } 4406 }
4407 depth--; 4407 depth--;
4408 } else if (matches4(next6, TokenType.GT_GT)) { 4408 } else if (matches4(next2, TokenType.GT_GT)) {
4409 depth -= 2; 4409 depth -= 2;
4410 } else if (matches4(next6, TokenType.GT_GT_EQ)) { 4410 } else if (matches4(next2, TokenType.GT_GT_EQ)) {
4411 if (depth < 2) { 4411 if (depth < 2) {
4412 return null; 4412 return null;
4413 } else if (depth == 2) { 4413 } else if (depth == 2) {
4414 Token fakeEquals = new Token(TokenType.EQ, next6.offset + 2); 4414 Token fakeEquals = new Token(TokenType.EQ, next2.offset + 2);
4415 fakeEquals.setNextWithoutSettingPrevious(next6.next); 4415 fakeEquals.setNextWithoutSettingPrevious(next2.next);
4416 return fakeEquals; 4416 return fakeEquals;
4417 } 4417 }
4418 depth -= 2; 4418 depth -= 2;
4419 } 4419 }
4420 next6 = next6.next; 4420 next2 = next2.next;
4421 } 4421 }
4422 return next6; 4422 return next2;
4423 } 4423 }
4424 /** 4424 /**
4425 * Translate the characters at the given index in the given string, appending the translated 4425 * Translate the characters at the given index in the given string, appending the translated
4426 * character to the given builder. The index is assumed to be valid. 4426 * character to the given builder. The index is assumed to be valid.
4427 * @param builder the builder to which the translated character is to be appen ded 4427 * @param builder the builder to which the translated character is to be appen ded
4428 * @param lexeme the string containing the character(s) to be translated 4428 * @param lexeme the string containing the character(s) to be translated
4429 * @param index the index of the character to be translated 4429 * @param index the index of the character to be translated
4430 * @return the index of the next character to be translated 4430 * @return the index of the next character to be translated
4431 */ 4431 */
4432 int translateCharacter(JavaStringBuilder builder, String lexeme, int index) { 4432 int translateCharacter(JavaStringBuilder builder, String lexeme, int index) {
4433 int currentChar = lexeme.codeUnitAt(index); 4433 int currentChar = lexeme.codeUnitAt(index);
4434 if (currentChar != 0x5C) { 4434 if (currentChar != 0x5C) {
4435 builder.appendChar(currentChar); 4435 builder.appendChar(currentChar);
4436 return index + 1; 4436 return index + 1;
4437 } 4437 }
4438 int length8 = lexeme.length; 4438 int length2 = lexeme.length;
4439 int currentIndex = index + 1; 4439 int currentIndex = index + 1;
4440 if (currentIndex >= length8) { 4440 if (currentIndex >= length2) {
4441 return length8; 4441 return length2;
4442 } 4442 }
4443 currentChar = lexeme.codeUnitAt(currentIndex); 4443 currentChar = lexeme.codeUnitAt(currentIndex);
4444 if (currentChar == 0x6E) { 4444 if (currentChar == 0x6E) {
4445 builder.appendChar(0xA); 4445 builder.appendChar(0xA);
4446 } else if (currentChar == 0x72) { 4446 } else if (currentChar == 0x72) {
4447 builder.appendChar(0xD); 4447 builder.appendChar(0xD);
4448 } else if (currentChar == 0x66) { 4448 } else if (currentChar == 0x66) {
4449 builder.appendChar(0xC); 4449 builder.appendChar(0xC);
4450 } else if (currentChar == 0x62) { 4450 } else if (currentChar == 0x62) {
4451 builder.appendChar(0x8); 4451 builder.appendChar(0x8);
4452 } else if (currentChar == 0x74) { 4452 } else if (currentChar == 0x74) {
4453 builder.appendChar(0x9); 4453 builder.appendChar(0x9);
4454 } else if (currentChar == 0x76) { 4454 } else if (currentChar == 0x76) {
4455 builder.appendChar(0xB); 4455 builder.appendChar(0xB);
4456 } else if (currentChar == 0x78) { 4456 } else if (currentChar == 0x78) {
4457 if (currentIndex + 2 >= length8) { 4457 if (currentIndex + 2 >= length2) {
4458 reportError4(ParserErrorCode.INVALID_HEX_ESCAPE, []); 4458 reportError4(ParserErrorCode.INVALID_HEX_ESCAPE, []);
4459 return length8; 4459 return length2;
4460 } 4460 }
4461 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); 4461 int firstDigit = lexeme.codeUnitAt(currentIndex + 1);
4462 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); 4462 int secondDigit = lexeme.codeUnitAt(currentIndex + 2);
4463 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) { 4463 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) {
4464 reportError4(ParserErrorCode.INVALID_HEX_ESCAPE, []); 4464 reportError4(ParserErrorCode.INVALID_HEX_ESCAPE, []);
4465 } else { 4465 } else {
4466 builder.appendChar((((Character.digit(firstDigit, 16) << 4) + Character. digit(secondDigit, 16)) as int)); 4466 builder.appendChar((((Character.digit(firstDigit, 16) << 4) + Character. digit(secondDigit, 16)) as int));
4467 } 4467 }
4468 return currentIndex + 3; 4468 return currentIndex + 3;
4469 } else if (currentChar == 0x75) { 4469 } else if (currentChar == 0x75) {
4470 currentIndex++; 4470 currentIndex++;
4471 if (currentIndex >= length8) { 4471 if (currentIndex >= length2) {
4472 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4472 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4473 return length8; 4473 return length2;
4474 } 4474 }
4475 currentChar = lexeme.codeUnitAt(currentIndex); 4475 currentChar = lexeme.codeUnitAt(currentIndex);
4476 if (currentChar == 0x7B) { 4476 if (currentChar == 0x7B) {
4477 currentIndex++; 4477 currentIndex++;
4478 if (currentIndex >= length8) { 4478 if (currentIndex >= length2) {
4479 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4479 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4480 return length8; 4480 return length2;
4481 } 4481 }
4482 currentChar = lexeme.codeUnitAt(currentIndex); 4482 currentChar = lexeme.codeUnitAt(currentIndex);
4483 int digitCount = 0; 4483 int digitCount = 0;
4484 int value = 0; 4484 int value = 0;
4485 while (currentChar != 0x7D) { 4485 while (currentChar != 0x7D) {
4486 if (!isHexDigit(currentChar)) { 4486 if (!isHexDigit(currentChar)) {
4487 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4487 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4488 currentIndex++; 4488 currentIndex++;
4489 while (currentIndex < length8 && lexeme.codeUnitAt(currentIndex) != 0x7D) { 4489 while (currentIndex < length2 && lexeme.codeUnitAt(currentIndex) != 0x7D) {
4490 currentIndex++; 4490 currentIndex++;
4491 } 4491 }
4492 return currentIndex + 1; 4492 return currentIndex + 1;
4493 } 4493 }
4494 digitCount++; 4494 digitCount++;
4495 value = (value << 4) + Character.digit(currentChar, 16); 4495 value = (value << 4) + Character.digit(currentChar, 16);
4496 currentIndex++; 4496 currentIndex++;
4497 if (currentIndex >= length8) { 4497 if (currentIndex >= length2) {
4498 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4498 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4499 return length8; 4499 return length2;
4500 } 4500 }
4501 currentChar = lexeme.codeUnitAt(currentIndex); 4501 currentChar = lexeme.codeUnitAt(currentIndex);
4502 } 4502 }
4503 if (digitCount < 1 || digitCount > 6) { 4503 if (digitCount < 1 || digitCount > 6) {
4504 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4504 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4505 } 4505 }
4506 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va lue, index, currentIndex); 4506 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va lue, index, currentIndex);
4507 return currentIndex + 1; 4507 return currentIndex + 1;
4508 } else { 4508 } else {
4509 if (currentIndex + 3 >= length8) { 4509 if (currentIndex + 3 >= length2) {
4510 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4510 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4511 return length8; 4511 return length2;
4512 } 4512 }
4513 int firstDigit = currentChar; 4513 int firstDigit = currentChar;
4514 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); 4514 int secondDigit = lexeme.codeUnitAt(currentIndex + 1);
4515 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); 4515 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2);
4516 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); 4516 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3);
4517 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t hirdDigit) || !isHexDigit(fourthDigit)) { 4517 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t hirdDigit) || !isHexDigit(fourthDigit)) {
4518 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 4518 reportError4(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
4519 } else { 4519 } else {
4520 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); 4520 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);
4521 } 4521 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4570 } 4570 }
4571 if (modifiers.finalKeyword != null) { 4571 if (modifiers.finalKeyword != null) {
4572 reportError5(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, [] ); 4572 reportError5(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, [] );
4573 } 4573 }
4574 if (modifiers.staticKeyword != null) { 4574 if (modifiers.staticKeyword != null) {
4575 reportError5(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword, []); 4575 reportError5(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword, []);
4576 } 4576 }
4577 if (modifiers.varKeyword != null) { 4577 if (modifiers.varKeyword != null) {
4578 reportError5(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varKe yword, []); 4578 reportError5(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varKe yword, []);
4579 } 4579 }
4580 Token externalKeyword6 = modifiers.externalKeyword; 4580 Token externalKeyword2 = modifiers.externalKeyword;
4581 Token constKeyword4 = modifiers.constKeyword; 4581 Token constKeyword2 = modifiers.constKeyword;
4582 Token factoryKeyword4 = modifiers.factoryKeyword; 4582 Token factoryKeyword2 = modifiers.factoryKeyword;
4583 if (externalKeyword6 != null && constKeyword4 != null && constKeyword4.offse t < externalKeyword6.offset) { 4583 if (externalKeyword2 != null && constKeyword2 != null && constKeyword2.offse t < externalKeyword2.offset) {
4584 reportError5(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword6, []); 4584 reportError5(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword2, []);
4585 } 4585 }
4586 if (externalKeyword6 != null && factoryKeyword4 != null && factoryKeyword4.o ffset < externalKeyword6.offset) { 4586 if (externalKeyword2 != null && factoryKeyword2 != null && factoryKeyword2.o ffset < externalKeyword2.offset) {
4587 reportError5(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword6, []) ; 4587 reportError5(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword2, []) ;
4588 } 4588 }
4589 return constKeyword4; 4589 return constKeyword2;
4590 } 4590 }
4591 /** 4591 /**
4592 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final', 4592 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final',
4593 * 'const' or 'var' keyword if there is one. 4593 * 'const' or 'var' keyword if there is one.
4594 * @param modifiers the modifiers being validated 4594 * @param modifiers the modifiers being validated
4595 * @return the 'final', 'const' or 'var' keyword associated with the field 4595 * @return the 'final', 'const' or 'var' keyword associated with the field
4596 */ 4596 */
4597 Token validateModifiersForField(Modifiers modifiers) { 4597 Token validateModifiersForField(Modifiers modifiers) {
4598 if (modifiers.abstractKeyword != null) { 4598 if (modifiers.abstractKeyword != null) {
4599 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 4599 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
4600 } 4600 }
4601 if (modifiers.externalKeyword != null) { 4601 if (modifiers.externalKeyword != null) {
4602 reportError5(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] ); 4602 reportError5(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] );
4603 } 4603 }
4604 if (modifiers.factoryKeyword != null) { 4604 if (modifiers.factoryKeyword != null) {
4605 reportError5(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []); 4605 reportError5(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []);
4606 } 4606 }
4607 Token staticKeyword3 = modifiers.staticKeyword; 4607 Token staticKeyword2 = modifiers.staticKeyword;
4608 Token constKeyword5 = modifiers.constKeyword; 4608 Token constKeyword2 = modifiers.constKeyword;
4609 Token finalKeyword3 = modifiers.finalKeyword; 4609 Token finalKeyword2 = modifiers.finalKeyword;
4610 Token varKeyword3 = modifiers.varKeyword; 4610 Token varKeyword2 = modifiers.varKeyword;
4611 if (constKeyword5 != null) { 4611 if (constKeyword2 != null) {
4612 if (finalKeyword3 != null) { 4612 if (finalKeyword2 != null) {
4613 reportError5(ParserErrorCode.CONST_AND_FINAL, finalKeyword3, []); 4613 reportError5(ParserErrorCode.CONST_AND_FINAL, finalKeyword2, []);
4614 } 4614 }
4615 if (varKeyword3 != null) { 4615 if (varKeyword2 != null) {
4616 reportError5(ParserErrorCode.CONST_AND_VAR, varKeyword3, []); 4616 reportError5(ParserErrorCode.CONST_AND_VAR, varKeyword2, []);
4617 } 4617 }
4618 if (staticKeyword3 != null && constKeyword5.offset < staticKeyword3.offset ) { 4618 if (staticKeyword2 != null && constKeyword2.offset < staticKeyword2.offset ) {
4619 reportError5(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword3, []); 4619 reportError5(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword2, []);
4620 } 4620 }
4621 } else if (finalKeyword3 != null) { 4621 } else if (finalKeyword2 != null) {
4622 if (varKeyword3 != null) { 4622 if (varKeyword2 != null) {
4623 reportError5(ParserErrorCode.FINAL_AND_VAR, varKeyword3, []); 4623 reportError5(ParserErrorCode.FINAL_AND_VAR, varKeyword2, []);
4624 } 4624 }
4625 if (staticKeyword3 != null && finalKeyword3.offset < staticKeyword3.offset ) { 4625 if (staticKeyword2 != null && finalKeyword2.offset < staticKeyword2.offset ) {
4626 reportError5(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword3, []); 4626 reportError5(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword2, []);
4627 } 4627 }
4628 } else if (varKeyword3 != null && staticKeyword3 != null && varKeyword3.offs et < staticKeyword3.offset) { 4628 } else if (varKeyword2 != null && staticKeyword2 != null && varKeyword2.offs et < staticKeyword2.offset) {
4629 reportError5(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword3, []); 4629 reportError5(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword2, []);
4630 } 4630 }
4631 return lexicallyFirst([constKeyword5, finalKeyword3, varKeyword3]); 4631 return lexicallyFirst([constKeyword2, finalKeyword2, varKeyword2]);
4632 } 4632 }
4633 /** 4633 /**
4634 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 4634 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
4635 * @param modifiers the modifiers being validated 4635 * @param modifiers the modifiers being validated
4636 */ 4636 */
4637 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { 4637 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) {
4638 if (modifiers.abstractKeyword != null) { 4638 if (modifiers.abstractKeyword != null) {
4639 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 4639 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
4640 } 4640 }
4641 if (modifiers.constKeyword != null) { 4641 if (modifiers.constKeyword != null) {
4642 reportError5(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); 4642 reportError5(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []);
4643 } 4643 }
4644 if (modifiers.factoryKeyword != null) { 4644 if (modifiers.factoryKeyword != null) {
4645 reportError5(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []); 4645 reportError5(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKey word, []);
4646 } 4646 }
4647 if (modifiers.finalKeyword != null) { 4647 if (modifiers.finalKeyword != null) {
4648 reportError5(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); 4648 reportError5(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []);
4649 } 4649 }
4650 if (modifiers.varKeyword != null) { 4650 if (modifiers.varKeyword != null) {
4651 reportError5(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); 4651 reportError5(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []);
4652 } 4652 }
4653 Token externalKeyword7 = modifiers.externalKeyword; 4653 Token externalKeyword2 = modifiers.externalKeyword;
4654 Token staticKeyword4 = modifiers.staticKeyword; 4654 Token staticKeyword2 = modifiers.staticKeyword;
4655 if (externalKeyword7 != null && staticKeyword4 != null && staticKeyword4.off set < externalKeyword7.offset) { 4655 if (externalKeyword2 != null && staticKeyword2 != null && staticKeyword2.off set < externalKeyword2.offset) {
4656 reportError5(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword7, []); 4656 reportError5(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword2, []);
4657 } 4657 }
4658 } 4658 }
4659 /** 4659 /**
4660 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 4660 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
4661 * @param modifiers the modifiers being validated 4661 * @param modifiers the modifiers being validated
4662 */ 4662 */
4663 void validateModifiersForOperator(Modifiers modifiers) { 4663 void validateModifiersForOperator(Modifiers modifiers) {
4664 if (modifiers.abstractKeyword != null) { 4664 if (modifiers.abstractKeyword != null) {
4665 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 4665 reportError4(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
4666 } 4666 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4718 * @return the 'final', 'const' or 'var' keyword associated with the field 4718 * @return the 'final', 'const' or 'var' keyword associated with the field
4719 */ 4719 */
4720 Token validateModifiersForTopLevelVariable(Modifiers modifiers) { 4720 Token validateModifiersForTopLevelVariable(Modifiers modifiers) {
4721 validateModifiersForTopLevelDeclaration(modifiers); 4721 validateModifiersForTopLevelDeclaration(modifiers);
4722 if (modifiers.abstractKeyword != null) { 4722 if (modifiers.abstractKeyword != null) {
4723 reportError4(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []); 4723 reportError4(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []);
4724 } 4724 }
4725 if (modifiers.externalKeyword != null) { 4725 if (modifiers.externalKeyword != null) {
4726 reportError5(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] ); 4726 reportError5(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [] );
4727 } 4727 }
4728 Token constKeyword6 = modifiers.constKeyword; 4728 Token constKeyword2 = modifiers.constKeyword;
4729 Token finalKeyword4 = modifiers.finalKeyword; 4729 Token finalKeyword2 = modifiers.finalKeyword;
4730 Token varKeyword4 = modifiers.varKeyword; 4730 Token varKeyword2 = modifiers.varKeyword;
4731 if (constKeyword6 != null) { 4731 if (constKeyword2 != null) {
4732 if (finalKeyword4 != null) { 4732 if (finalKeyword2 != null) {
4733 reportError5(ParserErrorCode.CONST_AND_FINAL, finalKeyword4, []); 4733 reportError5(ParserErrorCode.CONST_AND_FINAL, finalKeyword2, []);
4734 } 4734 }
4735 if (varKeyword4 != null) { 4735 if (varKeyword2 != null) {
4736 reportError5(ParserErrorCode.CONST_AND_VAR, varKeyword4, []); 4736 reportError5(ParserErrorCode.CONST_AND_VAR, varKeyword2, []);
4737 } 4737 }
4738 } else if (finalKeyword4 != null) { 4738 } else if (finalKeyword2 != null) {
4739 if (varKeyword4 != null) { 4739 if (varKeyword2 != null) {
4740 reportError5(ParserErrorCode.FINAL_AND_VAR, varKeyword4, []); 4740 reportError5(ParserErrorCode.FINAL_AND_VAR, varKeyword2, []);
4741 } 4741 }
4742 } 4742 }
4743 return lexicallyFirst([constKeyword6, finalKeyword4, varKeyword4]); 4743 return lexicallyFirst([constKeyword2, finalKeyword2, varKeyword2]);
4744 } 4744 }
4745 /** 4745 /**
4746 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract' 4746 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract'
4747 * keyword if there is one. 4747 * keyword if there is one.
4748 * @param modifiers the modifiers being validated 4748 * @param modifiers the modifiers being validated
4749 */ 4749 */
4750 void validateModifiersForTypedef(Modifiers modifiers) { 4750 void validateModifiersForTypedef(Modifiers modifiers) {
4751 validateModifiersForTopLevelDeclaration(modifiers); 4751 validateModifiersForTopLevelDeclaration(modifiers);
4752 if (modifiers.abstractKeyword != null) { 4752 if (modifiers.abstractKeyword != null) {
4753 reportError5(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKeyword, []); 4753 reportError5(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKeyword, []);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
5102 nl2(); 5102 nl2();
5103 } 5103 }
5104 if (identical(token, node.endToken)) { 5104 if (identical(token, node.endToken)) {
5105 break; 5105 break;
5106 } 5106 }
5107 } 5107 }
5108 return null; 5108 return null;
5109 } 5109 }
5110 Object visitCommentReference(CommentReference node) => null; 5110 Object visitCommentReference(CommentReference node) => null;
5111 Object visitCompilationUnit(CompilationUnit node) { 5111 Object visitCompilationUnit(CompilationUnit node) {
5112 ScriptTag scriptTag7 = node.scriptTag; 5112 ScriptTag scriptTag2 = node.scriptTag;
5113 NodeList<Directive> directives5 = node.directives; 5113 NodeList<Directive> directives2 = node.directives;
5114 visit(scriptTag7); 5114 visit(scriptTag2);
5115 String prefix = scriptTag7 == null ? "" : " "; 5115 String prefix = scriptTag2 == null ? "" : " ";
5116 visitList7(prefix, directives5, "\n"); 5116 visitList7(prefix, directives2, "\n");
5117 prefix = scriptTag7 == null && directives5.isEmpty ? "" : "\n\n"; 5117 prefix = scriptTag2 == null && directives2.isEmpty ? "" : "\n\n";
5118 visitList7(prefix, node.declarations, "\n"); 5118 visitList7(prefix, node.declarations, "\n");
5119 return null; 5119 return null;
5120 } 5120 }
5121 Object visitConditionalExpression(ConditionalExpression node) { 5121 Object visitConditionalExpression(ConditionalExpression node) {
5122 visit(node.condition); 5122 visit(node.condition);
5123 _writer.print(" ? "); 5123 _writer.print(" ? ");
5124 visit(node.thenExpression); 5124 visit(node.thenExpression);
5125 _writer.print(" : "); 5125 _writer.print(" : ");
5126 visit(node.elseExpression); 5126 visit(node.elseExpression);
5127 return null; 5127 return null;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
5239 visit(node.loopVariable); 5239 visit(node.loopVariable);
5240 _writer.print(" in "); 5240 _writer.print(" in ");
5241 visit(node.iterator); 5241 visit(node.iterator);
5242 _writer.print(") "); 5242 _writer.print(") ");
5243 visit(node.body); 5243 visit(node.body);
5244 return null; 5244 return null;
5245 } 5245 }
5246 Object visitFormalParameterList(FormalParameterList node) { 5246 Object visitFormalParameterList(FormalParameterList node) {
5247 String groupEnd = null; 5247 String groupEnd = null;
5248 _writer.print('('); 5248 _writer.print('(');
5249 NodeList<FormalParameter> parameters16 = node.parameters; 5249 NodeList<FormalParameter> parameters2 = node.parameters;
5250 int size8 = parameters16.length; 5250 int size2 = parameters2.length;
5251 for (int i = 0; i < size8; i++) { 5251 for (int i = 0; i < size2; i++) {
5252 FormalParameter parameter = parameters16[i]; 5252 FormalParameter parameter = parameters2[i];
5253 if (i > 0) { 5253 if (i > 0) {
5254 _writer.print(", "); 5254 _writer.print(", ");
5255 } 5255 }
5256 if (groupEnd == null && parameter is DefaultFormalParameter) { 5256 if (groupEnd == null && parameter is DefaultFormalParameter) {
5257 if (identical(parameter.kind, ParameterKind.NAMED)) { 5257 if (identical(parameter.kind, ParameterKind.NAMED)) {
5258 groupEnd = "}"; 5258 groupEnd = "}";
5259 _writer.print('{'); 5259 _writer.print('{');
5260 } else { 5260 } else {
5261 groupEnd = "]"; 5261 groupEnd = "]";
5262 _writer.print('['); 5262 _writer.print('[');
5263 } 5263 }
5264 } 5264 }
5265 parameter.accept(this); 5265 parameter.accept(this);
5266 } 5266 }
5267 if (groupEnd != null) { 5267 if (groupEnd != null) {
5268 _writer.print(groupEnd); 5268 _writer.print(groupEnd);
5269 } 5269 }
5270 _writer.print(')'); 5270 _writer.print(')');
5271 return null; 5271 return null;
5272 } 5272 }
5273 Object visitForStatement(ForStatement node) { 5273 Object visitForStatement(ForStatement node) {
5274 Expression initialization4 = node.initialization; 5274 Expression initialization2 = node.initialization;
5275 _writer.print("for ("); 5275 _writer.print("for (");
5276 if (initialization4 != null) { 5276 if (initialization2 != null) {
5277 visit(initialization4); 5277 visit(initialization2);
5278 } else { 5278 } else {
5279 visit(node.variables); 5279 visit(node.variables);
5280 } 5280 }
5281 _writer.print(";"); 5281 _writer.print(";");
5282 visit7(" ", node.condition); 5282 visit7(" ", node.condition);
5283 _writer.print(";"); 5283 _writer.print(";");
5284 visitList7(" ", node.updaters, ", "); 5284 visitList7(" ", node.updaters, ", ");
5285 _writer.print(") "); 5285 _writer.print(") ");
5286 visit(node.body); 5286 visit(node.body);
5287 return null; 5287 return null;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
5534 _writer.print("this"); 5534 _writer.print("this");
5535 visit7(".", node.constructorName); 5535 visit7(".", node.constructorName);
5536 visit(node.argumentList); 5536 visit(node.argumentList);
5537 return null; 5537 return null;
5538 } 5538 }
5539 Object visitRethrowExpression(RethrowExpression node) { 5539 Object visitRethrowExpression(RethrowExpression node) {
5540 _writer.print("rethrow"); 5540 _writer.print("rethrow");
5541 return null; 5541 return null;
5542 } 5542 }
5543 Object visitReturnStatement(ReturnStatement node) { 5543 Object visitReturnStatement(ReturnStatement node) {
5544 Expression expression18 = node.expression; 5544 Expression expression2 = node.expression;
5545 if (expression18 == null) { 5545 if (expression2 == null) {
5546 _writer.print("return;"); 5546 _writer.print("return;");
5547 } else { 5547 } else {
5548 _writer.print("return "); 5548 _writer.print("return ");
5549 expression18.accept(this); 5549 expression2.accept(this);
5550 _writer.print(";"); 5550 _writer.print(";");
5551 } 5551 }
5552 return null; 5552 return null;
5553 } 5553 }
5554 Object visitScriptTag(ScriptTag node) { 5554 Object visitScriptTag(ScriptTag node) {
5555 _writer.print(node.scriptTag.lexeme); 5555 _writer.print(node.scriptTag.lexeme);
5556 return null; 5556 return null;
5557 } 5557 }
5558 Object visitShowCombinator(ShowCombinator node) { 5558 Object visitShowCombinator(ShowCombinator node) {
5559 _writer.print("show "); 5559 _writer.print("show ");
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
5762 void visitList(NodeList<ASTNode> nodes) { 5762 void visitList(NodeList<ASTNode> nodes) {
5763 visitList5(nodes, ""); 5763 visitList5(nodes, "");
5764 } 5764 }
5765 /** 5765 /**
5766 * Print a list of nodes, separated by the given separator. 5766 * Print a list of nodes, separated by the given separator.
5767 * @param nodes the nodes to be printed 5767 * @param nodes the nodes to be printed
5768 * @param separator the separator to be printed between adjacent nodes 5768 * @param separator the separator to be printed between adjacent nodes
5769 */ 5769 */
5770 void visitList5(NodeList<ASTNode> nodes, String separator) { 5770 void visitList5(NodeList<ASTNode> nodes, String separator) {
5771 if (nodes != null) { 5771 if (nodes != null) {
5772 int size9 = nodes.length; 5772 int size2 = nodes.length;
5773 for (int i = 0; i < size9; i++) { 5773 for (int i = 0; i < size2; i++) {
5774 if ("\n" == separator) { 5774 if ("\n" == separator) {
5775 _writer.print("\n"); 5775 _writer.print("\n");
5776 indent(); 5776 indent();
5777 } else if (i > 0) { 5777 } else if (i > 0) {
5778 _writer.print(separator); 5778 _writer.print(separator);
5779 } 5779 }
5780 nodes[i].accept(this); 5780 nodes[i].accept(this);
5781 } 5781 }
5782 } 5782 }
5783 } 5783 }
5784 /** 5784 /**
5785 * Print a list of nodes, separated by the given separator. 5785 * Print a list of nodes, separated by the given separator.
5786 * @param nodes the nodes to be printed 5786 * @param nodes the nodes to be printed
5787 * @param separator the separator to be printed between adjacent nodes 5787 * @param separator the separator to be printed between adjacent nodes
5788 * @param suffix the suffix to be printed if the list is not empty 5788 * @param suffix the suffix to be printed if the list is not empty
5789 */ 5789 */
5790 void visitList6(NodeList<ASTNode> nodes, String separator, String suffix) { 5790 void visitList6(NodeList<ASTNode> nodes, String separator, String suffix) {
5791 if (nodes != null) { 5791 if (nodes != null) {
5792 int size10 = nodes.length; 5792 int size2 = nodes.length;
5793 if (size10 > 0) { 5793 if (size2 > 0) {
5794 for (int i = 0; i < size10; i++) { 5794 for (int i = 0; i < size2; i++) {
5795 if (i > 0) { 5795 if (i > 0) {
5796 _writer.print(separator); 5796 _writer.print(separator);
5797 } 5797 }
5798 nodes[i].accept(this); 5798 nodes[i].accept(this);
5799 } 5799 }
5800 _writer.print(suffix); 5800 _writer.print(suffix);
5801 } 5801 }
5802 } 5802 }
5803 } 5803 }
5804 /** 5804 /**
5805 * Print a list of nodes, separated by the given separator. 5805 * Print a list of nodes, separated by the given separator.
5806 * @param prefix the prefix to be printed if the list is not empty 5806 * @param prefix the prefix to be printed if the list is not empty
5807 * @param nodes the nodes to be printed 5807 * @param nodes the nodes to be printed
5808 * @param separator the separator to be printed between adjacent nodes 5808 * @param separator the separator to be printed between adjacent nodes
5809 */ 5809 */
5810 void visitList7(String prefix, NodeList<ASTNode> nodes, String separator) { 5810 void visitList7(String prefix, NodeList<ASTNode> nodes, String separator) {
5811 if (nodes != null) { 5811 if (nodes != null) {
5812 int size11 = nodes.length; 5812 int size2 = nodes.length;
5813 if (size11 > 0) { 5813 if (size2 > 0) {
5814 _writer.print(prefix); 5814 _writer.print(prefix);
5815 for (int i = 0; i < size11; i++) { 5815 for (int i = 0; i < size2; i++) {
5816 if (i > 0) { 5816 if (i > 0) {
5817 _writer.print(separator); 5817 _writer.print(separator);
5818 } 5818 }
5819 nodes[i].accept(this); 5819 nodes[i].accept(this);
5820 } 5820 }
5821 } 5821 }
5822 } 5822 }
5823 } 5823 }
5824 } 5824 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698