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

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

Issue 107833002: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/lib/src/generated/resolver.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 // 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 'instrumentation.dart'; 8 import 'instrumentation.dart';
9 import 'error.dart'; 9 import 'error.dart';
10 import 'source.dart'; 10 import 'source.dart';
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 * The source being parsed. 1298 * The source being parsed.
1299 */ 1299 */
1300 Source _source; 1300 Source _source;
1301 1301
1302 /** 1302 /**
1303 * The error listener that will be informed of any errors that are found durin g the parse. 1303 * The error listener that will be informed of any errors that are found durin g the parse.
1304 */ 1304 */
1305 AnalysisErrorListener _errorListener; 1305 AnalysisErrorListener _errorListener;
1306 1306
1307 /** 1307 /**
1308 * An [errorListener] lock, if more than `0`, then errors are not reported.
1309 */
1310 int _errorListenerLock = 0;
1311
1312 /**
1313 * A flag indicating whether parser is to parse function bodies.
1314 */
1315 bool _parseFunctionBodies = true;
1316
1317 /**
1308 * The next token to be parsed. 1318 * The next token to be parsed.
1309 */ 1319 */
1310 Token _currentToken; 1320 Token _currentToken;
1311 1321
1312 /** 1322 /**
1313 * A flag indicating whether the parser is currently in the body of a loop. 1323 * A flag indicating whether the parser is currently in the body of a loop.
1314 */ 1324 */
1315 bool _inLoop = false; 1325 bool _inLoop = false;
1316 1326
1317 /** 1327 /**
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.Parser.parseStatements"); 1412 InstrumentationBuilder instrumentation = Instrumentation.builder2("dart.engi ne.Parser.parseStatements");
1403 try { 1413 try {
1404 _currentToken = token; 1414 _currentToken = token;
1405 return parseStatements2(); 1415 return parseStatements2();
1406 } finally { 1416 } finally {
1407 instrumentation.log(); 1417 instrumentation.log();
1408 } 1418 }
1409 } 1419 }
1410 1420
1411 /** 1421 /**
1422 * Set whether parser is to parse function bodies.
1423 *
1424 * @param parseFunctionBodies `true` if parser is to parse function bodies
1425 */
1426 void set parseFunctionBodies(bool parseFunctionBodies) {
1427 this._parseFunctionBodies = parseFunctionBodies;
1428 }
1429
1430 /**
1412 * Parse an annotation. 1431 * Parse an annotation.
1413 * 1432 *
1414 * <pre> 1433 * <pre>
1415 * annotation ::= 1434 * annotation ::=
1416 * '@' qualified ('.' identifier)? arguments? 1435 * '@' qualified ('.' identifier)? arguments?
1417 * </pre> 1436 * </pre>
1418 * 1437 *
1419 * @return the annotation that was parsed 1438 * @return the annotation that was parsed
1420 */ 1439 */
1421 Annotation parseAnnotation() { 1440 Annotation parseAnnotation() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 } 1497 }
1479 Expression argument = parseArgument(); 1498 Expression argument = parseArgument();
1480 arguments.add(argument); 1499 arguments.add(argument);
1481 bool foundNamedArgument = argument is NamedExpression; 1500 bool foundNamedArgument = argument is NamedExpression;
1482 bool generatedError = false; 1501 bool generatedError = false;
1483 while (optional(TokenType.COMMA)) { 1502 while (optional(TokenType.COMMA)) {
1484 argument = parseArgument(); 1503 argument = parseArgument();
1485 arguments.add(argument); 1504 arguments.add(argument);
1486 if (foundNamedArgument) { 1505 if (foundNamedArgument) {
1487 if (!generatedError && argument is! NamedExpression) { 1506 if (!generatedError && argument is! NamedExpression) {
1488 reportError9(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, []); 1507 reportError10(ParserErrorCode.POSITIONAL_AFTER_NAMED_ARGUMENT, []);
1489 generatedError = true; 1508 generatedError = true;
1490 } 1509 }
1491 } else if (argument is NamedExpression) { 1510 } else if (argument is NamedExpression) {
1492 foundNamedArgument = true; 1511 foundNamedArgument = true;
1493 } 1512 }
1494 } 1513 }
1495 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 1514 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
1496 return new ArgumentList.full(leftParenthesis, arguments, rightParenthesis); 1515 return new ArgumentList.full(leftParenthesis, arguments, rightParenthesis);
1497 } 1516 }
1498 1517
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 Block parseBlock() { 1553 Block parseBlock() {
1535 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); 1554 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET);
1536 List<Statement> statements = new List<Statement>(); 1555 List<Statement> statements = new List<Statement>();
1537 Token statementStart = _currentToken; 1556 Token statementStart = _currentToken;
1538 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)) { 1557 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET)) {
1539 Statement statement = parseStatement2(); 1558 Statement statement = parseStatement2();
1540 if (statement != null) { 1559 if (statement != null) {
1541 statements.add(statement); 1560 statements.add(statement);
1542 } 1561 }
1543 if (identical(_currentToken, statementStart)) { 1562 if (identical(_currentToken, statementStart)) {
1544 reportError10(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]); 1563 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]);
1545 advance(); 1564 advance();
1546 } 1565 }
1547 statementStart = _currentToken; 1566 statementStart = _currentToken;
1548 } 1567 }
1549 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); 1568 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET);
1550 return new Block.full(leftBracket, statements, rightBracket); 1569 return new Block.full(leftBracket, statements, rightBracket);
1551 } 1570 }
1552 1571
1553 /** 1572 /**
1554 * Parse a class member. 1573 * Parse a class member.
(...skipping 24 matching lines...) Expand all
1579 return parseOperator(commentAndMetadata, modifiers.externalKeyword, retu rnType); 1598 return parseOperator(commentAndMetadata, modifiers.externalKeyword, retu rnType);
1580 } else if (matchesIdentifier() && matchesAny(peek(), [ 1599 } else if (matchesIdentifier() && matchesAny(peek(), [
1581 TokenType.OPEN_PAREN, 1600 TokenType.OPEN_PAREN,
1582 TokenType.OPEN_CURLY_BRACKET, 1601 TokenType.OPEN_CURLY_BRACKET,
1583 TokenType.FUNCTION])) { 1602 TokenType.FUNCTION])) {
1584 validateModifiersForGetterOrSetterOrMethod(modifiers); 1603 validateModifiersForGetterOrSetterOrMethod(modifiers);
1585 return parseMethodDeclaration(commentAndMetadata, modifiers.externalKeyw ord, modifiers.staticKeyword, returnType); 1604 return parseMethodDeclaration(commentAndMetadata, modifiers.externalKeyw ord, modifiers.staticKeyword, returnType);
1586 } else { 1605 } else {
1587 if (matchesIdentifier()) { 1606 if (matchesIdentifier()) {
1588 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC OLON])) { 1607 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC OLON])) {
1589 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); 1608 reportError9(ParserErrorCode.VOID_VARIABLE, returnType, []);
1590 return parseInitializedIdentifierList(commentAndMetadata, modifiers. staticKeyword, validateModifiersForField(modifiers), returnType); 1609 return parseInitializedIdentifierList(commentAndMetadata, modifiers. staticKeyword, validateModifiersForField(modifiers), returnType);
1591 } 1610 }
1592 } 1611 }
1593 if (isOperator(_currentToken)) { 1612 if (isOperator(_currentToken)) {
1594 validateModifiersForOperator(modifiers); 1613 validateModifiersForOperator(modifiers);
1595 return parseOperator(commentAndMetadata, modifiers.externalKeyword, re turnType); 1614 return parseOperator(commentAndMetadata, modifiers.externalKeyword, re turnType);
1596 } 1615 }
1597 reportError10(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []); 1616 reportError11(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []);
1598 return null; 1617 return null;
1599 } 1618 }
1600 } else if (matches(Keyword.GET) && matchesIdentifier2(peek())) { 1619 } else if (matches(Keyword.GET) && matchesIdentifier2(peek())) {
1601 validateModifiersForGetterOrSetterOrMethod(modifiers); 1620 validateModifiersForGetterOrSetterOrMethod(modifiers);
1602 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, null); 1621 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, null);
1603 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { 1622 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) {
1604 validateModifiersForGetterOrSetterOrMethod(modifiers); 1623 validateModifiersForGetterOrSetterOrMethod(modifiers);
1605 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, null); 1624 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, null);
1606 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { 1625 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) {
1607 validateModifiersForOperator(modifiers); 1626 validateModifiersForOperator(modifiers);
1608 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null); 1627 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null);
1609 } else if (!matchesIdentifier()) { 1628 } else if (!matchesIdentifier()) {
1610 if (isOperator(_currentToken)) { 1629 if (isOperator(_currentToken)) {
1611 validateModifiersForOperator(modifiers); 1630 validateModifiersForOperator(modifiers);
1612 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null ); 1631 return parseOperator(commentAndMetadata, modifiers.externalKeyword, null );
1613 } 1632 }
1614 reportError10(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []); 1633 reportError11(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []);
1615 return null; 1634 return null;
1616 } else if (matches4(peek(), TokenType.PERIOD) && matchesIdentifier2(peek2(2) ) && matches4(peek2(3), TokenType.OPEN_PAREN)) { 1635 } else if (matches4(peek(), TokenType.PERIOD) && matchesIdentifier2(peek2(2) ) && matches4(peek2(3), TokenType.OPEN_PAREN)) {
1617 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList()); 1636 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, val idateModifiersForConstructor(modifiers), modifiers.factoryKeyword, parseSimpleId entifier(), andAdvance, parseSimpleIdentifier(), parseFormalParameterList());
1618 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { 1637 } else if (matches4(peek(), TokenType.OPEN_PAREN)) {
1619 SimpleIdentifier methodName = parseSimpleIdentifier(); 1638 SimpleIdentifier methodName = parseSimpleIdentifier();
1620 FormalParameterList parameters = parseFormalParameterList(); 1639 FormalParameterList parameters = parseFormalParameterList();
1621 if (matches5(TokenType.COLON) || modifiers.factoryKeyword != null || metho dName.name == className) { 1640 if (matches5(TokenType.COLON) || modifiers.factoryKeyword != null || metho dName.name == className) {
1622 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName, null, null, parameters); 1641 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName, null, null, parameters);
1623 } 1642 }
1624 validateModifiersForGetterOrSetterOrMethod(modifiers); 1643 validateModifiersForGetterOrSetterOrMethod(modifiers);
1625 validateFormalParameterList(parameters); 1644 validateFormalParameterList(parameters);
1626 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo rd, modifiers.staticKeyword, null, methodName, parameters); 1645 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo rd, modifiers.staticKeyword, null, methodName, parameters);
1627 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) { 1646 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) {
1628 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo difiers.varKeyword == null) { 1647 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo difiers.varKeyword == null) {
1629 reportError9(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []); 1648 reportError10(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []);
1630 } 1649 }
1631 return parseInitializedIdentifierList(commentAndMetadata, modifiers.static Keyword, validateModifiersForField(modifiers), null); 1650 return parseInitializedIdentifierList(commentAndMetadata, modifiers.static Keyword, validateModifiersForField(modifiers), null);
1632 } 1651 }
1633 TypeName type = parseTypeName(); 1652 TypeName type = parseTypeName();
1634 if (matches(Keyword.GET) && matchesIdentifier2(peek())) { 1653 if (matches(Keyword.GET) && matchesIdentifier2(peek())) {
1635 validateModifiersForGetterOrSetterOrMethod(modifiers); 1654 validateModifiersForGetterOrSetterOrMethod(modifiers);
1636 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, type); 1655 return parseGetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, type);
1637 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) { 1656 } else if (matches(Keyword.SET) && matchesIdentifier2(peek())) {
1638 validateModifiersForGetterOrSetterOrMethod(modifiers); 1657 validateModifiersForGetterOrSetterOrMethod(modifiers);
1639 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, type); 1658 return parseSetter(commentAndMetadata, modifiers.externalKeyword, modifier s.staticKeyword, type);
1640 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { 1659 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) {
1641 validateModifiersForOperator(modifiers); 1660 validateModifiersForOperator(modifiers);
1642 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type); 1661 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type);
1643 } else if (!matchesIdentifier()) { 1662 } else if (!matchesIdentifier()) {
1644 if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 1663 if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
1645 return parseInitializedIdentifierList(commentAndMetadata, modifiers.stat icKeyword, validateModifiersForField(modifiers), type); 1664 return parseInitializedIdentifierList(commentAndMetadata, modifiers.stat icKeyword, validateModifiersForField(modifiers), type);
1646 } 1665 }
1647 if (isOperator(_currentToken)) { 1666 if (isOperator(_currentToken)) {
1648 validateModifiersForOperator(modifiers); 1667 validateModifiersForOperator(modifiers);
1649 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type ); 1668 return parseOperator(commentAndMetadata, modifiers.externalKeyword, type );
1650 } 1669 }
1651 reportError10(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []); 1670 reportError11(ParserErrorCode.EXPECTED_CLASS_MEMBER, _currentToken, []);
1652 return null; 1671 try {
1672 lockErrorListener();
1673 return parseInitializedIdentifierList(commentAndMetadata, modifiers.stat icKeyword, validateModifiersForField(modifiers), type);
1674 } finally {
1675 unlockErrorListener();
1676 }
1653 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { 1677 } else if (matches4(peek(), TokenType.OPEN_PAREN)) {
1654 SimpleIdentifier methodName = parseSimpleIdentifier(); 1678 SimpleIdentifier methodName = parseSimpleIdentifier();
1655 FormalParameterList parameters = parseFormalParameterList(); 1679 FormalParameterList parameters = parseFormalParameterList();
1656 if (methodName.name == className) { 1680 if (methodName.name == className) {
1657 reportError(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type, []); 1681 reportError9(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, type, []);
1658 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName, null, null, parameters); 1682 return parseConstructor(commentAndMetadata, modifiers.externalKeyword, v alidateModifiersForConstructor(modifiers), modifiers.factoryKeyword, methodName, null, null, parameters);
1659 } 1683 }
1660 validateModifiersForGetterOrSetterOrMethod(modifiers); 1684 validateModifiersForGetterOrSetterOrMethod(modifiers);
1661 validateFormalParameterList(parameters); 1685 validateFormalParameterList(parameters);
1662 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo rd, modifiers.staticKeyword, type, methodName, parameters); 1686 return parseMethodDeclaration2(commentAndMetadata, modifiers.externalKeywo rd, modifiers.staticKeyword, type, methodName, parameters);
1663 } 1687 }
1664 return parseInitializedIdentifierList(commentAndMetadata, modifiers.staticKe yword, validateModifiersForField(modifiers), type); 1688 return parseInitializedIdentifierList(commentAndMetadata, modifiers.staticKe yword, validateModifiersForField(modifiers), type);
1665 } 1689 }
1666 1690
1667 /** 1691 /**
(...skipping 29 matching lines...) Expand all
1697 bool partDirectiveFound = false; 1721 bool partDirectiveFound = false;
1698 bool directiveFoundAfterDeclaration = false; 1722 bool directiveFoundAfterDeclaration = false;
1699 List<Directive> directives = new List<Directive>(); 1723 List<Directive> directives = new List<Directive>();
1700 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>() ; 1724 List<CompilationUnitMember> declarations = new List<CompilationUnitMember>() ;
1701 Token memberStart = _currentToken; 1725 Token memberStart = _currentToken;
1702 while (!matches5(TokenType.EOF)) { 1726 while (!matches5(TokenType.EOF)) {
1703 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata(); 1727 CommentAndMetadata commentAndMetadata = parseCommentAndMetadata();
1704 if ((matches(Keyword.IMPORT) || matches(Keyword.EXPORT) || matches(Keyword .LIBRARY) || matches(Keyword.PART)) && !matches4(peek(), TokenType.PERIOD) && !m atches4(peek(), TokenType.LT) && !matches4(peek(), TokenType.OPEN_PAREN)) { 1728 if ((matches(Keyword.IMPORT) || matches(Keyword.EXPORT) || matches(Keyword .LIBRARY) || matches(Keyword.PART)) && !matches4(peek(), TokenType.PERIOD) && !m atches4(peek(), TokenType.LT) && !matches4(peek(), TokenType.OPEN_PAREN)) {
1705 Directive directive = parseDirective(commentAndMetadata); 1729 Directive directive = parseDirective(commentAndMetadata);
1706 if (declarations.length > 0 && !directiveFoundAfterDeclaration) { 1730 if (declarations.length > 0 && !directiveFoundAfterDeclaration) {
1707 reportError9(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, []); 1731 reportError10(ParserErrorCode.DIRECTIVE_AFTER_DECLARATION, []);
1708 directiveFoundAfterDeclaration = true; 1732 directiveFoundAfterDeclaration = true;
1709 } 1733 }
1710 if (directive is LibraryDirective) { 1734 if (directive is LibraryDirective) {
1711 if (libraryDirectiveFound) { 1735 if (libraryDirectiveFound) {
1712 reportError9(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, []); 1736 reportError10(ParserErrorCode.MULTIPLE_LIBRARY_DIRECTIVES, []);
1713 } else { 1737 } else {
1714 if (directives.length > 0) { 1738 if (directives.length > 0) {
1715 reportError9(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, []); 1739 reportError10(ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, []);
1716 } 1740 }
1717 libraryDirectiveFound = true; 1741 libraryDirectiveFound = true;
1718 } 1742 }
1719 } else if (directive is PartDirective) { 1743 } else if (directive is PartDirective) {
1720 partDirectiveFound = true; 1744 partDirectiveFound = true;
1721 } else if (partDirectiveFound) { 1745 } else if (partDirectiveFound) {
1722 if (directive is ExportDirective) { 1746 if (directive is ExportDirective) {
1723 reportError10(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []); 1747 reportError11(ParserErrorCode.EXPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []);
1724 } else if (directive is ImportDirective) { 1748 } else if (directive is ImportDirective) {
1725 reportError10(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []); 1749 reportError11(ParserErrorCode.IMPORT_DIRECTIVE_AFTER_PART_DIRECTIVE, (directive as NamespaceDirective).keyword, []);
1726 } 1750 }
1727 } 1751 }
1728 if (directive is PartOfDirective) { 1752 if (directive is PartOfDirective) {
1729 if (partOfDirectiveFound) { 1753 if (partOfDirectiveFound) {
1730 reportError9(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []); 1754 reportError10(ParserErrorCode.MULTIPLE_PART_OF_DIRECTIVES, []);
1731 } else { 1755 } else {
1732 int directiveCount = directives.length; 1756 int directiveCount = directives.length;
1733 for (int i = 0; i < directiveCount; i++) { 1757 for (int i = 0; i < directiveCount; i++) {
1734 reportError10(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, direc tives[i].keyword, []); 1758 reportError11(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, direc tives[i].keyword, []);
1735 } 1759 }
1736 partOfDirectiveFound = true; 1760 partOfDirectiveFound = true;
1737 } 1761 }
1738 } else { 1762 } else {
1739 if (partOfDirectiveFound) { 1763 if (partOfDirectiveFound) {
1740 reportError10(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directi ve.keyword, []); 1764 reportError11(ParserErrorCode.NON_PART_OF_DIRECTIVE_IN_PART, directi ve.keyword, []);
1741 } 1765 }
1742 } 1766 }
1743 directives.add(directive); 1767 directives.add(directive);
1744 } else if (matches5(TokenType.SEMICOLON)) { 1768 } else if (matches5(TokenType.SEMICOLON)) {
1745 reportError10(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]); 1769 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]);
1746 advance(); 1770 advance();
1747 } else { 1771 } else {
1748 CompilationUnitMember member = parseCompilationUnitMember(commentAndMeta data); 1772 CompilationUnitMember member = parseCompilationUnitMember(commentAndMeta data);
1749 if (member != null) { 1773 if (member != null) {
1750 declarations.add(member); 1774 declarations.add(member);
1751 } 1775 }
1752 } 1776 }
1753 if (identical(_currentToken, memberStart)) { 1777 if (identical(_currentToken, memberStart)) {
1754 reportError10(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]); 1778 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]);
1755 advance(); 1779 advance();
1756 while (!matches5(TokenType.EOF) && !couldBeStartOfCompilationUnitMember( )) { 1780 while (!matches5(TokenType.EOF) && !couldBeStartOfCompilationUnitMember( )) {
1757 advance(); 1781 advance();
1758 } 1782 }
1759 } 1783 }
1760 memberStart = _currentToken; 1784 memberStart = _currentToken;
1761 } 1785 }
1762 return new CompilationUnit.full(firstToken, scriptTag, directives, declarati ons, _currentToken); 1786 return new CompilationUnit.full(firstToken, scriptTag, directives, declarati ons, _currentToken);
1763 } 1787 }
1764 1788
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1930 bool reportedMuliplePositionalGroups = false; 1954 bool reportedMuliplePositionalGroups = false;
1931 bool reportedMulipleNamedGroups = false; 1955 bool reportedMulipleNamedGroups = false;
1932 bool reportedMixedGroups = false; 1956 bool reportedMixedGroups = false;
1933 bool wasOptionalParameter = false; 1957 bool wasOptionalParameter = false;
1934 Token initialToken = null; 1958 Token initialToken = null;
1935 do { 1959 do {
1936 if (firstParameter) { 1960 if (firstParameter) {
1937 firstParameter = false; 1961 firstParameter = false;
1938 } else if (!optional(TokenType.COMMA)) { 1962 } else if (!optional(TokenType.COMMA)) {
1939 if (getEndToken(leftParenthesis) != null) { 1963 if (getEndToken(leftParenthesis) != null) {
1940 reportError9(ParserErrorCode.EXPECTED_TOKEN, [TokenType.COMMA.lexeme]) ; 1964 reportError10(ParserErrorCode.EXPECTED_TOKEN, [TokenType.COMMA.lexeme] );
1941 } else { 1965 } else {
1942 reportError10(ParserErrorCode.MISSING_CLOSING_PARENTHESIS, _currentTok en.previous, []); 1966 reportError11(ParserErrorCode.MISSING_CLOSING_PARENTHESIS, _currentTok en.previous, []);
1943 break; 1967 break;
1944 } 1968 }
1945 } 1969 }
1946 initialToken = _currentToken; 1970 initialToken = _currentToken;
1947 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { 1971 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) {
1948 wasOptionalParameter = true; 1972 wasOptionalParameter = true;
1949 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) { 1973 if (leftSquareBracket != null && !reportedMuliplePositionalGroups) {
1950 reportError9(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, []) ; 1974 reportError10(ParserErrorCode.MULTIPLE_POSITIONAL_PARAMETER_GROUPS, [] );
1951 reportedMuliplePositionalGroups = true; 1975 reportedMuliplePositionalGroups = true;
1952 } 1976 }
1953 if (leftCurlyBracket != null && !reportedMixedGroups) { 1977 if (leftCurlyBracket != null && !reportedMixedGroups) {
1954 reportError9(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); 1978 reportError10(ParserErrorCode.MIXED_PARAMETER_GROUPS, []);
1955 reportedMixedGroups = true; 1979 reportedMixedGroups = true;
1956 } 1980 }
1957 leftSquareBracket = andAdvance; 1981 leftSquareBracket = andAdvance;
1958 currentParameters = positionalParameters; 1982 currentParameters = positionalParameters;
1959 kind = ParameterKind.POSITIONAL; 1983 kind = ParameterKind.POSITIONAL;
1960 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 1984 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
1961 wasOptionalParameter = true; 1985 wasOptionalParameter = true;
1962 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) { 1986 if (leftCurlyBracket != null && !reportedMulipleNamedGroups) {
1963 reportError9(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, []); 1987 reportError10(ParserErrorCode.MULTIPLE_NAMED_PARAMETER_GROUPS, []);
1964 reportedMulipleNamedGroups = true; 1988 reportedMulipleNamedGroups = true;
1965 } 1989 }
1966 if (leftSquareBracket != null && !reportedMixedGroups) { 1990 if (leftSquareBracket != null && !reportedMixedGroups) {
1967 reportError9(ParserErrorCode.MIXED_PARAMETER_GROUPS, []); 1991 reportError10(ParserErrorCode.MIXED_PARAMETER_GROUPS, []);
1968 reportedMixedGroups = true; 1992 reportedMixedGroups = true;
1969 } 1993 }
1970 leftCurlyBracket = andAdvance; 1994 leftCurlyBracket = andAdvance;
1971 currentParameters = namedParameters; 1995 currentParameters = namedParameters;
1972 kind = ParameterKind.NAMED; 1996 kind = ParameterKind.NAMED;
1973 } 1997 }
1974 FormalParameter parameter = parseFormalParameter(kind); 1998 FormalParameter parameter = parseFormalParameter(kind);
1975 parameters.add(parameter); 1999 parameters.add(parameter);
1976 currentParameters.add(parameter); 2000 currentParameters.add(parameter);
1977 if (identical(kind, ParameterKind.REQUIRED) && wasOptionalParameter) { 2001 if (identical(kind, ParameterKind.REQUIRED) && wasOptionalParameter) {
1978 reportError(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, parameter , []); 2002 reportError9(ParserErrorCode.NORMAL_BEFORE_OPTIONAL_PARAMETERS, paramete r, []);
1979 } 2003 }
1980 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) { 2004 if (matches5(TokenType.CLOSE_SQUARE_BRACKET)) {
1981 rightSquareBracket = andAdvance; 2005 rightSquareBracket = andAdvance;
1982 currentParameters = normalParameters; 2006 currentParameters = normalParameters;
1983 if (leftSquareBracket == null) { 2007 if (leftSquareBracket == null) {
1984 if (leftCurlyBracket != null) { 2008 if (leftCurlyBracket != null) {
1985 reportError9(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [ "}"]); 2009 reportError10(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["}"]);
1986 rightCurlyBracket = rightSquareBracket; 2010 rightCurlyBracket = rightSquareBracket;
1987 rightSquareBracket = null; 2011 rightSquareBracket = null;
1988 } else { 2012 } else {
1989 reportError9(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO UP, ["["]); 2013 reportError10(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GR OUP, ["["]);
1990 } 2014 }
1991 } 2015 }
1992 kind = ParameterKind.REQUIRED; 2016 kind = ParameterKind.REQUIRED;
1993 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 2017 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
1994 rightCurlyBracket = andAdvance; 2018 rightCurlyBracket = andAdvance;
1995 currentParameters = normalParameters; 2019 currentParameters = normalParameters;
1996 if (leftCurlyBracket == null) { 2020 if (leftCurlyBracket == null) {
1997 if (leftSquareBracket != null) { 2021 if (leftSquareBracket != null) {
1998 reportError9(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, [ "]"]); 2022 reportError10(ParserErrorCode.WRONG_TERMINATOR_FOR_PARAMETER_GROUP, ["]"]);
1999 rightSquareBracket = rightCurlyBracket; 2023 rightSquareBracket = rightCurlyBracket;
2000 rightCurlyBracket = null; 2024 rightCurlyBracket = null;
2001 } else { 2025 } else {
2002 reportError9(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GRO UP, ["{"]); 2026 reportError10(ParserErrorCode.UNEXPECTED_TERMINATOR_FOR_PARAMETER_GR OUP, ["{"]);
2003 } 2027 }
2004 } 2028 }
2005 kind = ParameterKind.REQUIRED; 2029 kind = ParameterKind.REQUIRED;
2006 } 2030 }
2007 } while (!matches5(TokenType.CLOSE_PAREN) && initialToken != _currentToken); 2031 } while (!matches5(TokenType.CLOSE_PAREN) && initialToken != _currentToken);
2008 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 2032 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
2009 if (leftSquareBracket != null && rightSquareBracket == null) { 2033 if (leftSquareBracket != null && rightSquareBracket == null) {
2010 reportError9(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["]"] ); 2034 reportError10(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["]" ]);
2011 } 2035 }
2012 if (leftCurlyBracket != null && rightCurlyBracket == null) { 2036 if (leftCurlyBracket != null && rightCurlyBracket == null) {
2013 reportError9(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["}"] ); 2037 reportError10(ParserErrorCode.MISSING_TERMINATOR_FOR_PARAMETER_GROUP, ["}" ]);
2014 } 2038 }
2015 if (leftSquareBracket == null) { 2039 if (leftSquareBracket == null) {
2016 leftSquareBracket = leftCurlyBracket; 2040 leftSquareBracket = leftCurlyBracket;
2017 } 2041 }
2018 if (rightSquareBracket == null) { 2042 if (rightSquareBracket == null) {
2019 rightSquareBracket = rightCurlyBracket; 2043 rightSquareBracket = rightCurlyBracket;
2020 } 2044 }
2021 return new FormalParameterList.full(leftParenthesis, parameters, leftSquareB racket, rightSquareBracket, rightParenthesis); 2045 return new FormalParameterList.full(leftParenthesis, parameters, leftSquareB racket, rightSquareBracket, rightParenthesis);
2022 } 2046 }
2023 2047
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2159 Token period = null; 2183 Token period = null;
2160 if (matches(Keyword.THIS)) { 2184 if (matches(Keyword.THIS)) {
2161 thisKeyword = andAdvance; 2185 thisKeyword = andAdvance;
2162 period = expect2(TokenType.PERIOD); 2186 period = expect2(TokenType.PERIOD);
2163 } 2187 }
2164 SimpleIdentifier identifier = parseSimpleIdentifier(); 2188 SimpleIdentifier identifier = parseSimpleIdentifier();
2165 if (matches5(TokenType.OPEN_PAREN)) { 2189 if (matches5(TokenType.OPEN_PAREN)) {
2166 FormalParameterList parameters = parseFormalParameterList(); 2190 FormalParameterList parameters = parseFormalParameterList();
2167 if (thisKeyword == null) { 2191 if (thisKeyword == null) {
2168 if (holder.keyword != null) { 2192 if (holder.keyword != null) {
2169 reportError10(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.key word, []); 2193 reportError11(ParserErrorCode.FUNCTION_TYPED_PARAMETER_VAR, holder.key word, []);
2170 } 2194 }
2171 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, commentAndMetadata.metadata, holder.type, identifier, parameters); 2195 return new FunctionTypedFormalParameter.full(commentAndMetadata.comment, commentAndMetadata.metadata, holder.type, identifier, parameters);
2172 } else { 2196 } else {
2173 return new FieldFormalParameter.full(commentAndMetadata.comment, comment AndMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifi er, parameters); 2197 return new FieldFormalParameter.full(commentAndMetadata.comment, comment AndMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifi er, parameters);
2174 } 2198 }
2175 } 2199 }
2176 TypeName type = holder.type; 2200 TypeName type = holder.type;
2177 if (type != null) { 2201 if (type != null) {
2178 if (matches3(type.name.beginToken, Keyword.VOID)) { 2202 if (matches3(type.name.beginToken, Keyword.VOID)) {
2179 reportError10(ParserErrorCode.VOID_PARAMETER, type.name.beginToken, []); 2203 reportError11(ParserErrorCode.VOID_PARAMETER, type.name.beginToken, []);
2180 } else if (holder.keyword != null && matches3(holder.keyword, Keyword.VAR) ) { 2204 } else if (holder.keyword != null && matches3(holder.keyword, Keyword.VAR) ) {
2181 reportError10(ParserErrorCode.VAR_AND_TYPE, holder.keyword, []); 2205 reportError11(ParserErrorCode.VAR_AND_TYPE, holder.keyword, []);
2182 } 2206 }
2183 } 2207 }
2184 if (thisKeyword != null) { 2208 if (thisKeyword != null) {
2185 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier , null); 2209 return new FieldFormalParameter.full(commentAndMetadata.comment, commentAn dMetadata.metadata, holder.keyword, holder.type, thisKeyword, period, identifier , null);
2186 } 2210 }
2187 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd Metadata.metadata, holder.keyword, holder.type, identifier); 2211 return new SimpleFormalParameter.full(commentAndMetadata.comment, commentAnd Metadata.metadata, holder.keyword, holder.type, identifier);
2188 } 2212 }
2189 2213
2190 /** 2214 /**
2191 * Parse a prefixed identifier. 2215 * Parse a prefixed identifier.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2233 * identifier ::= 2257 * identifier ::=
2234 * IDENTIFIER 2258 * IDENTIFIER
2235 * </pre> 2259 * </pre>
2236 * 2260 *
2237 * @return the simple identifier that was parsed 2261 * @return the simple identifier that was parsed
2238 */ 2262 */
2239 SimpleIdentifier parseSimpleIdentifier() { 2263 SimpleIdentifier parseSimpleIdentifier() {
2240 if (matchesIdentifier()) { 2264 if (matchesIdentifier()) {
2241 return new SimpleIdentifier.full(andAdvance); 2265 return new SimpleIdentifier.full(andAdvance);
2242 } 2266 }
2243 reportError9(ParserErrorCode.MISSING_IDENTIFIER, []); 2267 reportError10(ParserErrorCode.MISSING_IDENTIFIER, []);
2244 return createSyntheticIdentifier(); 2268 return createSyntheticIdentifier();
2245 } 2269 }
2246 2270
2247 /** 2271 /**
2248 * Parse a statement. 2272 * Parse a statement.
2249 * 2273 *
2250 * <pre> 2274 * <pre>
2251 * statement ::= 2275 * statement ::=
2252 * label* nonLabeledStatement 2276 * label* nonLabeledStatement
2253 * </pre> 2277 * </pre>
(...skipping 27 matching lines...) Expand all
2281 List<StringLiteral> strings = new List<StringLiteral>(); 2305 List<StringLiteral> strings = new List<StringLiteral>();
2282 while (matches5(TokenType.STRING)) { 2306 while (matches5(TokenType.STRING)) {
2283 Token string = andAdvance; 2307 Token string = andAdvance;
2284 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches5(TokenT ype.STRING_INTERPOLATION_IDENTIFIER)) { 2308 if (matches5(TokenType.STRING_INTERPOLATION_EXPRESSION) || matches5(TokenT ype.STRING_INTERPOLATION_IDENTIFIER)) {
2285 strings.add(parseStringInterpolation(string)); 2309 strings.add(parseStringInterpolation(string));
2286 } else { 2310 } else {
2287 strings.add(new SimpleStringLiteral.full(string, computeStringValue(stri ng.lexeme, true, true))); 2311 strings.add(new SimpleStringLiteral.full(string, computeStringValue(stri ng.lexeme, true, true)));
2288 } 2312 }
2289 } 2313 }
2290 if (strings.length < 1) { 2314 if (strings.length < 1) {
2291 reportError9(ParserErrorCode.EXPECTED_STRING_LITERAL, []); 2315 reportError10(ParserErrorCode.EXPECTED_STRING_LITERAL, []);
2292 return createSyntheticStringLiteral(); 2316 return createSyntheticStringLiteral();
2293 } else if (strings.length == 1) { 2317 } else if (strings.length == 1) {
2294 return strings[0]; 2318 return strings[0];
2295 } else { 2319 } else {
2296 return new AdjacentStrings.full(strings); 2320 return new AdjacentStrings.full(strings);
2297 } 2321 }
2298 } 2322 }
2299 2323
2300 /** 2324 /**
2301 * Parse a list of type arguments. 2325 * Parse a list of type arguments.
(...skipping 25 matching lines...) Expand all
2327 * <pre> 2351 * <pre>
2328 * type ::= 2352 * type ::=
2329 * qualified typeArguments? 2353 * qualified typeArguments?
2330 * </pre> 2354 * </pre>
2331 * 2355 *
2332 * @return the type name that was parsed 2356 * @return the type name that was parsed
2333 */ 2357 */
2334 TypeName parseTypeName() { 2358 TypeName parseTypeName() {
2335 Identifier typeName; 2359 Identifier typeName;
2336 if (matches(Keyword.VAR)) { 2360 if (matches(Keyword.VAR)) {
2337 reportError9(ParserErrorCode.VAR_AS_TYPE_NAME, []); 2361 reportError10(ParserErrorCode.VAR_AS_TYPE_NAME, []);
2338 typeName = new SimpleIdentifier.full(andAdvance); 2362 typeName = new SimpleIdentifier.full(andAdvance);
2339 } else if (matchesIdentifier()) { 2363 } else if (matchesIdentifier()) {
2340 typeName = parsePrefixedIdentifier(); 2364 typeName = parsePrefixedIdentifier();
2341 } else { 2365 } else {
2342 typeName = createSyntheticIdentifier(); 2366 typeName = createSyntheticIdentifier();
2343 reportError9(ParserErrorCode.EXPECTED_TYPE_NAME, []); 2367 reportError10(ParserErrorCode.EXPECTED_TYPE_NAME, []);
2344 } 2368 }
2345 TypeArgumentList typeArguments = null; 2369 TypeArgumentList typeArguments = null;
2346 if (matches5(TokenType.LT)) { 2370 if (matches5(TokenType.LT)) {
2347 typeArguments = parseTypeArgumentList(); 2371 typeArguments = parseTypeArgumentList();
2348 } 2372 }
2349 return new TypeName.full(typeName, typeArguments); 2373 return new TypeName.full(typeName, typeArguments);
2350 } 2374 }
2351 2375
2352 /** 2376 /**
2353 * Parse a type parameter. 2377 * Parse a type parameter.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 * value is invalid. 2452 * value is invalid.
2429 * 2453 *
2430 * @param builder the builder to which the scalar value is to be appended 2454 * @param builder the builder to which the scalar value is to be appended
2431 * @param escapeSequence the escape sequence that was parsed to produce the sc alar value 2455 * @param escapeSequence the escape sequence that was parsed to produce the sc alar value
2432 * @param scalarValue the value to be appended 2456 * @param scalarValue the value to be appended
2433 * @param startIndex the index of the first character representing the scalar value 2457 * @param startIndex the index of the first character representing the scalar value
2434 * @param endIndex the index of the last character representing the scalar val ue 2458 * @param endIndex the index of the last character representing the scalar val ue
2435 */ 2459 */
2436 void appendScalarValue(JavaStringBuilder builder, String escapeSequence, int s calarValue, int startIndex, int endIndex) { 2460 void appendScalarValue(JavaStringBuilder builder, String escapeSequence, int s calarValue, int startIndex, int endIndex) {
2437 if (scalarValue < 0 || scalarValue > Character.MAX_CODE_POINT || (scalarValu e >= 0xD800 && scalarValue <= 0xDFFF)) { 2461 if (scalarValue < 0 || scalarValue > Character.MAX_CODE_POINT || (scalarValu e >= 0xD800 && scalarValue <= 0xDFFF)) {
2438 reportError9(ParserErrorCode.INVALID_CODE_POINT, [escapeSequence]); 2462 reportError10(ParserErrorCode.INVALID_CODE_POINT, [escapeSequence]);
2439 return; 2463 return;
2440 } 2464 }
2441 if (scalarValue < Character.MAX_VALUE) { 2465 if (scalarValue < Character.MAX_VALUE) {
2442 builder.appendChar(scalarValue as int); 2466 builder.appendChar(scalarValue as int);
2443 } else { 2467 } else {
2444 builder.append(Character.toChars(scalarValue)); 2468 builder.append(Character.toChars(scalarValue));
2445 } 2469 }
2446 } 2470 }
2447 2471
2448 /** 2472 /**
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2579 * 2603 *
2580 * assignableSelector ::= 2604 * assignableSelector ::=
2581 * '[' expression ']' 2605 * '[' expression ']'
2582 * | '.' identifier 2606 * | '.' identifier
2583 * </pre> 2607 * </pre>
2584 * 2608 *
2585 * @param expression the expression being checked 2609 * @param expression the expression being checked
2586 */ 2610 */
2587 void ensureAssignable(Expression expression) { 2611 void ensureAssignable(Expression expression) {
2588 if (expression != null && !expression.isAssignable) { 2612 if (expression != null && !expression.isAssignable) {
2589 reportError9(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, []); 2613 reportError10(ParserErrorCode.ILLEGAL_ASSIGNMENT_TO_NON_ASSIGNABLE, []);
2590 } 2614 }
2591 } 2615 }
2592 2616
2593 /** 2617 /**
2594 * If the current token is a keyword matching the given string, return it afte r advancing to the 2618 * If the current token is a keyword matching the given string, return it afte r advancing to the
2595 * next token. Otherwise report an error and return the current token without advancing. 2619 * next token. Otherwise report an error and return the current token without advancing.
2596 * 2620 *
2597 * @param keyword the keyword that is expected 2621 * @param keyword the keyword that is expected
2598 * @return the token that matched the given type 2622 * @return the token that matched the given type
2599 */ 2623 */
2600 Token expect(Keyword keyword) { 2624 Token expect(Keyword keyword) {
2601 if (matches(keyword)) { 2625 if (matches(keyword)) {
2602 return andAdvance; 2626 return andAdvance;
2603 } 2627 }
2604 reportError9(ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax]); 2628 reportError10(ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax]);
2605 return _currentToken; 2629 return _currentToken;
2606 } 2630 }
2607 2631
2608 /** 2632 /**
2609 * If the current token has the expected type, return it after advancing to th e next token. 2633 * If the current token has the expected type, return it after advancing to th e next token.
2610 * Otherwise report an error and return the current token without advancing. 2634 * Otherwise report an error and return the current token without advancing.
2611 * 2635 *
2612 * @param type the type of token that is expected 2636 * @param type the type of token that is expected
2613 * @return the token that matched the given type 2637 * @return the token that matched the given type
2614 */ 2638 */
2615 Token expect2(TokenType type) { 2639 Token expect2(TokenType type) {
2616 if (matches5(type)) { 2640 if (matches5(type)) {
2617 return andAdvance; 2641 return andAdvance;
2618 } 2642 }
2619 if (identical(type, TokenType.SEMICOLON)) { 2643 if (identical(type, TokenType.SEMICOLON)) {
2620 reportError10(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [typ e.lexeme]); 2644 reportError11(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [typ e.lexeme]);
2621 } else { 2645 } else {
2622 reportError9(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme]); 2646 reportError10(ParserErrorCode.EXPECTED_TOKEN, [type.lexeme]);
2623 } 2647 }
2624 return _currentToken; 2648 return _currentToken;
2625 } 2649 }
2626 2650
2627 /** 2651 /**
2628 * Search the given list of ranges for a range that contains the given index. Return the range 2652 * Search the given list of ranges for a range that contains the given index. Return the range
2629 * that was found, or `null` if none of the ranges contain the index. 2653 * that was found, or `null` if none of the ranges contain the index.
2630 * 2654 *
2631 * @param ranges the ranges to be searched 2655 * @param ranges the ranges to be searched
2632 * @param index the index contained in the returned range 2656 * @param index the index contained in the returned range
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2955 if (offset < firstOffset) { 2979 if (offset < firstOffset) {
2956 first = token; 2980 first = token;
2957 firstOffset = offset; 2981 firstOffset = offset;
2958 } 2982 }
2959 } 2983 }
2960 } 2984 }
2961 return first; 2985 return first;
2962 } 2986 }
2963 2987
2964 /** 2988 /**
2989 * Increments the error reporting lock level. If level is more than `0`, then
2990 * [reportError] wont report any error.
2991 */
2992 void lockErrorListener() {
2993 _errorListenerLock++;
2994 }
2995
2996 /**
2965 * Return `true` if the current token matches the given keyword. 2997 * Return `true` if the current token matches the given keyword.
2966 * 2998 *
2967 * @param keyword the keyword that can optionally appear in the current locati on 2999 * @param keyword the keyword that can optionally appear in the current locati on
2968 * @return `true` if the current token matches the given keyword 3000 * @return `true` if the current token matches the given keyword
2969 */ 3001 */
2970 bool matches(Keyword keyword) => matches3(_currentToken, keyword); 3002 bool matches(Keyword keyword) => matches3(_currentToken, keyword);
2971 3003
2972 /** 3004 /**
2973 * Return `true` if the current token matches the given identifier. 3005 * Return `true` if the current token matches the given identifier.
2974 * 3006 *
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 * <pre> 3155 * <pre>
3124 * argumentDefinitionTest ::= 3156 * argumentDefinitionTest ::=
3125 * '?' identifier 3157 * '?' identifier
3126 * </pre> 3158 * </pre>
3127 * 3159 *
3128 * @return the argument definition test that was parsed 3160 * @return the argument definition test that was parsed
3129 */ 3161 */
3130 ArgumentDefinitionTest parseArgumentDefinitionTest() { 3162 ArgumentDefinitionTest parseArgumentDefinitionTest() {
3131 Token question = expect2(TokenType.QUESTION); 3163 Token question = expect2(TokenType.QUESTION);
3132 SimpleIdentifier identifier = parseSimpleIdentifier(); 3164 SimpleIdentifier identifier = parseSimpleIdentifier();
3133 reportError10(ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, question, []); 3165 reportError11(ParserErrorCode.DEPRECATED_ARGUMENT_DEFINITION_TEST, question, []);
3134 return new ArgumentDefinitionTest.full(question, identifier); 3166 return new ArgumentDefinitionTest.full(question, identifier);
3135 } 3167 }
3136 3168
3137 /** 3169 /**
3138 * Parse an assert statement. 3170 * Parse an assert statement.
3139 * 3171 *
3140 * <pre> 3172 * <pre>
3141 * assertStatement ::= 3173 * assertStatement ::=
3142 * 'assert' '(' conditionalExpression ')' ';' 3174 * 'assert' '(' conditionalExpression ')' ';'
3143 * </pre> 3175 * </pre>
3144 * 3176 *
3145 * @return the assert statement 3177 * @return the assert statement
3146 */ 3178 */
3147 AssertStatement parseAssertStatement() { 3179 AssertStatement parseAssertStatement() {
3148 Token keyword = expect(Keyword.ASSERT); 3180 Token keyword = expect(Keyword.ASSERT);
3149 Token leftParen = expect2(TokenType.OPEN_PAREN); 3181 Token leftParen = expect2(TokenType.OPEN_PAREN);
3150 Expression expression = parseExpression2(); 3182 Expression expression = parseExpression2();
3151 if (expression is AssignmentExpression) { 3183 if (expression is AssignmentExpression) {
3152 reportError(ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expression, [ ]); 3184 reportError9(ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expression, []);
3153 } else if (expression is CascadeExpression) { 3185 } else if (expression is CascadeExpression) {
3154 reportError(ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression, []); 3186 reportError9(ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression, []) ;
3155 } else if (expression is ThrowExpression) { 3187 } else if (expression is ThrowExpression) {
3156 reportError(ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression, []); 3188 reportError9(ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression, []);
3157 } else if (expression is RethrowExpression) { 3189 } else if (expression is RethrowExpression) {
3158 reportError(ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression, []); 3190 reportError9(ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression, []) ;
3159 } 3191 }
3160 Token rightParen = expect2(TokenType.CLOSE_PAREN); 3192 Token rightParen = expect2(TokenType.CLOSE_PAREN);
3161 Token semicolon = expect2(TokenType.SEMICOLON); 3193 Token semicolon = expect2(TokenType.SEMICOLON);
3162 return new AssertStatement.full(keyword, leftParen, expression, rightParen, semicolon); 3194 return new AssertStatement.full(keyword, leftParen, expression, rightParen, semicolon);
3163 } 3195 }
3164 3196
3165 /** 3197 /**
3166 * Parse an assignable expression. 3198 * Parse an assignable expression.
3167 * 3199 *
3168 * <pre> 3200 * <pre>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3230 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) { 3262 if (matches5(TokenType.OPEN_SQUARE_BRACKET)) {
3231 Token leftBracket = andAdvance; 3263 Token leftBracket = andAdvance;
3232 Expression index = parseExpression2(); 3264 Expression index = parseExpression2();
3233 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); 3265 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET);
3234 return new IndexExpression.forTarget_full(prefix, leftBracket, index, righ tBracket); 3266 return new IndexExpression.forTarget_full(prefix, leftBracket, index, righ tBracket);
3235 } else if (matches5(TokenType.PERIOD)) { 3267 } else if (matches5(TokenType.PERIOD)) {
3236 Token period = andAdvance; 3268 Token period = andAdvance;
3237 return new PropertyAccess.full(prefix, period, parseSimpleIdentifier()); 3269 return new PropertyAccess.full(prefix, period, parseSimpleIdentifier());
3238 } else { 3270 } else {
3239 if (!optional) { 3271 if (!optional) {
3240 reportError9(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); 3272 reportError10(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []);
3241 } 3273 }
3242 return prefix; 3274 return prefix;
3243 } 3275 }
3244 } 3276 }
3245 3277
3246 /** 3278 /**
3247 * Parse a bitwise and expression. 3279 * Parse a bitwise and expression.
3248 * 3280 *
3249 * <pre> 3281 * <pre>
3250 * bitwiseAndExpression ::= 3282 * bitwiseAndExpression ::=
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3303 * 3335 *
3304 * @return the break statement that was parsed 3336 * @return the break statement that was parsed
3305 */ 3337 */
3306 Statement parseBreakStatement() { 3338 Statement parseBreakStatement() {
3307 Token breakKeyword = expect(Keyword.BREAK); 3339 Token breakKeyword = expect(Keyword.BREAK);
3308 SimpleIdentifier label = null; 3340 SimpleIdentifier label = null;
3309 if (matchesIdentifier()) { 3341 if (matchesIdentifier()) {
3310 label = parseSimpleIdentifier(); 3342 label = parseSimpleIdentifier();
3311 } 3343 }
3312 if (!_inLoop && !_inSwitch && label == null) { 3344 if (!_inLoop && !_inSwitch && label == null) {
3313 reportError10(ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, breakKeyword, []); 3345 reportError11(ParserErrorCode.BREAK_OUTSIDE_OF_LOOP, breakKeyword, []);
3314 } 3346 }
3315 Token semicolon = expect2(TokenType.SEMICOLON); 3347 Token semicolon = expect2(TokenType.SEMICOLON);
3316 return new BreakStatement.full(breakKeyword, label, semicolon); 3348 return new BreakStatement.full(breakKeyword, label, semicolon);
3317 } 3349 }
3318 3350
3319 /** 3351 /**
3320 * Parse a cascade section. 3352 * Parse a cascade section.
3321 * 3353 *
3322 * <pre> 3354 * <pre>
3323 * cascadeSection ::= 3355 * cascadeSection ::=
(...skipping 15 matching lines...) Expand all
3339 SimpleIdentifier functionName = null; 3371 SimpleIdentifier functionName = null;
3340 if (matchesIdentifier()) { 3372 if (matchesIdentifier()) {
3341 functionName = parseSimpleIdentifier(); 3373 functionName = parseSimpleIdentifier();
3342 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) { 3374 } else if (identical(_currentToken.type, TokenType.OPEN_SQUARE_BRACKET)) {
3343 Token leftBracket = andAdvance; 3375 Token leftBracket = andAdvance;
3344 Expression index = parseExpression2(); 3376 Expression index = parseExpression2();
3345 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET); 3377 Token rightBracket = expect2(TokenType.CLOSE_SQUARE_BRACKET);
3346 expression = new IndexExpression.forCascade_full(period, leftBracket, inde x, rightBracket); 3378 expression = new IndexExpression.forCascade_full(period, leftBracket, inde x, rightBracket);
3347 period = null; 3379 period = null;
3348 } else { 3380 } else {
3349 reportError10(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [_current Token.lexeme]); 3381 reportError11(ParserErrorCode.MISSING_IDENTIFIER, _currentToken, [_current Token.lexeme]);
3350 functionName = createSyntheticIdentifier(); 3382 functionName = createSyntheticIdentifier();
3351 } 3383 }
3352 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) { 3384 if (identical(_currentToken.type, TokenType.OPEN_PAREN)) {
3353 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) { 3385 while (identical(_currentToken.type, TokenType.OPEN_PAREN)) {
3354 if (functionName != null) { 3386 if (functionName != null) {
3355 expression = new MethodInvocation.full(expression, period, functionNam e, parseArgumentList()); 3387 expression = new MethodInvocation.full(expression, period, functionNam e, parseArgumentList());
3356 period = null; 3388 period = null;
3357 functionName = null; 3389 functionName = null;
3358 } else if (expression == null) { 3390 } else if (expression == null) {
3359 expression = new MethodInvocation.full(expression, period, createSynth eticIdentifier(), parseArgumentList()); 3391 expression = new MethodInvocation.full(expression, period, createSynth eticIdentifier(), parseArgumentList());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
3425 } 3457 }
3426 ExtendsClause extendsClause = null; 3458 ExtendsClause extendsClause = null;
3427 WithClause withClause = null; 3459 WithClause withClause = null;
3428 ImplementsClause implementsClause = null; 3460 ImplementsClause implementsClause = null;
3429 bool foundClause = true; 3461 bool foundClause = true;
3430 while (foundClause) { 3462 while (foundClause) {
3431 if (matches(Keyword.EXTENDS)) { 3463 if (matches(Keyword.EXTENDS)) {
3432 if (extendsClause == null) { 3464 if (extendsClause == null) {
3433 extendsClause = parseExtendsClause(); 3465 extendsClause = parseExtendsClause();
3434 if (withClause != null) { 3466 if (withClause != null) {
3435 reportError10(ParserErrorCode.WITH_BEFORE_EXTENDS, withClause.withKe yword, []); 3467 reportError11(ParserErrorCode.WITH_BEFORE_EXTENDS, withClause.withKe yword, []);
3436 } else if (implementsClause != null) { 3468 } else if (implementsClause != null) {
3437 reportError10(ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, implementsC lause.keyword, []); 3469 reportError11(ParserErrorCode.IMPLEMENTS_BEFORE_EXTENDS, implementsC lause.keyword, []);
3438 } 3470 }
3439 } else { 3471 } else {
3440 reportError10(ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, extendsClause. keyword, []); 3472 reportError11(ParserErrorCode.MULTIPLE_EXTENDS_CLAUSES, extendsClause. keyword, []);
3441 parseExtendsClause(); 3473 parseExtendsClause();
3442 } 3474 }
3443 } else if (matches(Keyword.WITH)) { 3475 } else if (matches(Keyword.WITH)) {
3444 if (withClause == null) { 3476 if (withClause == null) {
3445 withClause = parseWithClause(); 3477 withClause = parseWithClause();
3446 if (implementsClause != null) { 3478 if (implementsClause != null) {
3447 reportError10(ParserErrorCode.IMPLEMENTS_BEFORE_WITH, implementsClau se.keyword, []); 3479 reportError11(ParserErrorCode.IMPLEMENTS_BEFORE_WITH, implementsClau se.keyword, []);
3448 } 3480 }
3449 } else { 3481 } else {
3450 reportError10(ParserErrorCode.MULTIPLE_WITH_CLAUSES, withClause.withKe yword, []); 3482 reportError11(ParserErrorCode.MULTIPLE_WITH_CLAUSES, withClause.withKe yword, []);
3451 parseWithClause(); 3483 parseWithClause();
3452 } 3484 }
3453 } else if (matches(Keyword.IMPLEMENTS)) { 3485 } else if (matches(Keyword.IMPLEMENTS)) {
3454 if (implementsClause == null) { 3486 if (implementsClause == null) {
3455 implementsClause = parseImplementsClause(); 3487 implementsClause = parseImplementsClause();
3456 } else { 3488 } else {
3457 reportError10(ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, implementsC lause.keyword, []); 3489 reportError11(ParserErrorCode.MULTIPLE_IMPLEMENTS_CLAUSES, implementsC lause.keyword, []);
3458 parseImplementsClause(); 3490 parseImplementsClause();
3459 } 3491 }
3460 } else { 3492 } else {
3461 foundClause = false; 3493 foundClause = false;
3462 } 3494 }
3463 } 3495 }
3464 if (withClause != null && extendsClause == null) { 3496 if (withClause != null && extendsClause == null) {
3465 reportError10(ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.withKeyword , []); 3497 reportError11(ParserErrorCode.WITH_WITHOUT_EXTENDS, withClause.withKeyword , []);
3466 } 3498 }
3467 NativeClause nativeClause = null; 3499 NativeClause nativeClause = null;
3468 if (matches2(_NATIVE) && matches4(peek(), TokenType.STRING)) { 3500 if (matches2(_NATIVE) && matches4(peek(), TokenType.STRING)) {
3469 nativeClause = parseNativeClause(); 3501 nativeClause = parseNativeClause();
3470 } 3502 }
3471 Token leftBracket = null; 3503 Token leftBracket = null;
3472 List<ClassMember> members = null; 3504 List<ClassMember> members = null;
3473 Token rightBracket = null; 3505 Token rightBracket = null;
3474 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 3506 if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
3475 leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); 3507 leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET);
3476 members = parseClassMembers(className, getEndToken(leftBracket)); 3508 members = parseClassMembers(className, getEndToken(leftBracket));
3477 rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); 3509 rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET);
3478 } else { 3510 } else {
3479 leftBracket = createSyntheticToken2(TokenType.OPEN_CURLY_BRACKET); 3511 leftBracket = createSyntheticToken2(TokenType.OPEN_CURLY_BRACKET);
3480 rightBracket = createSyntheticToken2(TokenType.CLOSE_CURLY_BRACKET); 3512 rightBracket = createSyntheticToken2(TokenType.CLOSE_CURLY_BRACKET);
3481 reportError9(ParserErrorCode.MISSING_CLASS_BODY, []); 3513 reportError10(ParserErrorCode.MISSING_CLASS_BODY, []);
3482 } 3514 }
3483 ClassDeclaration classDeclaration = new ClassDeclaration.full(commentAndMeta data.comment, commentAndMetadata.metadata, abstractKeyword, keyword, name, typeP arameters, extendsClause, withClause, implementsClause, leftBracket, members, ri ghtBracket); 3515 ClassDeclaration classDeclaration = new ClassDeclaration.full(commentAndMeta data.comment, commentAndMetadata.metadata, abstractKeyword, keyword, name, typeP arameters, extendsClause, withClause, implementsClause, leftBracket, members, ri ghtBracket);
3484 classDeclaration.nativeClause = nativeClause; 3516 classDeclaration.nativeClause = nativeClause;
3485 return classDeclaration; 3517 return classDeclaration;
3486 } 3518 }
3487 3519
3488 /** 3520 /**
3489 * Parse a list of class members. 3521 * Parse a list of class members.
3490 * 3522 *
3491 * <pre> 3523 * <pre>
3492 * classMembers ::= 3524 * classMembers ::=
3493 * (metadata memberDefinition)* 3525 * (metadata memberDefinition)*
3494 * </pre> 3526 * </pre>
3495 * 3527 *
3496 * @param className the name of the class whose members are being parsed 3528 * @param className the name of the class whose members are being parsed
3497 * @param closingBracket the closing bracket for the class, or `null` if the c losing bracket 3529 * @param closingBracket the closing bracket for the class, or `null` if the c losing bracket
3498 * is missing 3530 * is missing
3499 * @return the list of class members that were parsed 3531 * @return the list of class members that were parsed
3500 */ 3532 */
3501 List<ClassMember> parseClassMembers(String className, Token closingBracket) { 3533 List<ClassMember> parseClassMembers(String className, Token closingBracket) {
3502 List<ClassMember> members = new List<ClassMember>(); 3534 List<ClassMember> members = new List<ClassMember>();
3503 Token memberStart = _currentToken; 3535 Token memberStart = _currentToken;
3504 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET) && (closingBracket != null || (!matches(Keyword.CLASS) && !matches(Keyword.TYPED EF)))) { 3536 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET) && (closingBracket != null || (!matches(Keyword.CLASS) && !matches(Keyword.TYPED EF)))) {
3505 if (matches5(TokenType.SEMICOLON)) { 3537 if (matches5(TokenType.SEMICOLON)) {
3506 reportError10(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]); 3538 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]);
3507 advance(); 3539 advance();
3508 } else { 3540 } else {
3509 ClassMember member = parseClassMember(className); 3541 ClassMember member = parseClassMember(className);
3510 if (member != null) { 3542 if (member != null) {
3511 members.add(member); 3543 members.add(member);
3512 } 3544 }
3513 } 3545 }
3514 if (identical(_currentToken, memberStart)) { 3546 if (identical(_currentToken, memberStart)) {
3515 reportError10(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]); 3547 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]);
3516 advance(); 3548 advance();
3517 } 3549 }
3518 memberStart = _currentToken; 3550 memberStart = _currentToken;
3519 } 3551 }
3520 return members; 3552 return members;
3521 } 3553 }
3522 3554
3523 /** 3555 /**
3524 * Parse a class type alias. 3556 * Parse a class type alias.
3525 * 3557 *
(...skipping 27 matching lines...) Expand all
3553 } 3585 }
3554 ImplementsClause implementsClause = null; 3586 ImplementsClause implementsClause = null;
3555 if (matches(Keyword.IMPLEMENTS)) { 3587 if (matches(Keyword.IMPLEMENTS)) {
3556 implementsClause = parseImplementsClause(); 3588 implementsClause = parseImplementsClause();
3557 } 3589 }
3558 Token semicolon; 3590 Token semicolon;
3559 if (matches5(TokenType.SEMICOLON)) { 3591 if (matches5(TokenType.SEMICOLON)) {
3560 semicolon = andAdvance; 3592 semicolon = andAdvance;
3561 } else { 3593 } else {
3562 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 3594 if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
3563 reportError9(ParserErrorCode.EXPECTED_TOKEN, [TokenType.SEMICOLON.lexeme ]); 3595 reportError10(ParserErrorCode.EXPECTED_TOKEN, [TokenType.SEMICOLON.lexem e]);
3564 Token leftBracket = andAdvance; 3596 Token leftBracket = andAdvance;
3565 parseClassMembers(className.name, getEndToken(leftBracket)); 3597 parseClassMembers(className.name, getEndToken(leftBracket));
3566 expect2(TokenType.CLOSE_CURLY_BRACKET); 3598 expect2(TokenType.CLOSE_CURLY_BRACKET);
3567 } else { 3599 } else {
3568 reportError10(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [T okenType.SEMICOLON.lexeme]); 3600 reportError11(ParserErrorCode.EXPECTED_TOKEN, _currentToken.previous, [T okenType.SEMICOLON.lexeme]);
3569 } 3601 }
3570 semicolon = createSyntheticToken2(TokenType.SEMICOLON); 3602 semicolon = createSyntheticToken2(TokenType.SEMICOLON);
3571 } 3603 }
3572 return new ClassTypeAlias.full(commentAndMetadata.comment, commentAndMetadat a.metadata, keyword, className, typeParameters, equals, abstractKeyword, supercl ass, withClause, implementsClause, semicolon); 3604 return new ClassTypeAlias.full(commentAndMetadata.comment, commentAndMetadat a.metadata, keyword, className, typeParameters, equals, abstractKeyword, supercl ass, withClause, implementsClause, semicolon);
3573 } 3605 }
3574 3606
3575 /** 3607 /**
3576 * Parse a list of combinators in a directive. 3608 * Parse a list of combinators in a directive.
3577 * 3609 *
3578 * <pre> 3610 * <pre>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3752 } else if (matches(Keyword.TYPEDEF) && !matches4(peek(), TokenType.PERIOD) & & !matches4(peek(), TokenType.LT) && !matches4(peek(), TokenType.OPEN_PAREN)) { 3784 } else if (matches(Keyword.TYPEDEF) && !matches4(peek(), TokenType.PERIOD) & & !matches4(peek(), TokenType.LT) && !matches4(peek(), TokenType.OPEN_PAREN)) {
3753 validateModifiersForTypedef(modifiers); 3785 validateModifiersForTypedef(modifiers);
3754 return parseTypeAlias(commentAndMetadata); 3786 return parseTypeAlias(commentAndMetadata);
3755 } 3787 }
3756 if (matches(Keyword.VOID)) { 3788 if (matches(Keyword.VOID)) {
3757 TypeName returnType = parseReturnType(); 3789 TypeName returnType = parseReturnType();
3758 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p eek())) { 3790 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(p eek())) {
3759 validateModifiersForTopLevelFunction(modifiers); 3791 validateModifiersForTopLevelFunction(modifiers);
3760 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, null); 3792 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, null);
3761 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { 3793 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) {
3762 reportError10(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []); 3794 reportError11(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []);
3763 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, mo difiers.externalKeyword, returnType)); 3795 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, mo difiers.externalKeyword, returnType));
3764 } else if (matchesIdentifier() && matchesAny(peek(), [ 3796 } else if (matchesIdentifier() && matchesAny(peek(), [
3765 TokenType.OPEN_PAREN, 3797 TokenType.OPEN_PAREN,
3766 TokenType.OPEN_CURLY_BRACKET, 3798 TokenType.OPEN_CURLY_BRACKET,
3767 TokenType.FUNCTION])) { 3799 TokenType.FUNCTION])) {
3768 validateModifiersForTopLevelFunction(modifiers); 3800 validateModifiersForTopLevelFunction(modifiers);
3769 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, returnType); 3801 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKe yword, returnType);
3770 } else { 3802 } else {
3771 if (matchesIdentifier()) { 3803 if (matchesIdentifier()) {
3772 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC OLON])) { 3804 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMIC OLON])) {
3773 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); 3805 reportError9(ParserErrorCode.VOID_VARIABLE, returnType, []);
3774 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme nt, commentAndMetadata.metadata, parseVariableDeclarationList2(null, validateMod ifiersForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); 3806 return new TopLevelVariableDeclaration.full(commentAndMetadata.comme nt, commentAndMetadata.metadata, parseVariableDeclarationList2(null, validateMod ifiersForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON));
3775 } 3807 }
3776 } 3808 }
3777 reportError10(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []); 3809 reportError11(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []);
3778 return null; 3810 return null;
3779 } 3811 }
3780 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi er2(peek())) { 3812 } else if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifi er2(peek())) {
3781 validateModifiersForTopLevelFunction(modifiers); 3813 validateModifiersForTopLevelFunction(modifiers);
3782 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null); 3814 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null);
3783 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { 3815 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) {
3784 reportError10(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []); 3816 reportError11(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []);
3785 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, modi fiers.externalKeyword, null)); 3817 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, modi fiers.externalKeyword, null));
3786 } else if (!matchesIdentifier()) { 3818 } else if (!matchesIdentifier()) {
3787 reportError10(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []); 3819 reportError11(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []);
3788 return null; 3820 return null;
3789 } else if (matches4(peek(), TokenType.OPEN_PAREN)) { 3821 } else if (matches4(peek(), TokenType.OPEN_PAREN)) {
3790 validateModifiersForTopLevelFunction(modifiers); 3822 validateModifiersForTopLevelFunction(modifiers);
3791 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null); 3823 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, null);
3792 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) { 3824 } else if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEMI COLON])) {
3793 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo difiers.varKeyword == null) { 3825 if (modifiers.constKeyword == null && modifiers.finalKeyword == null && mo difiers.varKeyword == null) {
3794 reportError9(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []); 3826 reportError10(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []);
3795 } 3827 }
3796 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiers ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON)); 3828 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiers ForTopLevelVariable(modifiers), null), expect2(TokenType.SEMICOLON));
3797 } 3829 }
3798 TypeName returnType = parseReturnType(); 3830 TypeName returnType = parseReturnType();
3799 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(pee k())) { 3831 if ((matches(Keyword.GET) || matches(Keyword.SET)) && matchesIdentifier2(pee k())) {
3800 validateModifiersForTopLevelFunction(modifiers); 3832 validateModifiersForTopLevelFunction(modifiers);
3801 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, returnType); 3833 return parseFunctionDeclaration(commentAndMetadata, modifiers.externalKeyw ord, returnType);
3802 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) { 3834 } else if (matches(Keyword.OPERATOR) && isOperator(peek())) {
3803 reportError10(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []); 3835 reportError11(ParserErrorCode.TOP_LEVEL_OPERATOR, _currentToken, []);
3804 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, modi fiers.externalKeyword, returnType)); 3836 return convertToFunctionDeclaration(parseOperator(commentAndMetadata, modi fiers.externalKeyword, returnType));
3805 } else if (matches5(TokenType.AT)) { 3837 } else if (matches5(TokenType.AT)) {
3806 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiers ForTopLevelVariable(modifiers), returnType), expect2(TokenType.SEMICOLON)); 3838 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, parseVariableDeclarationList2(null, validateModifiers ForTopLevelVariable(modifiers), returnType), expect2(TokenType.SEMICOLON));
3807 } else if (!matchesIdentifier()) { 3839 } else if (!matchesIdentifier()) {
3808 reportError10(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []); 3840 reportError11(ParserErrorCode.EXPECTED_EXECUTABLE, _currentToken, []);
3809 Token semicolon; 3841 Token semicolon;
3810 if (matches5(TokenType.SEMICOLON)) { 3842 if (matches5(TokenType.SEMICOLON)) {
3811 semicolon = andAdvance; 3843 semicolon = andAdvance;
3812 } else { 3844 } else {
3813 semicolon = createSyntheticToken2(TokenType.SEMICOLON); 3845 semicolon = createSyntheticToken2(TokenType.SEMICOLON);
3814 } 3846 }
3815 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 3847 List<VariableDeclaration> variables = new List<VariableDeclaration>();
3816 variables.add(new VariableDeclaration.full(null, null, createSyntheticIden tifier(), null, null)); 3848 variables.add(new VariableDeclaration.full(null, null, createSyntheticIden tifier(), null, null));
3817 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, new VariableDeclarationList.full(null, null, null, re turnType, variables), semicolon); 3849 return new TopLevelVariableDeclaration.full(commentAndMetadata.comment, co mmentAndMetadata.metadata, new VariableDeclarationList.full(null, null, null, re turnType, variables), semicolon);
3818 } 3850 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3875 } 3907 }
3876 } while (optional(TokenType.COMMA)); 3908 } while (optional(TokenType.COMMA));
3877 } 3909 }
3878 ConstructorName redirectedConstructor = null; 3910 ConstructorName redirectedConstructor = null;
3879 FunctionBody body; 3911 FunctionBody body;
3880 if (matches5(TokenType.EQ)) { 3912 if (matches5(TokenType.EQ)) {
3881 separator = andAdvance; 3913 separator = andAdvance;
3882 redirectedConstructor = parseConstructorName(); 3914 redirectedConstructor = parseConstructorName();
3883 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON)); 3915 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON));
3884 if (factoryKeyword == null) { 3916 if (factoryKeyword == null) {
3885 reportError(ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, redi rectedConstructor, []); 3917 reportError9(ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR, red irectedConstructor, []);
3886 } 3918 }
3887 } else { 3919 } else {
3888 body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, fals e); 3920 body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION_BODY, fals e);
3889 if (constKeyword != null && factoryKeyword != null && externalKeyword == n ull) { 3921 if (constKeyword != null && factoryKeyword != null && externalKeyword == n ull) {
3890 reportError10(ParserErrorCode.CONST_FACTORY, factoryKeyword, []); 3922 reportError11(ParserErrorCode.CONST_FACTORY, factoryKeyword, []);
3891 } else if (body is EmptyFunctionBody) { 3923 } else if (body is EmptyFunctionBody) {
3892 if (factoryKeyword != null && externalKeyword == null) { 3924 if (factoryKeyword != null && externalKeyword == null) {
3893 reportError10(ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyword, [] ); 3925 reportError11(ParserErrorCode.FACTORY_WITHOUT_BODY, factoryKeyword, [] );
3894 } 3926 }
3895 } else { 3927 } else {
3896 if (constKeyword != null) { 3928 if (constKeyword != null) {
3897 reportError(ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body, []); 3929 reportError9(ParserErrorCode.CONST_CONSTRUCTOR_WITH_BODY, body, []);
3898 } else if (!bodyAllowed) { 3930 } else if (!bodyAllowed) {
3899 reportError(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body, []); 3931 reportError9(ParserErrorCode.EXTERNAL_CONSTRUCTOR_WITH_BODY, body, []) ;
3900 } 3932 }
3901 } 3933 }
3902 } 3934 }
3903 return new ConstructorDeclaration.full(commentAndMetadata.comment, commentAn dMetadata.metadata, externalKeyword, constKeyword, factoryKeyword, returnType, p eriod, name, parameters, separator, initializers, redirectedConstructor, body); 3935 return new ConstructorDeclaration.full(commentAndMetadata.comment, commentAn dMetadata.metadata, externalKeyword, constKeyword, factoryKeyword, returnType, p eriod, name, parameters, separator, initializers, redirectedConstructor, body);
3904 } 3936 }
3905 3937
3906 /** 3938 /**
3907 * Parse a field initializer within a constructor. 3939 * Parse a field initializer within a constructor.
3908 * 3940 *
3909 * <pre> 3941 * <pre>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
3944 * <pre> 3976 * <pre>
3945 * continueStatement ::= 3977 * continueStatement ::=
3946 * 'continue' identifier? ';' 3978 * 'continue' identifier? ';'
3947 * </pre> 3979 * </pre>
3948 * 3980 *
3949 * @return the continue statement that was parsed 3981 * @return the continue statement that was parsed
3950 */ 3982 */
3951 Statement parseContinueStatement() { 3983 Statement parseContinueStatement() {
3952 Token continueKeyword = expect(Keyword.CONTINUE); 3984 Token continueKeyword = expect(Keyword.CONTINUE);
3953 if (!_inLoop && !_inSwitch) { 3985 if (!_inLoop && !_inSwitch) {
3954 reportError10(ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, continueKeyword, [ ]); 3986 reportError11(ParserErrorCode.CONTINUE_OUTSIDE_OF_LOOP, continueKeyword, [ ]);
3955 } 3987 }
3956 SimpleIdentifier label = null; 3988 SimpleIdentifier label = null;
3957 if (matchesIdentifier()) { 3989 if (matchesIdentifier()) {
3958 label = parseSimpleIdentifier(); 3990 label = parseSimpleIdentifier();
3959 } 3991 }
3960 if (_inSwitch && !_inLoop && label == null) { 3992 if (_inSwitch && !_inLoop && label == null) {
3961 reportError10(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, continueKeyw ord, []); 3993 reportError11(ParserErrorCode.CONTINUE_WITHOUT_LABEL_IN_CASE, continueKeyw ord, []);
3962 } 3994 }
3963 Token semicolon = expect2(TokenType.SEMICOLON); 3995 Token semicolon = expect2(TokenType.SEMICOLON);
3964 return new ContinueStatement.full(continueKeyword, label, semicolon); 3996 return new ContinueStatement.full(continueKeyword, label, semicolon);
3965 } 3997 }
3966 3998
3967 /** 3999 /**
3968 * Parse a directive. 4000 * Parse a directive.
3969 * 4001 *
3970 * <pre> 4002 * <pre>
3971 * directive ::= 4003 * directive ::=
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
4084 Expression expression; 4116 Expression expression;
4085 if (matches(Keyword.SUPER) && _currentToken.next.type.isEqualityOperator) { 4117 if (matches(Keyword.SUPER) && _currentToken.next.type.isEqualityOperator) {
4086 expression = new SuperExpression.full(andAdvance); 4118 expression = new SuperExpression.full(andAdvance);
4087 } else { 4119 } else {
4088 expression = parseRelationalExpression(); 4120 expression = parseRelationalExpression();
4089 } 4121 }
4090 bool leftEqualityExpression = false; 4122 bool leftEqualityExpression = false;
4091 while (_currentToken.type.isEqualityOperator) { 4123 while (_currentToken.type.isEqualityOperator) {
4092 Token operator = andAdvance; 4124 Token operator = andAdvance;
4093 if (leftEqualityExpression) { 4125 if (leftEqualityExpression) {
4094 reportError(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, express ion, []); 4126 reportError9(ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND, expres sion, []);
4095 } 4127 }
4096 expression = new BinaryExpression.full(expression, operator, parseRelation alExpression()); 4128 expression = new BinaryExpression.full(expression, operator, parseRelation alExpression());
4097 leftEqualityExpression = true; 4129 leftEqualityExpression = true;
4098 } 4130 }
4099 return expression; 4131 return expression;
4100 } 4132 }
4101 4133
4102 /** 4134 /**
4103 * Parse an export directive. 4135 * Parse an export directive.
4104 * 4136 *
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4158 keyword = andAdvance; 4190 keyword = andAdvance;
4159 if (isTypedIdentifier(_currentToken)) { 4191 if (isTypedIdentifier(_currentToken)) {
4160 type = parseTypeName(); 4192 type = parseTypeName();
4161 } 4193 }
4162 } else if (matches(Keyword.VAR)) { 4194 } else if (matches(Keyword.VAR)) {
4163 keyword = andAdvance; 4195 keyword = andAdvance;
4164 } else { 4196 } else {
4165 if (isTypedIdentifier(_currentToken)) { 4197 if (isTypedIdentifier(_currentToken)) {
4166 type = parseReturnType(); 4198 type = parseReturnType();
4167 } else if (!optional) { 4199 } else if (!optional) {
4168 reportError9(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []); 4200 reportError10(ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE, []);
4169 } 4201 }
4170 } 4202 }
4171 return new FinalConstVarOrType(keyword, type); 4203 return new FinalConstVarOrType(keyword, type);
4172 } 4204 }
4173 4205
4174 /** 4206 /**
4175 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be 4207 * Parse a formal parameter. At most one of `isOptional` and `isNamed` can be
4176 * `true`. 4208 * `true`.
4177 * 4209 *
4178 * <pre> 4210 * <pre>
4179 * defaultFormalParameter ::= 4211 * defaultFormalParameter ::=
4180 * normalFormalParameter ('=' expression)? 4212 * normalFormalParameter ('=' expression)?
4181 * 4213 *
4182 * defaultNamedParameter ::= 4214 * defaultNamedParameter ::=
4183 * normalFormalParameter (':' expression)? 4215 * normalFormalParameter (':' expression)?
4184 * </pre> 4216 * </pre>
4185 * 4217 *
4186 * @param kind the kind of parameter being expected based on the presence or a bsence of group 4218 * @param kind the kind of parameter being expected based on the presence or a bsence of group
4187 * delimiters 4219 * delimiters
4188 * @return the formal parameter that was parsed 4220 * @return the formal parameter that was parsed
4189 */ 4221 */
4190 FormalParameter parseFormalParameter(ParameterKind kind) { 4222 FormalParameter parseFormalParameter(ParameterKind kind) {
4191 NormalFormalParameter parameter = parseNormalFormalParameter(); 4223 NormalFormalParameter parameter = parseNormalFormalParameter();
4192 if (matches5(TokenType.EQ)) { 4224 if (matches5(TokenType.EQ)) {
4193 Token seperator = andAdvance; 4225 Token seperator = andAdvance;
4194 Expression defaultValue = parseExpression2(); 4226 Expression defaultValue = parseExpression2();
4195 if (identical(kind, ParameterKind.NAMED)) { 4227 if (identical(kind, ParameterKind.NAMED)) {
4196 reportError10(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, seper ator, []); 4228 reportError11(ParserErrorCode.WRONG_SEPARATOR_FOR_NAMED_PARAMETER, seper ator, []);
4197 } else if (identical(kind, ParameterKind.REQUIRED)) { 4229 } else if (identical(kind, ParameterKind.REQUIRED)) {
4198 reportError(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, paramete r, []); 4230 reportError9(ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, paramet er, []);
4199 } 4231 }
4200 return new DefaultFormalParameter.full(parameter, kind, seperator, default Value); 4232 return new DefaultFormalParameter.full(parameter, kind, seperator, default Value);
4201 } else if (matches5(TokenType.COLON)) { 4233 } else if (matches5(TokenType.COLON)) {
4202 Token seperator = andAdvance; 4234 Token seperator = andAdvance;
4203 Expression defaultValue = parseExpression2(); 4235 Expression defaultValue = parseExpression2();
4204 if (identical(kind, ParameterKind.POSITIONAL)) { 4236 if (identical(kind, ParameterKind.POSITIONAL)) {
4205 reportError10(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, seperator, []); 4237 reportError11(ParserErrorCode.WRONG_SEPARATOR_FOR_POSITIONAL_PARAMETER, seperator, []);
4206 } else if (identical(kind, ParameterKind.REQUIRED)) { 4238 } else if (identical(kind, ParameterKind.REQUIRED)) {
4207 reportError(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, [] ); 4239 reportError9(ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter, [ ]);
4208 } 4240 }
4209 return new DefaultFormalParameter.full(parameter, kind, seperator, default Value); 4241 return new DefaultFormalParameter.full(parameter, kind, seperator, default Value);
4210 } else if (kind != ParameterKind.REQUIRED) { 4242 } else if (kind != ParameterKind.REQUIRED) {
4211 return new DefaultFormalParameter.full(parameter, kind, null, null); 4243 return new DefaultFormalParameter.full(parameter, kind, null, null);
4212 } 4244 }
4213 return parameter; 4245 return parameter;
4214 } 4246 }
4215 4247
4216 /** 4248 /**
4217 * Parse a for statement. 4249 * Parse a for statement.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4249 variableList = new VariableDeclarationList.full(commentAndMetadata.com ment, commentAndMetadata.metadata, null, null, variables); 4281 variableList = new VariableDeclarationList.full(commentAndMetadata.com ment, commentAndMetadata.metadata, null, null, variables);
4250 } else if (isInitializedVariableDeclaration()) { 4282 } else if (isInitializedVariableDeclaration()) {
4251 variableList = parseVariableDeclarationList(commentAndMetadata); 4283 variableList = parseVariableDeclarationList(commentAndMetadata);
4252 } else { 4284 } else {
4253 initialization = parseExpression2(); 4285 initialization = parseExpression2();
4254 } 4286 }
4255 if (matches(Keyword.IN)) { 4287 if (matches(Keyword.IN)) {
4256 DeclaredIdentifier loopVariable = null; 4288 DeclaredIdentifier loopVariable = null;
4257 SimpleIdentifier identifier = null; 4289 SimpleIdentifier identifier = null;
4258 if (variableList == null) { 4290 if (variableList == null) {
4259 reportError9(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []); 4291 reportError10(ParserErrorCode.MISSING_VARIABLE_IN_FOR_EACH, []);
4260 } else { 4292 } else {
4261 NodeList<VariableDeclaration> variables = variableList.variables; 4293 NodeList<VariableDeclaration> variables = variableList.variables;
4262 if (variables.length > 1) { 4294 if (variables.length > 1) {
4263 reportError9(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [vari ables.length.toString()]); 4295 reportError10(ParserErrorCode.MULTIPLE_VARIABLES_IN_FOR_EACH, [var iables.length.toString()]);
4264 } 4296 }
4265 VariableDeclaration variable = variables[0]; 4297 VariableDeclaration variable = variables[0];
4266 if (variable.initializer != null) { 4298 if (variable.initializer != null) {
4267 reportError9(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, []) ; 4299 reportError10(ParserErrorCode.INITIALIZED_VARIABLE_IN_FOR_EACH, [] );
4268 } 4300 }
4269 Token keyword = variableList.keyword; 4301 Token keyword = variableList.keyword;
4270 TypeName type = variableList.type; 4302 TypeName type = variableList.type;
4271 if (keyword != null || type != null) { 4303 if (keyword != null || type != null) {
4272 loopVariable = new DeclaredIdentifier.full(commentAndMetadata.comm ent, commentAndMetadata.metadata, keyword, type, variable.name); 4304 loopVariable = new DeclaredIdentifier.full(commentAndMetadata.comm ent, commentAndMetadata.metadata, keyword, type, variable.name);
4273 } else { 4305 } else {
4274 if (!commentAndMetadata.metadata.isEmpty) { 4306 if (!commentAndMetadata.metadata.isEmpty) {
4275 } 4307 }
4276 identifier = variable.name; 4308 identifier = variable.name;
4277 } 4309 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 * functionBody ::= 4343 * functionBody ::=
4312 * '=>' expression ';' 4344 * '=>' expression ';'
4313 * | block 4345 * | block
4314 * 4346 *
4315 * functionExpressionBody ::= 4347 * functionExpressionBody ::=
4316 * '=>' expression 4348 * '=>' expression
4317 * | block 4349 * | block
4318 * </pre> 4350 * </pre>
4319 * 4351 *
4320 * @param mayBeEmpty `true` if the function body is allowed to be empty 4352 * @param mayBeEmpty `true` if the function body is allowed to be empty
4321 * @param emptyErrorCode the error code to report if function body expecte, bu t not found 4353 * @param emptyErrorCode the error code to report if function body expected, b ut not found
4322 * @param inExpression `true` if the function body is being parsed as part of an expression 4354 * @param inExpression `true` if the function body is being parsed as part of an expression
4323 * and therefore does not have a terminating semicolon 4355 * and therefore does not have a terminating semicolon
4324 * @return the function body that was parsed 4356 * @return the function body that was parsed
4325 */ 4357 */
4326 FunctionBody parseFunctionBody(bool mayBeEmpty, ParserErrorCode emptyErrorCode , bool inExpression) { 4358 FunctionBody parseFunctionBody(bool mayBeEmpty, ParserErrorCode emptyErrorCode , bool inExpression) {
4327 bool wasInLoop = _inLoop; 4359 bool wasInLoop = _inLoop;
4328 bool wasInSwitch = _inSwitch; 4360 bool wasInSwitch = _inSwitch;
4329 _inLoop = false; 4361 _inLoop = false;
4330 _inSwitch = false; 4362 _inSwitch = false;
4331 try { 4363 try {
4332 if (matches5(TokenType.SEMICOLON)) { 4364 if (matches5(TokenType.SEMICOLON)) {
4333 if (!mayBeEmpty) { 4365 if (!mayBeEmpty) {
4334 reportError9(emptyErrorCode, []); 4366 reportError10(emptyErrorCode, []);
4335 } 4367 }
4336 return new EmptyFunctionBody.full(andAdvance); 4368 return new EmptyFunctionBody.full(andAdvance);
4337 } else if (matches5(TokenType.FUNCTION)) { 4369 } else if (matches5(TokenType.FUNCTION)) {
4338 Token functionDefinition = andAdvance; 4370 Token functionDefinition = andAdvance;
4339 Expression expression = parseExpression2(); 4371 Expression expression = parseExpression2();
4340 Token semicolon = null; 4372 Token semicolon = null;
4341 if (!inExpression) { 4373 if (!inExpression) {
4342 semicolon = expect2(TokenType.SEMICOLON); 4374 semicolon = expect2(TokenType.SEMICOLON);
4343 } 4375 }
4376 if (!_parseFunctionBodies) {
4377 return new EmptyFunctionBody.full(createSyntheticToken2(TokenType.SEMI COLON));
4378 }
4344 return new ExpressionFunctionBody.full(functionDefinition, expression, s emicolon); 4379 return new ExpressionFunctionBody.full(functionDefinition, expression, s emicolon);
4345 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 4380 } else if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
4381 if (!_parseFunctionBodies) {
4382 skipBlock();
4383 return new EmptyFunctionBody.full(createSyntheticToken2(TokenType.SEMI COLON));
4384 }
4346 return new BlockFunctionBody.full(parseBlock()); 4385 return new BlockFunctionBody.full(parseBlock());
4347 } else if (matches2(_NATIVE)) { 4386 } else if (matches2(_NATIVE)) {
4348 Token nativeToken = andAdvance; 4387 Token nativeToken = andAdvance;
4349 StringLiteral stringLiteral = null; 4388 StringLiteral stringLiteral = null;
4350 if (matches5(TokenType.STRING)) { 4389 if (matches5(TokenType.STRING)) {
4351 stringLiteral = parseStringLiteral(); 4390 stringLiteral = parseStringLiteral();
4352 } 4391 }
4353 return new NativeFunctionBody.full(nativeToken, stringLiteral, expect2(T okenType.SEMICOLON)); 4392 return new NativeFunctionBody.full(nativeToken, stringLiteral, expect2(T okenType.SEMICOLON));
4354 } else { 4393 } else {
4355 reportError9(emptyErrorCode, []); 4394 reportError10(emptyErrorCode, []);
4356 return new EmptyFunctionBody.full(createSyntheticToken2(TokenType.SEMICO LON)); 4395 return new EmptyFunctionBody.full(createSyntheticToken2(TokenType.SEMICO LON));
4357 } 4396 }
4358 } finally { 4397 } finally {
4359 _inLoop = wasInLoop; 4398 _inLoop = wasInLoop;
4360 _inSwitch = wasInSwitch; 4399 _inSwitch = wasInSwitch;
4361 } 4400 }
4362 } 4401 }
4363 4402
4364 /** 4403 /**
4365 * Parse a function declaration. 4404 * Parse a function declaration.
(...skipping 20 matching lines...) Expand all
4386 } else if (matches(Keyword.SET) && !matches4(peek(), TokenType.OPEN_PAREN)) { 4425 } else if (matches(Keyword.SET) && !matches4(peek(), TokenType.OPEN_PAREN)) {
4387 keyword = andAdvance; 4426 keyword = andAdvance;
4388 } 4427 }
4389 SimpleIdentifier name = parseSimpleIdentifier(); 4428 SimpleIdentifier name = parseSimpleIdentifier();
4390 FormalParameterList parameters = null; 4429 FormalParameterList parameters = null;
4391 if (!isGetter) { 4430 if (!isGetter) {
4392 if (matches5(TokenType.OPEN_PAREN)) { 4431 if (matches5(TokenType.OPEN_PAREN)) {
4393 parameters = parseFormalParameterList(); 4432 parameters = parseFormalParameterList();
4394 validateFormalParameterList(parameters); 4433 validateFormalParameterList(parameters);
4395 } else { 4434 } else {
4396 reportError9(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, []); 4435 reportError10(ParserErrorCode.MISSING_FUNCTION_PARAMETERS, []);
4397 } 4436 }
4398 } else if (matches5(TokenType.OPEN_PAREN)) { 4437 } else if (matches5(TokenType.OPEN_PAREN)) {
4399 reportError9(ParserErrorCode.GETTER_WITH_PARAMETERS, []); 4438 reportError10(ParserErrorCode.GETTER_WITH_PARAMETERS, []);
4400 parseFormalParameterList(); 4439 parseFormalParameterList();
4401 } 4440 }
4402 FunctionBody body; 4441 FunctionBody body;
4403 if (externalKeyword == null) { 4442 if (externalKeyword == null) {
4404 body = parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTION_BODY, fal se); 4443 body = parseFunctionBody(false, ParserErrorCode.MISSING_FUNCTION_BODY, fal se);
4405 } else { 4444 } else {
4406 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON)); 4445 body = new EmptyFunctionBody.full(expect2(TokenType.SEMICOLON));
4407 } 4446 }
4408 return new FunctionDeclaration.full(commentAndMetadata.comment, commentAndMe tadata.metadata, externalKeyword, returnType, keyword, name, new FunctionExpress ion.full(parameters, body)); 4447 return new FunctionDeclaration.full(commentAndMetadata.comment, commentAndMe tadata.metadata, externalKeyword, returnType, keyword, name, new FunctionExpress ion.full(parameters, body));
4409 } 4448 }
(...skipping 25 matching lines...) Expand all
4435 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 4474 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
4436 * declaration 4475 * declaration
4437 * @param returnType the return type, or `null` if there is no return type 4476 * @param returnType the return type, or `null` if there is no return type
4438 * @return the function declaration statement that was parsed 4477 * @return the function declaration statement that was parsed
4439 */ 4478 */
4440 Statement parseFunctionDeclarationStatement2(CommentAndMetadata commentAndMeta data, TypeName returnType) { 4479 Statement parseFunctionDeclarationStatement2(CommentAndMetadata commentAndMeta data, TypeName returnType) {
4441 FunctionDeclaration declaration = parseFunctionDeclaration(commentAndMetadat a, null, returnType); 4480 FunctionDeclaration declaration = parseFunctionDeclaration(commentAndMetadat a, null, returnType);
4442 Token propertyKeyword = declaration.propertyKeyword; 4481 Token propertyKeyword = declaration.propertyKeyword;
4443 if (propertyKeyword != null) { 4482 if (propertyKeyword != null) {
4444 if (identical((propertyKeyword as KeywordToken).keyword, Keyword.GET)) { 4483 if (identical((propertyKeyword as KeywordToken).keyword, Keyword.GET)) {
4445 reportError10(ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword, []); 4484 reportError11(ParserErrorCode.GETTER_IN_FUNCTION, propertyKeyword, []);
4446 } else { 4485 } else {
4447 reportError10(ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword, []); 4486 reportError11(ParserErrorCode.SETTER_IN_FUNCTION, propertyKeyword, []);
4448 } 4487 }
4449 } 4488 }
4450 return new FunctionDeclarationStatement.full(declaration); 4489 return new FunctionDeclarationStatement.full(declaration);
4451 } 4490 }
4452 4491
4453 /** 4492 /**
4454 * Parse a function type alias. 4493 * Parse a function type alias.
4455 * 4494 *
4456 * <pre> 4495 * <pre>
4457 * functionTypeAlias ::= 4496 * functionTypeAlias ::=
(...skipping 11 matching lines...) Expand all
4469 TypeName returnType = null; 4508 TypeName returnType = null;
4470 if (hasReturnTypeInTypeAlias()) { 4509 if (hasReturnTypeInTypeAlias()) {
4471 returnType = parseReturnType(); 4510 returnType = parseReturnType();
4472 } 4511 }
4473 SimpleIdentifier name = parseSimpleIdentifier(); 4512 SimpleIdentifier name = parseSimpleIdentifier();
4474 TypeParameterList typeParameters = null; 4513 TypeParameterList typeParameters = null;
4475 if (matches5(TokenType.LT)) { 4514 if (matches5(TokenType.LT)) {
4476 typeParameters = parseTypeParameterList(); 4515 typeParameters = parseTypeParameterList();
4477 } 4516 }
4478 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.EOF)) { 4517 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.EOF)) {
4479 reportError9(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []); 4518 reportError10(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []);
4480 FormalParameterList parameters = new FormalParameterList.full(createSynthe ticToken2(TokenType.OPEN_PAREN), null, null, null, createSyntheticToken2(TokenTy pe.CLOSE_PAREN)); 4519 FormalParameterList parameters = new FormalParameterList.full(createSynthe ticToken2(TokenType.OPEN_PAREN), null, null, null, createSyntheticToken2(TokenTy pe.CLOSE_PAREN));
4481 Token semicolon = expect2(TokenType.SEMICOLON); 4520 Token semicolon = expect2(TokenType.SEMICOLON);
4482 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMe tadata.metadata, keyword, returnType, name, typeParameters, parameters, semicolo n); 4521 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMe tadata.metadata, keyword, returnType, name, typeParameters, parameters, semicolo n);
4483 } else if (!matches5(TokenType.OPEN_PAREN)) { 4522 } else if (!matches5(TokenType.OPEN_PAREN)) {
4484 reportError9(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []); 4523 reportError10(ParserErrorCode.MISSING_TYPEDEF_PARAMETERS, []);
4485 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMe tadata.metadata, keyword, returnType, name, typeParameters, new FormalParameterL ist.full(createSyntheticToken2(TokenType.OPEN_PAREN), null, null, null, createSy ntheticToken2(TokenType.CLOSE_PAREN)), createSyntheticToken2(TokenType.SEMICOLON )); 4524 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMe tadata.metadata, keyword, returnType, name, typeParameters, new FormalParameterL ist.full(createSyntheticToken2(TokenType.OPEN_PAREN), null, null, null, createSy ntheticToken2(TokenType.CLOSE_PAREN)), createSyntheticToken2(TokenType.SEMICOLON ));
4486 } 4525 }
4487 FormalParameterList parameters = parseFormalParameterList(); 4526 FormalParameterList parameters = parseFormalParameterList();
4488 validateFormalParameterList(parameters); 4527 validateFormalParameterList(parameters);
4489 Token semicolon = expect2(TokenType.SEMICOLON); 4528 Token semicolon = expect2(TokenType.SEMICOLON);
4490 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMeta data.metadata, keyword, returnType, name, typeParameters, parameters, semicolon) ; 4529 return new FunctionTypeAlias.full(commentAndMetadata.comment, commentAndMeta data.metadata, keyword, returnType, name, typeParameters, parameters, semicolon) ;
4491 } 4530 }
4492 4531
4493 /** 4532 /**
4494 * Parse a getter. 4533 * Parse a getter.
(...skipping 11 matching lines...) Expand all
4506 * @param externalKeyword the 'external' token 4545 * @param externalKeyword the 'external' token
4507 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic 4546 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic
4508 * @param the return type that has already been parsed, or `null` if there was no return 4547 * @param the return type that has already been parsed, or `null` if there was no return
4509 * type 4548 * type
4510 * @return the getter that was parsed 4549 * @return the getter that was parsed
4511 */ 4550 */
4512 MethodDeclaration parseGetter(CommentAndMetadata commentAndMetadata, Token ext ernalKeyword, Token staticKeyword, TypeName returnType) { 4551 MethodDeclaration parseGetter(CommentAndMetadata commentAndMetadata, Token ext ernalKeyword, Token staticKeyword, TypeName returnType) {
4513 Token propertyKeyword = expect(Keyword.GET); 4552 Token propertyKeyword = expect(Keyword.GET);
4514 SimpleIdentifier name = parseSimpleIdentifier(); 4553 SimpleIdentifier name = parseSimpleIdentifier();
4515 if (matches5(TokenType.OPEN_PAREN) && matches4(peek(), TokenType.CLOSE_PAREN )) { 4554 if (matches5(TokenType.OPEN_PAREN) && matches4(peek(), TokenType.CLOSE_PAREN )) {
4516 reportError9(ParserErrorCode.GETTER_WITH_PARAMETERS, []); 4555 reportError10(ParserErrorCode.GETTER_WITH_PARAMETERS, []);
4517 advance(); 4556 advance();
4518 advance(); 4557 advance();
4519 } 4558 }
4520 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo rd == null, ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, false); 4559 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo rd == null, ParserErrorCode.STATIC_GETTER_WITHOUT_BODY, false);
4521 if (externalKeyword != null && body is! EmptyFunctionBody) { 4560 if (externalKeyword != null && body is! EmptyFunctionBody) {
4522 reportError9(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, []); 4561 reportError10(ParserErrorCode.EXTERNAL_GETTER_WITH_BODY, []);
4523 } 4562 }
4524 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null , name, null, body); 4563 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null , name, null, body);
4525 } 4564 }
4526 4565
4527 /** 4566 /**
4528 * Parse a list of identifiers. 4567 * Parse a list of identifiers.
4529 * 4568 *
4530 * <pre> 4569 * <pre>
4531 * identifierList ::= 4570 * identifierList ::=
4532 * identifier (',' identifier)* 4571 * identifier (',' identifier)*
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
4668 * @param missingNameError the error code to be used if the library name is mi ssing 4707 * @param missingNameError the error code to be used if the library name is mi ssing
4669 * @param missingNameToken the token associated with the error produced if the library name is 4708 * @param missingNameToken the token associated with the error produced if the library name is
4670 * missing 4709 * missing
4671 * @return the library name that was parsed 4710 * @return the library name that was parsed
4672 */ 4711 */
4673 LibraryIdentifier parseLibraryName(ParserErrorCode missingNameError, Token mis singNameToken) { 4712 LibraryIdentifier parseLibraryName(ParserErrorCode missingNameError, Token mis singNameToken) {
4674 if (matchesIdentifier()) { 4713 if (matchesIdentifier()) {
4675 return parseLibraryIdentifier(); 4714 return parseLibraryIdentifier();
4676 } else if (matches5(TokenType.STRING)) { 4715 } else if (matches5(TokenType.STRING)) {
4677 StringLiteral string = parseStringLiteral(); 4716 StringLiteral string = parseStringLiteral();
4678 reportError(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string, []); 4717 reportError9(ParserErrorCode.NON_IDENTIFIER_LIBRARY_NAME, string, []);
4679 } else { 4718 } else {
4680 reportError10(missingNameError, missingNameToken, []); 4719 reportError11(missingNameError, missingNameToken, []);
4681 } 4720 }
4682 List<SimpleIdentifier> components = new List<SimpleIdentifier>(); 4721 List<SimpleIdentifier> components = new List<SimpleIdentifier>();
4683 components.add(createSyntheticIdentifier()); 4722 components.add(createSyntheticIdentifier());
4684 return new LibraryIdentifier.full(components); 4723 return new LibraryIdentifier.full(components);
4685 } 4724 }
4686 4725
4687 /** 4726 /**
4688 * Parse a list literal. 4727 * Parse a list literal.
4689 * 4728 *
4690 * <pre> 4729 * <pre>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4741 TypedLiteral parseListOrMapLiteral(Token modifier) { 4780 TypedLiteral parseListOrMapLiteral(Token modifier) {
4742 TypeArgumentList typeArguments = null; 4781 TypeArgumentList typeArguments = null;
4743 if (matches5(TokenType.LT)) { 4782 if (matches5(TokenType.LT)) {
4744 typeArguments = parseTypeArgumentList(); 4783 typeArguments = parseTypeArgumentList();
4745 } 4784 }
4746 if (matches5(TokenType.OPEN_CURLY_BRACKET)) { 4785 if (matches5(TokenType.OPEN_CURLY_BRACKET)) {
4747 return parseMapLiteral(modifier, typeArguments); 4786 return parseMapLiteral(modifier, typeArguments);
4748 } else if (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.IND EX)) { 4787 } else if (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.IND EX)) {
4749 return parseListLiteral(modifier, typeArguments); 4788 return parseListLiteral(modifier, typeArguments);
4750 } 4789 }
4751 reportError9(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, []); 4790 reportError10(ParserErrorCode.EXPECTED_LIST_OR_MAP_LITERAL, []);
4752 return new ListLiteral.full(modifier, typeArguments, createSyntheticToken2(T okenType.OPEN_SQUARE_BRACKET), null, createSyntheticToken2(TokenType.CLOSE_SQUAR E_BRACKET)); 4791 return new ListLiteral.full(modifier, typeArguments, createSyntheticToken2(T okenType.OPEN_SQUARE_BRACKET), null, createSyntheticToken2(TokenType.CLOSE_SQUAR E_BRACKET));
4753 } 4792 }
4754 4793
4755 /** 4794 /**
4756 * Parse a logical and expression. 4795 * Parse a logical and expression.
4757 * 4796 *
4758 * <pre> 4797 * <pre>
4759 * logicalAndExpression ::= 4798 * logicalAndExpression ::=
4760 * equalityExpression ('&&' equalityExpression)* 4799 * equalityExpression ('&&' equalityExpression)*
4761 * </pre> 4800 * </pre>
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
4840 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic 4879 * @param staticKeyword the static keyword, or `null` if the getter is not sta tic
4841 * @param returnType the return type of the method 4880 * @param returnType the return type of the method
4842 * @param name the name of the method 4881 * @param name the name of the method
4843 * @param parameters the parameters to the method 4882 * @param parameters the parameters to the method
4844 * @return the method declaration that was parsed 4883 * @return the method declaration that was parsed
4845 */ 4884 */
4846 MethodDeclaration parseMethodDeclaration2(CommentAndMetadata commentAndMetadat a, Token externalKeyword, Token staticKeyword, TypeName returnType, SimpleIdenti fier name, FormalParameterList parameters) { 4885 MethodDeclaration parseMethodDeclaration2(CommentAndMetadata commentAndMetadat a, Token externalKeyword, Token staticKeyword, TypeName returnType, SimpleIdenti fier name, FormalParameterList parameters) {
4847 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo rd == null, ParserErrorCode.MISSING_FUNCTION_BODY, false); 4886 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo rd == null, ParserErrorCode.MISSING_FUNCTION_BODY, false);
4848 if (externalKeyword != null) { 4887 if (externalKeyword != null) {
4849 if (body is! EmptyFunctionBody) { 4888 if (body is! EmptyFunctionBody) {
4850 reportError(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body, []); 4889 reportError9(ParserErrorCode.EXTERNAL_METHOD_WITH_BODY, body, []);
4851 } 4890 }
4852 } else if (staticKeyword != null) { 4891 } else if (staticKeyword != null) {
4853 if (body is EmptyFunctionBody) { 4892 if (body is EmptyFunctionBody) {
4854 reportError(ParserErrorCode.ABSTRACT_STATIC_METHOD, body, []); 4893 reportError9(ParserErrorCode.ABSTRACT_STATIC_METHOD, body, []);
4855 } 4894 }
4856 } 4895 }
4857 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, staticKeyword, returnType, null, null, name, par ameters, body); 4896 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, staticKeyword, returnType, null, null, name, par ameters, body);
4858 } 4897 }
4859 4898
4860 /** 4899 /**
4861 * Parse the modifiers preceding a declaration. This method allows the modifie rs to appear in any 4900 * Parse the modifiers preceding a declaration. This method allows the modifie rs to appear in any
4862 * order but does generate errors for duplicated modifiers. Checks for other p roblems, such as 4901 * order but does generate errors for duplicated modifiers. Checks for other p roblems, such as
4863 * having the modifiers appear in the wrong order or specifying both 'const' a nd 'final', are 4902 * having the modifiers appear in the wrong order or specifying both 'const' a nd 'final', are
4864 * reported in one of the methods whose name is prefixed with `validateModifie rsFor`. 4903 * reported in one of the methods whose name is prefixed with `validateModifie rsFor`.
4865 * 4904 *
4866 * <pre> 4905 * <pre>
4867 * modifiers ::= 4906 * modifiers ::=
4868 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | ' var')* 4907 * ('abstract' | 'const' | 'external' | 'factory' | 'final' | 'static' | ' var')*
4869 * </pre> 4908 * </pre>
4870 * 4909 *
4871 * @return the modifiers that were parsed 4910 * @return the modifiers that were parsed
4872 */ 4911 */
4873 Modifiers parseModifiers() { 4912 Modifiers parseModifiers() {
4874 Modifiers modifiers = new Modifiers(); 4913 Modifiers modifiers = new Modifiers();
4875 bool progress = true; 4914 bool progress = true;
4876 while (progress) { 4915 while (progress) {
4877 if (matches4(peek(), TokenType.PERIOD) || matches4(peek(), TokenType.LT) | | matches4(peek(), TokenType.OPEN_PAREN)) { 4916 if (matches4(peek(), TokenType.PERIOD) || matches4(peek(), TokenType.LT) | | matches4(peek(), TokenType.OPEN_PAREN)) {
4878 return modifiers; 4917 return modifiers;
4879 } 4918 }
4880 if (matches(Keyword.ABSTRACT)) { 4919 if (matches(Keyword.ABSTRACT)) {
4881 if (modifiers.abstractKeyword != null) { 4920 if (modifiers.abstractKeyword != null) {
4882 reportError9(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem e]); 4921 reportError10(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexe me]);
4883 advance(); 4922 advance();
4884 } else { 4923 } else {
4885 modifiers.abstractKeyword = andAdvance; 4924 modifiers.abstractKeyword = andAdvance;
4886 } 4925 }
4887 } else if (matches(Keyword.CONST)) { 4926 } else if (matches(Keyword.CONST)) {
4888 if (modifiers.constKeyword != null) { 4927 if (modifiers.constKeyword != null) {
4889 reportError9(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem e]); 4928 reportError10(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexe me]);
4890 advance(); 4929 advance();
4891 } else { 4930 } else {
4892 modifiers.constKeyword = andAdvance; 4931 modifiers.constKeyword = andAdvance;
4893 } 4932 }
4894 } else if (matches(Keyword.EXTERNAL) && !matches4(peek(), TokenType.PERIOD ) && !matches4(peek(), TokenType.LT)) { 4933 } else if (matches(Keyword.EXTERNAL) && !matches4(peek(), TokenType.PERIOD ) && !matches4(peek(), TokenType.LT)) {
4895 if (modifiers.externalKeyword != null) { 4934 if (modifiers.externalKeyword != null) {
4896 reportError9(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem e]); 4935 reportError10(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexe me]);
4897 advance(); 4936 advance();
4898 } else { 4937 } else {
4899 modifiers.externalKeyword = andAdvance; 4938 modifiers.externalKeyword = andAdvance;
4900 } 4939 }
4901 } else if (matches(Keyword.FACTORY) && !matches4(peek(), TokenType.PERIOD) && !matches4(peek(), TokenType.LT)) { 4940 } else if (matches(Keyword.FACTORY) && !matches4(peek(), TokenType.PERIOD) && !matches4(peek(), TokenType.LT)) {
4902 if (modifiers.factoryKeyword != null) { 4941 if (modifiers.factoryKeyword != null) {
4903 reportError9(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem e]); 4942 reportError10(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexe me]);
4904 advance(); 4943 advance();
4905 } else { 4944 } else {
4906 modifiers.factoryKeyword = andAdvance; 4945 modifiers.factoryKeyword = andAdvance;
4907 } 4946 }
4908 } else if (matches(Keyword.FINAL)) { 4947 } else if (matches(Keyword.FINAL)) {
4909 if (modifiers.finalKeyword != null) { 4948 if (modifiers.finalKeyword != null) {
4910 reportError9(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem e]); 4949 reportError10(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexe me]);
4911 advance(); 4950 advance();
4912 } else { 4951 } else {
4913 modifiers.finalKeyword = andAdvance; 4952 modifiers.finalKeyword = andAdvance;
4914 } 4953 }
4915 } else if (matches(Keyword.STATIC) && !matches4(peek(), TokenType.PERIOD) && !matches4(peek(), TokenType.LT)) { 4954 } else if (matches(Keyword.STATIC) && !matches4(peek(), TokenType.PERIOD) && !matches4(peek(), TokenType.LT)) {
4916 if (modifiers.staticKeyword != null) { 4955 if (modifiers.staticKeyword != null) {
4917 reportError9(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem e]); 4956 reportError10(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexe me]);
4918 advance(); 4957 advance();
4919 } else { 4958 } else {
4920 modifiers.staticKeyword = andAdvance; 4959 modifiers.staticKeyword = andAdvance;
4921 } 4960 }
4922 } else if (matches(Keyword.VAR)) { 4961 } else if (matches(Keyword.VAR)) {
4923 if (modifiers.varKeyword != null) { 4962 if (modifiers.varKeyword != null) {
4924 reportError9(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexem e]); 4963 reportError10(ParserErrorCode.DUPLICATED_MODIFIER, [_currentToken.lexe me]);
4925 advance(); 4964 advance();
4926 } else { 4965 } else {
4927 modifiers.varKeyword = andAdvance; 4966 modifiers.varKeyword = andAdvance;
4928 } 4967 }
4929 } else { 4968 } else {
4930 progress = false; 4969 progress = false;
4931 } 4970 }
4932 } 4971 }
4933 return modifiers; 4972 return modifiers;
4934 } 4973 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
5050 } else if (identical(keyword, Keyword.VOID)) { 5089 } else if (identical(keyword, Keyword.VOID)) {
5051 TypeName returnType = parseReturnType(); 5090 TypeName returnType = parseReturnType();
5052 if (matchesIdentifier() && matchesAny(peek(), [ 5091 if (matchesIdentifier() && matchesAny(peek(), [
5053 TokenType.OPEN_PAREN, 5092 TokenType.OPEN_PAREN,
5054 TokenType.OPEN_CURLY_BRACKET, 5093 TokenType.OPEN_CURLY_BRACKET,
5055 TokenType.FUNCTION])) { 5094 TokenType.FUNCTION])) {
5056 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe); 5095 return parseFunctionDeclarationStatement2(commentAndMetadata, returnTy pe);
5057 } else { 5096 } else {
5058 if (matchesIdentifier()) { 5097 if (matchesIdentifier()) {
5059 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) { 5098 if (matchesAny(peek(), [TokenType.EQ, TokenType.COMMA, TokenType.SEM ICOLON])) {
5060 reportError(ParserErrorCode.VOID_VARIABLE, returnType, []); 5099 reportError9(ParserErrorCode.VOID_VARIABLE, returnType, []);
5061 return parseVariableDeclarationStatement(commentAndMetadata); 5100 return parseVariableDeclarationStatement(commentAndMetadata);
5062 } 5101 }
5063 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 5102 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
5064 return parseVariableDeclarationStatement2(commentAndMetadata, null, returnType); 5103 return parseVariableDeclarationStatement2(commentAndMetadata, null, returnType);
5065 } 5104 }
5066 reportError9(ParserErrorCode.MISSING_STATEMENT, []); 5105 reportError10(ParserErrorCode.MISSING_STATEMENT, []);
5067 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOL ON)); 5106 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOL ON));
5068 } 5107 }
5069 } else if (identical(keyword, Keyword.CONST)) { 5108 } else if (identical(keyword, Keyword.CONST)) {
5070 if (matchesAny(peek(), [ 5109 if (matchesAny(peek(), [
5071 TokenType.LT, 5110 TokenType.LT,
5072 TokenType.OPEN_CURLY_BRACKET, 5111 TokenType.OPEN_CURLY_BRACKET,
5073 TokenType.OPEN_SQUARE_BRACKET, 5112 TokenType.OPEN_SQUARE_BRACKET,
5074 TokenType.INDEX])) { 5113 TokenType.INDEX])) {
5075 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON)); 5114 return new ExpressionStatement.full(parseExpression2(), expect2(TokenT ype.SEMICOLON));
5076 } else if (matches4(peek(), TokenType.IDENTIFIER)) { 5115 } else if (matches4(peek(), TokenType.IDENTIFIER)) {
5077 Token afterType = skipTypeName(peek()); 5116 Token afterType = skipTypeName(peek());
5078 if (afterType != null) { 5117 if (afterType != null) {
5079 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) { 5118 if (matches4(afterType, TokenType.OPEN_PAREN) || (matches4(afterType , TokenType.PERIOD) && matches4(afterType.next, TokenType.IDENTIFIER) && matches 4(afterType.next.next, TokenType.OPEN_PAREN))) {
5080 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON)); 5119 return new ExpressionStatement.full(parseExpression2(), expect2(To kenType.SEMICOLON));
5081 } 5120 }
5082 } 5121 }
5083 } 5122 }
5084 return parseVariableDeclarationStatement(commentAndMetadata); 5123 return parseVariableDeclarationStatement(commentAndMetadata);
5085 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) || identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) { 5124 } else if (identical(keyword, Keyword.NEW) || identical(keyword, Keyword.T RUE) || identical(keyword, Keyword.FALSE) || identical(keyword, Keyword.NULL) || identical(keyword, Keyword.SUPER) || identical(keyword, Keyword.THIS)) {
5086 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON)); 5125 return new ExpressionStatement.full(parseExpression2(), expect2(TokenTyp e.SEMICOLON));
5087 } else { 5126 } else {
5088 reportError9(ParserErrorCode.MISSING_STATEMENT, []); 5127 reportError10(ParserErrorCode.MISSING_STATEMENT, []);
5089 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON )); 5128 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON ));
5090 } 5129 }
5091 } else if (matches5(TokenType.SEMICOLON)) { 5130 } else if (matches5(TokenType.SEMICOLON)) {
5092 return parseEmptyStatement(); 5131 return parseEmptyStatement();
5093 } else if (isInitializedVariableDeclaration()) { 5132 } else if (isInitializedVariableDeclaration()) {
5094 return parseVariableDeclarationStatement(commentAndMetadata); 5133 return parseVariableDeclarationStatement(commentAndMetadata);
5095 } else if (isFunctionDeclaration()) { 5134 } else if (isFunctionDeclaration()) {
5096 return parseFunctionDeclarationStatement(); 5135 return parseFunctionDeclarationStatement();
5097 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) { 5136 } else if (matches5(TokenType.CLOSE_CURLY_BRACKET)) {
5098 reportError9(ParserErrorCode.MISSING_STATEMENT, []); 5137 reportError10(ParserErrorCode.MISSING_STATEMENT, []);
5099 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON)) ; 5138 return new EmptyStatement.full(createSyntheticToken2(TokenType.SEMICOLON)) ;
5100 } else { 5139 } else {
5101 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType. SEMICOLON)); 5140 return new ExpressionStatement.full(parseExpression2(), expect2(TokenType. SEMICOLON));
5102 } 5141 }
5103 } 5142 }
5104 5143
5105 /** 5144 /**
5106 * Parse an operator declaration. 5145 * Parse an operator declaration.
5107 * 5146 *
5108 * <pre> 5147 * <pre>
5109 * operatorDeclaration ::= 5148 * operatorDeclaration ::=
5110 * operatorSignature (';' | functionBody) 5149 * operatorSignature (';' | functionBody)
5111 * 5150 *
5112 * operatorSignature ::= 5151 * operatorSignature ::=
5113 * 'external'? returnType? 'operator' operator formalParameterList 5152 * 'external'? returnType? 'operator' operator formalParameterList
5114 * </pre> 5153 * </pre>
5115 * 5154 *
5116 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the 5155 * @param commentAndMetadata the documentation comment and metadata to be asso ciated with the
5117 * declaration 5156 * declaration
5118 * @param externalKeyword the 'external' token 5157 * @param externalKeyword the 'external' token
5119 * @param the return type that has already been parsed, or `null` if there was no return 5158 * @param the return type that has already been parsed, or `null` if there was no return
5120 * type 5159 * type
5121 * @return the operator declaration that was parsed 5160 * @return the operator declaration that was parsed
5122 */ 5161 */
5123 MethodDeclaration parseOperator(CommentAndMetadata commentAndMetadata, Token e xternalKeyword, TypeName returnType) { 5162 MethodDeclaration parseOperator(CommentAndMetadata commentAndMetadata, Token e xternalKeyword, TypeName returnType) {
5124 Token operatorKeyword; 5163 Token operatorKeyword;
5125 if (matches(Keyword.OPERATOR)) { 5164 if (matches(Keyword.OPERATOR)) {
5126 operatorKeyword = andAdvance; 5165 operatorKeyword = andAdvance;
5127 } else { 5166 } else {
5128 reportError10(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToken, []) ; 5167 reportError11(ParserErrorCode.MISSING_KEYWORD_OPERATOR, _currentToken, []) ;
5129 operatorKeyword = createSyntheticToken(Keyword.OPERATOR); 5168 operatorKeyword = createSyntheticToken(Keyword.OPERATOR);
5130 } 5169 }
5131 if (!_currentToken.isUserDefinableOperator) { 5170 if (!_currentToken.isUserDefinableOperator) {
5132 reportError9(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken.l exeme]); 5171 reportError10(ParserErrorCode.NON_USER_DEFINABLE_OPERATOR, [_currentToken. lexeme]);
5133 } 5172 }
5134 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance); 5173 SimpleIdentifier name = new SimpleIdentifier.full(andAdvance);
5135 if (matches5(TokenType.EQ)) { 5174 if (matches5(TokenType.EQ)) {
5136 Token previous = _currentToken.previous; 5175 Token previous = _currentToken.previous;
5137 if ((matches4(previous, TokenType.EQ_EQ) || matches4(previous, TokenType.B ANG_EQ)) && _currentToken.offset == previous.offset + 2) { 5176 if ((matches4(previous, TokenType.EQ_EQ) || matches4(previous, TokenType.B ANG_EQ)) && _currentToken.offset == previous.offset + 2) {
5138 reportError9(ParserErrorCode.INVALID_OPERATOR, ["${previous.lexeme}${_cu rrentToken.lexeme}"]); 5177 reportError10(ParserErrorCode.INVALID_OPERATOR, ["${previous.lexeme}${_c urrentToken.lexeme}"]);
5139 advance(); 5178 advance();
5140 } 5179 }
5141 } 5180 }
5142 FormalParameterList parameters = parseFormalParameterList(); 5181 FormalParameterList parameters = parseFormalParameterList();
5143 validateFormalParameterList(parameters); 5182 validateFormalParameterList(parameters);
5144 FunctionBody body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION _BODY, false); 5183 FunctionBody body = parseFunctionBody(true, ParserErrorCode.MISSING_FUNCTION _BODY, false);
5145 if (externalKeyword != null && body is! EmptyFunctionBody) { 5184 if (externalKeyword != null && body is! EmptyFunctionBody) {
5146 reportError9(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []); 5185 reportError10(ParserErrorCode.EXTERNAL_OPERATOR_WITH_BODY, []);
5147 } 5186 }
5148 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p arameters, body); 5187 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, null, returnType, null, operatorKeyword, name, p arameters, body);
5149 } 5188 }
5150 5189
5151 /** 5190 /**
5152 * Parse a return type if one is given, otherwise return `null` without advanc ing. 5191 * Parse a return type if one is given, otherwise return `null` without advanc ing.
5153 * 5192 *
5154 * @return the return type that was parsed 5193 * @return the return type that was parsed
5155 */ 5194 */
5156 TypeName parseOptionalReturnType() { 5195 TypeName parseOptionalReturnType() {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5221 } else { 5260 } else {
5222 operand = parseAssignableSelector(operand, true); 5261 operand = parseAssignableSelector(operand, true);
5223 } 5262 }
5224 } while (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.PER IOD) || matches5(TokenType.OPEN_PAREN)); 5263 } while (matches5(TokenType.OPEN_SQUARE_BRACKET) || matches5(TokenType.PER IOD) || matches5(TokenType.OPEN_PAREN));
5225 return operand; 5264 return operand;
5226 } 5265 }
5227 if (!_currentToken.type.isIncrementOperator) { 5266 if (!_currentToken.type.isIncrementOperator) {
5228 return operand; 5267 return operand;
5229 } 5268 }
5230 if (operand is Literal || operand is FunctionExpressionInvocation) { 5269 if (operand is Literal || operand is FunctionExpressionInvocation) {
5231 reportError9(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []); 5270 reportError10(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, []);
5232 } 5271 }
5233 Token operator = andAdvance; 5272 Token operator = andAdvance;
5234 return new PostfixExpression.full(operand, operator); 5273 return new PostfixExpression.full(operand, operator);
5235 } 5274 }
5236 5275
5237 /** 5276 /**
5238 * Parse a primary expression. 5277 * Parse a primary expression.
5239 * 5278 *
5240 * <pre> 5279 * <pre>
5241 * primary ::= 5280 * primary ::=
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
5314 } 5353 }
5315 Token leftParenthesis = andAdvance; 5354 Token leftParenthesis = andAdvance;
5316 Expression expression = parseExpression2(); 5355 Expression expression = parseExpression2();
5317 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 5356 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
5318 return new ParenthesizedExpression.full(leftParenthesis, expression, right Parenthesis); 5357 return new ParenthesizedExpression.full(leftParenthesis, expression, right Parenthesis);
5319 } else if (matches5(TokenType.LT)) { 5358 } else if (matches5(TokenType.LT)) {
5320 return parseListOrMapLiteral(null); 5359 return parseListOrMapLiteral(null);
5321 } else if (matches5(TokenType.QUESTION)) { 5360 } else if (matches5(TokenType.QUESTION)) {
5322 return parseArgumentDefinitionTest(); 5361 return parseArgumentDefinitionTest();
5323 } else if (matches(Keyword.VOID)) { 5362 } else if (matches(Keyword.VOID)) {
5324 reportError9(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]); 5363 reportError10(ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken.lexeme]);
5325 advance(); 5364 advance();
5326 return parsePrimaryExpression(); 5365 return parsePrimaryExpression();
5327 } else if (matches5(TokenType.HASH)) { 5366 } else if (matches5(TokenType.HASH)) {
5328 return parseSymbolLiteral(); 5367 return parseSymbolLiteral();
5329 } else { 5368 } else {
5330 reportError9(ParserErrorCode.MISSING_IDENTIFIER, []); 5369 reportError10(ParserErrorCode.MISSING_IDENTIFIER, []);
5331 return createSyntheticIdentifier(); 5370 return createSyntheticIdentifier();
5332 } 5371 }
5333 } 5372 }
5334 5373
5335 /** 5374 /**
5336 * Parse a redirecting constructor invocation. 5375 * Parse a redirecting constructor invocation.
5337 * 5376 *
5338 * <pre> 5377 * <pre>
5339 * redirectingConstructorInvocation ::= 5378 * redirectingConstructorInvocation ::=
5340 * 'this' ('.' identifier)? arguments 5379 * 'this' ('.' identifier)? arguments
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
5441 * type 5480 * type
5442 * @return the setter that was parsed 5481 * @return the setter that was parsed
5443 */ 5482 */
5444 MethodDeclaration parseSetter(CommentAndMetadata commentAndMetadata, Token ext ernalKeyword, Token staticKeyword, TypeName returnType) { 5483 MethodDeclaration parseSetter(CommentAndMetadata commentAndMetadata, Token ext ernalKeyword, Token staticKeyword, TypeName returnType) {
5445 Token propertyKeyword = expect(Keyword.SET); 5484 Token propertyKeyword = expect(Keyword.SET);
5446 SimpleIdentifier name = parseSimpleIdentifier(); 5485 SimpleIdentifier name = parseSimpleIdentifier();
5447 FormalParameterList parameters = parseFormalParameterList(); 5486 FormalParameterList parameters = parseFormalParameterList();
5448 validateFormalParameterList(parameters); 5487 validateFormalParameterList(parameters);
5449 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo rd == null, ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, false); 5488 FunctionBody body = parseFunctionBody(externalKeyword != null || staticKeywo rd == null, ParserErrorCode.STATIC_SETTER_WITHOUT_BODY, false);
5450 if (externalKeyword != null && body is! EmptyFunctionBody) { 5489 if (externalKeyword != null && body is! EmptyFunctionBody) {
5451 reportError9(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, []); 5490 reportError10(ParserErrorCode.EXTERNAL_SETTER_WITH_BODY, []);
5452 } 5491 }
5453 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null , name, parameters, body); 5492 return new MethodDeclaration.full(commentAndMetadata.comment, commentAndMeta data.metadata, externalKeyword, staticKeyword, returnType, propertyKeyword, null , name, parameters, body);
5454 } 5493 }
5455 5494
5456 /** 5495 /**
5457 * Parse a shift expression. 5496 * Parse a shift expression.
5458 * 5497 *
5459 * <pre> 5498 * <pre>
5460 * shiftExpression ::= 5499 * shiftExpression ::=
5461 * additiveExpression (shiftOperator additiveExpression)* 5500 * additiveExpression (shiftOperator additiveExpression)*
(...skipping 25 matching lines...) Expand all
5487 * </pre> 5526 * </pre>
5488 * 5527 *
5489 * @return the statements that were parsed 5528 * @return the statements that were parsed
5490 */ 5529 */
5491 List<Statement> parseStatements2() { 5530 List<Statement> parseStatements2() {
5492 List<Statement> statements = new List<Statement>(); 5531 List<Statement> statements = new List<Statement>();
5493 Token statementStart = _currentToken; 5532 Token statementStart = _currentToken;
5494 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET) && !isSwitchMember()) { 5533 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET) && !isSwitchMember()) {
5495 statements.add(parseStatement2()); 5534 statements.add(parseStatement2());
5496 if (identical(_currentToken, statementStart)) { 5535 if (identical(_currentToken, statementStart)) {
5497 reportError10(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]); 5536 reportError11(ParserErrorCode.UNEXPECTED_TOKEN, _currentToken, [_current Token.lexeme]);
5498 advance(); 5537 advance();
5499 } 5538 }
5500 statementStart = _currentToken; 5539 statementStart = _currentToken;
5501 } 5540 }
5502 return statements; 5541 return statements;
5503 } 5542 }
5504 5543
5505 /** 5544 /**
5506 * Parse a string literal that contains interpolations. 5545 * Parse a string literal that contains interpolations.
5507 * 5546 *
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
5585 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN); 5624 Token rightParenthesis = expect2(TokenType.CLOSE_PAREN);
5586 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET); 5625 Token leftBracket = expect2(TokenType.OPEN_CURLY_BRACKET);
5587 Token defaultKeyword = null; 5626 Token defaultKeyword = null;
5588 List<SwitchMember> members = new List<SwitchMember>(); 5627 List<SwitchMember> members = new List<SwitchMember>();
5589 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET )) { 5628 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRACKET )) {
5590 List<Label> labels = new List<Label>(); 5629 List<Label> labels = new List<Label>();
5591 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) { 5630 while (matchesIdentifier() && matches4(peek(), TokenType.COLON)) {
5592 SimpleIdentifier identifier = parseSimpleIdentifier(); 5631 SimpleIdentifier identifier = parseSimpleIdentifier();
5593 String label = identifier.token.lexeme; 5632 String label = identifier.token.lexeme;
5594 if (definedLabels.contains(label)) { 5633 if (definedLabels.contains(label)) {
5595 reportError10(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, i dentifier.token, [label]); 5634 reportError11(ParserErrorCode.DUPLICATE_LABEL_IN_SWITCH_STATEMENT, i dentifier.token, [label]);
5596 } else { 5635 } else {
5597 definedLabels.add(label); 5636 definedLabels.add(label);
5598 } 5637 }
5599 Token colon = expect2(TokenType.COLON); 5638 Token colon = expect2(TokenType.COLON);
5600 labels.add(new Label.full(identifier, colon)); 5639 labels.add(new Label.full(identifier, colon));
5601 } 5640 }
5602 if (matches(Keyword.CASE)) { 5641 if (matches(Keyword.CASE)) {
5603 Token caseKeyword = andAdvance; 5642 Token caseKeyword = andAdvance;
5604 Expression caseExpression = parseExpression2(); 5643 Expression caseExpression = parseExpression2();
5605 Token colon = expect2(TokenType.COLON); 5644 Token colon = expect2(TokenType.COLON);
5606 members.add(new SwitchCase.full(labels, caseKeyword, caseExpression, c olon, parseStatements2())); 5645 members.add(new SwitchCase.full(labels, caseKeyword, caseExpression, c olon, parseStatements2()));
5607 if (defaultKeyword != null) { 5646 if (defaultKeyword != null) {
5608 reportError10(ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, ca seKeyword, []); 5647 reportError11(ParserErrorCode.SWITCH_HAS_CASE_AFTER_DEFAULT_CASE, ca seKeyword, []);
5609 } 5648 }
5610 } else if (matches(Keyword.DEFAULT)) { 5649 } else if (matches(Keyword.DEFAULT)) {
5611 if (defaultKeyword != null) { 5650 if (defaultKeyword != null) {
5612 reportError10(ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, pee k(), []); 5651 reportError11(ParserErrorCode.SWITCH_HAS_MULTIPLE_DEFAULT_CASES, pee k(), []);
5613 } 5652 }
5614 defaultKeyword = andAdvance; 5653 defaultKeyword = andAdvance;
5615 Token colon = expect2(TokenType.COLON); 5654 Token colon = expect2(TokenType.COLON);
5616 members.add(new SwitchDefault.full(labels, defaultKeyword, colon, pars eStatements2())); 5655 members.add(new SwitchDefault.full(labels, defaultKeyword, colon, pars eStatements2()));
5617 } else { 5656 } else {
5618 reportError9(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, []); 5657 reportError10(ParserErrorCode.EXPECTED_CASE_OR_DEFAULT, []);
5619 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRA CKET) && !matches(Keyword.CASE) && !matches(Keyword.DEFAULT)) { 5658 while (!matches5(TokenType.EOF) && !matches5(TokenType.CLOSE_CURLY_BRA CKET) && !matches(Keyword.CASE) && !matches(Keyword.DEFAULT)) {
5620 advance(); 5659 advance();
5621 } 5660 }
5622 } 5661 }
5623 } 5662 }
5624 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET); 5663 Token rightBracket = expect2(TokenType.CLOSE_CURLY_BRACKET);
5625 return new SwitchStatement.full(keyword, leftParenthesis, expression, righ tParenthesis, leftBracket, members, rightBracket); 5664 return new SwitchStatement.full(keyword, leftParenthesis, expression, righ tParenthesis, leftBracket, members, rightBracket);
5626 } finally { 5665 } finally {
5627 _inSwitch = wasInSwitch; 5666 _inSwitch = wasInSwitch;
5628 } 5667 }
(...skipping 12 matching lines...) Expand all
5641 SymbolLiteral parseSymbolLiteral() { 5680 SymbolLiteral parseSymbolLiteral() {
5642 Token poundSign = andAdvance; 5681 Token poundSign = andAdvance;
5643 List<Token> components = new List<Token>(); 5682 List<Token> components = new List<Token>();
5644 if (matchesIdentifier()) { 5683 if (matchesIdentifier()) {
5645 components.add(andAdvance); 5684 components.add(andAdvance);
5646 while (matches5(TokenType.PERIOD)) { 5685 while (matches5(TokenType.PERIOD)) {
5647 advance(); 5686 advance();
5648 if (matchesIdentifier()) { 5687 if (matchesIdentifier()) {
5649 components.add(andAdvance); 5688 components.add(andAdvance);
5650 } else { 5689 } else {
5651 reportError9(ParserErrorCode.MISSING_IDENTIFIER, []); 5690 reportError10(ParserErrorCode.MISSING_IDENTIFIER, []);
5652 components.add(createSyntheticToken2(TokenType.IDENTIFIER)); 5691 components.add(createSyntheticToken2(TokenType.IDENTIFIER));
5653 break; 5692 break;
5654 } 5693 }
5655 } 5694 }
5656 } else if (_currentToken.isOperator) { 5695 } else if (_currentToken.isOperator) {
5657 components.add(andAdvance); 5696 components.add(andAdvance);
5658 } else { 5697 } else {
5659 reportError9(ParserErrorCode.MISSING_IDENTIFIER, []); 5698 reportError10(ParserErrorCode.MISSING_IDENTIFIER, []);
5660 components.add(createSyntheticToken2(TokenType.IDENTIFIER)); 5699 components.add(createSyntheticToken2(TokenType.IDENTIFIER));
5661 } 5700 }
5662 return new SymbolLiteral.full(poundSign, new List.from(components)); 5701 return new SymbolLiteral.full(poundSign, new List.from(components));
5663 } 5702 }
5664 5703
5665 /** 5704 /**
5666 * Parse a throw expression. 5705 * Parse a throw expression.
5667 * 5706 *
5668 * <pre> 5707 * <pre>
5669 * throwExpression ::= 5708 * throwExpression ::=
5670 * 'throw' expression 5709 * 'throw' expression
5671 * </pre> 5710 * </pre>
5672 * 5711 *
5673 * @return the throw expression that was parsed 5712 * @return the throw expression that was parsed
5674 */ 5713 */
5675 Expression parseThrowExpression() { 5714 Expression parseThrowExpression() {
5676 Token keyword = expect(Keyword.THROW); 5715 Token keyword = expect(Keyword.THROW);
5677 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) { 5716 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) {
5678 reportError10(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken, []); 5717 reportError11(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken, []);
5679 return new ThrowExpression.full(keyword, createSyntheticIdentifier()); 5718 return new ThrowExpression.full(keyword, createSyntheticIdentifier());
5680 } 5719 }
5681 Expression expression = parseExpression2(); 5720 Expression expression = parseExpression2();
5682 return new ThrowExpression.full(keyword, expression); 5721 return new ThrowExpression.full(keyword, expression);
5683 } 5722 }
5684 5723
5685 /** 5724 /**
5686 * Parse a throw expression. 5725 * Parse a throw expression.
5687 * 5726 *
5688 * <pre> 5727 * <pre>
5689 * throwExpressionWithoutCascade ::= 5728 * throwExpressionWithoutCascade ::=
5690 * 'throw' expressionWithoutCascade 5729 * 'throw' expressionWithoutCascade
5691 * </pre> 5730 * </pre>
5692 * 5731 *
5693 * @return the throw expression that was parsed 5732 * @return the throw expression that was parsed
5694 */ 5733 */
5695 Expression parseThrowExpressionWithoutCascade() { 5734 Expression parseThrowExpressionWithoutCascade() {
5696 Token keyword = expect(Keyword.THROW); 5735 Token keyword = expect(Keyword.THROW);
5697 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) { 5736 if (matches5(TokenType.SEMICOLON) || matches5(TokenType.CLOSE_PAREN)) {
5698 reportError10(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken, []); 5737 reportError11(ParserErrorCode.MISSING_EXPRESSION_IN_THROW, _currentToken, []);
5699 return new ThrowExpression.full(keyword, createSyntheticIdentifier()); 5738 return new ThrowExpression.full(keyword, createSyntheticIdentifier());
5700 } 5739 }
5701 Expression expression = parseExpressionWithoutCascade(); 5740 Expression expression = parseExpressionWithoutCascade();
5702 return new ThrowExpression.full(keyword, expression); 5741 return new ThrowExpression.full(keyword, expression);
5703 } 5742 }
5704 5743
5705 /** 5744 /**
5706 * Parse a try statement. 5745 * Parse a try statement.
5707 * 5746 *
5708 * <pre> 5747 * <pre>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5752 } 5791 }
5753 Block catchBody = parseBlock(); 5792 Block catchBody = parseBlock();
5754 catchClauses.add(new CatchClause.full(onKeyword, exceptionType, catchKeywo rd, leftParenthesis, exceptionParameter, comma, stackTraceParameter, rightParent hesis, catchBody)); 5793 catchClauses.add(new CatchClause.full(onKeyword, exceptionType, catchKeywo rd, leftParenthesis, exceptionParameter, comma, stackTraceParameter, rightParent hesis, catchBody));
5755 } 5794 }
5756 Token finallyKeyword = null; 5795 Token finallyKeyword = null;
5757 if (matches(Keyword.FINALLY)) { 5796 if (matches(Keyword.FINALLY)) {
5758 finallyKeyword = andAdvance; 5797 finallyKeyword = andAdvance;
5759 finallyClause = parseBlock(); 5798 finallyClause = parseBlock();
5760 } else { 5799 } else {
5761 if (catchClauses.isEmpty) { 5800 if (catchClauses.isEmpty) {
5762 reportError9(ParserErrorCode.MISSING_CATCH_OR_FINALLY, []); 5801 reportError10(ParserErrorCode.MISSING_CATCH_OR_FINALLY, []);
5763 } 5802 }
5764 } 5803 }
5765 return new TryStatement.full(tryKeyword, body, catchClauses, finallyKeyword, finallyClause); 5804 return new TryStatement.full(tryKeyword, body, catchClauses, finallyKeyword, finallyClause);
5766 } 5805 }
5767 5806
5768 /** 5807 /**
5769 * Parse a type alias. 5808 * Parse a type alias.
5770 * 5809 *
5771 * <pre> 5810 * <pre>
5772 * typeAlias ::= 5811 * typeAlias ::=
(...skipping 20 matching lines...) Expand all
5793 * @return the type alias that was parsed 5832 * @return the type alias that was parsed
5794 */ 5833 */
5795 TypeAlias parseTypeAlias(CommentAndMetadata commentAndMetadata) { 5834 TypeAlias parseTypeAlias(CommentAndMetadata commentAndMetadata) {
5796 Token keyword = expect(Keyword.TYPEDEF); 5835 Token keyword = expect(Keyword.TYPEDEF);
5797 if (matchesIdentifier()) { 5836 if (matchesIdentifier()) {
5798 Token next = peek(); 5837 Token next = peek();
5799 if (matches4(next, TokenType.LT)) { 5838 if (matches4(next, TokenType.LT)) {
5800 next = skipTypeParameterList(next); 5839 next = skipTypeParameterList(next);
5801 if (next != null && matches4(next, TokenType.EQ)) { 5840 if (next != null && matches4(next, TokenType.EQ)) {
5802 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword) ; 5841 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword) ;
5803 reportError10(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, [] ); 5842 reportError11(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, [] );
5804 return typeAlias; 5843 return typeAlias;
5805 } 5844 }
5806 } else if (matches4(next, TokenType.EQ)) { 5845 } else if (matches4(next, TokenType.EQ)) {
5807 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword); 5846 TypeAlias typeAlias = parseClassTypeAlias(commentAndMetadata, keyword);
5808 reportError10(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []); 5847 reportError11(ParserErrorCode.DEPRECATED_CLASS_TYPE_ALIAS, keyword, []);
5809 return typeAlias; 5848 return typeAlias;
5810 } 5849 }
5811 } 5850 }
5812 return parseFunctionTypeAlias(commentAndMetadata, keyword); 5851 return parseFunctionTypeAlias(commentAndMetadata, keyword);
5813 } 5852 }
5814 5853
5815 /** 5854 /**
5816 * Parse a unary expression. 5855 * Parse a unary expression.
5817 * 5856 *
5818 * <pre> 5857 * <pre>
(...skipping 25 matching lines...) Expand all
5844 } 5883 }
5845 if (identical(operator.type, TokenType.MINUS_MINUS)) { 5884 if (identical(operator.type, TokenType.MINUS_MINUS)) {
5846 int offset = operator.offset; 5885 int offset = operator.offset;
5847 Token firstOperator = new Token(TokenType.MINUS, offset); 5886 Token firstOperator = new Token(TokenType.MINUS, offset);
5848 Token secondOperator = new Token(TokenType.MINUS, offset + 1); 5887 Token secondOperator = new Token(TokenType.MINUS, offset + 1);
5849 secondOperator.setNext(_currentToken); 5888 secondOperator.setNext(_currentToken);
5850 firstOperator.setNext(secondOperator); 5889 firstOperator.setNext(secondOperator);
5851 operator.previous.setNext(firstOperator); 5890 operator.previous.setNext(firstOperator);
5852 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance))); 5891 return new PrefixExpression.full(firstOperator, new PrefixExpression.f ull(secondOperator, new SuperExpression.full(andAdvance)));
5853 } else { 5892 } else {
5854 reportError9(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.lex eme]); 5893 reportError10(ParserErrorCode.INVALID_OPERATOR_FOR_SUPER, [operator.le xeme]);
5855 return new PrefixExpression.full(operator, new SuperExpression.full(an dAdvance)); 5894 return new PrefixExpression.full(operator, new SuperExpression.full(an dAdvance));
5856 } 5895 }
5857 } 5896 }
5858 return new PrefixExpression.full(operator, parseAssignableExpression(false )); 5897 return new PrefixExpression.full(operator, parseAssignableExpression(false ));
5859 } else if (matches5(TokenType.PLUS)) { 5898 } else if (matches5(TokenType.PLUS)) {
5860 reportError9(ParserErrorCode.MISSING_IDENTIFIER, []); 5899 reportError10(ParserErrorCode.MISSING_IDENTIFIER, []);
5861 return createSyntheticIdentifier(); 5900 return createSyntheticIdentifier();
5862 } 5901 }
5863 return parsePostfixExpression(); 5902 return parsePostfixExpression();
5864 } 5903 }
5865 5904
5866 /** 5905 /**
5867 * Parse a variable declaration. 5906 * Parse a variable declaration.
5868 * 5907 *
5869 * <pre> 5908 * <pre>
5870 * variableDeclaration ::= 5909 * variableDeclaration ::=
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5911 * 5950 *
5912 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list, or 5951 * @param commentAndMetadata the metadata to be associated with the variable d eclaration list, or
5913 * `null` if there is no attempt at parsing the comment and metadata 5952 * `null` if there is no attempt at parsing the comment and metadata
5914 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if 5953 * @param keyword the token representing the 'final', 'const' or 'var' keyword , or `null` if
5915 * there is no keyword 5954 * there is no keyword
5916 * @param type the type of the variables in the list 5955 * @param type the type of the variables in the list
5917 * @return the variable declaration list that was parsed 5956 * @return the variable declaration list that was parsed
5918 */ 5957 */
5919 VariableDeclarationList parseVariableDeclarationList2(CommentAndMetadata comme ntAndMetadata, Token keyword, TypeName type) { 5958 VariableDeclarationList parseVariableDeclarationList2(CommentAndMetadata comme ntAndMetadata, Token keyword, TypeName type) {
5920 if (type != null && keyword != null && matches3(keyword, Keyword.VAR)) { 5959 if (type != null && keyword != null && matches3(keyword, Keyword.VAR)) {
5921 reportError10(ParserErrorCode.VAR_AND_TYPE, keyword, []); 5960 reportError11(ParserErrorCode.VAR_AND_TYPE, keyword, []);
5922 } 5961 }
5923 List<VariableDeclaration> variables = new List<VariableDeclaration>(); 5962 List<VariableDeclaration> variables = new List<VariableDeclaration>();
5924 variables.add(parseVariableDeclaration()); 5963 variables.add(parseVariableDeclaration());
5925 while (matches5(TokenType.COMMA)) { 5964 while (matches5(TokenType.COMMA)) {
5926 advance(); 5965 advance();
5927 variables.add(parseVariableDeclaration()); 5966 variables.add(parseVariableDeclaration());
5928 } 5967 }
5929 return new VariableDeclarationList.full(commentAndMetadata != null ? comment AndMetadata.comment : null, commentAndMetadata != null ? commentAndMetadata.meta data : null, keyword, type, variables); 5968 return new VariableDeclarationList.full(commentAndMetadata != null ? comment AndMetadata.comment : null, commentAndMetadata != null ? commentAndMetadata.meta data : null, keyword, type, variables);
5930 } 5969 }
5931 5970
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
6010 */ 6049 */
6011 Token peek2(int distance) { 6050 Token peek2(int distance) {
6012 Token token = _currentToken; 6051 Token token = _currentToken;
6013 for (int i = 0; i < distance; i++) { 6052 for (int i = 0; i < distance; i++) {
6014 token = token.next; 6053 token = token.next;
6015 } 6054 }
6016 return token; 6055 return token;
6017 } 6056 }
6018 6057
6019 /** 6058 /**
6059 * Report the given [AnalysisError].
6060 *
6061 * @param error the error to be reported
6062 */
6063 void reportError(AnalysisError error) {
6064 if (_errorListenerLock != 0) {
6065 return;
6066 }
6067 _errorListener.onError(error);
6068 }
6069
6070 /**
6020 * Report an error with the given error code and arguments. 6071 * Report an error with the given error code and arguments.
6021 * 6072 *
6022 * @param errorCode the error code of the error to be reported 6073 * @param errorCode the error code of the error to be reported
6023 * @param node the node specifying the location of the error 6074 * @param node the node specifying the location of the error
6024 * @param arguments the arguments to the error, used to compose the error mess age 6075 * @param arguments the arguments to the error, used to compose the error mess age
6025 */ 6076 */
6026 void reportError(ParserErrorCode errorCode, ASTNode node, List<Object> argumen ts) { 6077 void reportError9(ParserErrorCode errorCode, ASTNode node, List<Object> argume nts) {
6027 _errorListener.onError(new AnalysisError.con2(_source, node.offset, node.len gth, errorCode, arguments)); 6078 reportError(new AnalysisError.con2(_source, node.offset, node.length, errorC ode, arguments));
6028 } 6079 }
6029 6080
6030 /** 6081 /**
6031 * Report an error with the given error code and arguments. 6082 * Report an error with the given error code and arguments.
6032 * 6083 *
6033 * @param errorCode the error code of the error to be reported 6084 * @param errorCode the error code of the error to be reported
6034 * @param arguments the arguments to the error, used to compose the error mess age 6085 * @param arguments the arguments to the error, used to compose the error mess age
6035 */ 6086 */
6036 void reportError9(ParserErrorCode errorCode, List<Object> arguments) { 6087 void reportError10(ParserErrorCode errorCode, List<Object> arguments) {
6037 reportError10(errorCode, _currentToken, arguments); 6088 reportError11(errorCode, _currentToken, arguments);
6038 } 6089 }
6039 6090
6040 /** 6091 /**
6041 * Report an error with the given error code and arguments. 6092 * Report an error with the given error code and arguments.
6042 * 6093 *
6043 * @param errorCode the error code of the error to be reported 6094 * @param errorCode the error code of the error to be reported
6044 * @param token the token specifying the location of the error 6095 * @param token the token specifying the location of the error
6045 * @param arguments the arguments to the error, used to compose the error mess age 6096 * @param arguments the arguments to the error, used to compose the error mess age
6046 */ 6097 */
6047 void reportError10(ParserErrorCode errorCode, Token token, List<Object> argume nts) { 6098 void reportError11(ParserErrorCode errorCode, Token token, List<Object> argume nts) {
6048 _errorListener.onError(new AnalysisError.con2(_source, token.offset, token.l ength, errorCode, arguments)); 6099 reportError(new AnalysisError.con2(_source, token.offset, token.length, erro rCode, arguments));
6049 } 6100 }
6050 6101
6051 /** 6102 /**
6103 * Skips a block with all containing blocks.
6104 */
6105 void skipBlock() {
6106 _currentToken = (_currentToken as BeginToken).endToken.next;
6107 }
6108
6109 /**
6052 * Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the 6110 * Parse the 'final', 'const', 'var' or type preceding a variable declaration, starting at the
6053 * given token, without actually creating a type or changing the current token . Return the token 6111 * given token, without actually creating a type or changing the current token . Return the token
6054 * following the type that was parsed, or `null` if the given token is not the first token 6112 * following the type that was parsed, or `null` if the given token is not the first token
6055 * in a valid type. 6113 * in a valid type.
6056 * 6114 *
6057 * <pre> 6115 * <pre>
6058 * finalConstVarOrType ::= 6116 * finalConstVarOrType ::=
6059 * | 'final' type? 6117 * | 'final' type?
6060 * | 'const' type? 6118 * | 'const' type?
6061 * | 'var' 6119 * | 'var'
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
6479 } else if (currentChar == 0x66) { 6537 } else if (currentChar == 0x66) {
6480 builder.appendChar(0xC); 6538 builder.appendChar(0xC);
6481 } else if (currentChar == 0x62) { 6539 } else if (currentChar == 0x62) {
6482 builder.appendChar(0x8); 6540 builder.appendChar(0x8);
6483 } else if (currentChar == 0x74) { 6541 } else if (currentChar == 0x74) {
6484 builder.appendChar(0x9); 6542 builder.appendChar(0x9);
6485 } else if (currentChar == 0x76) { 6543 } else if (currentChar == 0x76) {
6486 builder.appendChar(0xB); 6544 builder.appendChar(0xB);
6487 } else if (currentChar == 0x78) { 6545 } else if (currentChar == 0x78) {
6488 if (currentIndex + 2 >= length) { 6546 if (currentIndex + 2 >= length) {
6489 reportError9(ParserErrorCode.INVALID_HEX_ESCAPE, []); 6547 reportError10(ParserErrorCode.INVALID_HEX_ESCAPE, []);
6490 return length; 6548 return length;
6491 } 6549 }
6492 int firstDigit = lexeme.codeUnitAt(currentIndex + 1); 6550 int firstDigit = lexeme.codeUnitAt(currentIndex + 1);
6493 int secondDigit = lexeme.codeUnitAt(currentIndex + 2); 6551 int secondDigit = lexeme.codeUnitAt(currentIndex + 2);
6494 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) { 6552 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit)) {
6495 reportError9(ParserErrorCode.INVALID_HEX_ESCAPE, []); 6553 reportError10(ParserErrorCode.INVALID_HEX_ESCAPE, []);
6496 } else { 6554 } else {
6497 builder.appendChar(((Character.digit(firstDigit, 16) << 4) + Character.d igit(secondDigit, 16)) as int); 6555 builder.appendChar(((Character.digit(firstDigit, 16) << 4) + Character.d igit(secondDigit, 16)) as int);
6498 } 6556 }
6499 return currentIndex + 3; 6557 return currentIndex + 3;
6500 } else if (currentChar == 0x75) { 6558 } else if (currentChar == 0x75) {
6501 currentIndex++; 6559 currentIndex++;
6502 if (currentIndex >= length) { 6560 if (currentIndex >= length) {
6503 reportError9(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 6561 reportError10(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
6504 return length; 6562 return length;
6505 } 6563 }
6506 currentChar = lexeme.codeUnitAt(currentIndex); 6564 currentChar = lexeme.codeUnitAt(currentIndex);
6507 if (currentChar == 0x7B) { 6565 if (currentChar == 0x7B) {
6508 currentIndex++; 6566 currentIndex++;
6509 if (currentIndex >= length) { 6567 if (currentIndex >= length) {
6510 reportError9(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 6568 reportError10(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
6511 return length; 6569 return length;
6512 } 6570 }
6513 currentChar = lexeme.codeUnitAt(currentIndex); 6571 currentChar = lexeme.codeUnitAt(currentIndex);
6514 int digitCount = 0; 6572 int digitCount = 0;
6515 int value = 0; 6573 int value = 0;
6516 while (currentChar != 0x7D) { 6574 while (currentChar != 0x7D) {
6517 if (!isHexDigit(currentChar)) { 6575 if (!isHexDigit(currentChar)) {
6518 reportError9(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 6576 reportError10(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
6519 currentIndex++; 6577 currentIndex++;
6520 while (currentIndex < length && lexeme.codeUnitAt(currentIndex) != 0 x7D) { 6578 while (currentIndex < length && lexeme.codeUnitAt(currentIndex) != 0 x7D) {
6521 currentIndex++; 6579 currentIndex++;
6522 } 6580 }
6523 return currentIndex + 1; 6581 return currentIndex + 1;
6524 } 6582 }
6525 digitCount++; 6583 digitCount++;
6526 value = (value << 4) + Character.digit(currentChar, 16); 6584 value = (value << 4) + Character.digit(currentChar, 16);
6527 currentIndex++; 6585 currentIndex++;
6528 if (currentIndex >= length) { 6586 if (currentIndex >= length) {
6529 reportError9(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 6587 reportError10(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
6530 return length; 6588 return length;
6531 } 6589 }
6532 currentChar = lexeme.codeUnitAt(currentIndex); 6590 currentChar = lexeme.codeUnitAt(currentIndex);
6533 } 6591 }
6534 if (digitCount < 1 || digitCount > 6) { 6592 if (digitCount < 1 || digitCount > 6) {
6535 reportError9(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 6593 reportError10(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
6536 } 6594 }
6537 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va lue, index, currentIndex); 6595 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), va lue, index, currentIndex);
6538 return currentIndex + 1; 6596 return currentIndex + 1;
6539 } else { 6597 } else {
6540 if (currentIndex + 3 >= length) { 6598 if (currentIndex + 3 >= length) {
6541 reportError9(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 6599 reportError10(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
6542 return length; 6600 return length;
6543 } 6601 }
6544 int firstDigit = currentChar; 6602 int firstDigit = currentChar;
6545 int secondDigit = lexeme.codeUnitAt(currentIndex + 1); 6603 int secondDigit = lexeme.codeUnitAt(currentIndex + 1);
6546 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2); 6604 int thirdDigit = lexeme.codeUnitAt(currentIndex + 2);
6547 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3); 6605 int fourthDigit = lexeme.codeUnitAt(currentIndex + 3);
6548 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t hirdDigit) || !isHexDigit(fourthDigit)) { 6606 if (!isHexDigit(firstDigit) || !isHexDigit(secondDigit) || !isHexDigit(t hirdDigit) || !isHexDigit(fourthDigit)) {
6549 reportError9(ParserErrorCode.INVALID_UNICODE_ESCAPE, []); 6607 reportError10(ParserErrorCode.INVALID_UNICODE_ESCAPE, []);
6550 } else { 6608 } else {
6551 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), (((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16)) < < 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16) , index, currentIndex + 3); 6609 appendScalarValue(builder, lexeme.substring(index, currentIndex + 1), (((((Character.digit(firstDigit, 16) << 4) + Character.digit(secondDigit, 16)) < < 4) + Character.digit(thirdDigit, 16)) << 4) + Character.digit(fourthDigit, 16) , index, currentIndex + 3);
6552 } 6610 }
6553 return currentIndex + 4; 6611 return currentIndex + 4;
6554 } 6612 }
6555 } else { 6613 } else {
6556 builder.appendChar(currentChar); 6614 builder.appendChar(currentChar);
6557 } 6615 }
6558 return currentIndex + 1; 6616 return currentIndex + 1;
6559 } 6617 }
6560 6618
6561 /** 6619 /**
6620 * Decrements the error reporting lock level. If level is more than `0`, then
6621 * [reportError] wont report any error.
6622 */
6623 void unlockErrorListener() {
6624 if (_errorListenerLock == 0) {
6625 throw new IllegalStateException("Attempt to unlock not locked error listen er.");
6626 }
6627 _errorListenerLock--;
6628 }
6629
6630 /**
6562 * Validate that the given parameter list does not contain any field initializ ers. 6631 * Validate that the given parameter list does not contain any field initializ ers.
6563 * 6632 *
6564 * @param parameterList the parameter list to be validated 6633 * @param parameterList the parameter list to be validated
6565 */ 6634 */
6566 void validateFormalParameterList(FormalParameterList parameterList) { 6635 void validateFormalParameterList(FormalParameterList parameterList) {
6567 for (FormalParameter parameter in parameterList.parameters) { 6636 for (FormalParameter parameter in parameterList.parameters) {
6568 if (parameter is FieldFormalParameter) { 6637 if (parameter is FieldFormalParameter) {
6569 reportError(ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, (para meter as FieldFormalParameter).identifier, []); 6638 reportError9(ParserErrorCode.FIELD_INITIALIZER_OUTSIDE_CONSTRUCTOR, (par ameter as FieldFormalParameter).identifier, []);
6570 } 6639 }
6571 } 6640 }
6572 } 6641 }
6573 6642
6574 /** 6643 /**
6575 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract' 6644 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract'
6576 * keyword if there is one. 6645 * keyword if there is one.
6577 * 6646 *
6578 * @param modifiers the modifiers being validated 6647 * @param modifiers the modifiers being validated
6579 */ 6648 */
6580 Token validateModifiersForClass(Modifiers modifiers) { 6649 Token validateModifiersForClass(Modifiers modifiers) {
6581 validateModifiersForTopLevelDeclaration(modifiers); 6650 validateModifiersForTopLevelDeclaration(modifiers);
6582 if (modifiers.constKeyword != null) { 6651 if (modifiers.constKeyword != null) {
6583 reportError10(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []); 6652 reportError11(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []);
6584 } 6653 }
6585 if (modifiers.externalKeyword != null) { 6654 if (modifiers.externalKeyword != null) {
6586 reportError10(ParserErrorCode.EXTERNAL_CLASS, modifiers.externalKeyword, [ ]); 6655 reportError11(ParserErrorCode.EXTERNAL_CLASS, modifiers.externalKeyword, [ ]);
6587 } 6656 }
6588 if (modifiers.finalKeyword != null) { 6657 if (modifiers.finalKeyword != null) {
6589 reportError10(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []); 6658 reportError11(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []);
6590 } 6659 }
6591 if (modifiers.varKeyword != null) { 6660 if (modifiers.varKeyword != null) {
6592 reportError10(ParserErrorCode.VAR_CLASS, modifiers.varKeyword, []); 6661 reportError11(ParserErrorCode.VAR_CLASS, modifiers.varKeyword, []);
6593 } 6662 }
6594 return modifiers.abstractKeyword; 6663 return modifiers.abstractKeyword;
6595 } 6664 }
6596 6665
6597 /** 6666 /**
6598 * Validate that the given set of modifiers is appropriate for a constructor a nd return the 6667 * Validate that the given set of modifiers is appropriate for a constructor a nd return the
6599 * 'const' keyword if there is one. 6668 * 'const' keyword if there is one.
6600 * 6669 *
6601 * @param modifiers the modifiers being validated 6670 * @param modifiers the modifiers being validated
6602 * @return the 'const' or 'final' keyword associated with the constructor 6671 * @return the 'const' or 'final' keyword associated with the constructor
6603 */ 6672 */
6604 Token validateModifiersForConstructor(Modifiers modifiers) { 6673 Token validateModifiersForConstructor(Modifiers modifiers) {
6605 if (modifiers.abstractKeyword != null) { 6674 if (modifiers.abstractKeyword != null) {
6606 reportError9(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 6675 reportError10(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
6607 } 6676 }
6608 if (modifiers.finalKeyword != null) { 6677 if (modifiers.finalKeyword != null) {
6609 reportError10(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, [ ]); 6678 reportError11(ParserErrorCode.FINAL_CONSTRUCTOR, modifiers.finalKeyword, [ ]);
6610 } 6679 }
6611 if (modifiers.staticKeyword != null) { 6680 if (modifiers.staticKeyword != null) {
6612 reportError10(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword, []); 6681 reportError11(ParserErrorCode.STATIC_CONSTRUCTOR, modifiers.staticKeyword, []);
6613 } 6682 }
6614 if (modifiers.varKeyword != null) { 6683 if (modifiers.varKeyword != null) {
6615 reportError10(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varK eyword, []); 6684 reportError11(ParserErrorCode.CONSTRUCTOR_WITH_RETURN_TYPE, modifiers.varK eyword, []);
6616 } 6685 }
6617 Token externalKeyword = modifiers.externalKeyword; 6686 Token externalKeyword = modifiers.externalKeyword;
6618 Token constKeyword = modifiers.constKeyword; 6687 Token constKeyword = modifiers.constKeyword;
6619 Token factoryKeyword = modifiers.factoryKeyword; 6688 Token factoryKeyword = modifiers.factoryKeyword;
6620 if (externalKeyword != null && constKeyword != null && constKeyword.offset < externalKeyword.offset) { 6689 if (externalKeyword != null && constKeyword != null && constKeyword.offset < externalKeyword.offset) {
6621 reportError10(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword, []); 6690 reportError11(ParserErrorCode.EXTERNAL_AFTER_CONST, externalKeyword, []);
6622 } 6691 }
6623 if (externalKeyword != null && factoryKeyword != null && factoryKeyword.offs et < externalKeyword.offset) { 6692 if (externalKeyword != null && factoryKeyword != null && factoryKeyword.offs et < externalKeyword.offset) {
6624 reportError10(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword, []) ; 6693 reportError11(ParserErrorCode.EXTERNAL_AFTER_FACTORY, externalKeyword, []) ;
6625 } 6694 }
6626 return constKeyword; 6695 return constKeyword;
6627 } 6696 }
6628 6697
6629 /** 6698 /**
6630 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final', 6699 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final',
6631 * 'const' or 'var' keyword if there is one. 6700 * 'const' or 'var' keyword if there is one.
6632 * 6701 *
6633 * @param modifiers the modifiers being validated 6702 * @param modifiers the modifiers being validated
6634 * @return the 'final', 'const' or 'var' keyword associated with the field 6703 * @return the 'final', 'const' or 'var' keyword associated with the field
6635 */ 6704 */
6636 Token validateModifiersForField(Modifiers modifiers) { 6705 Token validateModifiersForField(Modifiers modifiers) {
6637 if (modifiers.abstractKeyword != null) { 6706 if (modifiers.abstractKeyword != null) {
6638 reportError9(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 6707 reportError10(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
6639 } 6708 }
6640 if (modifiers.externalKeyword != null) { 6709 if (modifiers.externalKeyword != null) {
6641 reportError10(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [ ]); 6710 reportError11(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [ ]);
6642 } 6711 }
6643 if (modifiers.factoryKeyword != null) { 6712 if (modifiers.factoryKeyword != null) {
6644 reportError10(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKe yword, []); 6713 reportError11(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKe yword, []);
6645 } 6714 }
6646 Token staticKeyword = modifiers.staticKeyword; 6715 Token staticKeyword = modifiers.staticKeyword;
6647 Token constKeyword = modifiers.constKeyword; 6716 Token constKeyword = modifiers.constKeyword;
6648 Token finalKeyword = modifiers.finalKeyword; 6717 Token finalKeyword = modifiers.finalKeyword;
6649 Token varKeyword = modifiers.varKeyword; 6718 Token varKeyword = modifiers.varKeyword;
6650 if (constKeyword != null) { 6719 if (constKeyword != null) {
6651 if (finalKeyword != null) { 6720 if (finalKeyword != null) {
6652 reportError10(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []); 6721 reportError11(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []);
6653 } 6722 }
6654 if (varKeyword != null) { 6723 if (varKeyword != null) {
6655 reportError10(ParserErrorCode.CONST_AND_VAR, varKeyword, []); 6724 reportError11(ParserErrorCode.CONST_AND_VAR, varKeyword, []);
6656 } 6725 }
6657 if (staticKeyword != null && constKeyword.offset < staticKeyword.offset) { 6726 if (staticKeyword != null && constKeyword.offset < staticKeyword.offset) {
6658 reportError10(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword, []); 6727 reportError11(ParserErrorCode.STATIC_AFTER_CONST, staticKeyword, []);
6659 } 6728 }
6660 } else if (finalKeyword != null) { 6729 } else if (finalKeyword != null) {
6661 if (varKeyword != null) { 6730 if (varKeyword != null) {
6662 reportError10(ParserErrorCode.FINAL_AND_VAR, varKeyword, []); 6731 reportError11(ParserErrorCode.FINAL_AND_VAR, varKeyword, []);
6663 } 6732 }
6664 if (staticKeyword != null && finalKeyword.offset < staticKeyword.offset) { 6733 if (staticKeyword != null && finalKeyword.offset < staticKeyword.offset) {
6665 reportError10(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword, []); 6734 reportError11(ParserErrorCode.STATIC_AFTER_FINAL, staticKeyword, []);
6666 } 6735 }
6667 } else if (varKeyword != null && staticKeyword != null && varKeyword.offset < staticKeyword.offset) { 6736 } else if (varKeyword != null && staticKeyword != null && varKeyword.offset < staticKeyword.offset) {
6668 reportError10(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword, []); 6737 reportError11(ParserErrorCode.STATIC_AFTER_VAR, staticKeyword, []);
6669 } 6738 }
6670 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]); 6739 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]);
6671 } 6740 }
6672 6741
6673 /** 6742 /**
6674 * Validate that the given set of modifiers is appropriate for a local functio n. 6743 * Validate that the given set of modifiers is appropriate for a local functio n.
6675 * 6744 *
6676 * @param modifiers the modifiers being validated 6745 * @param modifiers the modifiers being validated
6677 */ 6746 */
6678 void validateModifiersForFunctionDeclarationStatement(Modifiers modifiers) { 6747 void validateModifiersForFunctionDeclarationStatement(Modifiers modifiers) {
6679 if (modifiers.abstractKeyword != null || modifiers.constKeyword != null || m odifiers.externalKeyword != null || modifiers.factoryKeyword != null || modifier s.finalKeyword != null || modifiers.staticKeyword != null || modifiers.varKeywor d != null) { 6748 if (modifiers.abstractKeyword != null || modifiers.constKeyword != null || m odifiers.externalKeyword != null || modifiers.factoryKeyword != null || modifier s.finalKeyword != null || modifiers.staticKeyword != null || modifiers.varKeywor d != null) {
6680 reportError9(ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER, []); 6749 reportError10(ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER, []);
6681 } 6750 }
6682 } 6751 }
6683 6752
6684 /** 6753 /**
6685 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 6754 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
6686 * 6755 *
6687 * @param modifiers the modifiers being validated 6756 * @param modifiers the modifiers being validated
6688 */ 6757 */
6689 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) { 6758 void validateModifiersForGetterOrSetterOrMethod(Modifiers modifiers) {
6690 if (modifiers.abstractKeyword != null) { 6759 if (modifiers.abstractKeyword != null) {
6691 reportError9(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 6760 reportError10(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
6692 } 6761 }
6693 if (modifiers.constKeyword != null) { 6762 if (modifiers.constKeyword != null) {
6694 reportError10(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); 6763 reportError11(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []);
6695 } 6764 }
6696 if (modifiers.factoryKeyword != null) { 6765 if (modifiers.factoryKeyword != null) {
6697 reportError10(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKe yword, []); 6766 reportError11(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKe yword, []);
6698 } 6767 }
6699 if (modifiers.finalKeyword != null) { 6768 if (modifiers.finalKeyword != null) {
6700 reportError10(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); 6769 reportError11(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []);
6701 } 6770 }
6702 if (modifiers.varKeyword != null) { 6771 if (modifiers.varKeyword != null) {
6703 reportError10(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); 6772 reportError11(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []);
6704 } 6773 }
6705 Token externalKeyword = modifiers.externalKeyword; 6774 Token externalKeyword = modifiers.externalKeyword;
6706 Token staticKeyword = modifiers.staticKeyword; 6775 Token staticKeyword = modifiers.staticKeyword;
6707 if (externalKeyword != null && staticKeyword != null && staticKeyword.offset < externalKeyword.offset) { 6776 if (externalKeyword != null && staticKeyword != null && staticKeyword.offset < externalKeyword.offset) {
6708 reportError10(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword, []); 6777 reportError11(ParserErrorCode.EXTERNAL_AFTER_STATIC, externalKeyword, []);
6709 } 6778 }
6710 } 6779 }
6711 6780
6712 /** 6781 /**
6713 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method. 6782 * Validate that the given set of modifiers is appropriate for a getter, sette r, or method.
6714 * 6783 *
6715 * @param modifiers the modifiers being validated 6784 * @param modifiers the modifiers being validated
6716 */ 6785 */
6717 void validateModifiersForOperator(Modifiers modifiers) { 6786 void validateModifiersForOperator(Modifiers modifiers) {
6718 if (modifiers.abstractKeyword != null) { 6787 if (modifiers.abstractKeyword != null) {
6719 reportError9(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []); 6788 reportError10(ParserErrorCode.ABSTRACT_CLASS_MEMBER, []);
6720 } 6789 }
6721 if (modifiers.constKeyword != null) { 6790 if (modifiers.constKeyword != null) {
6722 reportError10(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []); 6791 reportError11(ParserErrorCode.CONST_METHOD, modifiers.constKeyword, []);
6723 } 6792 }
6724 if (modifiers.factoryKeyword != null) { 6793 if (modifiers.factoryKeyword != null) {
6725 reportError10(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKe yword, []); 6794 reportError11(ParserErrorCode.NON_CONSTRUCTOR_FACTORY, modifiers.factoryKe yword, []);
6726 } 6795 }
6727 if (modifiers.finalKeyword != null) { 6796 if (modifiers.finalKeyword != null) {
6728 reportError10(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []); 6797 reportError11(ParserErrorCode.FINAL_METHOD, modifiers.finalKeyword, []);
6729 } 6798 }
6730 if (modifiers.staticKeyword != null) { 6799 if (modifiers.staticKeyword != null) {
6731 reportError10(ParserErrorCode.STATIC_OPERATOR, modifiers.staticKeyword, [] ); 6800 reportError11(ParserErrorCode.STATIC_OPERATOR, modifiers.staticKeyword, [] );
6732 } 6801 }
6733 if (modifiers.varKeyword != null) { 6802 if (modifiers.varKeyword != null) {
6734 reportError10(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); 6803 reportError11(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []);
6735 } 6804 }
6736 } 6805 }
6737 6806
6738 /** 6807 /**
6739 * Validate that the given set of modifiers is appropriate for a top-level dec laration. 6808 * Validate that the given set of modifiers is appropriate for a top-level dec laration.
6740 * 6809 *
6741 * @param modifiers the modifiers being validated 6810 * @param modifiers the modifiers being validated
6742 */ 6811 */
6743 void validateModifiersForTopLevelDeclaration(Modifiers modifiers) { 6812 void validateModifiersForTopLevelDeclaration(Modifiers modifiers) {
6744 if (modifiers.factoryKeyword != null) { 6813 if (modifiers.factoryKeyword != null) {
6745 reportError10(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, modifiers.fac toryKeyword, []); 6814 reportError11(ParserErrorCode.FACTORY_TOP_LEVEL_DECLARATION, modifiers.fac toryKeyword, []);
6746 } 6815 }
6747 if (modifiers.staticKeyword != null) { 6816 if (modifiers.staticKeyword != null) {
6748 reportError10(ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, modifiers.stat icKeyword, []); 6817 reportError11(ParserErrorCode.STATIC_TOP_LEVEL_DECLARATION, modifiers.stat icKeyword, []);
6749 } 6818 }
6750 } 6819 }
6751 6820
6752 /** 6821 /**
6753 * Validate that the given set of modifiers is appropriate for a top-level fun ction. 6822 * Validate that the given set of modifiers is appropriate for a top-level fun ction.
6754 * 6823 *
6755 * @param modifiers the modifiers being validated 6824 * @param modifiers the modifiers being validated
6756 */ 6825 */
6757 void validateModifiersForTopLevelFunction(Modifiers modifiers) { 6826 void validateModifiersForTopLevelFunction(Modifiers modifiers) {
6758 validateModifiersForTopLevelDeclaration(modifiers); 6827 validateModifiersForTopLevelDeclaration(modifiers);
6759 if (modifiers.abstractKeyword != null) { 6828 if (modifiers.abstractKeyword != null) {
6760 reportError9(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, []); 6829 reportError10(ParserErrorCode.ABSTRACT_TOP_LEVEL_FUNCTION, []);
6761 } 6830 }
6762 if (modifiers.constKeyword != null) { 6831 if (modifiers.constKeyword != null) {
6763 reportError10(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []); 6832 reportError11(ParserErrorCode.CONST_CLASS, modifiers.constKeyword, []);
6764 } 6833 }
6765 if (modifiers.finalKeyword != null) { 6834 if (modifiers.finalKeyword != null) {
6766 reportError10(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []); 6835 reportError11(ParserErrorCode.FINAL_CLASS, modifiers.finalKeyword, []);
6767 } 6836 }
6768 if (modifiers.varKeyword != null) { 6837 if (modifiers.varKeyword != null) {
6769 reportError10(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []); 6838 reportError11(ParserErrorCode.VAR_RETURN_TYPE, modifiers.varKeyword, []);
6770 } 6839 }
6771 } 6840 }
6772 6841
6773 /** 6842 /**
6774 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final', 6843 * Validate that the given set of modifiers is appropriate for a field and ret urn the 'final',
6775 * 'const' or 'var' keyword if there is one. 6844 * 'const' or 'var' keyword if there is one.
6776 * 6845 *
6777 * @param modifiers the modifiers being validated 6846 * @param modifiers the modifiers being validated
6778 * @return the 'final', 'const' or 'var' keyword associated with the field 6847 * @return the 'final', 'const' or 'var' keyword associated with the field
6779 */ 6848 */
6780 Token validateModifiersForTopLevelVariable(Modifiers modifiers) { 6849 Token validateModifiersForTopLevelVariable(Modifiers modifiers) {
6781 validateModifiersForTopLevelDeclaration(modifiers); 6850 validateModifiersForTopLevelDeclaration(modifiers);
6782 if (modifiers.abstractKeyword != null) { 6851 if (modifiers.abstractKeyword != null) {
6783 reportError9(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []); 6852 reportError10(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE, []);
6784 } 6853 }
6785 if (modifiers.externalKeyword != null) { 6854 if (modifiers.externalKeyword != null) {
6786 reportError10(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [ ]); 6855 reportError11(ParserErrorCode.EXTERNAL_FIELD, modifiers.externalKeyword, [ ]);
6787 } 6856 }
6788 Token constKeyword = modifiers.constKeyword; 6857 Token constKeyword = modifiers.constKeyword;
6789 Token finalKeyword = modifiers.finalKeyword; 6858 Token finalKeyword = modifiers.finalKeyword;
6790 Token varKeyword = modifiers.varKeyword; 6859 Token varKeyword = modifiers.varKeyword;
6791 if (constKeyword != null) { 6860 if (constKeyword != null) {
6792 if (finalKeyword != null) { 6861 if (finalKeyword != null) {
6793 reportError10(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []); 6862 reportError11(ParserErrorCode.CONST_AND_FINAL, finalKeyword, []);
6794 } 6863 }
6795 if (varKeyword != null) { 6864 if (varKeyword != null) {
6796 reportError10(ParserErrorCode.CONST_AND_VAR, varKeyword, []); 6865 reportError11(ParserErrorCode.CONST_AND_VAR, varKeyword, []);
6797 } 6866 }
6798 } else if (finalKeyword != null) { 6867 } else if (finalKeyword != null) {
6799 if (varKeyword != null) { 6868 if (varKeyword != null) {
6800 reportError10(ParserErrorCode.FINAL_AND_VAR, varKeyword, []); 6869 reportError11(ParserErrorCode.FINAL_AND_VAR, varKeyword, []);
6801 } 6870 }
6802 } 6871 }
6803 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]); 6872 return lexicallyFirst([constKeyword, finalKeyword, varKeyword]);
6804 } 6873 }
6805 6874
6806 /** 6875 /**
6807 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract' 6876 * Validate that the given set of modifiers is appropriate for a class and ret urn the 'abstract'
6808 * keyword if there is one. 6877 * keyword if there is one.
6809 * 6878 *
6810 * @param modifiers the modifiers being validated 6879 * @param modifiers the modifiers being validated
6811 */ 6880 */
6812 void validateModifiersForTypedef(Modifiers modifiers) { 6881 void validateModifiersForTypedef(Modifiers modifiers) {
6813 validateModifiersForTopLevelDeclaration(modifiers); 6882 validateModifiersForTopLevelDeclaration(modifiers);
6814 if (modifiers.abstractKeyword != null) { 6883 if (modifiers.abstractKeyword != null) {
6815 reportError10(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKeyword, []); 6884 reportError11(ParserErrorCode.ABSTRACT_TYPEDEF, modifiers.abstractKeyword, []);
6816 } 6885 }
6817 if (modifiers.constKeyword != null) { 6886 if (modifiers.constKeyword != null) {
6818 reportError10(ParserErrorCode.CONST_TYPEDEF, modifiers.constKeyword, []); 6887 reportError11(ParserErrorCode.CONST_TYPEDEF, modifiers.constKeyword, []);
6819 } 6888 }
6820 if (modifiers.externalKeyword != null) { 6889 if (modifiers.externalKeyword != null) {
6821 reportError10(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword, []); 6890 reportError11(ParserErrorCode.EXTERNAL_TYPEDEF, modifiers.externalKeyword, []);
6822 } 6891 }
6823 if (modifiers.finalKeyword != null) { 6892 if (modifiers.finalKeyword != null) {
6824 reportError10(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []); 6893 reportError11(ParserErrorCode.FINAL_TYPEDEF, modifiers.finalKeyword, []);
6825 } 6894 }
6826 if (modifiers.varKeyword != null) { 6895 if (modifiers.varKeyword != null) {
6827 reportError10(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []); 6896 reportError11(ParserErrorCode.VAR_TYPEDEF, modifiers.varKeyword, []);
6828 } 6897 }
6829 } 6898 }
6830 } 6899 }
6831 6900
6832 /** 6901 /**
6833 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword token. 6902 * Instances of the class `SyntheticKeywordToken` implement a synthetic keyword token.
6834 */ 6903 */
6835 class Parser_SyntheticKeywordToken extends KeywordToken { 6904 class Parser_SyntheticKeywordToken extends KeywordToken {
6836 /** 6905 /**
6837 * Initialize a newly created token to represent the given keyword. 6906 * Initialize a newly created token to represent the given keyword.
(...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after
9223 if ("\n" == separator) { 9292 if ("\n" == separator) {
9224 _writer.print("\n"); 9293 _writer.print("\n");
9225 indent(); 9294 indent();
9226 } else if (i > 0) { 9295 } else if (i > 0) {
9227 _writer.print(separator); 9296 _writer.print(separator);
9228 } 9297 }
9229 _writer.print(tokens[i].lexeme); 9298 _writer.print(tokens[i].lexeme);
9230 } 9299 }
9231 } 9300 }
9232 } 9301 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698