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

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

Issue 12803014: New Analysis Engine translation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 'error.dart'; 9 import 'error.dart';
10 import 'source.dart'; 10 import 'source.dart';
11 import 'scanner.dart'; 11 import 'scanner.dart';
12 import 'ast.dart'; 12 import 'ast.dart';
13 import 'package:analyzer_experimental/src/generated/utilities_dart.dart'; 13 import 'utilities_dart.dart';
14 14
15 /** 15 /**
16 * Instances of the class {@code CommentAndMetadata} implement a simple data-hol der for a method 16 * Instances of the class {@code CommentAndMetadata} implement a simple data-hol der for a method
17 * that needs to return multiple values. 17 * that needs to return multiple values.
18 * @coverage dart.engine.parser 18 * @coverage dart.engine.parser
19 */ 19 */
20 class CommentAndMetadata { 20 class CommentAndMetadata {
21 /** 21 /**
22 * The documentation comment that was parsed, or {@code null} if none was give n. 22 * The documentation comment that was parsed, or {@code null} if none was give n.
23 */ 23 */
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 /** 547 /**
548 * Return {@code true} if the current token appears to be the beginning of a s witch member. 548 * Return {@code true} if the current token appears to be the beginning of a s witch member.
549 * @return {@code true} if the current token appears to be the beginning of a switch member 549 * @return {@code true} if the current token appears to be the beginning of a switch member
550 */ 550 */
551 bool isSwitchMember() { 551 bool isSwitchMember() {
552 Token token = _currentToken; 552 Token token = _currentToken;
553 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy pe.COLON)) { 553 while (matches4(token, TokenType.IDENTIFIER) && matches4(token.next, TokenTy pe.COLON)) {
554 token = token.next.next; 554 token = token.next.next;
555 } 555 }
556 if (identical(token.type, TokenType.KEYWORD)) { 556 if (identical(token.type, TokenType.KEYWORD)) {
557 Keyword keyword29 = ((token as KeywordToken)).keyword; 557 Keyword keyword30 = ((token as KeywordToken)).keyword;
558 return identical(keyword29, Keyword.CASE) || identical(keyword29, Keyword. DEFAULT); 558 return identical(keyword30, Keyword.CASE) || identical(keyword30, Keyword. DEFAULT);
559 } 559 }
560 return false; 560 return false;
561 } 561 }
562 /** 562 /**
563 * Compare the given tokens to find the token that appears first in the source being parsed. That 563 * Compare the given tokens to find the token that appears first in the source being parsed. That
564 * is, return the left-most of all of the tokens. The arguments are allowed to be {@code null}. 564 * is, return the left-most of all of the tokens. The arguments are allowed to be {@code null}.
565 * Return the token with the smallest offset, or {@code null} if there are no arguments or if all 565 * Return the token with the smallest offset, or {@code null} if there are no arguments or if all
566 * of the arguments are {@code null}. 566 * of the arguments are {@code null}.
567 * @param tokens the tokens being compared 567 * @param tokens the tokens being compared
568 * @return the token with the smallest offset 568 * @return the token with the smallest offset
(...skipping 22 matching lines...) Expand all
591 * @param identifier the identifier that can optionally appear in the current location 591 * @param identifier the identifier that can optionally appear in the current location
592 * @return {@code true} if the current token matches the given identifier 592 * @return {@code true} if the current token matches the given identifier
593 */ 593 */
594 bool matches2(String identifier) => identical(_currentToken.type, TokenType.ID ENTIFIER) && _currentToken.lexeme == identifier; 594 bool matches2(String identifier) => identical(_currentToken.type, TokenType.ID ENTIFIER) && _currentToken.lexeme == identifier;
595 /** 595 /**
596 * Return {@code true} if the given token matches the given keyword. 596 * Return {@code true} if the given token matches the given keyword.
597 * @param token the token being tested 597 * @param token the token being tested
598 * @param keyword the keyword that is being tested for 598 * @param keyword the keyword that is being tested for
599 * @return {@code true} if the given token matches the given keyword 599 * @return {@code true} if the given token matches the given keyword
600 */ 600 */
601 bool matches3(Token token, Keyword keyword37) => identical(token.type, TokenTy pe.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword37); 601 bool matches3(Token token, Keyword keyword38) => identical(token.type, TokenTy pe.KEYWORD) && identical(((token as KeywordToken)).keyword, keyword38);
602 /** 602 /**
603 * Return {@code true} if the given token has the given type. 603 * Return {@code true} if the given token has the given type.
604 * @param token the token being tested 604 * @param token the token being tested
605 * @param type the type of token that is being tested for 605 * @param type the type of token that is being tested for
606 * @return {@code true} if the given token has the given type 606 * @return {@code true} if the given token has the given type
607 */ 607 */
608 bool matches4(Token token, TokenType type31) => identical(token.type, type31); 608 bool matches4(Token token, TokenType type31) => identical(token.type, type31);
609 /** 609 /**
610 * Return {@code true} if the current token has the given type. Note that this method, unlike 610 * Return {@code true} if the current token has the given type. Note that this method, unlike
611 * other variants, will modify the token stream if possible to match a wider r ange of tokens. In 611 * other variants, will modify the token stream if possible to match a wider r ange of tokens. In
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 * comment 1344 * comment
1345 * @param sourceOffset the offset of the first character of the reference sour ce 1345 * @param sourceOffset the offset of the first character of the reference sour ce
1346 * @return the comment reference that was parsed 1346 * @return the comment reference that was parsed
1347 */ 1347 */
1348 CommentReference parseCommentReference(String referenceSource, int sourceOffse t) { 1348 CommentReference parseCommentReference(String referenceSource, int sourceOffse t) {
1349 if (referenceSource.length == 0) { 1349 if (referenceSource.length == 0) {
1350 return null; 1350 return null;
1351 } 1351 }
1352 try { 1352 try {
1353 List<bool> errorFound = [false]; 1353 List<bool> errorFound = [false];
1354 AnalysisErrorListener listener = new AnalysisErrorListener_7(errorFound); 1354 AnalysisErrorListener listener = new AnalysisErrorListener_8(errorFound);
1355 StringScanner scanner = new StringScanner(null, referenceSource, listener) ; 1355 StringScanner scanner = new StringScanner(null, referenceSource, listener) ;
1356 scanner.setSourceStart(1, 1, sourceOffset); 1356 scanner.setSourceStart(1, 1, sourceOffset);
1357 Token firstToken = scanner.tokenize(); 1357 Token firstToken = scanner.tokenize();
1358 if (!errorFound[0]) { 1358 if (!errorFound[0]) {
1359 Token newKeyword = null; 1359 Token newKeyword = null;
1360 if (matches3(firstToken, Keyword.NEW)) { 1360 if (matches3(firstToken, Keyword.NEW)) {
1361 newKeyword = firstToken; 1361 newKeyword = firstToken;
1362 firstToken = firstToken.next; 1362 firstToken = firstToken.next;
1363 } 1363 }
1364 if (matchesIdentifier2(firstToken)) { 1364 if (matchesIdentifier2(firstToken)) {
(...skipping 10 matching lines...) Expand all
1375 } 1375 }
1376 if (nextToken.type != TokenType.EOF) { 1376 if (nextToken.type != TokenType.EOF) {
1377 } 1377 }
1378 return new CommentReference.full(newKeyword, identifier); 1378 return new CommentReference.full(newKeyword, identifier);
1379 } else if (matches3(firstToken, Keyword.THIS) || matches3(firstToken, Ke yword.NULL) || matches3(firstToken, Keyword.TRUE) || matches3(firstToken, Keywor d.FALSE)) { 1379 } else if (matches3(firstToken, Keyword.THIS) || matches3(firstToken, Ke yword.NULL) || matches3(firstToken, Keyword.TRUE) || matches3(firstToken, Keywor d.FALSE)) {
1380 return null; 1380 return null;
1381 } else if (matches4(firstToken, TokenType.STRING)) { 1381 } else if (matches4(firstToken, TokenType.STRING)) {
1382 } else { 1382 } else {
1383 } 1383 }
1384 } 1384 }
1385 } on JavaException catch (exception) { 1385 } catch (exception) {
1386 } 1386 }
1387 return null; 1387 return null;
1388 } 1388 }
1389 /** 1389 /**
1390 * Parse all of the comment references occurring in the given array of documen tation comments. 1390 * Parse all of the comment references occurring in the given array of documen tation comments.
1391 * <pre> 1391 * <pre>
1392 * commentReference ::= 1392 * commentReference ::=
1393 * '[' 'new'? qualified ']' libraryReference? 1393 * '[' 'new'? qualified ']' libraryReference?
1394 * libraryReference ::= 1394 * libraryReference ::=
1395 * '(' stringLiteral ')' 1395 * '(' stringLiteral ')'
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, null); 1541 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, null);
1542 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) { 1542 } else if (matches(Keyword.OPERATOR) && peek().isOperator()) {
1543 return null; 1543 return null;
1544 } else if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN , TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { 1544 } else if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN , TokenType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) {
1545 validateModifiersForTopLevelFunction(modifiers); 1545 validateModifiersForTopLevelFunction(modifiers);
1546 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, null); 1546 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, null);
1547 } else { 1547 } else {
1548 if (matchesIdentifier()) { 1548 if (matchesIdentifier()) {
1549 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC OLON])) { 1549 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC OLON])) {
1550 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); 1550 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []);
1551 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme nt, commentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiers ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); 1551 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme nt, commentAndMetadata.metadata, parseVariableDeclarationList2(null, validateMod ifiersForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON));
1552 } 1552 }
1553 } 1553 }
1554 return null; 1554 return null;
1555 } 1555 }
1556 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi er2(peek())) { 1556 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi er2(peek())) {
1557 validateModifiersForTopLevelFunction(modifiers); 1557 validateModifiersForTopLevelFunction(modifiers);
1558 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null); 1558 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null);
1559 } else if (matches(Keyword.OPERATOR) && peek().isOperator() && matches4(peek 2(2), TokenType.OPEN_PAREN)) { 1559 } else if (matches(Keyword.OPERATOR) && peek().isOperator() && matches4(peek 2(2), TokenType.OPEN_PAREN)) {
1560 return null; 1560 return null;
1561 } else if (!matchesIdentifier()) { 1561 } else if (!matchesIdentifier()) {
1562 return null; 1562 return null;
1563 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { 1563 } else if (matches4(peek(), TokenType.OPEN_PAREN)) {
1564 validateModifiersForTopLevelFunction(modifiers); 1564 validateModifiersForTopLevelFunction(modifiers);
1565 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null); 1565 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null);
1566 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) { 1566 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) {
1567 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTop LevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); 1567 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiers ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON));
1568 } 1568 }
1569 TypeName returnType = parseReturnType(); 1569 TypeName returnType = parseReturnType();
1570 if (matches(Keyword.GET) || matches(Keyword.SET)) { 1570 if (matches(Keyword.GET) || matches(Keyword.SET)) {
1571 validateModifiersForTopLevelFunction(modifiers); 1571 validateModifiersForTopLevelFunction(modifiers);
1572 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, returnType); 1572 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, returnType);
1573 } else if (!matchesIdentifier()) { 1573 } else if (!matchesIdentifier()) {
1574 return null; 1574 return null;
1575 } 1575 }
1576 if (matchesAny(peek(), [TokenType.OPEN_PAREN, TokenType.FUNCTION, TokenType. OPEN_CURLY_BRACKET])) { 1576 if (matchesAny(peek(), [TokenType.OPEN_PAREN, TokenType.FUNCTION, TokenType. OPEN_CURLY_BRACKET])) {
1577 validateModifiersForTopLevelFunction(modifiers); 1577 validateModifiersForTopLevelFunction(modifiers);
1578 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, returnType); 1578 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, returnType);
1579 } 1579 }
1580 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, comm entAndMetadata.metadata, parseVariableDeclarationList2(validateModifiersForTopLe velVariable(modifiers), returnType), expect2(TokenType.SEMICOLON)); 1580 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, comm entAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiersFo rTopLevelVariable(modifiers), returnType), expect2(TokenType.SEMICOLON));
1581 } 1581 }
1582 /** 1582 /**
1583 * Parse a conditional expression. 1583 * Parse a conditional expression.
1584 * <pre> 1584 * <pre>
1585 * conditionalExpression ::= 1585 * conditionalExpression ::=
1586 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithoutCasc ade)? 1586 * logicalOrExpression ('?' expressionWithoutCascade ':' expressionWithoutCasc ade)?
1587 * </pre> 1587 * </pre>
1588 * @return the conditional expression that was parsed 1588 * @return the conditional expression that was parsed
1589 */ 1589 */
1590 Expression parseConditionalExpression() { 1590 Expression parseConditionalExpression() {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 if (matchesIdentifier()) { 1725 if (matchesIdentifier()) {
1726 label = parseSimpleIdentifier(); 1726 label = parseSimpleIdentifier();
1727 } 1727 }
1728 if (_inSwitch && !_inLoop && label == null) { 1728 if (_inSwitch && !_inLoop && label == null) {
1729 reportError5(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, continueKeywo rd, []); 1729 reportError5(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, continueKeywo rd, []);
1730 } 1730 }
1731 Token semicolon = expect2(TokenType.SEMICOLON); 1731 Token semicolon = expect2(TokenType.SEMICOLON);
1732 return new ContinueStatement.full(continueKeyword, label, semicolon); 1732 return new ContinueStatement.full(continueKeyword, label, semicolon);
1733 } 1733 }
1734 /** 1734 /**
1735 * Parse a declared identifier declaration.
1736 * @param commentAndMetadata the metadata to be associated with the directive
1737 * @return the declared identifier that was parsed
1738 */
1739 DeclaredIdentifier parseDeclaredIdentifier(CommentAndMetadata commentAndMetada ta) {
1740 FinalConstVarOrType finalConstVarOrType = parseFinalConstVarOrType(false);
1741 SimpleIdentifier identifier = parseSimpleIdentifier();
1742 return new DeclaredIdentifier.full(commentAndMetadata.comment, commentAndMet adata.metadata, finalConstVarOrType.keyword, finalConstVarOrType.type, identifie r);
1743 }
1744 /**
1745 * Parse a directive. 1735 * Parse a directive.
1746 * <pre> 1736 * <pre>
1747 * directive ::= 1737 * directive ::=
1748 * exportDirective 1738 * exportDirective
1749 * | libraryDirective 1739 * | libraryDirective
1750 * | importDirective 1740 * | importDirective
1751 * | partDirective 1741 * | partDirective
1752 * </pre> 1742 * </pre>
1753 * @param commentAndMetadata the metadata to be associated with the directive 1743 * @param commentAndMetadata the metadata to be associated with the directive
1754 * @return the directive that was parsed 1744 * @return the directive that was parsed
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 * expression ::= 1868 * expression ::=
1879 * assignableExpression assignmentOperator expression 1869 * assignableExpression assignmentOperator expression
1880 * | conditionalExpression cascadeSection 1870 * | conditionalExpression cascadeSection
1881 * | throwExpression 1871 * | throwExpression
1882 * </pre> 1872 * </pre>
1883 * @return the expression that was parsed 1873 * @return the expression that was parsed
1884 */ 1874 */
1885 Expression parseExpression2() { 1875 Expression parseExpression2() {
1886 if (matches(Keyword.THROW)) { 1876 if (matches(Keyword.THROW)) {
1887 return parseThrowExpression(); 1877 return parseThrowExpression();
1878 } else if (matches(Keyword.RETHROW)) {
1879 return parseRethrowExpression();
1888 } 1880 }
1889 Expression expression = parseConditionalExpression(); 1881 Expression expression = parseConditionalExpression();
1890 TokenType tokenType = _currentToken.type; 1882 TokenType tokenType = _currentToken.type;
1891 if (identical(tokenType, TokenType.PERIOD_PERIOD)) { 1883 if (identical(tokenType, TokenType.PERIOD_PERIOD)) {
1892 List<Expression> cascadeSections = new List<Expression>(); 1884 List<Expression> cascadeSections = new List<Expression>();
1893 while (identical(tokenType, TokenType.PERIOD_PERIOD)) { 1885 while (identical(tokenType, TokenType.PERIOD_PERIOD)) {
1894 Expression section = parseCascadeSection(); 1886 Expression section = parseCascadeSection();
1895 if (section != null) { 1887 if (section != null) {
1896 cascadeSections.add(section); 1888 cascadeSections.add(section);
1897 } 1889 }
(...skipping 29 matching lines...) Expand all
1927 * expressionWithoutCascade ::= 1919 * expressionWithoutCascade ::=
1928 * assignableExpression assignmentOperator expressionWithoutCascade 1920 * assignableExpression assignmentOperator expressionWithoutCascade
1929 * | conditionalExpression 1921 * | conditionalExpression
1930 * | throwExpressionWithoutCascade 1922 * | throwExpressionWithoutCascade
1931 * </pre> 1923 * </pre>
1932 * @return the expression that was parsed 1924 * @return the expression that was parsed
1933 */ 1925 */
1934 Expression parseExpressionWithoutCascade() { 1926 Expression parseExpressionWithoutCascade() {
1935 if (matches(Keyword.THROW)) { 1927 if (matches(Keyword.THROW)) {
1936 return parseThrowExpressionWithoutCascade(); 1928 return parseThrowExpressionWithoutCascade();
1929 } else if (matches(Keyword.RETHROW)) {
1930 return parseRethrowExpression();
1937 } 1931 }
1938 Expression expression = parseConditionalExpression(); 1932 Expression expression = parseConditionalExpression();
1939 if (_currentToken.type.isAssignmentOperator()) { 1933 if (_currentToken.type.isAssignmentOperator()) {
1940 Token operator = andAdvance; 1934 Token operator = andAdvance;
1941 ensureAssignable(expression); 1935 ensureAssignable(expression);
1942 expression = new AssignmentExpression.full(expression, operator, parseExpr essionWithoutCascade()); 1936 expression = new AssignmentExpression.full(expression, operator, parseExpr essionWithoutCascade());
1943 } 1937 }
1944 return expression; 1938 return expression;
1945 } 1939 }
1946 /** 1940 /**
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2173 Token forKeyword = expect(Keyword.FOR); 2167 Token forKeyword = expect(Keyword.FOR);
2174 Token leftParenthesis = expect2(TokenType.OPEN_PAREN); 2168 Token leftParenthesis = expect2(TokenType.OPEN_PAREN);
2175 VariableDeclarationList variableList = null; 2169 VariableDeclarationList variableList = null;
2176 Expression initialization = null; 2170 Expression initialization = null;
2177 if (!matches5(TokenType.SEMICOLON)) { 2171 if (!matches5(TokenType.SEMICOLON)) {
2178 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 2172 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
2179 if (matchesIdentifier() && matches3(peek(), Keyword.IN)) { 2173 if (matchesIdentifier() && matches3(peek(), Keyword.IN)) {
2180 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 2174 List<VariableDeclaration> variables = new List<VariableDeclaration>();
2181 SimpleIdentifier variableName = parseSimpleIdentifier(); 2175 SimpleIdentifier variableName = parseSimpleIdentifier();
2182 variables.add(new VariableDeclaration.full(null, null, variableName, n ull, null)); 2176 variables.add(new VariableDeclaration.full(null, null, variableName, n ull, null));
2183 variableList = new VariableDeclarationList.full(null, null, variables) ; 2177 variableList = new VariableDeclarationList.full(commentAndMetadata.com ment, commentAndMetadata.metadata, null, null, variables);
2184 } else if (isInitializedVariableDeclaration()) { 2178 } else if (isInitializedVariableDeclaration()) {
2185 variableList = parseVariableDeclarationList(); 2179 variableList = parseVariableDeclarationList(commentAndMetadata);
2186 } else { 2180 } else {
2187 initialization = parseExpression2(); 2181 initialization = parseExpression2();
2188 } 2182 }
2189 if (matches(Keyword.IN)) { 2183 if (matches(Keyword.IN)) {
2190 DeclaredIdentifier loopVariable = null; 2184 DeclaredIdentifier loopVariable = null;
2191 if (variableList == null) { 2185 if (variableList == null) {
2192 reportError4(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); 2186 reportError4(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []);
2193 } else { 2187 } else {
2194 NodeList<VariableDeclaration> variables3 = variableList.variables; 2188 NodeList<VariableDeclaration> variables3 = variableList.variables;
2195 if (variables3.length > 1) { 2189 if (variables3.length > 1) {
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 * </pre> 2503 * </pre>
2510 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 2504 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
2511 * declaration 2505 * declaration
2512 * @param staticKeyword the static keyword, or {@code null} if the getter is n ot static 2506 * @param staticKeyword the static keyword, or {@code null} if the getter is n ot static
2513 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or {@code null} if 2507 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or {@code null} if
2514 * there is no keyword 2508 * there is no keyword
2515 * @param type the type that has already been parsed, or {@code null} if 'var' was provided 2509 * @param type the type that has already been parsed, or {@code null} if 'var' was provided
2516 * @return the getter that was parsed 2510 * @return the getter that was parsed
2517 */ 2511 */
2518 FieldDeclaration parseInitializedIdentifierList(CommentAndMetadata commentAndM etadata, Token staticKeyword, Token keyword, TypeName type) { 2512 FieldDeclaration parseInitializedIdentifierList(CommentAndMetadata commentAndM etadata, Token staticKeyword, Token keyword, TypeName type) {
2519 VariableDeclarationList fieldList = parseVariableDeclarationList2(keyword, t ype); 2513 VariableDeclarationList fieldList = parseVariableDeclarationList2(null, keyw ord, type);
2520 return new FieldDeclaration.full(commentAndMetadata.comment, commentAndMetad ata.metadata, staticKeyword, fieldList, expect2(TokenType.SEMICOLON)); 2514 return new FieldDeclaration.full(commentAndMetadata.comment, commentAndMetad ata.metadata, staticKeyword, fieldList, expect2(TokenType.SEMICOLON));
2521 } 2515 }
2522 /** 2516 /**
2523 * Parse an instance creation expression. 2517 * Parse an instance creation expression.
2524 * <pre> 2518 * <pre>
2525 * instanceCreationExpression ::= 2519 * instanceCreationExpression ::=
2526 * ('new' | 'const') type ('.' identifier)? argumentList 2520 * ('new' | 'const') type ('.' identifier)? argumentList
2527 * </pre> 2521 * </pre>
2528 * @param keyword the 'new' or 'const' keyword that introduces the expression 2522 * @param keyword the 'new' or 'const' keyword that introduces the expression
2529 * @return the instance creation expression that was parsed 2523 * @return the instance creation expression that was parsed
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2900 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 2894 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
2901 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 2895 if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
2902 if (matches4(peek(), TokenType.STRING)) { 2896 if (matches4(peek(), TokenType.STRING)) {
2903 Token afterString = skipStringLiteral(_currentToken.next); 2897 Token afterString = skipStringLiteral(_currentToken.next);
2904 if (afterString != null && identical(afterString.type, TokenType.COLON)) { 2898 if (afterString != null && identical(afterString.type, TokenType.COLON)) {
2905 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON)); 2899 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON));
2906 } 2900 }
2907 } 2901 }
2908 return parseBlock(); 2902 return parseBlock();
2909 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken)) .keyword.isPseudoKeyword()) { 2903 } else if (matches5(TokenType.KEYWORD) && !((_currentToken as KeywordToken)) .keyword.isPseudoKeyword()) {
2910 Keyword keyword30 = ((_currentToken as KeywordToken)).keyword; 2904 Keyword keyword31 = ((_currentToken as KeywordToken)).keyword;
2911 if (identical(keyword30, Keyword.ASSERT)) { 2905 if (identical(keyword31, Keyword.ASSERT)) {
2912 return parseAssertStatement(); 2906 return parseAssertStatement();
2913 } else if (identical(keyword30, Keyword.BREAK)) { 2907 } else if (identical(keyword31, Keyword.BREAK)) {
2914 return parseBreakStatement(); 2908 return parseBreakStatement();
2915 } else if (identical(keyword30, Keyword.CONTINUE)) { 2909 } else if (identical(keyword31, Keyword.CONTINUE)) {
2916 return parseContinueStatement(); 2910 return parseContinueStatement();
2917 } else if (identical(keyword30, Keyword.DO)) { 2911 } else if (identical(keyword31, Keyword.DO)) {
2918 return parseDoStatement(); 2912 return parseDoStatement();
2919 } else if (identical(keyword30, Keyword.FOR)) { 2913 } else if (identical(keyword31, Keyword.FOR)) {
2920 return parseForStatement(); 2914 return parseForStatement();
2921 } else if (identical(keyword30, Keyword.IF)) { 2915 } else if (identical(keyword31, Keyword.IF)) {
2922 return parseIfStatement(); 2916 return parseIfStatement();
2923 } else if (identical(keyword30, Keyword.RETURN)) { 2917 } else if (identical(keyword31, Keyword.RETHROW)) {
2918 return new ExpressionStatement.full(parseRethrowExpression(), expect2(To kenType.SEMICOLON));
2919 } else if (identical(keyword31, Keyword.RETURN)) {
2924 return parseReturnStatement(); 2920 return parseReturnStatement();
2925 } else if (identical(keyword30, Keyword.SWITCH)) { 2921 } else if (identical(keyword31, Keyword.SWITCH)) {
2926 return parseSwitchStatement(); 2922 return parseSwitchStatement();
2927 } else if (identical(keyword30, Keyword.THROW)) { 2923 } else if (identical(keyword31, Keyword.THROW)) {
2928 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke nType.SEMICOLON)); 2924 return new ExpressionStatement.full(parseThrowExpression(), expect2(Toke nType.SEMICOLON));
2929 } else if (identical(keyword30, Keyword.TRY)) { 2925 } else if (identical(keyword31, Keyword.TRY)) {
2930 return parseTryStatement(); 2926 return parseTryStatement();
2931 } else if (identical(keyword30, Keyword.WHILE)) { 2927 } else if (identical(keyword31, Keyword.WHILE)) {
2932 return parseWhileStatement(); 2928 return parseWhileStatement();
2933 } else if (identical(keyword30, Keyword.VAR) || identical(keyword30, Keywo rd.FINAL)) { 2929 } else if (identical(keyword31, Keyword.VAR) || identical(keyword31, Keywo rd.FINAL)) {
2934 return parseVariableDeclarationStatement(); 2930 return parseVariableDeclarationStatement(commentAndMetadata);
2935 } else if (identical(keyword30, Keyword.VOID)) { 2931 } else if (identical(keyword31, Keyword.VOID)) {
2936 TypeName returnType = parseReturnType(); 2932 TypeName returnType = parseReturnType();
2937 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) { 2933 if (matchesIdentifier() && matchesAny(peek(), [TokenType.OPEN_PAREN, Tok enType.OPEN_CURLY_BRACKET, TokenType.FUNCTION])) {
2938 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe); 2934 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe);
2939 } else { 2935 } else {
2940 if (matchesIdentifier()) { 2936 if (matchesIdentifier()) {
2941 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) { 2937 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) {
2942 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); 2938 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []);
2943 return parseVariableDeclarationStatement(); 2939 return parseVariableDeclarationStatement(commentAndMetadata);
2944 } 2940 }
2945 } 2941 }
2946 return null; 2942 return null;
2947 } 2943 }
2948 } else if (identical(keyword30, Keyword.CONST)) { 2944 } else if (identical(keyword31, Keyword.CONST)) {
2949 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) { 2945 if (matchesAny(peek(), [TokenType.LT, TokenType.OPEN_CURLY_BRACKET, Toke nType.OPEN_SQUARE_BRACKET, TokenType.INDEX])) {
2950 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON)); 2946 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON));
2951 } else if (matches4(peek(), TokenType.IDENTIFIER)) { 2947 } else if (matches4(peek(), TokenType.IDENTIFIER)) {
2952 Token afterType = skipTypeName(peek()); 2948 Token afterType = skipTypeName(peek());
2953 if (afterType != null) { 2949 if (afterType != null) {
2954 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) { 2950 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) {
2955 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON)); 2951 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON));
2956 } 2952 }
2957 } 2953 }
2958 } 2954 }
2959 return parseVariableDeclarationStatement(); 2955 return parseVariableDeclarationStatement(commentAndMetadata);
2960 } else if (identical(keyword30, Keyword.NEW) || identical(keyword30, Keywo rd.TRUE) || identical(keyword30, Keyword.FALSE) || identical(keyword30, Keyword. NULL) || identical(keyword30, Keyword.SUPER) || identical(keyword30, Keyword.THI S)) { 2956 } 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)) {
2961 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON)); 2957 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON));
2962 } else { 2958 } else {
2963 return null; 2959 return null;
2964 } 2960 }
2965 } else if (matches5(TokenType.SEMICOLON)) { 2961 } else if (matches5(TokenType.SEMICOLON)) {
2966 return parseEmptyStatement(); 2962 return parseEmptyStatement();
2967 } else if (isInitializedVariableDeclaration()) { 2963 } else if (isInitializedVariableDeclaration()) {
2968 return parseVariableDeclarationStatement(); 2964 return parseVariableDeclarationStatement(commentAndMetadata);
2969 } else if (isFunctionDeclaration()) { 2965 } else if (isFunctionDeclaration()) {
2970 return parseFunctionDeclarationStatement(); 2966 return parseFunctionDeclarationStatement();
2971 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 2967 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
2972 reportError4(ParserErrorCode.MISSING_STATEMENT, []); 2968 reportError4(ParserErrorCode.MISSING_STATEMENT, []);
2973 return new EmptyStatement.full(createSyntheticToken(TokenType.SEMICOLON)); 2969 return new EmptyStatement.full(createSyntheticToken(TokenType.SEMICOLON));
2974 } else { 2970 } else {
2975 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType. SEMICOLON)); 2971 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType. SEMICOLON));
2976 } 2972 }
2977 } 2973 }
2978 /** 2974 /**
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 notOperator = andAdvance; 3271 notOperator = andAdvance;
3276 } 3272 }
3277 expression = new IsExpression.full(expression, isOperator, notOperator, pa rseTypeName()); 3273 expression = new IsExpression.full(expression, isOperator, notOperator, pa rseTypeName());
3278 } else if (_currentToken.type.isRelationalOperator()) { 3274 } else if (_currentToken.type.isRelationalOperator()) {
3279 Token operator = andAdvance; 3275 Token operator = andAdvance;
3280 expression = new BinaryExpression.full(expression, operator, parseShiftExp ression()); 3276 expression = new BinaryExpression.full(expression, operator, parseShiftExp ression());
3281 } 3277 }
3282 return expression; 3278 return expression;
3283 } 3279 }
3284 /** 3280 /**
3281 * Parse a rethrow expression.
3282 * <pre>
3283 * rethrowExpression ::=
3284 * 'rethrow'
3285 * </pre>
3286 * @return the rethrow expression that was parsed
3287 */
3288 Expression parseRethrowExpression() => new RethrowExpression.full(expect(Keywo rd.RETHROW));
3289 /**
3285 * Parse a return statement. 3290 * Parse a return statement.
3286 * <pre> 3291 * <pre>
3287 * returnStatement ::= 3292 * returnStatement ::=
3288 * 'return' expression? ';' 3293 * 'return' expression? ';'
3289 * </pre> 3294 * </pre>
3290 * @return the return statement that was parsed 3295 * @return the return statement that was parsed
3291 */ 3296 */
3292 Statement parseReturnStatement() { 3297 Statement parseReturnStatement() {
3293 Token returnKeyword = expect(Keyword.RETURN); 3298 Token returnKeyword = expect(Keyword.RETURN);
3294 if (matches5(TokenType.SEMICOLON)) { 3299 if (matches5(TokenType.SEMICOLON)) {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
3552 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); 3557 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET);
3553 return new SwitchStatement.full(keyword, leftParenthesis, expression, righ tParenthesis, leftBracket, members, rightBracket); 3558 return new SwitchStatement.full(keyword, leftParenthesis, expression, righ tParenthesis, leftBracket, members, rightBracket);
3554 } finally { 3559 } finally {
3555 _inSwitch = wasInSwitch; 3560 _inSwitch = wasInSwitch;
3556 } 3561 }
3557 } 3562 }
3558 /** 3563 /**
3559 * Parse a throw expression. 3564 * Parse a throw expression.
3560 * <pre> 3565 * <pre>
3561 * throwExpression ::= 3566 * throwExpression ::=
3562 * 'throw' expression? ';' 3567 * 'throw' expression
3563 * </pre> 3568 * </pre>
3564 * @return the throw expression that was parsed 3569 * @return the throw expression that was parsed
3565 */ 3570 */
3566 Expression parseThrowExpression() { 3571 Expression parseThrowExpression() {
3567 Token keyword = expect(Keyword.THROW); 3572 Token keyword = expect(Keyword.THROW);
3568 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) { 3573 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) {
3569 return new ThrowExpression.full(keyword, null); 3574 return new ThrowExpression.full(keyword, null);
3570 } 3575 }
3571 Expression expression = parseExpression2(); 3576 Expression expression = parseExpression2();
3572 return new ThrowExpression.full(keyword, expression); 3577 return new ThrowExpression.full(keyword, expression);
3573 } 3578 }
3574 /** 3579 /**
3575 * Parse a throw expression. 3580 * Parse a throw expression.
3576 * <pre> 3581 * <pre>
3577 * throwExpressionWithoutCascade ::= 3582 * throwExpressionWithoutCascade ::=
3578 * 'throw' expressionWithoutCascade? ';' 3583 * 'throw' expressionWithoutCascade
3579 * </pre> 3584 * </pre>
3580 * @return the throw expression that was parsed 3585 * @return the throw expression that was parsed
3581 */ 3586 */
3582 Expression parseThrowExpressionWithoutCascade() { 3587 Expression parseThrowExpressionWithoutCascade() {
3583 Token keyword = expect(Keyword.THROW); 3588 Token keyword = expect(Keyword.THROW);
3584 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) { 3589 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) {
3585 return new ThrowExpression.full(keyword, null); 3590 return new ThrowExpression.full(keyword, null);
3586 } 3591 }
3587 Expression expression = parseExpressionWithoutCascade(); 3592 Expression expression = parseExpressionWithoutCascade();
3588 return new ThrowExpression.full(keyword, expression); 3593 return new ThrowExpression.full(keyword, expression);
3589 } 3594 }
3590 /** 3595 /**
3591 * Parse a try statement. 3596 * Parse a try statement.
3592 * <pre> 3597 * <pre>
3593 * tryStatement ::= 3598 * tryStatement ::=
3594 * 'try' block (onPart+ finallyPart? | finallyPart) 3599 * 'try' block (onPart+ finallyPart? | finallyPart)
3595 * onPart ::= 3600 * onPart ::=
3596 * catchPart block 3601 * catchPart block
3597 * | 'on' qualified catchPart? block 3602 * | 'on' type catchPart? block
3598 * catchPart ::= 3603 * catchPart ::=
3599 * 'catch' '(' identifier (',' identifier)? ')' 3604 * 'catch' '(' identifier (',' identifier)? ')'
3600 * finallyPart ::= 3605 * finallyPart ::=
3601 * 'finally' block 3606 * 'finally' block
3602 * </pre> 3607 * </pre>
3603 * @return the try statement that was parsed 3608 * @return the try statement that was parsed
3604 */ 3609 */
3605 Statement parseTryStatement() { 3610 Statement parseTryStatement() {
3606 Token tryKeyword = expect(Keyword.TRY); 3611 Token tryKeyword = expect(Keyword.TRY);
3607 Block body = parseBlock(); 3612 Block body = parseBlock();
3608 List<CatchClause> catchClauses = new List<CatchClause>(); 3613 List<CatchClause> catchClauses = new List<CatchClause>();
3609 Block finallyClause = null; 3614 Block finallyClause = null;
3610 while (matches2(_ON) || matches(Keyword.CATCH)) { 3615 while (matches2(_ON) || matches(Keyword.CATCH)) {
3611 Token onKeyword = null; 3616 Token onKeyword = null;
3612 TypeName exceptionType = null; 3617 TypeName exceptionType = null;
3613 if (matches2(_ON)) { 3618 if (matches2(_ON)) {
3614 onKeyword = andAdvance; 3619 onKeyword = andAdvance;
3615 exceptionType = new TypeName.full(parsePrefixedIdentifier(), null); 3620 exceptionType = parseTypeName();
3616 } 3621 }
3617 Token catchKeyword = null; 3622 Token catchKeyword = null;
3618 Token leftParenthesis = null; 3623 Token leftParenthesis = null;
3619 SimpleIdentifier exceptionParameter = null; 3624 SimpleIdentifier exceptionParameter = null;
3620 Token comma = null; 3625 Token comma = null;
3621 SimpleIdentifier stackTraceParameter = null; 3626 SimpleIdentifier stackTraceParameter = null;
3622 Token rightParenthesis = null; 3627 Token rightParenthesis = null;
3623 if (matches(Keyword.CATCH)) { 3628 if (matches(Keyword.CATCH)) {
3624 catchKeyword = andAdvance; 3629 catchKeyword = andAdvance;
3625 leftParenthesis = expect2(TokenType.OPEN_PAREN); 3630 leftParenthesis = expect2(TokenType.OPEN_PAREN);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
3769 if (matches(Keyword.SUPER)) { 3774 if (matches(Keyword.SUPER)) {
3770 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(), TokenType.PERIOD)) { 3775 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(), TokenType.PERIOD)) {
3771 return new PrefixExpression.full(operator, parseUnaryExpression()); 3776 return new PrefixExpression.full(operator, parseUnaryExpression());
3772 } 3777 }
3773 return new PrefixExpression.full(operator, new SuperExpression.full(andA dvance)); 3778 return new PrefixExpression.full(operator, new SuperExpression.full(andA dvance));
3774 } 3779 }
3775 return new PrefixExpression.full(operator, parseUnaryExpression()); 3780 return new PrefixExpression.full(operator, parseUnaryExpression());
3776 } else if (_currentToken.type.isIncrementOperator()) { 3781 } else if (_currentToken.type.isIncrementOperator()) {
3777 Token operator = andAdvance; 3782 Token operator = andAdvance;
3778 if (matches(Keyword.SUPER)) { 3783 if (matches(Keyword.SUPER)) {
3784 if (matches4(peek(), TokenType.OPEN_SQUARE_BRACKET) || matches4(peek(), TokenType.PERIOD)) {
3785 return new PrefixExpression.full(operator, parseUnaryExpression());
3786 }
3779 if (identical(operator.type, TokenType.MINUS_MINUS)) { 3787 if (identical(operator.type, TokenType.MINUS_MINUS)) {
3780 int offset9 = operator.offset; 3788 int offset9 = operator.offset;
3781 Token firstOperator = new Token(TokenType.MINUS, offset9); 3789 Token firstOperator = new Token(TokenType.MINUS, offset9);
3782 Token secondOperator = new Token(TokenType.MINUS, offset9 + 1); 3790 Token secondOperator = new Token(TokenType.MINUS, offset9 + 1);
3783 secondOperator.setNext(_currentToken); 3791 secondOperator.setNext(_currentToken);
3784 firstOperator.setNext(secondOperator); 3792 firstOperator.setNext(secondOperator);
3785 operator.previous.setNext(firstOperator); 3793 operator.previous.setNext(firstOperator);
3786 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance))); 3794 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance)));
3787 } else { 3795 } else {
3788 reportError4(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex eme]); 3796 reportError4(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex eme]);
(...skipping 24 matching lines...) Expand all
3813 initializer = parseExpression2(); 3821 initializer = parseExpression2();
3814 } 3822 }
3815 return new VariableDeclaration.full(commentAndMetadata.comment, commentAndMe tadata.metadata, name, equals, initializer); 3823 return new VariableDeclaration.full(commentAndMetadata.comment, commentAndMe tadata.metadata, name, equals, initializer);
3816 } 3824 }
3817 /** 3825 /**
3818 * Parse a variable declaration list. 3826 * Parse a variable declaration list.
3819 * <pre> 3827 * <pre>
3820 * variableDeclarationList ::= 3828 * variableDeclarationList ::=
3821 * finalConstVarOrType variableDeclaration (',' variableDeclaration) 3829 * finalConstVarOrType variableDeclaration (',' variableDeclaration)
3822 * </pre> 3830 * </pre>
3831 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list
3823 * @return the variable declaration list that was parsed 3832 * @return the variable declaration list that was parsed
3824 */ 3833 */
3825 VariableDeclarationList parseVariableDeclarationList() { 3834 VariableDeclarationList parseVariableDeclarationList(CommentAndMetadata commen tAndMetadata) {
3826 FinalConstVarOrType holder = parseFinalConstVarOrType(false); 3835 FinalConstVarOrType holder = parseFinalConstVarOrType(false);
3827 return parseVariableDeclarationList2(holder.keyword, holder.type); 3836 return parseVariableDeclarationList2(commentAndMetadata, holder.keyword, hol der.type);
3828 } 3837 }
3829 /** 3838 /**
3830 * Parse a variable declaration list. 3839 * Parse a variable declaration list.
3831 * <pre> 3840 * <pre>
3832 * variableDeclarationList ::= 3841 * variableDeclarationList ::=
3833 * finalConstVarOrType variableDeclaration (',' variableDeclaration) 3842 * finalConstVarOrType variableDeclaration (',' variableDeclaration)
3834 * </pre> 3843 * </pre>
3844 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list, or
3845 * <code>null</code> if there is no attempt at parsing the comment and metadat a
3835 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or {@code null} if 3846 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or {@code null} if
3836 * there is no keyword 3847 * there is no keyword
3837 * @param type the type of the variables in the list 3848 * @param type the type of the variables in the list
3838 * @return the variable declaration list that was parsed 3849 * @return the variable declaration list that was parsed
3839 */ 3850 */
3840 VariableDeclarationList parseVariableDeclarationList2(Token keyword, TypeName type) { 3851 VariableDeclarationList parseVariableDeclarationList2(CommentAndMetadata comme ntAndMetadata, Token keyword, TypeName type) {
3841 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 3852 List<VariableDeclaration> variables = new List<VariableDeclaration>();
3842 variables.add(parseVariableDeclaration()); 3853 variables.add(parseVariableDeclaration());
3843 while (matches5(TokenType.COMMA)) { 3854 while (matches5(TokenType.COMMA)) {
3844 advance(); 3855 advance();
3845 variables.add(parseVariableDeclaration()); 3856 variables.add(parseVariableDeclaration());
3846 } 3857 }
3847 return new VariableDeclarationList.full(keyword, type, variables); 3858 return new VariableDeclarationList.full(commentAndMetadata != null ? comment AndMetadata.comment : null, commentAndMetadata != null ? commentAndMetadata.meta data : null, keyword, type, variables);
3848 } 3859 }
3849 /** 3860 /**
3850 * Parse a variable declaration statement. 3861 * Parse a variable declaration statement.
3851 * <pre> 3862 * <pre>
3852 * variableDeclarationStatement ::= 3863 * variableDeclarationStatement ::=
3853 * variableDeclarationList ';' 3864 * variableDeclarationList ';'
3854 * </pre> 3865 * </pre>
3855 * @return the variable declaration statement that was parsed 3866 * @return the variable declaration statement that was parsed
3856 */ 3867 */
3857 VariableDeclarationStatement parseVariableDeclarationStatement() { 3868 VariableDeclarationStatement parseVariableDeclarationStatement(CommentAndMetad ata commentAndMetadata) {
3858 VariableDeclarationList variableList = parseVariableDeclarationList(); 3869 VariableDeclarationList variableList = parseVariableDeclarationList(commentA ndMetadata);
3859 Token semicolon = expect2(TokenType.SEMICOLON); 3870 Token semicolon = expect2(TokenType.SEMICOLON);
3860 return new VariableDeclarationStatement.full(variableList, semicolon); 3871 return new VariableDeclarationStatement.full(variableList, semicolon);
3861 } 3872 }
3862 /** 3873 /**
3863 * Parse a while statement. 3874 * Parse a while statement.
3864 * <pre> 3875 * <pre>
3865 * whileStatement ::= 3876 * whileStatement ::=
3866 * 'while' '(' expression ')' statement 3877 * 'while' '(' expression ')' statement
3867 * </pre> 3878 * </pre>
3868 * @return the while statement that was parsed 3879 * @return the while statement that was parsed
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
4637 reportError5(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword, []); 4648 reportError5(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword, []);
4638 } 4649 }
4639 if (modifiers.finalKeyword != null) { 4650 if (modifiers.finalKeyword != null) {
4640 reportError5(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []); 4651 reportError5(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []);
4641 } 4652 }
4642 if (modifiers.varKeyword != null) { 4653 if (modifiers.varKeyword != null) {
4643 reportError5(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []); 4654 reportError5(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []);
4644 } 4655 }
4645 } 4656 }
4646 } 4657 }
4647 class AnalysisErrorListener_7 implements AnalysisErrorListener { 4658 class AnalysisErrorListener_8 implements AnalysisErrorListener {
4648 List<bool> errorFound; 4659 List<bool> errorFound;
4649 AnalysisErrorListener_7(this.errorFound); 4660 AnalysisErrorListener_8(this.errorFound);
4650 void onError(AnalysisError error) { 4661 void onError(AnalysisError error) {
4651 errorFound[0] = true; 4662 errorFound[0] = true;
4652 } 4663 }
4653 } 4664 }
4654 /** 4665 /**
4655 * The enumeration {@code ParserErrorCode} defines the error codes used for erro rs detected by the 4666 * The enumeration {@code ParserErrorCode} defines the error codes used for erro rs detected by the
4656 * parser. The convention for this class is for the name of the error code to in dicate the problem 4667 * parser. The convention for this class is for the name of the error code to in dicate the problem
4657 * that caused the error to be generated and for the error message to explain wh at is wrong and, 4668 * that caused the error to be generated and for the error message to explain wh at is wrong and,
4658 * when appropriate, how the problem can be corrected. 4669 * when appropriate, how the problem can be corrected.
4659 * @coverage dart.engine.parser 4670 * @coverage dart.engine.parser
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4708 static final ParserErrorCode INVALID_CODE_POINT = new ParserErrorCode.con2('IN VALID_CODE_POINT', 46, "The escape sequence '%s' is not a valid code point"); 4719 static final ParserErrorCode INVALID_CODE_POINT = new ParserErrorCode.con2('IN VALID_CODE_POINT', 46, "The escape sequence '%s' is not a valid code point");
4709 static final ParserErrorCode INVALID_COMMENT_REFERENCE = new ParserErrorCode.c on2('INVALID_COMMENT_REFERENCE', 47, "Comment references should contain a possib ly prefixed identifier and can start with 'new', but should not contain anything else"); 4720 static final ParserErrorCode INVALID_COMMENT_REFERENCE = new ParserErrorCode.c on2('INVALID_COMMENT_REFERENCE', 47, "Comment references should contain a possib ly prefixed identifier and can start with 'new', but should not contain anything else");
4710 static final ParserErrorCode INVALID_HEX_ESCAPE = new ParserErrorCode.con2('IN VALID_HEX_ESCAPE', 48, "An escape sequence starting with '\\x' must be followed by 2 hexidecimal digits"); 4721 static final ParserErrorCode INVALID_HEX_ESCAPE = new ParserErrorCode.con2('IN VALID_HEX_ESCAPE', 48, "An escape sequence starting with '\\x' must be followed by 2 hexidecimal digits");
4711 static final ParserErrorCode INVALID_OPERATOR_FOR_SUPER = new ParserErrorCode. con2('INVALID_OPERATOR_FOR_SUPER', 49, "The operator '%s' cannot be used with 's uper'"); 4722 static final ParserErrorCode INVALID_OPERATOR_FOR_SUPER = new ParserErrorCode. con2('INVALID_OPERATOR_FOR_SUPER', 49, "The operator '%s' cannot be used with 's uper'");
4712 static final ParserErrorCode INVALID_UNICODE_ESCAPE = new ParserErrorCode.con2 ('INVALID_UNICODE_ESCAPE', 50, "An escape sequence starting with '\\u' must be f ollowed by 4 hexidecimal digits or from 1 to 6 digits between '{' and '}'"); 4723 static final ParserErrorCode INVALID_UNICODE_ESCAPE = new ParserErrorCode.con2 ('INVALID_UNICODE_ESCAPE', 50, "An escape sequence starting with '\\u' must be f ollowed by 4 hexidecimal digits or from 1 to 6 digits between '{' and '}'");
4713 static final ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = new ParserErrorCode .con2('LIBRARY_DIRECTIVE_NOT_FIRST', 51, "The library directive must appear befo re all other directives"); 4724 static final ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = new ParserErrorCode .con2('LIBRARY_DIRECTIVE_NOT_FIRST', 51, "The library directive must appear befo re all other directives");
4714 static final ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = new ParserErrorCode .con2('MISSING_ASSIGNABLE_SELECTOR', 52, "Missing selector such as \".<identifie r>\" or \"[0]\""); 4725 static final ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = new ParserErrorCode .con2('MISSING_ASSIGNABLE_SELECTOR', 52, "Missing selector such as \".<identifie r>\" or \"[0]\"");
4715 static final ParserErrorCode MISSING_CATCH_OR_FINALLY = new ParserErrorCode.co n2('MISSING_CATCH_OR_FINALLY', 53, "A try statement must have either a catch or finally clause"); 4726 static final ParserErrorCode MISSING_CATCH_OR_FINALLY = new ParserErrorCode.co n2('MISSING_CATCH_OR_FINALLY', 53, "A try statement must have either a catch or finally clause");
4716 static final ParserErrorCode MISSING_CLASS_BODY = new ParserErrorCode.con2('MI SSING_CLASS_BODY', 54, "A class definition must have a body, even if it is empty "); 4727 static final ParserErrorCode MISSING_CLASS_BODY = new ParserErrorCode.con2('MI SSING_CLASS_BODY', 54, "A class definition must have a body, even if it is empty ");
4717 static final ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE = new ParserError Code.con2('MISSING_CONST_FINAL_VAR_OR_TYPE', 55, "Variables must be declared usi ng the keywords 'const', 'final', 'var' or a type name"); 4728 static final ParserErrorCode MISSING_CONST_FINAL_VAR_OR_TYPE = new ParserError Code.con2('MISSING_CONST_FINAL_VAR_OR_TYPE', 55, "Variables must be declared usi ng the keywords 'const', 'final', 'var' or a type name");
4718 static final ParserErrorCode MISSING_FUNCTION_BODY = new ParserErrorCode.con2( 'MISSING_FUNCTION_BODY', 56, "A function body must be provided"); 4729 static final ParserErrorCode MISSING_EXPRESSION_IN_THROW = new ParserErrorCode .con2('MISSING_EXPRESSION_IN_THROW', 56, "Throw expressions must compute the obj ect to be thrown");
4719 static final ParserErrorCode MISSING_FUNCTION_PARAMETERS = new ParserErrorCode .con2('MISSING_FUNCTION_PARAMETERS', 57, "Functions must have an explicit list o f parameters"); 4730 static final ParserErrorCode MISSING_FUNCTION_BODY = new ParserErrorCode.con2( 'MISSING_FUNCTION_BODY', 57, "A function body must be provided");
4720 static final ParserErrorCode MISSING_IDENTIFIER = new ParserErrorCode.con2('MI SSING_IDENTIFIER', 58, "Expected an identifier"); 4731 static final ParserErrorCode MISSING_FUNCTION_PARAMETERS = new ParserErrorCode .con2('MISSING_FUNCTION_PARAMETERS', 58, "Functions must have an explicit list o f parameters");
4721 static final ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = new ParserErr orCode.con2('MISSING_NAME_IN_LIBRARY_DIRECTIVE', 59, "Library directives must in clude a library name"); 4732 static final ParserErrorCode MISSING_IDENTIFIER = new ParserErrorCode.con2('MI SSING_IDENTIFIER', 59, "Expected an identifier");
4722 static final ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE = new ParserErr orCode.con2('MISSING_NAME_IN_PART_OF_DIRECTIVE', 60, "Library directives must in clude a library name"); 4733 static final ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = new ParserErr orCode.con2('MISSING_NAME_IN_LIBRARY_DIRECTIVE', 60, "Library directives must in clude a library name");
4723 static final ParserErrorCode MISSING_STATEMENT = new ParserErrorCode.con2('MIS SING_STATEMENT', 61, "Expected a statement"); 4734 static final ParserErrorCode MISSING_NAME_IN_PART_OF_DIRECTIVE = new ParserErr orCode.con2('MISSING_NAME_IN_PART_OF_DIRECTIVE', 61, "Library directives must in clude a library name");
4724 static final ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP = new Pars erErrorCode.con2('MISSING_TERMINATOR_FOR_PARAMETER_GROUP', 62, "There is no '%s' to close the parameter group"); 4735 static final ParserErrorCode MISSING_STATEMENT = new ParserErrorCode.con2('MIS SING_STATEMENT', 62, "Expected a statement");
4725 static final ParserErrorCode MISSING_TYPEDEF_PARAMETERS = new ParserErrorCode. con2('MISSING_TYPEDEF_PARAMETERS', 63, "Type aliases for functions must have an explicit list of parameters"); 4736 static final ParserErrorCode MISSING_TERMINATOR_FOR_PARAMETER_GROUP = new Pars erErrorCode.con2('MISSING_TERMINATOR_FOR_PARAMETER_GROUP', 63, "There is no '%s' to close the parameter group");
4726 static final ParserErrorCode MISSING_VARIABLE_IN_FOR_EACH = new ParserErrorCod e.con2('MISSING_VARIABLE_IN_FOR_EACH', 64, "A loop variable must be declared in a for-each loop before the 'in', but none were found"); 4737 static final ParserErrorCode MISSING_TYPEDEF_PARAMETERS = new ParserErrorCode. con2('MISSING_TYPEDEF_PARAMETERS', 64, "Type aliases for functions must have an explicit list of parameters");
4727 static final ParserErrorCode MIXED_PARAMETER_GROUPS = new ParserErrorCode.con2 ('MIXED_PARAMETER_GROUPS', 65, "Cannot have both positional and named parameters in a single parameter list"); 4738 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");
4728 static final ParserErrorCode MULTIPLE_EXTENDS_CLAUSES = new ParserErrorCode.co n2('MULTIPLE_EXTENDS_CLAUSES', 66, "Each class definition can have at most one e xtends clause"); 4739 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");
4729 static final ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = new ParserErrorCode .con2('MULTIPLE_IMPLEMENTS_CLAUSES', 67, "Each class definition can have at most one implements clause"); 4740 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");
4730 static final ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES = new ParserErrorCode .con2('MULTIPLE_LIBRARY_DIRECTIVES', 68, "Only one library directive may be decl ared in a file"); 4741 static final ParserErrorCode MULTIPLE_IMPLEMENTS_CLAUSES = new ParserErrorCode .con2('MULTIPLE_IMPLEMENTS_CLAUSES', 68, "Each class definition can have at most one implements clause");
4731 static final ParserErrorCode MULTIPLE_NAMED_PARAMETER_GROUPS = new ParserError Code.con2('MULTIPLE_NAMED_PARAMETER_GROUPS', 69, "Cannot have multiple groups of named parameters in a single parameter list"); 4742 static final ParserErrorCode MULTIPLE_LIBRARY_DIRECTIVES = new ParserErrorCode .con2('MULTIPLE_LIBRARY_DIRECTIVES', 69, "Only one library directive may be decl ared in a file");
4732 static final ParserErrorCode MULTIPLE_PART_OF_DIRECTIVES = new ParserErrorCode .con2('MULTIPLE_PART_OF_DIRECTIVES', 70, "Only one part-of directive may be decl ared in a file"); 4743 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");
4733 static final ParserErrorCode MULTIPLE_POSITIONAL_PARAMETER_GROUPS = new Parser ErrorCode.con2('MULTIPLE_POSITIONAL_PARAMETER_GROUPS', 71, "Cannot have multiple groups of positional parameters in a single parameter list"); 4744 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");
4734 static final ParserErrorCode MULTIPLE_VARIABLES_IN_FOR_EACH = new ParserErrorC ode.con2('MULTIPLE_VARIABLES_IN_FOR_EACH', 72, "A single loop variable must be d eclared in a for-each loop before the 'in', but %s were found"); 4745 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");
4735 static final ParserErrorCode MULTIPLE_WITH_CLAUSES = new ParserErrorCode.con2( 'MULTIPLE_WITH_CLAUSES', 73, "Each class definition can have at most one with cl ause"); 4746 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");
4736 static final ParserErrorCode NAMED_PARAMETER_OUTSIDE_GROUP = new ParserErrorCo de.con2('NAMED_PARAMETER_OUTSIDE_GROUP', 74, "Named parameters must be enclosed in curly braces ('{' and '}')"); 4747 static final ParserErrorCode MULTIPLE_WITH_CLAUSES = new ParserErrorCode.con2( 'MULTIPLE_WITH_CLAUSES', 74, "Each class definition can have at most one with cl ause");
4737 static final ParserErrorCode NON_CONSTRUCTOR_FACTORY = new ParserErrorCode.con 2('NON_CONSTRUCTOR_FACTORY', 75, "Only constructors can be declared to be a 'fac tory'"); 4748 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 '}')");
4738 static final ParserErrorCode NON_IDENTIFIER_LIBRARY_NAME = new ParserErrorCode .con2('NON_IDENTIFIER_LIBRARY_NAME', 76, "The name of a library must be an ident ifier"); 4749 static final ParserErrorCode NON_CONSTRUCTOR_FACTORY = new ParserErrorCode.con 2('NON_CONSTRUCTOR_FACTORY', 76, "Only constructors can be declared to be a 'fac tory'");
4739 static final ParserErrorCode NON_PART_OF_DIRECTIVE_IN_PART = new ParserErrorCo de.con2('NON_PART_OF_DIRECTIVE_IN_PART', 77, "The part-of directive must be the only directive in a part"); 4750 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");
4740 static final ParserErrorCode NON_USER_DEFINABLE_OPERATOR = new ParserErrorCode .con2('NON_USER_DEFINABLE_OPERATOR', 78, "The operator '%s' is not user definabl e"); 4751 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");
4741 static final ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = new ParserError Code.con2('POSITIONAL_AFTER_NAMED_ARGUMENT', 79, "Positional arguments must occu r before named arguments"); 4752 static final ParserErrorCode NON_USER_DEFINABLE_OPERATOR = new ParserErrorCode .con2('NON_USER_DEFINABLE_OPERATOR', 79, "The operator '%s' is not user definabl e");
4742 static final ParserErrorCode POSITIONAL_PARAMETER_OUTSIDE_GROUP = new ParserEr rorCode.con2('POSITIONAL_PARAMETER_OUTSIDE_GROUP', 80, "Positional parameters mu st be enclosed in square brackets ('[' and ']')"); 4753 static final ParserErrorCode POSITIONAL_AFTER_NAMED_ARGUMENT = new ParserError Code.con2('POSITIONAL_AFTER_NAMED_ARGUMENT', 80, "Positional arguments must occu r before named arguments");
4743 static final ParserErrorCode STATIC_AFTER_CONST = new ParserErrorCode.con2('ST ATIC_AFTER_CONST', 81, "The modifier 'static' should be before the modifier 'con st'"); 4754 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 ']')");
4744 static final ParserErrorCode STATIC_AFTER_FINAL = new ParserErrorCode.con2('ST ATIC_AFTER_FINAL', 82, "The modifier 'static' should be before the modifier 'fin al'"); 4755 static final ParserErrorCode STATIC_AFTER_CONST = new ParserErrorCode.con2('ST ATIC_AFTER_CONST', 82, "The modifier 'static' should be before the modifier 'con st'");
4745 static final ParserErrorCode STATIC_AFTER_VAR = new ParserErrorCode.con2('STAT IC_AFTER_VAR', 83, "The modifier 'static' should be before the modifier 'var'"); 4756 static final ParserErrorCode STATIC_AFTER_FINAL = new ParserErrorCode.con2('ST ATIC_AFTER_FINAL', 83, "The modifier 'static' should be before the modifier 'fin al'");
4746 static final ParserErrorCode STATIC_CONSTRUCTOR = new ParserErrorCode.con2('ST ATIC_CONSTRUCTOR', 84, "Constructors cannot be static"); 4757 static final ParserErrorCode STATIC_AFTER_VAR = new ParserErrorCode.con2('STAT IC_AFTER_VAR', 84, "The modifier 'static' should be before the modifier 'var'");
4747 static final ParserErrorCode STATIC_OPERATOR = new ParserErrorCode.con2('STATI C_OPERATOR', 85, "Operators cannot be static"); 4758 static final ParserErrorCode STATIC_CONSTRUCTOR = new ParserErrorCode.con2('ST ATIC_CONSTRUCTOR', 85, "Constructors cannot be static");
4748 static final ParserErrorCode STATIC_TOP_LEVEL_DECLARATION = new ParserErrorCod e.con2('STATIC_TOP_LEVEL_DECLARATION', 86, "Top-level declarations cannot be dec lared to be 'static'"); 4759 static final ParserErrorCode STATIC_OPERATOR = new ParserErrorCode.con2('STATI C_OPERATOR', 86, "Operators cannot be static");
4749 static final ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP = new P arserErrorCode.con2('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP', 87, "There is n o '%s' to open a parameter group"); 4760 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'");
4750 static final ParserErrorCode UNEXPECTED_TOKEN = new ParserErrorCode.con2('UNEX PECTED_TOKEN', 88, "Unexpected token '%s'"); 4761 static final ParserErrorCode UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP = new P arserErrorCode.con2('UNEXPECTED_TERMINATOR_FOR_PARAMETER_GROUP', 88, "There is n o '%s' to open a parameter group");
4751 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" ); 4762 static final ParserErrorCode UNEXPECTED_TOKEN = new ParserErrorCode.con2('UNEX PECTED_TOKEN', 89, "Unexpected token '%s'");
4752 static final ParserErrorCode WITH_BEFORE_EXTENDS = new ParserErrorCode.con2('W ITH_BEFORE_EXTENDS', 90, "The extends clause must be before the with clause"); 4763 static final ParserErrorCode USE_OF_UNARY_PLUS_OPERATOR = new ParserErrorCode. con2('USE_OF_UNARY_PLUS_OPERATOR', 90, "There is no unary plus operator in Dart" );
4753 static final ParserErrorCode WITH_WITHOUT_EXTENDS = new ParserErrorCode.con2(' WITH_WITHOUT_EXTENDS', 91, "The with clause cannot be used without an extends cl ause"); 4764 static final ParserErrorCode WITH_BEFORE_EXTENDS = new ParserErrorCode.con2('W ITH_BEFORE_EXTENDS', 91, "The extends clause must be before the with clause");
4754 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 ':'"); 4765 static final ParserErrorCode WITH_WITHOUT_EXTENDS = new ParserErrorCode.con2(' WITH_WITHOUT_EXTENDS', 92, "The with clause cannot be used without an extends cl ause");
4755 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 '='"); 4766 static final ParserErrorCode WRONG_SEPARATOR_FOR_NAMED_PARAMETER = new ParserE rrorCode.con2('WRONG_SEPARATOR_FOR_NAMED_PARAMETER', 93, "The default value of a named parameter should be preceeded by ':'");
4756 static final ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = new Parser ErrorCode.con2('WRONG_TERMINATOR_FOR_PARAMETER_GROUP', 94, "Expected '%s' to clo se parameter group"); 4767 static final ParserErrorCode WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER = new Pa rserErrorCode.con2('WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER', 94, "The default value of a positional parameter should be preceeded by '='");
4757 static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con2('VAR_CLASS', 95, "Classes cannot be declared to be 'var'"); 4768 static final ParserErrorCode WRONG_TERMINATOR_FOR_PARAMETER_GROUP = new Parser ErrorCode.con2('WRONG_TERMINATOR_FOR_PARAMETER_GROUP', 95, "Expected '%s' to clo se parameter group");
4758 static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con2('VAR_R ETURN_TYPE', 96, "The return type cannot be 'var'"); 4769 static final ParserErrorCode VAR_CLASS = new ParserErrorCode.con2('VAR_CLASS', 96, "Classes cannot be declared to be 'var'");
4759 static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con2('VAR_TYPED EF', 97, "Type aliases cannot be declared to be 'var'"); 4770 static final ParserErrorCode VAR_RETURN_TYPE = new ParserErrorCode.con2('VAR_R ETURN_TYPE', 97, "The return type cannot be 'var'");
4760 static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con2('VOID_P ARAMETER', 98, "Parameters cannot have a type of 'void'"); 4771 static final ParserErrorCode VAR_TYPEDEF = new ParserErrorCode.con2('VAR_TYPED EF', 98, "Type aliases cannot be declared to be 'var'");
4761 static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con2('VOID_VA RIABLE', 99, "Variables cannot have a type of 'void'"); 4772 static final ParserErrorCode VOID_PARAMETER = new ParserErrorCode.con2('VOID_P ARAMETER', 99, "Parameters cannot have a type of 'void'");
4762 static final List<ParserErrorCode> values = [ABSTRACT_CLASS_MEMBER, ABSTRACT_S TATIC_METHOD, ABSTRACT_TOP_LEVEL_FUNCTION, ABSTRACT_TOP_LEVEL_VARIABLE, ABSTRACT _TYPEDEF, BREAK_OUTSIDE_OF_LOOP, CONST_AND_FINAL, CONST_AND_VAR, CONST_CLASS, CO NST_METHOD, CONST_TYPEDEF, CONSTRUCTOR_WITH_RETURN_TYPE, CONTINUE_OUTSIDE_OF_LOO P, CONTINUE_WITHOUT_LABEL_IN_CASE, DIRECTIVE_AFTER_DECLARATION, DUPLICATE_LABEL_ IN_SWITCH_STATEMENT, DUPLICATED_MODIFIER, EXPECTED_CASE_OR_DEFAULT, EXPECTED_LIS T_OR_MAP_LITERAL, EXPECTED_STRING_LITERAL, EXPECTED_TOKEN, EXPORT_DIRECTIVE_AFTE R_PART_DIRECTIVE, EXTERNAL_AFTER_CONST, EXTERNAL_AFTER_FACTORY, EXTERNAL_AFTER_S TATIC, EXTERNAL_CLASS, EXTERNAL_CONSTRUCTOR_WITH_BODY, EXTERNAL_FIELD, EXTERNAL_ GETTER_WITH_BODY, EXTERNAL_METHOD_WITH_BODY, EXTERNAL_OPERATOR_WITH_BODY, EXTERN AL_SETTER_WITH_BODY, EXTERNAL_TYPEDEF, FACTORY_TOP_LEVEL_DECLARATION, FIELD_INIT IALIZER_OUTSIDE_CONSTRUCTOR, FINAL_AND_VAR, FINAL_CLASS, FINAL_CONSTRUCTOR, FINA L_METHOD, FINAL_TYPEDEF, GETTER_WITH_PARAMETERS, ILLEGAL_ASSIGNMENT_TO_NON_ASSIG NABLE, IMPLEMENTS_BEFORE_EXTENDS, IMPLEMENTS_BEFORE_WITH, IMPORT_DIRECTIVE_AFTER _PART_DIRECTIVE, INITIALIZED_VARIABLE_IN_FOR_EACH, INVALID_CODE_POINT, INVALID_C OMMENT_REFERENCE, INVALID_HEX_ESCAPE, INVALID_OPERATOR_FOR_SUPER, INVALID_UNICOD E_ESCAPE, LIBRARY_DIRECTIVE_NOT_FIRST, MISSING_ASSIGNABLE_SELECTOR, MISSING_CATC H_OR_FINALLY, MISSING_CLASS_BODY, MISSING_CONST_FINAL_VAR_OR_TYPE, MISSING_FUNCT ION_BODY, MISSING_FUNCTION_PARAMETERS, MISSING_IDENTIFIER, MISSING_NAME_IN_LIBRA RY_DIRECTIVE, MISSING_NAME_IN_PART_OF_DIRECTIVE, MISSING_STATEMENT, MISSING_TERM INATOR_FOR_PARAMETER_GROUP, MISSING_TYPEDEF_PARAMETERS, MISSING_VARIABLE_IN_FOR_ EACH, MIXED_PARAMETER_GROUPS, MULTIPLE_EXTENDS_CLAUSES, MULTIPLE_IMPLEMENTS_CLAU SES, MULTIPLE_LIBRARY_DIRECTIVES, MULTIPLE_NAMED_PARAMETER_GROUPS, MULTIPLE_PART _OF_DIRECTIVES, MULTIPLE_POSITIONAL_PARAMETER_GROUPS, MULTIPLE_VARIABLES_IN_FOR_ EACH, MULTIPLE_WITH_CLAUSES, NAMED_PARAMETER_OUTSIDE_GROUP, NON_CONSTRUCTOR_FACT ORY, NON_IDENTIFIER_LIBRARY_NAME, NON_PART_OF_DIRECTIVE_IN_PART, NON_USER_DEFINA BLE_OPERATOR, POSITIONAL_AFTER_NAMED_ARGUMENT, POSITIONAL_PARAMETER_OUTSIDE_GROU P, STATIC_AFTER_CONST, STATIC_AFTER_FINAL, STATIC_AFTER_VAR, STATIC_CONSTRUCTOR, STATIC_OPERATOR, STATIC_TOP_LEVEL_DECLARATION, UNEXPECTED_TERMINATOR_FOR_PARAME TER_GROUP, UNEXPECTED_TOKEN, USE_OF_UNARY_PLUS_OPERATOR, WITH_BEFORE_EXTENDS, WI TH_WITHOUT_EXTENDS, WRONG_SEPARATOR_FOR_NAMED_PARAMETER, WRONG_SEPARATOR_FOR_POS ITIONAL_PARAMETER, WRONG_TERMINATOR_FOR_PARAMETER_GROUP, VAR_CLASS, VAR_RETURN_T YPE, VAR_TYPEDEF, VOID_PARAMETER, VOID_VARIABLE]; 4773 static final ParserErrorCode VOID_VARIABLE = new ParserErrorCode.con2('VOID_VA RIABLE', 100, "Variables cannot have a type of 'void'");
4774 static final List<ParserErrorCode> values = [ABSTRACT_CLASS_MEMBER, ABSTRACT_S TATIC_METHOD, ABSTRACT_TOP_LEVEL_FUNCTION, ABSTRACT_TOP_LEVEL_VARIABLE, ABSTRACT _TYPEDEF, BREAK_OUTSIDE_OF_LOOP, CONST_AND_FINAL, CONST_AND_VAR, CONST_CLASS, CO NST_METHOD, CONST_TYPEDEF, CONSTRUCTOR_WITH_RETURN_TYPE, CONTINUE_OUTSIDE_OF_LOO P, CONTINUE_WITHOUT_LABEL_IN_CASE, DIRECTIVE_AFTER_DECLARATION, DUPLICATE_LABEL_ IN_SWITCH_STATEMENT, DUPLICATED_MODIFIER, EXPECTED_CASE_OR_DEFAULT, EXPECTED_LIS T_OR_MAP_LITERAL, EXPECTED_STRING_LITERAL, EXPECTED_TOKEN, EXPORT_DIRECTIVE_AFTE R_PART_DIRECTIVE, EXTERNAL_AFTER_CONST, EXTERNAL_AFTER_FACTORY, EXTERNAL_AFTER_S TATIC, EXTERNAL_CLASS, EXTERNAL_CONSTRUCTOR_WITH_BODY, EXTERNAL_FIELD, EXTERNAL_ GETTER_WITH_BODY, EXTERNAL_METHOD_WITH_BODY, EXTERNAL_OPERATOR_WITH_BODY, EXTERN AL_SETTER_WITH_BODY, EXTERNAL_TYPEDEF, FACTORY_TOP_LEVEL_DECLARATION, FIELD_INIT IALIZER_OUTSIDE_CONSTRUCTOR, FINAL_AND_VAR, FINAL_CLASS, FINAL_CONSTRUCTOR, FINA L_METHOD, FINAL_TYPEDEF, GETTER_WITH_PARAMETERS, ILLEGAL_ASSIGNMENT_TO_NON_ASSIG NABLE, IMPLEMENTS_BEFORE_EXTENDS, IMPLEMENTS_BEFORE_WITH, IMPORT_DIRECTIVE_AFTER _PART_DIRECTIVE, INITIALIZED_VARIABLE_IN_FOR_EACH, INVALID_CODE_POINT, INVALID_C OMMENT_REFERENCE, INVALID_HEX_ESCAPE, INVALID_OPERATOR_FOR_SUPER, INVALID_UNICOD E_ESCAPE, LIBRARY_DIRECTIVE_NOT_FIRST, MISSING_ASSIGNABLE_SELECTOR, MISSING_CATC H_OR_FINALLY, MISSING_CLASS_BODY, MISSING_CONST_FINAL_VAR_OR_TYPE, MISSING_EXPRE SSION_IN_THROW, MISSING_FUNCTION_BODY, MISSING_FUNCTION_PARAMETERS, MISSING_IDEN TIFIER, MISSING_NAME_IN_LIBRARY_DIRECTIVE, MISSING_NAME_IN_PART_OF_DIRECTIVE, MI SSING_STATEMENT, MISSING_TERMINATOR_FOR_PARAMETER_GROUP, MISSING_TYPEDEF_PARAMET ERS, MISSING_VARIABLE_IN_FOR_EACH, MIXED_PARAMETER_GROUPS, MULTIPLE_EXTENDS_CLAU SES, MULTIPLE_IMPLEMENTS_CLAUSES, MULTIPLE_LIBRARY_DIRECTIVES, MULTIPLE_NAMED_PA RAMETER_GROUPS, MULTIPLE_PART_OF_DIRECTIVES, MULTIPLE_POSITIONAL_PARAMETER_GROUP S, MULTIPLE_VARIABLES_IN_FOR_EACH, MULTIPLE_WITH_CLAUSES, NAMED_PARAMETER_OUTSID E_GROUP, NON_CONSTRUCTOR_FACTORY, NON_IDENTIFIER_LIBRARY_NAME, NON_PART_OF_DIREC TIVE_IN_PART, NON_USER_DEFINABLE_OPERATOR, POSITIONAL_AFTER_NAMED_ARGUMENT, POSI TIONAL_PARAMETER_OUTSIDE_GROUP, STATIC_AFTER_CONST, STATIC_AFTER_FINAL, STATIC_A FTER_VAR, STATIC_CONSTRUCTOR, STATIC_OPERATOR, STATIC_TOP_LEVEL_DECLARATION, UNE XPECTED_TERMINATOR_FOR_PARAMETER_GROUP, UNEXPECTED_TOKEN, USE_OF_UNARY_PLUS_OPER ATOR, WITH_BEFORE_EXTENDS, WITH_WITHOUT_EXTENDS, WRONG_SEPARATOR_FOR_NAMED_PARAM ETER, WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, WRONG_TERMINATOR_FOR_PARAMETER_G ROUP, VAR_CLASS, VAR_RETURN_TYPE, VAR_TYPEDEF, VOID_PARAMETER, VOID_VARIABLE];
4763 String __name; 4775 String __name;
4764 int __ordinal = 0; 4776 int __ordinal = 0;
4765 int get ordinal => __ordinal; 4777 int get ordinal => __ordinal;
4766 /** 4778 /**
4767 * The severity of this error. 4779 * The severity of this error.
4768 */ 4780 */
4769 ErrorSeverity _severity; 4781 ErrorSeverity _severity;
4770 /** 4782 /**
4771 * The message template used to create the message to be displayed for this er ror. 4783 * The message template used to create the message to be displayed for this er ror.
4772 */ 4784 */
4773 String _message; 4785 String _message;
4774 /** 4786 /**
4775 * Initialize a newly created error code to have the given severity and messag e. 4787 * Initialize a newly created error code to have the given severity and messag e.
4776 * @param severity the severity of the error 4788 * @param severity the severity of the error
4777 * @param message the message template used to create the message to be displa yed for the error 4789 * @param message the message template used to create the message to be displa yed for the error
4778 */ 4790 */
4779 ParserErrorCode.con1(String ___name, int ___ordinal, ErrorSeverity severity2, String message2) { 4791 ParserErrorCode.con1(String ___name, int ___ordinal, ErrorSeverity severity2, String message2) {
4780 _jtd_constructor_271_impl(___name, ___ordinal, severity2, message2); 4792 _jtd_constructor_275_impl(___name, ___ordinal, severity2, message2);
4781 } 4793 }
4782 _jtd_constructor_271_impl(String ___name, int ___ordinal, ErrorSeverity severi ty2, String message2) { 4794 _jtd_constructor_275_impl(String ___name, int ___ordinal, ErrorSeverity severi ty2, String message2) {
4783 __name = ___name; 4795 __name = ___name;
4784 __ordinal = ___ordinal; 4796 __ordinal = ___ordinal;
4785 this._severity = severity2; 4797 this._severity = severity2;
4786 this._message = message2; 4798 this._message = message2;
4787 } 4799 }
4788 /** 4800 /**
4789 * Initialize a newly created error code to have the given message and a sever ity of ERROR. 4801 * Initialize a newly created error code to have the given message and a sever ity of ERROR.
4790 * @param message the message template used to create the message to be displa yed for the error 4802 * @param message the message template used to create the message to be displa yed for the error
4791 */ 4803 */
4792 ParserErrorCode.con2(String ___name, int ___ordinal, String message) { 4804 ParserErrorCode.con2(String ___name, int ___ordinal, String message) {
4793 _jtd_constructor_272_impl(___name, ___ordinal, message); 4805 _jtd_constructor_276_impl(___name, ___ordinal, message);
4794 } 4806 }
4795 _jtd_constructor_272_impl(String ___name, int ___ordinal, String message) { 4807 _jtd_constructor_276_impl(String ___name, int ___ordinal, String message) {
4796 _jtd_constructor_271_impl(___name, ___ordinal, ErrorSeverity.ERROR, message) ; 4808 _jtd_constructor_275_impl(___name, ___ordinal, ErrorSeverity.ERROR, message) ;
4797 } 4809 }
4798 ErrorSeverity get errorSeverity => _severity; 4810 ErrorSeverity get errorSeverity => _severity;
4799 String get message => _message; 4811 String get message => _message;
4800 ErrorType get type => ErrorType.SYNTACTIC_ERROR; 4812 ErrorType get type => ErrorType.SYNTACTIC_ERROR;
4801 bool needsRecompilation() => true; 4813 bool needsRecompilation() => true;
4802 String toString() => __name; 4814 String toString() => __name;
4803 } 4815 }
4804 /** 4816 /**
4805 * Instances of the class {link ToFormattedSourceVisitor} write a source represe ntation of a visited 4817 * Instances of the class {link ToFormattedSourceVisitor} write a source represe ntation of a visited
4806 * AST node (and all of it's children) to a writer. 4818 * AST node (and all of it's children) to a writer.
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
5385 } 5397 }
5386 visit(node.propertyName); 5398 visit(node.propertyName);
5387 return null; 5399 return null;
5388 } 5400 }
5389 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { 5401 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
5390 _writer.print("this"); 5402 _writer.print("this");
5391 visit7(".", node.constructorName); 5403 visit7(".", node.constructorName);
5392 visit(node.argumentList); 5404 visit(node.argumentList);
5393 return null; 5405 return null;
5394 } 5406 }
5407 Object visitRethrowExpression(RethrowExpression node) {
5408 _writer.print("rethrow");
5409 return null;
5410 }
5395 Object visitReturnStatement(ReturnStatement node) { 5411 Object visitReturnStatement(ReturnStatement node) {
5396 Expression expression17 = node.expression; 5412 Expression expression17 = node.expression;
5397 if (expression17 == null) { 5413 if (expression17 == null) {
5398 _writer.print("return;"); 5414 _writer.print("return;");
5399 } else { 5415 } else {
5400 _writer.print("return "); 5416 _writer.print("return ");
5401 expression17.accept(this); 5417 expression17.accept(this);
5402 _writer.print(";"); 5418 _writer.print(";");
5403 } 5419 }
5404 return null; 5420 return null;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
5667 for (int i = 0; i < size10; i++) { 5683 for (int i = 0; i < size10; i++) {
5668 if (i > 0) { 5684 if (i > 0) {
5669 _writer.print(separator); 5685 _writer.print(separator);
5670 } 5686 }
5671 nodes[i].accept(this); 5687 nodes[i].accept(this);
5672 } 5688 }
5673 } 5689 }
5674 } 5690 }
5675 } 5691 }
5676 } 5692 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/java_io.dart ('k') | pkg/analyzer_experimental/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698