| OLD | NEW |
| 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 fasta.parser.parser; | 5 library fasta.parser.parser; |
| 6 | 6 |
| 7 import '../fasta_codes.dart' | 7 import '../fasta_codes.dart' |
| 8 show | 8 show |
| 9 FastaCode, | 9 FastaCode, |
| 10 FastaMessage, | 10 FastaMessage, |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 Token typedefKeyword = token; | 557 Token typedefKeyword = token; |
| 558 listener.beginFunctionTypeAlias(token); | 558 listener.beginFunctionTypeAlias(token); |
| 559 Token equals; | 559 Token equals; |
| 560 if (optional('=', peekAfterNominalType(token.next))) { | 560 if (optional('=', peekAfterNominalType(token.next))) { |
| 561 token = parseIdentifier(token.next, IdentifierContext.typedefDeclaration); | 561 token = parseIdentifier(token.next, IdentifierContext.typedefDeclaration); |
| 562 token = parseTypeVariablesOpt(token); | 562 token = parseTypeVariablesOpt(token); |
| 563 equals = token; | 563 equals = token; |
| 564 token = expect('=', token); | 564 token = expect('=', token); |
| 565 token = parseType(token); | 565 token = parseType(token); |
| 566 } else { | 566 } else { |
| 567 token = parseReturnTypeOpt(token.next); | 567 token = parseTypeOpt(token.next); |
| 568 token = parseIdentifier(token, IdentifierContext.typedefDeclaration); | 568 token = parseIdentifier(token, IdentifierContext.typedefDeclaration); |
| 569 token = parseTypeVariablesOpt(token); | 569 token = parseTypeVariablesOpt(token); |
| 570 token = parseFormalParameters(token); | 570 token = parseFormalParameters(token); |
| 571 } | 571 } |
| 572 listener.endFunctionTypeAlias(typedefKeyword, equals, token); | 572 listener.endFunctionTypeAlias(typedefKeyword, equals, token); |
| 573 return expect(';', token); | 573 return expect(';', token); |
| 574 } | 574 } |
| 575 | 575 |
| 576 Token parseMixinApplication(Token token) { | 576 Token parseMixinApplication(Token token) { |
| 577 listener.beginMixinApplication(token); | 577 listener.beginMixinApplication(token); |
| 578 token = parseType(token); | 578 token = parseType(token); |
| 579 Token withKeyword = token; | 579 Token withKeyword = token; |
| 580 token = expect('with', token); | 580 token = expect('with', token); |
| 581 token = parseTypeList(token); | 581 token = parseTypeList(token); |
| 582 listener.endMixinApplication(withKeyword); | 582 listener.endMixinApplication(withKeyword); |
| 583 return token; | 583 return token; |
| 584 } | 584 } |
| 585 | 585 |
| 586 Token parseReturnTypeOpt(Token token) { | |
| 587 if (identical(token.stringValue, 'void')) { | |
| 588 if (isGeneralizedFunctionType(token.next)) { | |
| 589 return parseType(token); | |
| 590 } else { | |
| 591 listener.handleVoidKeyword(token); | |
| 592 return token.next; | |
| 593 } | |
| 594 } else { | |
| 595 return parseTypeOpt(token); | |
| 596 } | |
| 597 } | |
| 598 | |
| 599 Token parseFormalParametersOpt(Token token) { | 586 Token parseFormalParametersOpt(Token token) { |
| 600 if (optional('(', token)) { | 587 if (optional('(', token)) { |
| 601 return parseFormalParameters(token); | 588 return parseFormalParameters(token); |
| 602 } else { | 589 } else { |
| 603 listener.handleNoFormalParameters(token); | 590 listener.handleNoFormalParameters(token); |
| 604 return token; | 591 return token; |
| 605 } | 592 } |
| 606 } | 593 } |
| 607 | 594 |
| 608 Token skipFormalParameters(Token token) { | 595 Token skipFormalParameters(Token token) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 parseIdentifier(token, IdentifierContext.formalParameterDeclaration); | 673 parseIdentifier(token, IdentifierContext.formalParameterDeclaration); |
| 687 } else if (inFunctionType) { | 674 } else if (inFunctionType) { |
| 688 token = parseType(token); | 675 token = parseType(token); |
| 689 if (token.isIdentifier) { | 676 if (token.isIdentifier) { |
| 690 token = parseIdentifier( | 677 token = parseIdentifier( |
| 691 token, IdentifierContext.formalParameterDeclaration); | 678 token, IdentifierContext.formalParameterDeclaration); |
| 692 } else { | 679 } else { |
| 693 listener.handleNoName(token); | 680 listener.handleNoName(token); |
| 694 } | 681 } |
| 695 } else { | 682 } else { |
| 696 token = parseReturnTypeOpt(token); | 683 token = parseTypeOpt(token); |
| 697 if (optional('this', token)) { | 684 if (optional('this', token)) { |
| 698 thisKeyword = token; | 685 thisKeyword = token; |
| 699 token = expect('.', token.next); | 686 token = expect('.', token.next); |
| 700 nameToken = token; | 687 nameToken = token; |
| 701 token = parseIdentifier(token, IdentifierContext.fieldInitializer); | 688 token = parseIdentifier(token, IdentifierContext.fieldInitializer); |
| 702 } else { | 689 } else { |
| 703 nameToken = token; | 690 nameToken = token; |
| 704 token = parseIdentifier( | 691 token = parseIdentifier( |
| 705 token, IdentifierContext.formalParameterDeclaration); | 692 token, IdentifierContext.formalParameterDeclaration); |
| 706 } | 693 } |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 Token parseIdentifier(Token token, IdentifierContext context) { | 1028 Token parseIdentifier(Token token, IdentifierContext context) { |
| 1042 if (!token.isIdentifier) { | 1029 if (!token.isIdentifier) { |
| 1043 token = | 1030 token = |
| 1044 reportUnrecoverableErrorCodeWithToken(token, codeExpectedIdentifier) | 1031 reportUnrecoverableErrorCodeWithToken(token, codeExpectedIdentifier) |
| 1045 .next; | 1032 .next; |
| 1046 } else if (token.isBuiltInIdentifier && | 1033 } else if (token.isBuiltInIdentifier && |
| 1047 !context.isBuiltInIdentifierAllowed) { | 1034 !context.isBuiltInIdentifierAllowed) { |
| 1048 if (context.inDeclaration) { | 1035 if (context.inDeclaration) { |
| 1049 reportRecoverableErrorCodeWithToken( | 1036 reportRecoverableErrorCodeWithToken( |
| 1050 token, codeBuiltInIdentifierInDeclaration); | 1037 token, codeBuiltInIdentifierInDeclaration); |
| 1051 } else if (!optional("dynamic", token)) { | 1038 } else if (!optional("dynamic", token) && !optional("void", token)) { |
| 1052 reportRecoverableErrorCodeWithToken(token, codeBuiltInIdentifierAsType); | 1039 reportRecoverableErrorCodeWithToken(token, codeBuiltInIdentifierAsType); |
| 1053 } | 1040 } |
| 1054 } else if (!inPlainSync && token.isPseudo) { | 1041 } else if (!inPlainSync && token.isPseudo) { |
| 1055 if (optional('await', token)) { | 1042 if (optional('await', token)) { |
| 1056 reportRecoverableErrorCode(token, codeAwaitAsIdentifier); | 1043 reportRecoverableErrorCode(token, codeAwaitAsIdentifier); |
| 1057 } else if (optional('yield', token)) { | 1044 } else if (optional('yield', token)) { |
| 1058 reportRecoverableErrorCode(token, codeYieldAsIdentifier); | 1045 reportRecoverableErrorCode(token, codeYieldAsIdentifier); |
| 1059 } else if (optional('async', token)) { | 1046 } else if (optional('async', token)) { |
| 1060 reportRecoverableErrorCode(token, codeAsyncAsIdentifier); | 1047 reportRecoverableErrorCode(token, codeAsyncAsIdentifier); |
| 1061 } | 1048 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 (optional('<', token.next) || optional('(', token.next)); | 1105 (optional('<', token.next) || optional('(', token.next)); |
| 1119 } | 1106 } |
| 1120 | 1107 |
| 1121 Token parseType(Token token) { | 1108 Token parseType(Token token) { |
| 1122 Token begin = token; | 1109 Token begin = token; |
| 1123 if (isGeneralizedFunctionType(token)) { | 1110 if (isGeneralizedFunctionType(token)) { |
| 1124 // A function type without return type. | 1111 // A function type without return type. |
| 1125 // Push the non-existing return type first. The loop below will | 1112 // Push the non-existing return type first. The loop below will |
| 1126 // generate the full type. | 1113 // generate the full type. |
| 1127 listener.handleNoType(token); | 1114 listener.handleNoType(token); |
| 1128 } else if (identical(token.stringValue, 'void') && | |
| 1129 isGeneralizedFunctionType(token.next)) { | |
| 1130 listener.handleVoidKeyword(token); | |
| 1131 token = token.next; | |
| 1132 } else { | 1115 } else { |
| 1133 if (isValidTypeReference(token)) { | 1116 if (isValidTypeReference(token)) { |
| 1134 token = parseIdentifier(token, IdentifierContext.typeReference); | 1117 token = parseIdentifier(token, IdentifierContext.typeReference); |
| 1135 token = parseQualifiedRestOpt( | 1118 token = parseQualifiedRestOpt( |
| 1136 token, IdentifierContext.typeReferenceContinuation); | 1119 token, IdentifierContext.typeReferenceContinuation); |
| 1137 } else { | 1120 } else { |
| 1138 token = | 1121 token = |
| 1139 reportUnrecoverableErrorCodeWithToken(token, codeExpectedType).next; | 1122 reportUnrecoverableErrorCodeWithToken(token, codeExpectedType).next; |
| 1140 listener.handleInvalidTypeReference(token); | 1123 listener.handleInvalidTypeReference(token); |
| 1141 } | 1124 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 if (getOrSet != null) { | 1379 if (getOrSet != null) { |
| 1397 reportRecoverableErrorCodeWithToken( | 1380 reportRecoverableErrorCodeWithToken( |
| 1398 getOrSet, | 1381 getOrSet, |
| 1399 hasModifier || hasType | 1382 hasModifier || hasType |
| 1400 ? codeExtraneousModifier | 1383 ? codeExtraneousModifier |
| 1401 : codeExtraneousModifierReplace); | 1384 : codeExtraneousModifierReplace); |
| 1402 } | 1385 } |
| 1403 | 1386 |
| 1404 if (!hasType) { | 1387 if (!hasType) { |
| 1405 listener.handleNoType(name); | 1388 listener.handleNoType(name); |
| 1406 } else if (optional('void', type) && | |
| 1407 !isGeneralizedFunctionType(type.next)) { | |
| 1408 listener.handleNoType(name); | |
| 1409 // TODO(ahe): This error is reported twice, second time is from | |
| 1410 // [parseVariablesDeclarationMaybeSemicolon] via | |
| 1411 // [PartialFieldListElement.parseNode]. | |
| 1412 reportRecoverableErrorCode(type, codeInvalidVoid); | |
| 1413 } else { | 1389 } else { |
| 1414 parseType(type); | 1390 parseType(type); |
| 1415 if (isVar) { | 1391 if (isVar) { |
| 1416 reportRecoverableErrorCodeWithToken( | 1392 reportRecoverableErrorCodeWithToken( |
| 1417 modifiers.head, codeExtraneousModifier); | 1393 modifiers.head, codeExtraneousModifier); |
| 1418 } | 1394 } |
| 1419 } | 1395 } |
| 1420 | 1396 |
| 1421 IdentifierContext context = isTopLevel | 1397 IdentifierContext context = isTopLevel |
| 1422 ? IdentifierContext.topLevelVariableDeclaration | 1398 ? IdentifierContext.topLevelVariableDeclaration |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 if (externalModifier != null) { | 1432 if (externalModifier != null) { |
| 1457 parseModifier(externalModifier); | 1433 parseModifier(externalModifier); |
| 1458 listener.handleModifiers(1); | 1434 listener.handleModifiers(1); |
| 1459 } else { | 1435 } else { |
| 1460 listener.handleModifiers(0); | 1436 listener.handleModifiers(0); |
| 1461 } | 1437 } |
| 1462 | 1438 |
| 1463 if (type == null) { | 1439 if (type == null) { |
| 1464 listener.handleNoType(name); | 1440 listener.handleNoType(name); |
| 1465 } else { | 1441 } else { |
| 1466 parseReturnTypeOpt(type); | 1442 parseTypeOpt(type); |
| 1467 } | 1443 } |
| 1468 Token token = | 1444 Token token = |
| 1469 parseIdentifier(name, IdentifierContext.topLevelFunctionDeclaration); | 1445 parseIdentifier(name, IdentifierContext.topLevelFunctionDeclaration); |
| 1470 | 1446 |
| 1471 if (getOrSet == null) { | 1447 if (getOrSet == null) { |
| 1472 token = parseTypeVariablesOpt(token); | 1448 token = parseTypeVariablesOpt(token); |
| 1473 } else { | 1449 } else { |
| 1474 listener.handleNoTypeVariables(token); | 1450 listener.handleNoTypeVariables(token); |
| 1475 } | 1451 } |
| 1476 token = parseFormalParametersOpt(token); | 1452 token = parseFormalParametersOpt(token); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 if (closeToken != null) { | 1799 if (closeToken != null) { |
| 1824 peek = closeToken.next; | 1800 peek = closeToken.next; |
| 1825 } | 1801 } |
| 1826 | 1802 |
| 1827 return peek; | 1803 return peek; |
| 1828 } | 1804 } |
| 1829 | 1805 |
| 1830 /// If [token] is the start of a type, returns the token after that type. | 1806 /// If [token] is the start of a type, returns the token after that type. |
| 1831 /// If [token] is not the start of a type, null is returned. | 1807 /// If [token] is not the start of a type, null is returned. |
| 1832 Token peekAfterIfType(Token token) { | 1808 Token peekAfterIfType(Token token) { |
| 1833 if (!optional('void', token) && !token.isIdentifier) { | 1809 if (!token.isIdentifier) { |
| 1834 return null; | 1810 return null; |
| 1835 } | 1811 } |
| 1836 return peekAfterType(token); | 1812 return peekAfterType(token); |
| 1837 } | 1813 } |
| 1838 | 1814 |
| 1839 Token skipClassBody(Token token) { | 1815 Token skipClassBody(Token token) { |
| 1840 if (!optional('{', token)) { | 1816 if (!optional('{', token)) { |
| 1841 return reportUnrecoverableErrorCodeWithToken( | 1817 return reportUnrecoverableErrorCodeWithToken( |
| 1842 token, codeExpectedClassBodyToSkip) | 1818 token, codeExpectedClassBodyToSkip) |
| 1843 .next; | 1819 .next; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2009 } | 1985 } |
| 2010 if (getOrSet != null && constModifier != null) { | 1986 if (getOrSet != null && constModifier != null) { |
| 2011 reportRecoverableErrorCodeWithToken( | 1987 reportRecoverableErrorCodeWithToken( |
| 2012 constModifier, codeExtraneousModifier); | 1988 constModifier, codeExtraneousModifier); |
| 2013 } | 1989 } |
| 2014 parseModifierList(modifiers); | 1990 parseModifierList(modifiers); |
| 2015 | 1991 |
| 2016 if (type == null) { | 1992 if (type == null) { |
| 2017 listener.handleNoType(name); | 1993 listener.handleNoType(name); |
| 2018 } else { | 1994 } else { |
| 2019 parseReturnTypeOpt(type); | 1995 parseTypeOpt(type); |
| 2020 } | 1996 } |
| 2021 Token token; | 1997 Token token; |
| 2022 if (optional('operator', name)) { | 1998 if (optional('operator', name)) { |
| 2023 token = parseOperatorName(name); | 1999 token = parseOperatorName(name); |
| 2024 if (staticModifier != null) { | 2000 if (staticModifier != null) { |
| 2025 reportRecoverableErrorCodeWithToken( | 2001 reportRecoverableErrorCodeWithToken( |
| 2026 staticModifier, codeExtraneousModifier); | 2002 staticModifier, codeExtraneousModifier); |
| 2027 } | 2003 } |
| 2028 } else { | 2004 } else { |
| 2029 token = parseIdentifier(name, IdentifierContext.methodDeclaration); | 2005 token = parseIdentifier(name, IdentifierContext.methodDeclaration); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2114 token = | 2090 token = |
| 2115 parseIdentifier(token, IdentifierContext.localAccessorDeclaration); | 2091 parseIdentifier(token, IdentifierContext.localAccessorDeclaration); |
| 2116 } | 2092 } |
| 2117 } else if (optional('operator', token)) { | 2093 } else if (optional('operator', token)) { |
| 2118 // operator <op> (... | 2094 // operator <op> (... |
| 2119 listener.handleNoType(token); | 2095 listener.handleNoType(token); |
| 2120 listener.beginFunctionName(token); | 2096 listener.beginFunctionName(token); |
| 2121 token = parseOperatorName(token); | 2097 token = parseOperatorName(token); |
| 2122 } else { | 2098 } else { |
| 2123 // <type>? <get>? <name> | 2099 // <type>? <get>? <name> |
| 2124 token = parseReturnTypeOpt(token); | 2100 token = parseTypeOpt(token); |
| 2125 if (identical(getOrSet, token)) { | 2101 if (identical(getOrSet, token)) { |
| 2126 token = token.next; | 2102 token = token.next; |
| 2127 } | 2103 } |
| 2128 listener.beginFunctionName(token); | 2104 listener.beginFunctionName(token); |
| 2129 if (optional('operator', token)) { | 2105 if (optional('operator', token)) { |
| 2130 token = parseOperatorName(token); | 2106 token = parseOperatorName(token); |
| 2131 } else { | 2107 } else { |
| 2132 token = | 2108 token = |
| 2133 parseIdentifier(token, IdentifierContext.localFunctionDeclaration); | 2109 parseIdentifier(token, IdentifierContext.localFunctionDeclaration); |
| 2134 } | 2110 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2168 listener.beginFunctionDeclaration(token); | 2144 listener.beginFunctionDeclaration(token); |
| 2169 token = parseFunction(token, null); | 2145 token = parseFunction(token, null); |
| 2170 listener.endFunctionDeclaration(token); | 2146 listener.endFunctionDeclaration(token); |
| 2171 return token; | 2147 return token; |
| 2172 } | 2148 } |
| 2173 | 2149 |
| 2174 Token parseFunctionExpression(Token token) { | 2150 Token parseFunctionExpression(Token token) { |
| 2175 Token beginToken = token; | 2151 Token beginToken = token; |
| 2176 listener.beginFunction(token); | 2152 listener.beginFunction(token); |
| 2177 listener.handleModifiers(0); | 2153 listener.handleModifiers(0); |
| 2178 token = parseReturnTypeOpt(token); | 2154 token = parseTypeOpt(token); |
| 2179 listener.beginFunctionName(token); | 2155 listener.beginFunctionName(token); |
| 2180 token = parseIdentifier(token, IdentifierContext.functionExpressionName); | 2156 token = parseIdentifier(token, IdentifierContext.functionExpressionName); |
| 2181 listener.endFunctionName(beginToken, token); | 2157 listener.endFunctionName(beginToken, token); |
| 2182 token = parseTypeVariablesOpt(token); | 2158 token = parseTypeVariablesOpt(token); |
| 2183 token = parseFormalParameters(token); | 2159 token = parseFormalParameters(token); |
| 2184 listener.handleNoInitializers(); | 2160 listener.handleNoInitializers(); |
| 2185 AsyncModifier savedAsyncModifier = asyncState; | 2161 AsyncModifier savedAsyncModifier = asyncState; |
| 2186 token = parseAsyncModifier(token); | 2162 token = parseAsyncModifier(token); |
| 2187 bool isBlock = optional('{', token); | 2163 bool isBlock = optional('{', token); |
| 2188 token = parseFunctionBody(token, true, false); | 2164 token = parseFunctionBody(token, true, false); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2384 reportRecoverableErrorCode(token, codeAwaitForNotAsync); | 2360 reportRecoverableErrorCode(token, codeAwaitForNotAsync); |
| 2385 } | 2361 } |
| 2386 return parseForStatement(token, token.next); | 2362 return parseForStatement(token, token.next); |
| 2387 } else if (identical(value, 'for')) { | 2363 } else if (identical(value, 'for')) { |
| 2388 return parseForStatement(null, token); | 2364 return parseForStatement(null, token); |
| 2389 } else if (identical(value, 'rethrow')) { | 2365 } else if (identical(value, 'rethrow')) { |
| 2390 return parseRethrowStatement(token); | 2366 return parseRethrowStatement(token); |
| 2391 } else if (identical(value, 'throw') && optional(';', token.next)) { | 2367 } else if (identical(value, 'throw') && optional(';', token.next)) { |
| 2392 // TODO(kasperl): Stop dealing with throw here. | 2368 // TODO(kasperl): Stop dealing with throw here. |
| 2393 return parseRethrowStatement(token); | 2369 return parseRethrowStatement(token); |
| 2394 } else if (identical(value, 'void')) { | |
| 2395 return parseExpressionStatementOrDeclaration(token); | |
| 2396 } else if (identical(value, 'while')) { | 2370 } else if (identical(value, 'while')) { |
| 2397 return parseWhileStatement(token); | 2371 return parseWhileStatement(token); |
| 2398 } else if (identical(value, 'do')) { | 2372 } else if (identical(value, 'do')) { |
| 2399 return parseDoWhileStatement(token); | 2373 return parseDoWhileStatement(token); |
| 2400 } else if (identical(value, 'try')) { | 2374 } else if (identical(value, 'try')) { |
| 2401 return parseTryStatement(token); | 2375 return parseTryStatement(token); |
| 2402 } else if (identical(value, 'switch')) { | 2376 } else if (identical(value, 'switch')) { |
| 2403 return parseSwitchStatement(token); | 2377 return parseSwitchStatement(token); |
| 2404 } else if (identical(value, 'break')) { | 2378 } else if (identical(value, 'break')) { |
| 2405 return parseBreakStatement(token); | 2379 return parseBreakStatement(token); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2484 return token; | 2458 return token; |
| 2485 } else { | 2459 } else { |
| 2486 return null; | 2460 return null; |
| 2487 } | 2461 } |
| 2488 } | 2462 } |
| 2489 | 2463 |
| 2490 Token parseExpressionStatementOrDeclaration(Token token) { | 2464 Token parseExpressionStatementOrDeclaration(Token token) { |
| 2491 if (!inPlainSync && optional("await", token)) { | 2465 if (!inPlainSync && optional("await", token)) { |
| 2492 return parseExpressionStatement(token); | 2466 return parseExpressionStatement(token); |
| 2493 } | 2467 } |
| 2494 assert(token.isIdentifier || identical(token.stringValue, 'void')); | 2468 assert(token.isIdentifier); |
| 2495 Token identifier = peekIdentifierAfterType(token); | 2469 Token identifier = peekIdentifierAfterType(token); |
| 2496 if (identifier != null) { | 2470 if (identifier != null) { |
| 2497 assert(identifier.isIdentifier); | 2471 assert(identifier.isIdentifier); |
| 2498 | 2472 |
| 2499 // If the identifier token has a type substitution comment /*=T*/, | 2473 // If the identifier token has a type substitution comment /*=T*/, |
| 2500 // then the set of tokens type tokens should be replaced with the | 2474 // then the set of tokens type tokens should be replaced with the |
| 2501 // tokens parsed from the comment. | 2475 // tokens parsed from the comment. |
| 2502 token = | 2476 token = |
| 2503 listener.replaceTokenWithGenericCommentTypeAssign(token, identifier); | 2477 listener.replaceTokenWithGenericCommentTypeAssign(token, identifier); |
| 2504 | 2478 |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2914 } else if (identical(value, "null")) { | 2888 } else if (identical(value, "null")) { |
| 2915 return parseLiteralNull(token); | 2889 return parseLiteralNull(token); |
| 2916 } else if (identical(value, "this")) { | 2890 } else if (identical(value, "this")) { |
| 2917 return parseThisExpression(token, context); | 2891 return parseThisExpression(token, context); |
| 2918 } else if (identical(value, "super")) { | 2892 } else if (identical(value, "super")) { |
| 2919 return parseSuperExpression(token, context); | 2893 return parseSuperExpression(token, context); |
| 2920 } else if (identical(value, "new")) { | 2894 } else if (identical(value, "new")) { |
| 2921 return parseNewExpression(token); | 2895 return parseNewExpression(token); |
| 2922 } else if (identical(value, "const")) { | 2896 } else if (identical(value, "const")) { |
| 2923 return parseConstExpression(token); | 2897 return parseConstExpression(token); |
| 2924 } else if (identical(value, "void")) { | |
| 2925 return parseFunctionExpression(token); | |
| 2926 } else if (!inPlainSync && | 2898 } else if (!inPlainSync && |
| 2927 (identical(value, "yield") || identical(value, "async"))) { | 2899 (identical(value, "yield") || identical(value, "async"))) { |
| 2928 return expressionExpected(token); | 2900 return expressionExpected(token); |
| 2929 } else if (token.isIdentifier) { | 2901 } else if (token.isIdentifier) { |
| 2930 return parseSendOrFunctionLiteral(token, context); | 2902 return parseSendOrFunctionLiteral(token, context); |
| 2931 } else { | 2903 } else { |
| 2932 return expressionExpected(token); | 2904 return expressionExpected(token); |
| 2933 } | 2905 } |
| 2934 } else if (kind == OPEN_PAREN_TOKEN) { | 2906 } else if (kind == OPEN_PAREN_TOKEN) { |
| 2935 return parseParenthesizedExpressionOrFunctionLiteral(token); | 2907 return parseParenthesizedExpressionOrFunctionLiteral(token); |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3917 return reportUnrecoverableError( | 3889 return reportUnrecoverableError( |
| 3918 token, () => code.format(uri, token.charOffset, string)); | 3890 token, () => code.format(uri, token.charOffset, string)); |
| 3919 } | 3891 } |
| 3920 } | 3892 } |
| 3921 | 3893 |
| 3922 typedef FastaMessage NoArgument(Uri uri, int charOffset); | 3894 typedef FastaMessage NoArgument(Uri uri, int charOffset); |
| 3923 | 3895 |
| 3924 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token); | 3896 typedef FastaMessage TokenArgument(Uri uri, int charOffset, Token token); |
| 3925 | 3897 |
| 3926 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string); | 3898 typedef FastaMessage StringArgument(Uri uri, int charOffset, String string); |
| OLD | NEW |