| 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 dart2js.parser; | 5 library dart2js.parser; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../tokens/keyword.dart' show | 8 import '../tokens/keyword.dart' show |
| 9 Keyword; | 9 Keyword; |
| 10 import '../tokens/precedence.dart' show | 10 import '../tokens/precedence.dart' show |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * | 91 * |
| 92 * Parse methods are generally named parseGrammarProductionSuffix. The | 92 * Parse methods are generally named parseGrammarProductionSuffix. The |
| 93 * suffix can be one of "opt", or "star". "opt" means zero or one | 93 * suffix can be one of "opt", or "star". "opt" means zero or one |
| 94 * matches, "star" means zero or more matches. For example, | 94 * matches, "star" means zero or more matches. For example, |
| 95 * [parseMetadataStar] corresponds to this grammar snippet: [: | 95 * [parseMetadataStar] corresponds to this grammar snippet: [: |
| 96 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :]. | 96 * metadata* :], and [parseTypeOpt] corresponds to: [: type? :]. |
| 97 */ | 97 */ |
| 98 class Parser { | 98 class Parser { |
| 99 final Listener listener; | 99 final Listener listener; |
| 100 bool mayParseFunctionExpressions = true; | 100 bool mayParseFunctionExpressions = true; |
| 101 bool yieldIsKeyword; | 101 bool asyncAwaitKeywordsEnabled; |
| 102 bool awaitIsKeyword; | |
| 103 | 102 |
| 104 Parser(this.listener, | 103 Parser(this.listener, |
| 105 {this.yieldIsKeyword: false, this.awaitIsKeyword: false}); | 104 {this.asyncAwaitKeywordsEnabled: false}); |
| 106 | 105 |
| 107 Token parseUnit(Token token) { | 106 Token parseUnit(Token token) { |
| 108 listener.beginCompilationUnit(token); | 107 listener.beginCompilationUnit(token); |
| 109 int count = 0; | 108 int count = 0; |
| 110 while (!identical(token.kind, EOF_TOKEN)) { | 109 while (!identical(token.kind, EOF_TOKEN)) { |
| 111 token = parseTopLevelDeclaration(token); | 110 token = parseTopLevelDeclaration(token); |
| 112 listener.endTopLevelDeclaration(token); | 111 listener.endTopLevelDeclaration(token); |
| 113 count++; | 112 count++; |
| 114 } | 113 } |
| 115 listener.endCompilationUnit(count, token); | 114 listener.endCompilationUnit(count, token); |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 } | 960 } |
| 962 | 961 |
| 963 if (type == null) { | 962 if (type == null) { |
| 964 listener.handleNoType(name); | 963 listener.handleNoType(name); |
| 965 } else { | 964 } else { |
| 966 parseReturnTypeOpt(type); | 965 parseReturnTypeOpt(type); |
| 967 } | 966 } |
| 968 Token token = parseIdentifier(name); | 967 Token token = parseIdentifier(name); |
| 969 | 968 |
| 970 token = parseFormalParametersOpt(token); | 969 token = parseFormalParametersOpt(token); |
| 971 bool previousYieldIsKeyword = yieldIsKeyword; | 970 bool previousAsyncAwaitKeywordsEnabled = asyncAwaitKeywordsEnabled; |
| 972 bool previousAwaitIsKeyword = awaitIsKeyword; | |
| 973 token = parseAsyncModifier(token); | 971 token = parseAsyncModifier(token); |
| 974 token = parseFunctionBody(token, false, externalModifier != null); | 972 token = parseFunctionBody(token, false, externalModifier != null); |
| 975 yieldIsKeyword = previousYieldIsKeyword; | 973 asyncAwaitKeywordsEnabled = previousAsyncAwaitKeywordsEnabled; |
| 976 awaitIsKeyword = previousAwaitIsKeyword; | |
| 977 Token endToken = token; | 974 Token endToken = token; |
| 978 token = token.next; | 975 token = token.next; |
| 979 if (token.kind == BAD_INPUT_TOKEN) { | 976 if (token.kind == BAD_INPUT_TOKEN) { |
| 980 token = listener.unexpected(token); | 977 token = listener.unexpected(token); |
| 981 } | 978 } |
| 982 listener.endTopLevelMethod(start, getOrSet, endToken); | 979 listener.endTopLevelMethod(start, getOrSet, endToken); |
| 983 return token; | 980 return token; |
| 984 } | 981 } |
| 985 | 982 |
| 986 /// Looks ahead to find the name of a member. Returns a link of the modifiers, | 983 /// Looks ahead to find the name of a member. Returns a link of the modifiers, |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 staticModifier, MessageKind.EXTRANEOUS_MODIFIER, | 1370 staticModifier, MessageKind.EXTRANEOUS_MODIFIER, |
| 1374 {'modifier': staticModifier}); | 1371 {'modifier': staticModifier}); |
| 1375 } | 1372 } |
| 1376 } else { | 1373 } else { |
| 1377 token = parseIdentifier(name); | 1374 token = parseIdentifier(name); |
| 1378 } | 1375 } |
| 1379 | 1376 |
| 1380 token = parseQualifiedRestOpt(token); | 1377 token = parseQualifiedRestOpt(token); |
| 1381 token = parseFormalParametersOpt(token); | 1378 token = parseFormalParametersOpt(token); |
| 1382 token = parseInitializersOpt(token); | 1379 token = parseInitializersOpt(token); |
| 1383 bool previousYieldIsKeyword = yieldIsKeyword; | 1380 bool previousAsyncAwaitKeywordsEnabled = asyncAwaitKeywordsEnabled; |
| 1384 bool previousAwaitIsKeyword = awaitIsKeyword; | |
| 1385 token = parseAsyncModifier(token); | 1381 token = parseAsyncModifier(token); |
| 1386 if (optional('=', token)) { | 1382 if (optional('=', token)) { |
| 1387 token = parseRedirectingFactoryBody(token); | 1383 token = parseRedirectingFactoryBody(token); |
| 1388 } else { | 1384 } else { |
| 1389 token = parseFunctionBody( | 1385 token = parseFunctionBody( |
| 1390 token, false, staticModifier == null || externalModifier != null); | 1386 token, false, staticModifier == null || externalModifier != null); |
| 1391 } | 1387 } |
| 1392 yieldIsKeyword = previousYieldIsKeyword; | 1388 asyncAwaitKeywordsEnabled = previousAsyncAwaitKeywordsEnabled; |
| 1393 awaitIsKeyword = previousAwaitIsKeyword; | |
| 1394 listener.endMethod(getOrSet, start, token); | 1389 listener.endMethod(getOrSet, start, token); |
| 1395 return token.next; | 1390 return token.next; |
| 1396 } | 1391 } |
| 1397 | 1392 |
| 1398 Token parseFactoryMethod(Token token) { | 1393 Token parseFactoryMethod(Token token) { |
| 1399 assert(isFactoryDeclaration(token)); | 1394 assert(isFactoryDeclaration(token)); |
| 1400 Token start = token; | 1395 Token start = token; |
| 1401 Token externalModifier; | 1396 Token externalModifier; |
| 1402 if (identical(token.stringValue, 'external')) { | 1397 if (identical(token.stringValue, 'external')) { |
| 1403 externalModifier = token; | 1398 externalModifier = token; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 if (optional('operator', token)) { | 1456 if (optional('operator', token)) { |
| 1462 token = parseOperatorName(token); | 1457 token = parseOperatorName(token); |
| 1463 } else { | 1458 } else { |
| 1464 token = parseIdentifier(token); | 1459 token = parseIdentifier(token); |
| 1465 } | 1460 } |
| 1466 } | 1461 } |
| 1467 token = parseQualifiedRestOpt(token); | 1462 token = parseQualifiedRestOpt(token); |
| 1468 listener.endFunctionName(token); | 1463 listener.endFunctionName(token); |
| 1469 token = parseFormalParametersOpt(token); | 1464 token = parseFormalParametersOpt(token); |
| 1470 token = parseInitializersOpt(token); | 1465 token = parseInitializersOpt(token); |
| 1471 bool previousYieldIsKeyword = yieldIsKeyword; | 1466 bool previousAsyncAwaitKeywordsEnabled = asyncAwaitKeywordsEnabled; |
| 1472 bool previousAwaitIsKeyword = awaitIsKeyword; | |
| 1473 token = parseAsyncModifier(token); | 1467 token = parseAsyncModifier(token); |
| 1474 if (optional('=', token)) { | 1468 if (optional('=', token)) { |
| 1475 token = parseRedirectingFactoryBody(token); | 1469 token = parseRedirectingFactoryBody(token); |
| 1476 } else { | 1470 } else { |
| 1477 token = parseFunctionBody(token, false, true); | 1471 token = parseFunctionBody(token, false, true); |
| 1478 } | 1472 } |
| 1479 yieldIsKeyword = previousYieldIsKeyword; | 1473 asyncAwaitKeywordsEnabled = previousAsyncAwaitKeywordsEnabled; |
| 1480 awaitIsKeyword = previousAwaitIsKeyword; | |
| 1481 listener.endFunction(getOrSet, token); | 1474 listener.endFunction(getOrSet, token); |
| 1482 return token.next; | 1475 return token.next; |
| 1483 } | 1476 } |
| 1484 | 1477 |
| 1485 Token parseUnnamedFunction(Token token) { | 1478 Token parseUnnamedFunction(Token token) { |
| 1486 listener.beginUnnamedFunction(token); | 1479 listener.beginUnnamedFunction(token); |
| 1487 token = parseFormalParameters(token); | 1480 token = parseFormalParameters(token); |
| 1488 bool previousYieldIsKeyword = yieldIsKeyword; | 1481 bool previousAsyncAwaitKeywordsEnabled = asyncAwaitKeywordsEnabled; |
| 1489 bool previousAwaitIsKeyword = awaitIsKeyword; | |
| 1490 token = parseAsyncModifier(token); | 1482 token = parseAsyncModifier(token); |
| 1491 bool isBlock = optional('{', token); | 1483 bool isBlock = optional('{', token); |
| 1492 token = parseFunctionBody(token, true, false); | 1484 token = parseFunctionBody(token, true, false); |
| 1493 yieldIsKeyword = previousYieldIsKeyword; | 1485 asyncAwaitKeywordsEnabled = previousAsyncAwaitKeywordsEnabled; |
| 1494 awaitIsKeyword = previousAwaitIsKeyword; | |
| 1495 listener.endUnnamedFunction(token); | 1486 listener.endUnnamedFunction(token); |
| 1496 return isBlock ? token.next : token; | 1487 return isBlock ? token.next : token; |
| 1497 } | 1488 } |
| 1498 | 1489 |
| 1499 Token parseFunctionDeclaration(Token token) { | 1490 Token parseFunctionDeclaration(Token token) { |
| 1500 listener.beginFunctionDeclaration(token); | 1491 listener.beginFunctionDeclaration(token); |
| 1501 token = parseFunction(token, null); | 1492 token = parseFunction(token, null); |
| 1502 listener.endFunctionDeclaration(token); | 1493 listener.endFunctionDeclaration(token); |
| 1503 return token; | 1494 return token; |
| 1504 } | 1495 } |
| 1505 | 1496 |
| 1506 Token parseFunctionExpression(Token token) { | 1497 Token parseFunctionExpression(Token token) { |
| 1507 listener.beginFunction(token); | 1498 listener.beginFunction(token); |
| 1508 listener.handleModifiers(0); | 1499 listener.handleModifiers(0); |
| 1509 token = parseReturnTypeOpt(token); | 1500 token = parseReturnTypeOpt(token); |
| 1510 listener.beginFunctionName(token); | 1501 listener.beginFunctionName(token); |
| 1511 token = parseIdentifier(token); | 1502 token = parseIdentifier(token); |
| 1512 listener.endFunctionName(token); | 1503 listener.endFunctionName(token); |
| 1513 token = parseFormalParameters(token); | 1504 token = parseFormalParameters(token); |
| 1514 listener.handleNoInitializers(); | 1505 listener.handleNoInitializers(); |
| 1515 bool previousYieldIsKeyword = yieldIsKeyword; | 1506 bool previousAsyncAwaitKeywordsEnabled = asyncAwaitKeywordsEnabled; |
| 1516 bool previousAwaitIsKeyword = awaitIsKeyword; | |
| 1517 token = parseAsyncModifier(token); | 1507 token = parseAsyncModifier(token); |
| 1518 bool isBlock = optional('{', token); | 1508 bool isBlock = optional('{', token); |
| 1519 token = parseFunctionBody(token, true, false); | 1509 token = parseFunctionBody(token, true, false); |
| 1520 yieldIsKeyword = previousYieldIsKeyword; | 1510 asyncAwaitKeywordsEnabled = previousAsyncAwaitKeywordsEnabled; |
| 1521 awaitIsKeyword = previousAwaitIsKeyword; | |
| 1522 listener.endFunction(null, token); | 1511 listener.endFunction(null, token); |
| 1523 return isBlock ? token.next : token; | 1512 return isBlock ? token.next : token; |
| 1524 } | 1513 } |
| 1525 | 1514 |
| 1526 Token parseConstructorReference(Token token) { | 1515 Token parseConstructorReference(Token token) { |
| 1527 Token start = token; | 1516 Token start = token; |
| 1528 listener.beginConstructorReference(start); | 1517 listener.beginConstructorReference(start); |
| 1529 token = parseIdentifier(token); | 1518 token = parseIdentifier(token); |
| 1530 token = parseQualifiedRestOpt(token); | 1519 token = parseQualifiedRestOpt(token); |
| 1531 token = parseTypeArgumentsOpt(token); | 1520 token = parseTypeArgumentsOpt(token); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 ++statementCount; | 1569 ++statementCount; |
| 1581 } | 1570 } |
| 1582 listener.endFunctionBody(statementCount, begin, token); | 1571 listener.endFunctionBody(statementCount, begin, token); |
| 1583 expect('}', token); | 1572 expect('}', token); |
| 1584 return token; | 1573 return token; |
| 1585 } | 1574 } |
| 1586 | 1575 |
| 1587 Token parseAsyncModifier(Token token) { | 1576 Token parseAsyncModifier(Token token) { |
| 1588 Token async; | 1577 Token async; |
| 1589 Token star; | 1578 Token star; |
| 1590 awaitIsKeyword = false; | 1579 asyncAwaitKeywordsEnabled = false; |
| 1591 yieldIsKeyword = false; | |
| 1592 if (optional('async', token)) { | 1580 if (optional('async', token)) { |
| 1593 awaitIsKeyword = true; | 1581 asyncAwaitKeywordsEnabled = true; |
| 1594 async = token; | 1582 async = token; |
| 1595 token = token.next; | 1583 token = token.next; |
| 1596 if (optional('*', token)) { | 1584 if (optional('*', token)) { |
| 1597 yieldIsKeyword = true; | |
| 1598 star = token; | 1585 star = token; |
| 1599 token = token.next; | 1586 token = token.next; |
| 1600 } | 1587 } |
| 1601 } else if (optional('sync', token)) { | 1588 } else if (optional('sync', token)) { |
| 1602 async = token; | 1589 async = token; |
| 1603 token = token.next; | 1590 token = token.next; |
| 1604 if (optional('*', token)) { | 1591 if (optional('*', token)) { |
| 1605 yieldIsKeyword = true; | 1592 asyncAwaitKeywordsEnabled = true; |
| 1606 star = token; | 1593 star = token; |
| 1607 token = token.next; | 1594 token = token.next; |
| 1608 } else { | 1595 } else { |
| 1609 listener.reportError(async, | 1596 listener.reportError(async, |
| 1610 MessageKind.INVALID_SYNC_MODIFIER); | 1597 MessageKind.INVALID_SYNC_MODIFIER); |
| 1611 } | 1598 } |
| 1612 } | 1599 } |
| 1613 listener.handleAsyncModifier(async, star); | 1600 listener.handleAsyncModifier(async, star); |
| 1614 return token; | 1601 return token; |
| 1615 } | 1602 } |
| 1616 | 1603 |
| 1617 Token parseStatement(Token token) { | 1604 Token parseStatement(Token token) { |
| 1618 final value = token.stringValue; | 1605 final value = token.stringValue; |
| 1619 if (identical(token.kind, IDENTIFIER_TOKEN)) { | 1606 if (identical(token.kind, IDENTIFIER_TOKEN)) { |
| 1620 return parseExpressionStatementOrDeclaration(token); | 1607 return parseExpressionStatementOrDeclaration(token); |
| 1621 } else if (identical(value, '{')) { | 1608 } else if (identical(value, '{')) { |
| 1622 return parseBlock(token); | 1609 return parseBlock(token); |
| 1623 } else if (identical(value, 'return')) { | 1610 } else if (identical(value, 'return')) { |
| 1624 return parseReturnStatement(token); | 1611 return parseReturnStatement(token); |
| 1625 } else if (identical(value, 'var') || identical(value, 'final')) { | 1612 } else if (identical(value, 'var') || identical(value, 'final')) { |
| 1626 return parseVariablesDeclaration(token); | 1613 return parseVariablesDeclaration(token); |
| 1627 } else if (identical(value, 'if')) { | 1614 } else if (identical(value, 'if')) { |
| 1628 return parseIfStatement(token); | 1615 return parseIfStatement(token); |
| 1629 } else if (awaitIsKeyword && identical(value, 'await')) { | 1616 } else if (asyncAwaitKeywordsEnabled && identical(value, 'await')) { |
| 1630 if (identical(token.next.stringValue, 'for')) { | 1617 if (identical(token.next.stringValue, 'for')) { |
| 1631 return parseForStatement(token, token.next); | 1618 return parseForStatement(token, token.next); |
| 1632 } else { | 1619 } else { |
| 1633 return parseExpressionStatement(token); | 1620 return parseExpressionStatement(token); |
| 1634 } | 1621 } |
| 1635 } else if (identical(value, 'for')) { | 1622 } else if (identical(value, 'for')) { |
| 1636 return parseForStatement(null, token); | 1623 return parseForStatement(null, token); |
| 1637 } else if (identical(value, 'rethrow')) { | 1624 } else if (identical(value, 'rethrow')) { |
| 1638 return parseRethrowStatement(token); | 1625 return parseRethrowStatement(token); |
| 1639 } else if (identical(value, 'throw') && optional(';', token.next)) { | 1626 } else if (identical(value, 'throw') && optional(';', token.next)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1650 } else if (identical(value, 'switch')) { | 1637 } else if (identical(value, 'switch')) { |
| 1651 return parseSwitchStatement(token); | 1638 return parseSwitchStatement(token); |
| 1652 } else if (identical(value, 'break')) { | 1639 } else if (identical(value, 'break')) { |
| 1653 return parseBreakStatement(token); | 1640 return parseBreakStatement(token); |
| 1654 } else if (identical(value, 'continue')) { | 1641 } else if (identical(value, 'continue')) { |
| 1655 return parseContinueStatement(token); | 1642 return parseContinueStatement(token); |
| 1656 } else if (identical(value, 'assert')) { | 1643 } else if (identical(value, 'assert')) { |
| 1657 return parseAssertStatement(token); | 1644 return parseAssertStatement(token); |
| 1658 } else if (identical(value, ';')) { | 1645 } else if (identical(value, ';')) { |
| 1659 return parseEmptyStatement(token); | 1646 return parseEmptyStatement(token); |
| 1660 } else if (yieldIsKeyword && identical(value, 'yield')) { | 1647 } else if (asyncAwaitKeywordsEnabled && identical(value, 'yield')) { |
| 1661 return parseYieldStatement(token); | 1648 return parseYieldStatement(token); |
| 1662 } else if (identical(value, 'const')) { | 1649 } else if (identical(value, 'const')) { |
| 1663 return parseExpressionStatementOrConstDeclaration(token); | 1650 return parseExpressionStatementOrConstDeclaration(token); |
| 1664 } else if (token.isIdentifier()) { | 1651 } else if (token.isIdentifier()) { |
| 1665 return parseExpressionStatementOrDeclaration(token); | 1652 return parseExpressionStatementOrDeclaration(token); |
| 1666 } else { | 1653 } else { |
| 1667 return parseExpressionStatement(token); | 1654 return parseExpressionStatement(token); |
| 1668 } | 1655 } |
| 1669 } | 1656 } |
| 1670 | 1657 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 token = parseExpressionWithoutCascade(token.next); | 1919 token = parseExpressionWithoutCascade(token.next); |
| 1933 listener.handleAssignmentExpression(assignment); | 1920 listener.handleAssignmentExpression(assignment); |
| 1934 } | 1921 } |
| 1935 listener.endCascade(); | 1922 listener.endCascade(); |
| 1936 return token; | 1923 return token; |
| 1937 } | 1924 } |
| 1938 | 1925 |
| 1939 Token parseUnaryExpression(Token token, bool allowCascades) { | 1926 Token parseUnaryExpression(Token token, bool allowCascades) { |
| 1940 String value = token.stringValue; | 1927 String value = token.stringValue; |
| 1941 // Prefix: | 1928 // Prefix: |
| 1942 if (awaitIsKeyword && optional('await', token)) { | 1929 if (asyncAwaitKeywordsEnabled && optional('await', token)) { |
| 1943 return parseAwaitExpression(token, allowCascades); | 1930 return parseAwaitExpression(token, allowCascades); |
| 1944 } else if (identical(value, '+')) { | 1931 } else if (identical(value, '+')) { |
| 1945 // Dart no longer allows prefix-plus. | 1932 // Dart no longer allows prefix-plus. |
| 1946 listener.reportError(token, MessageKind.UNSUPPORTED_PREFIX_PLUS); | 1933 listener.reportError(token, MessageKind.UNSUPPORTED_PREFIX_PLUS); |
| 1947 return parseUnaryExpression(token.next, allowCascades); | 1934 return parseUnaryExpression(token.next, allowCascades); |
| 1948 } else if ((identical(value, '!')) || | 1935 } else if ((identical(value, '!')) || |
| 1949 (identical(value, '-')) || | 1936 (identical(value, '-')) || |
| 1950 (identical(value, '~'))) { | 1937 (identical(value, '~'))) { |
| 1951 Token operator = token; | 1938 Token operator = token; |
| 1952 // Right associative, so we recurse at the same precedence | 1939 // Right associative, so we recurse at the same precedence |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1983 listener.endSend(token); | 1970 listener.endSend(token); |
| 1984 } else { | 1971 } else { |
| 1985 break; | 1972 break; |
| 1986 } | 1973 } |
| 1987 } | 1974 } |
| 1988 return token; | 1975 return token; |
| 1989 } | 1976 } |
| 1990 | 1977 |
| 1991 Token parsePrimary(Token token) { | 1978 Token parsePrimary(Token token) { |
| 1992 final kind = token.kind; | 1979 final kind = token.kind; |
| 1993 if (identical(kind, IDENTIFIER_TOKEN)) { | 1980 if (kind == IDENTIFIER_TOKEN) { |
| 1994 return parseSendOrFunctionLiteral(token); | 1981 return parseSendOrFunctionLiteral(token); |
| 1995 } else if (identical(kind, INT_TOKEN) | 1982 } else if (kind == INT_TOKEN |
| 1996 || identical(kind, HEXADECIMAL_TOKEN)) { | 1983 || kind == HEXADECIMAL_TOKEN) { |
| 1997 return parseLiteralInt(token); | 1984 return parseLiteralInt(token); |
| 1998 } else if (identical(kind, DOUBLE_TOKEN)) { | 1985 } else if (kind == DOUBLE_TOKEN) { |
| 1999 return parseLiteralDouble(token); | 1986 return parseLiteralDouble(token); |
| 2000 } else if (identical(kind, STRING_TOKEN)) { | 1987 } else if (kind == STRING_TOKEN) { |
| 2001 return parseLiteralString(token); | 1988 return parseLiteralString(token); |
| 2002 } else if (identical(kind, HASH_TOKEN)) { | 1989 } else if (kind == HASH_TOKEN) { |
| 2003 return parseLiteralSymbol(token); | 1990 return parseLiteralSymbol(token); |
| 2004 } else if (identical(kind, KEYWORD_TOKEN)) { | 1991 } else if (kind == KEYWORD_TOKEN) { |
| 2005 final value = token.stringValue; | 1992 final value = token.stringValue; |
| 2006 if ((identical(value, 'true')) || (identical(value, 'false'))) { | 1993 if (value == 'true' || value == 'false') { |
| 2007 return parseLiteralBool(token); | 1994 return parseLiteralBool(token); |
| 2008 } else if (identical(value, 'null')) { | 1995 } else if (value == 'null') { |
| 2009 return parseLiteralNull(token); | 1996 return parseLiteralNull(token); |
| 2010 } else if (identical(value, 'this')) { | 1997 } else if (value == 'this') { |
| 2011 return parseThisExpression(token); | 1998 return parseThisExpression(token); |
| 2012 } else if (identical(value, 'super')) { | 1999 } else if (value == 'super') { |
| 2013 return parseSuperExpression(token); | 2000 return parseSuperExpression(token); |
| 2014 } else if (identical(value, 'new')) { | 2001 } else if (value == 'new') { |
| 2015 return parseNewExpression(token); | 2002 return parseNewExpression(token); |
| 2016 } else if (identical(value, 'const')) { | 2003 } else if (value == 'const') { |
| 2017 return parseConstExpression(token); | 2004 return parseConstExpression(token); |
| 2018 } else if (identical(value, 'void')) { | 2005 } else if (value == 'void') { |
| 2019 return parseFunctionExpression(token); | 2006 return parseFunctionExpression(token); |
| 2007 } else if (asyncAwaitKeywordsEnabled && |
| 2008 (value == 'yield' || value == 'async')) { |
| 2009 return listener.expectedExpression(token); |
| 2020 } else if (token.isIdentifier()) { | 2010 } else if (token.isIdentifier()) { |
| 2021 return parseSendOrFunctionLiteral(token); | 2011 return parseSendOrFunctionLiteral(token); |
| 2022 } else { | 2012 } else { |
| 2023 return listener.expectedExpression(token); | 2013 return listener.expectedExpression(token); |
| 2024 } | 2014 } |
| 2025 } else if (identical(kind, OPEN_PAREN_TOKEN)) { | 2015 } else if (kind == OPEN_PAREN_TOKEN) { |
| 2026 return parseParenthesizedExpressionOrFunctionLiteral(token); | 2016 return parseParenthesizedExpressionOrFunctionLiteral(token); |
| 2027 } else if ((identical(kind, LT_TOKEN)) || | 2017 } else if ((kind == LT_TOKEN) || |
| 2028 (identical(kind, OPEN_SQUARE_BRACKET_TOKEN)) || | 2018 (kind == OPEN_SQUARE_BRACKET_TOKEN) || |
| 2029 (identical(kind, OPEN_CURLY_BRACKET_TOKEN)) || | 2019 (kind == OPEN_CURLY_BRACKET_TOKEN) || |
| 2030 identical(token.stringValue, '[]')) { | 2020 token.stringValue == '[]') { |
| 2031 return parseLiteralListOrMap(token); | 2021 return parseLiteralListOrMap(token); |
| 2032 } else { | 2022 } else { |
| 2033 return listener.expectedExpression(token); | 2023 return listener.expectedExpression(token); |
| 2034 } | 2024 } |
| 2035 } | 2025 } |
| 2036 | 2026 |
| 2037 Token parseParenthesizedExpressionOrFunctionLiteral(Token token) { | 2027 Token parseParenthesizedExpressionOrFunctionLiteral(Token token) { |
| 2038 BeginGroupToken beginGroup = token; | 2028 BeginGroupToken beginGroup = token; |
| 2039 Token nextToken = beginGroup.endGroup.next; | 2029 Token nextToken = beginGroup.endGroup.next; |
| 2040 int kind = nextToken.kind; | 2030 int kind = nextToken.kind; |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2744 } | 2734 } |
| 2745 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2735 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2746 return expectSemicolon(token); | 2736 return expectSemicolon(token); |
| 2747 } | 2737 } |
| 2748 | 2738 |
| 2749 Token parseEmptyStatement(Token token) { | 2739 Token parseEmptyStatement(Token token) { |
| 2750 listener.handleEmptyStatement(token); | 2740 listener.handleEmptyStatement(token); |
| 2751 return expectSemicolon(token); | 2741 return expectSemicolon(token); |
| 2752 } | 2742 } |
| 2753 } | 2743 } |
| OLD | NEW |