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

Side by Side Diff: pkg/dart_parser/lib/src/parser.dart

Issue 2649923002: Update listener error handling. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « pkg/dart_parser/lib/src/listener.dart ('k') | pkg/fasta/lib/src/kernel/body_builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart_parser; 5 library dart_parser;
6 6
7 import 'package:dart_scanner/src/keyword.dart' show 7 import 'package:dart_scanner/src/keyword.dart' show
8 Keyword; 8 Keyword;
9 9
10 import 'package:dart_scanner/src/precedence.dart' show 10 import 'package:dart_scanner/src/precedence.dart' show
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 listener.handleFunctionTypedFormalParameter(token); 475 listener.handleFunctionTypedFormalParameter(token);
476 } 476 }
477 String value = token.stringValue; 477 String value = token.stringValue;
478 if ((identical('=', value)) || (identical(':', value))) { 478 if ((identical('=', value)) || (identical(':', value))) {
479 // TODO(ahe): Validate that these are only used for optional parameters. 479 // TODO(ahe): Validate that these are only used for optional parameters.
480 Token equal = token; 480 Token equal = token;
481 token = parseExpression(token.next); 481 token = parseExpression(token.next);
482 listener.handleValuedFormalParameter(equal, token); 482 listener.handleValuedFormalParameter(equal, token);
483 if (type.isRequired) { 483 if (type.isRequired) {
484 listener.reportError( 484 listener.reportError(
485 equal, ErrorKind.REQUIRED_PARAMETER_WITH_DEFAULT); 485 equal, ErrorKind.RequiredParameterWithDefault);
486 } else if (type.isPositional && identical(':', value)) { 486 } else if (type.isPositional && identical(':', value)) {
487 listener.reportError( 487 listener.reportError(
488 equal, ErrorKind.POSITIONAL_PARAMETER_WITH_EQUALS); 488 equal, ErrorKind.PositionalParameterWithEquals);
489 } 489 }
490 } 490 }
491 listener.endFormalParameter(thisKeyword); 491 listener.endFormalParameter(thisKeyword);
492 return token; 492 return token;
493 } 493 }
494 494
495 Token parseOptionalFormalParameters(Token token, bool isNamed) { 495 Token parseOptionalFormalParameters(Token token, bool isNamed) {
496 Token begin = token; 496 Token begin = token;
497 listener.beginOptionalFormalParameters(begin); 497 listener.beginOptionalFormalParameters(begin);
498 assert((isNamed && optional('{', token)) || optional('[', token)); 498 assert((isNamed && optional('{', token)) || optional('[', token));
499 int parameterCount = 0; 499 int parameterCount = 0;
500 do { 500 do {
501 token = token.next; 501 token = token.next;
502 if (isNamed && optional('}', token)) { 502 if (isNamed && optional('}', token)) {
503 break; 503 break;
504 } else if (!isNamed && optional(']', token)) { 504 } else if (!isNamed && optional(']', token)) {
505 break; 505 break;
506 } 506 }
507 var type = 507 var type =
508 isNamed ? FormalParameterType.NAMED : FormalParameterType.POSITIONAL; 508 isNamed ? FormalParameterType.NAMED : FormalParameterType.POSITIONAL;
509 token = parseFormalParameter(token, type); 509 token = parseFormalParameter(token, type);
510 ++parameterCount; 510 ++parameterCount;
511 } while (optional(',', token)); 511 } while (optional(',', token));
512 if (parameterCount == 0) { 512 if (parameterCount == 0) {
513 listener.reportError( 513 listener.reportError(
514 token, 514 token,
515 isNamed 515 isNamed
516 ? ErrorKind.EMPTY_NAMED_PARAMETER_LIST 516 ? ErrorKind.EmptyNamedParameterList
517 : ErrorKind.EMPTY_OPTIONAL_PARAMETER_LIST); 517 : ErrorKind.EmptyOptionalParameterList);
518 } 518 }
519 listener.endOptionalFormalParameters(parameterCount, begin, token); 519 listener.endOptionalFormalParameters(parameterCount, begin, token);
520 if (isNamed) { 520 if (isNamed) {
521 return expect('}', token); 521 return expect('}', token);
522 } else { 522 } else {
523 return expect(']', token); 523 return expect(']', token);
524 } 524 }
525 } 525 }
526 526
527 Token parseTypeOpt(Token token) { 527 Token parseTypeOpt(Token token) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 } 994 }
995 bool hasTypeOrModifier = hasType; 995 bool hasTypeOrModifier = hasType;
996 if (varFinalOrConst != null) { 996 if (varFinalOrConst != null) {
997 parseModifier(varFinalOrConst); 997 parseModifier(varFinalOrConst);
998 modifierCount++; 998 modifierCount++;
999 hasTypeOrModifier = true; 999 hasTypeOrModifier = true;
1000 modifierList.remove(varFinalOrConst); 1000 modifierList.remove(varFinalOrConst);
1001 } 1001 }
1002 listener.handleModifiers(modifierCount); 1002 listener.handleModifiers(modifierCount);
1003 var kind = hasTypeOrModifier 1003 var kind = hasTypeOrModifier
1004 ? ErrorKind.EXTRANEOUS_MODIFIER 1004 ? ErrorKind.ExtraneousModifier
1005 : ErrorKind.EXTRANEOUS_MODIFIER_REPLACE; 1005 : ErrorKind.ExtraneousModifierReplace;
1006 for (Token modifier in modifierList) { 1006 for (Token modifier in modifierList) {
1007 listener.reportError(modifier, kind, {'modifier': modifier}); 1007 listener.reportError(modifier, kind, {'modifier': modifier});
1008 } 1008 }
1009 return null; 1009 return null;
1010 } 1010 }
1011 1011
1012 /// Removes the optional `covariant` token from the modifiers, if there 1012 /// Removes the optional `covariant` token from the modifiers, if there
1013 /// is no `static` in the list, and `covariant` is the first modifier. 1013 /// is no `static` in the list, and `covariant` is the first modifier.
1014 Link<Token> removeOptCovariantTokenIfNotStatic(Link<Token> modifiers) { 1014 Link<Token> removeOptCovariantTokenIfNotStatic(Link<Token> modifiers) {
1015 if (modifiers.isEmpty || 1015 if (modifiers.isEmpty ||
(...skipping 20 matching lines...) Expand all
1036 expectVarFinalOrConst(modifiers, hasType, !isTopLevel); 1036 expectVarFinalOrConst(modifiers, hasType, !isTopLevel);
1037 bool isVar = false; 1037 bool isVar = false;
1038 bool hasModifier = false; 1038 bool hasModifier = false;
1039 if (varFinalOrConst != null) { 1039 if (varFinalOrConst != null) {
1040 hasModifier = true; 1040 hasModifier = true;
1041 isVar = optional('var', varFinalOrConst); 1041 isVar = optional('var', varFinalOrConst);
1042 } 1042 }
1043 1043
1044 if (getOrSet != null) { 1044 if (getOrSet != null) {
1045 var kind = (hasModifier || hasType) 1045 var kind = (hasModifier || hasType)
1046 ? ErrorKind.EXTRANEOUS_MODIFIER 1046 ? ErrorKind.ExtraneousModifier
1047 : ErrorKind.EXTRANEOUS_MODIFIER_REPLACE; 1047 : ErrorKind.ExtraneousModifierReplace;
1048 listener.reportError(getOrSet, kind, {'modifier': getOrSet}); 1048 listener.reportError(getOrSet, kind, {'modifier': getOrSet});
1049 } 1049 }
1050 1050
1051 if (!hasType) { 1051 if (!hasType) {
1052 listener.handleNoType(name); 1052 listener.handleNoType(name);
1053 } else if (optional('void', type)) { 1053 } else if (optional('void', type)) {
1054 listener.handleNoType(name); 1054 listener.handleNoType(name);
1055 // TODO(ahe): This error is reported twice, second time is from 1055 // TODO(ahe): This error is reported twice, second time is from
1056 // [parseVariablesDeclarationMaybeSemicolon] via 1056 // [parseVariablesDeclarationMaybeSemicolon] via
1057 // [PartialFieldListElement.parseNode]. 1057 // [PartialFieldListElement.parseNode].
1058 listener.reportError(type, ErrorKind.INVALID_VOID); 1058 listener.reportError(type, ErrorKind.InvalidVoid);
1059 } else { 1059 } else {
1060 parseType(type); 1060 parseType(type);
1061 if (isVar) { 1061 if (isVar) {
1062 listener.reportError(modifiers.head, ErrorKind.EXTRANEOUS_MODIFIER, 1062 listener.reportError(modifiers.head, ErrorKind.ExtraneousModifier,
1063 {'modifier': modifiers.head}); 1063 {'modifier': modifiers.head});
1064 } 1064 }
1065 } 1065 }
1066 1066
1067 Token token = parseIdentifier(name); 1067 Token token = parseIdentifier(name);
1068 1068
1069 int fieldCount = 1; 1069 int fieldCount = 1;
1070 token = parseVariableInitializerOpt(token); 1070 token = parseVariableInitializerOpt(token);
1071 while (optional(',', token)) { 1071 while (optional(',', token)) {
1072 token = parseIdentifier(token.next); 1072 token = parseIdentifier(token.next);
(...skipping 13 matching lines...) Expand all
1086 Token parseTopLevelMethod(Token start, Link<Token> modifiers, Token type, 1086 Token parseTopLevelMethod(Token start, Link<Token> modifiers, Token type,
1087 Token getOrSet, Token name) { 1087 Token getOrSet, Token name) {
1088 Token externalModifier; 1088 Token externalModifier;
1089 // TODO(johnniwinther): Move error reporting to resolution to give more 1089 // TODO(johnniwinther): Move error reporting to resolution to give more
1090 // specific error messages. 1090 // specific error messages.
1091 for (Token modifier in modifiers) { 1091 for (Token modifier in modifiers) {
1092 if (externalModifier == null && optional('external', modifier)) { 1092 if (externalModifier == null && optional('external', modifier)) {
1093 externalModifier = modifier; 1093 externalModifier = modifier;
1094 } else { 1094 } else {
1095 listener.reportError( 1095 listener.reportError(
1096 modifier, ErrorKind.EXTRANEOUS_MODIFIER, {'modifier': modifier}); 1096 modifier, ErrorKind.ExtraneousModifier, {'modifier': modifier});
1097 } 1097 }
1098 } 1098 }
1099 if (externalModifier != null) { 1099 if (externalModifier != null) {
1100 parseModifier(externalModifier); 1100 parseModifier(externalModifier);
1101 listener.handleModifiers(1); 1101 listener.handleModifiers(1);
1102 } else { 1102 } else {
1103 listener.handleModifiers(0); 1103 listener.handleModifiers(0);
1104 } 1104 }
1105 1105
1106 if (type == null) { 1106 if (type == null) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 } while (optional(',', token)); 1248 } while (optional(',', token));
1249 mayParseFunctionExpressions = old; 1249 mayParseFunctionExpressions = old;
1250 listener.endInitializers(count, begin, token); 1250 listener.endInitializers(count, begin, token);
1251 return token; 1251 return token;
1252 } 1252 }
1253 1253
1254 Token parseLiteralStringOrRecoverExpression(Token token) { 1254 Token parseLiteralStringOrRecoverExpression(Token token) {
1255 if (identical(token.kind, STRING_TOKEN)) { 1255 if (identical(token.kind, STRING_TOKEN)) {
1256 return parseLiteralString(token); 1256 return parseLiteralString(token);
1257 } else { 1257 } else {
1258 listener.reportError(token, ErrorKind.EXPECTED_STRING); 1258 listener.reportError(token, ErrorKind.ExpectedString);
1259 return parseExpression(token); 1259 return parseExpression(token);
1260 } 1260 }
1261 } 1261 }
1262 1262
1263 Token expectSemicolon(Token token) { 1263 Token expectSemicolon(Token token) {
1264 return expect(';', token); 1264 return expect(';', token);
1265 } 1265 }
1266 1266
1267 bool isModifier(Token token) { 1267 bool isModifier(Token token) {
1268 final String value = token.stringValue; 1268 final String value = token.stringValue;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 Token constModifier; 1484 Token constModifier;
1485 int modifierCount = 0; 1485 int modifierCount = 0;
1486 int allowedModifierCount = 1; 1486 int allowedModifierCount = 1;
1487 // TODO(johnniwinther): Move error reporting to resolution to give more 1487 // TODO(johnniwinther): Move error reporting to resolution to give more
1488 // specific error messages. 1488 // specific error messages.
1489 for (Token modifier in modifiers) { 1489 for (Token modifier in modifiers) {
1490 if (externalModifier == null && optional('external', modifier)) { 1490 if (externalModifier == null && optional('external', modifier)) {
1491 modifierCount++; 1491 modifierCount++;
1492 externalModifier = modifier; 1492 externalModifier = modifier;
1493 if (modifierCount != allowedModifierCount) { 1493 if (modifierCount != allowedModifierCount) {
1494 listener.reportError(modifier, ErrorKind.EXTRANEOUS_MODIFIER, 1494 listener.reportError(modifier, ErrorKind.ExtraneousModifier,
1495 {'modifier': modifier}); 1495 {'modifier': modifier});
1496 } 1496 }
1497 allowedModifierCount++; 1497 allowedModifierCount++;
1498 } else if (staticModifier == null && optional('static', modifier)) { 1498 } else if (staticModifier == null && optional('static', modifier)) {
1499 modifierCount++; 1499 modifierCount++;
1500 staticModifier = modifier; 1500 staticModifier = modifier;
1501 if (modifierCount != allowedModifierCount) { 1501 if (modifierCount != allowedModifierCount) {
1502 listener.reportError(modifier, ErrorKind.EXTRANEOUS_MODIFIER, 1502 listener.reportError(modifier, ErrorKind.ExtraneousModifier,
1503 {'modifier': modifier}); 1503 {'modifier': modifier});
1504 } 1504 }
1505 } else if (constModifier == null && optional('const', modifier)) { 1505 } else if (constModifier == null && optional('const', modifier)) {
1506 modifierCount++; 1506 modifierCount++;
1507 constModifier = modifier; 1507 constModifier = modifier;
1508 if (modifierCount != allowedModifierCount) { 1508 if (modifierCount != allowedModifierCount) {
1509 listener.reportError(modifier, ErrorKind.EXTRANEOUS_MODIFIER, 1509 listener.reportError(modifier, ErrorKind.ExtraneousModifier,
1510 {'modifier': modifier}); 1510 {'modifier': modifier});
1511 } 1511 }
1512 } else { 1512 } else {
1513 listener.reportError( 1513 listener.reportError(
1514 modifier, ErrorKind.EXTRANEOUS_MODIFIER, {'modifier': modifier}); 1514 modifier, ErrorKind.ExtraneousModifier, {'modifier': modifier});
1515 } 1515 }
1516 } 1516 }
1517 if (getOrSet != null && constModifier != null) { 1517 if (getOrSet != null && constModifier != null) {
1518 listener.reportError(constModifier, ErrorKind.EXTRANEOUS_MODIFIER, 1518 listener.reportError(constModifier, ErrorKind.ExtraneousModifier,
1519 {'modifier': constModifier}); 1519 {'modifier': constModifier});
1520 } 1520 }
1521 parseModifierList(modifiers); 1521 parseModifierList(modifiers);
1522 1522
1523 if (type == null) { 1523 if (type == null) {
1524 listener.handleNoType(name); 1524 listener.handleNoType(name);
1525 } else { 1525 } else {
1526 parseReturnTypeOpt(type); 1526 parseReturnTypeOpt(type);
1527 } 1527 }
1528 Token token; 1528 Token token;
1529 if (optional('operator', name)) { 1529 if (optional('operator', name)) {
1530 token = parseOperatorName(name); 1530 token = parseOperatorName(name);
1531 if (staticModifier != null) { 1531 if (staticModifier != null) {
1532 listener.reportError(staticModifier, ErrorKind.EXTRANEOUS_MODIFIER, 1532 listener.reportError(staticModifier, ErrorKind.ExtraneousModifier,
1533 {'modifier': staticModifier}); 1533 {'modifier': staticModifier});
1534 } 1534 }
1535 } else { 1535 } else {
1536 token = parseIdentifier(name); 1536 token = parseIdentifier(name);
1537 } 1537 }
1538 1538
1539 token = parseQualifiedRestOpt(token); 1539 token = parseQualifiedRestOpt(token);
1540 if (getOrSet == null) { 1540 if (getOrSet == null) {
1541 token = parseTypeVariablesOpt(token); 1541 token = parseTypeVariablesOpt(token);
1542 } else { 1542 } else {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 listener.endRedirectingFactoryBody(equals, semicolon); 1710 listener.endRedirectingFactoryBody(equals, semicolon);
1711 return token; 1711 return token;
1712 } 1712 }
1713 1713
1714 Token skipFunctionBody(Token token, bool isExpression, bool allowAbstract) { 1714 Token skipFunctionBody(Token token, bool isExpression, bool allowAbstract) {
1715 assert(!isExpression); 1715 assert(!isExpression);
1716 token = skipAsyncModifier(token); 1716 token = skipAsyncModifier(token);
1717 String value = token.stringValue; 1717 String value = token.stringValue;
1718 if (identical(value, ';')) { 1718 if (identical(value, ';')) {
1719 if (!allowAbstract) { 1719 if (!allowAbstract) {
1720 listener.reportError(token, ErrorKind.EXPECTED_BODY); 1720 listener.reportError(token, ErrorKind.ExpectedBody);
1721 } 1721 }
1722 listener.handleNoFunctionBody(token); 1722 listener.handleNoFunctionBody(token);
1723 } else { 1723 } else {
1724 if (identical(value, '=>')) { 1724 if (identical(value, '=>')) {
1725 token = parseExpression(token.next); 1725 token = parseExpression(token.next);
1726 expectSemicolon(token); 1726 expectSemicolon(token);
1727 } else if (value == '=') { 1727 } else if (value == '=') {
1728 token = parseRedirectingFactoryBody(token); 1728 token = parseRedirectingFactoryBody(token);
1729 expectSemicolon(token); 1729 expectSemicolon(token);
1730 } else { 1730 } else {
1731 token = skipBlock(token); 1731 token = skipBlock(token);
1732 } 1732 }
1733 listener.skippedFunctionBody(token); 1733 listener.skippedFunctionBody(token);
1734 } 1734 }
1735 return token; 1735 return token;
1736 } 1736 }
1737 1737
1738 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) { 1738 Token parseFunctionBody(Token token, bool isExpression, bool allowAbstract) {
1739 if (optional(';', token)) { 1739 if (optional(';', token)) {
1740 if (!allowAbstract) { 1740 if (!allowAbstract) {
1741 listener.reportError(token, ErrorKind.EXPECTED_BODY); 1741 listener.reportError(token, ErrorKind.ExpectedBody);
1742 } 1742 }
1743 listener.endFunctionBody(0, null, token); 1743 listener.endFunctionBody(0, null, token);
1744 return token; 1744 return token;
1745 } else if (optional('=>', token)) { 1745 } else if (optional('=>', token)) {
1746 Token begin = token; 1746 Token begin = token;
1747 token = parseExpression(token.next); 1747 token = parseExpression(token.next);
1748 if (!isExpression) { 1748 if (!isExpression) {
1749 expectSemicolon(token); 1749 expectSemicolon(token);
1750 listener.endReturnStatement(true, begin, token); 1750 listener.endReturnStatement(true, begin, token);
1751 } else { 1751 } else {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 token = token.next; 1803 token = token.next;
1804 } 1804 }
1805 } else if (optional('sync', token)) { 1805 } else if (optional('sync', token)) {
1806 async = token; 1806 async = token;
1807 token = token.next; 1807 token = token.next;
1808 if (optional('*', token)) { 1808 if (optional('*', token)) {
1809 asyncAwaitKeywordsEnabled = true; 1809 asyncAwaitKeywordsEnabled = true;
1810 star = token; 1810 star = token;
1811 token = token.next; 1811 token = token.next;
1812 } else { 1812 } else {
1813 listener.reportError(async, ErrorKind.INVALID_SYNC_MODIFIER); 1813 listener.reportError(async, ErrorKind.InvalidSyncModifier);
1814 } 1814 }
1815 } 1815 }
1816 listener.handleAsyncModifier(async, star); 1816 listener.handleAsyncModifier(async, star);
1817 return token; 1817 return token;
1818 } 1818 }
1819 1819
1820 Token parseStatement(Token token) { 1820 Token parseStatement(Token token) {
1821 final value = token.stringValue; 1821 final value = token.stringValue;
1822 if (identical(token.kind, IDENTIFIER_TOKEN)) { 1822 if (identical(token.kind, IDENTIFIER_TOKEN)) {
1823 return parseExpressionStatementOrDeclaration(token); 1823 return parseExpressionStatementOrDeclaration(token);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2247 return token; 2247 return token;
2248 } 2248 }
2249 2249
2250 Token parseUnaryExpression(Token token, bool allowCascades) { 2250 Token parseUnaryExpression(Token token, bool allowCascades) {
2251 String value = token.stringValue; 2251 String value = token.stringValue;
2252 // Prefix: 2252 // Prefix:
2253 if (asyncAwaitKeywordsEnabled && optional('await', token)) { 2253 if (asyncAwaitKeywordsEnabled && optional('await', token)) {
2254 return parseAwaitExpression(token, allowCascades); 2254 return parseAwaitExpression(token, allowCascades);
2255 } else if (identical(value, '+')) { 2255 } else if (identical(value, '+')) {
2256 // Dart no longer allows prefix-plus. 2256 // Dart no longer allows prefix-plus.
2257 listener.reportError(token, ErrorKind.UNSUPPORTED_PREFIX_PLUS); 2257 listener.reportError(token, ErrorKind.UnsupportedPrefixPlus);
2258 return parseUnaryExpression(token.next, allowCascades); 2258 return parseUnaryExpression(token.next, allowCascades);
2259 } else if ((identical(value, '!')) || 2259 } else if ((identical(value, '!')) ||
2260 (identical(value, '-')) || 2260 (identical(value, '-')) ||
2261 (identical(value, '~'))) { 2261 (identical(value, '~'))) {
2262 Token operator = token; 2262 Token operator = token;
2263 // Right associative, so we recurse at the same precedence 2263 // Right associative, so we recurse at the same precedence
2264 // level. 2264 // level.
2265 token = parsePrecedenceExpression( 2265 token = parsePrecedenceExpression(
2266 token.next, POSTFIX_PRECEDENCE, allowCascades); 2266 token.next, POSTFIX_PRECEDENCE, allowCascades);
2267 listener.handleUnaryPrefixExpression(operator); 2267 listener.handleUnaryPrefixExpression(operator);
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2842 Token parseForStatement(Token awaitToken, Token token) { 2842 Token parseForStatement(Token awaitToken, Token token) {
2843 Token forToken = token; 2843 Token forToken = token;
2844 listener.beginForStatement(forToken); 2844 listener.beginForStatement(forToken);
2845 token = expect('for', token); 2845 token = expect('for', token);
2846 token = expect('(', token); 2846 token = expect('(', token);
2847 token = parseVariablesDeclarationOrExpressionOpt(token); 2847 token = parseVariablesDeclarationOrExpressionOpt(token);
2848 if (optional('in', token)) { 2848 if (optional('in', token)) {
2849 return parseForInRest(awaitToken, forToken, token); 2849 return parseForInRest(awaitToken, forToken, token);
2850 } else { 2850 } else {
2851 if (awaitToken != null) { 2851 if (awaitToken != null) {
2852 listener.reportError(awaitToken, ErrorKind.INVALID_AWAIT_FOR); 2852 listener.reportError(awaitToken, ErrorKind.InvalidAwaitFor);
2853 } 2853 }
2854 return parseForRest(forToken, token); 2854 return parseForRest(forToken, token);
2855 } 2855 }
2856 } 2856 }
2857 2857
2858 Token parseVariablesDeclarationOrExpressionOpt(Token token) { 2858 Token parseVariablesDeclarationOrExpressionOpt(Token token) {
2859 final String value = token.stringValue; 2859 final String value = token.stringValue;
2860 if (identical(value, ';')) { 2860 if (identical(value, ';')) {
2861 listener.handleNoExpression(token); 2861 listener.handleNoExpression(token);
2862 return token; 2862 return token;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3170 } 3170 }
3171 listener.handleContinueStatement(hasTarget, continueKeyword, token); 3171 listener.handleContinueStatement(hasTarget, continueKeyword, token);
3172 return expectSemicolon(token); 3172 return expectSemicolon(token);
3173 } 3173 }
3174 3174
3175 Token parseEmptyStatement(Token token) { 3175 Token parseEmptyStatement(Token token) {
3176 listener.handleEmptyStatement(token); 3176 listener.handleEmptyStatement(token);
3177 return expectSemicolon(token); 3177 return expectSemicolon(token);
3178 } 3178 }
3179 } 3179 }
OLDNEW
« no previous file with comments | « pkg/dart_parser/lib/src/listener.dart ('k') | pkg/fasta/lib/src/kernel/body_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698