| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of scanner; | 5 part of scanner; |
| 6 | 6 |
| 7 class FormalParameterType { | 7 class FormalParameterType { |
| 8 final String type; | 8 final String type; |
| 9 const FormalParameterType(this.type); | 9 const FormalParameterType(this.type); |
| 10 bool get isRequired => this == REQUIRED; | 10 bool get isRequired => this == REQUIRED; |
| (...skipping 1563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 token = parseConditionalExpressionRest(token); | 1574 token = parseConditionalExpressionRest(token); |
| 1575 } else { | 1575 } else { |
| 1576 // Left associative, so we recurse at the next higher | 1576 // Left associative, so we recurse at the next higher |
| 1577 // precedence level. | 1577 // precedence level. |
| 1578 token = parsePrecedenceExpression(token.next, level + 1, | 1578 token = parsePrecedenceExpression(token.next, level + 1, |
| 1579 allowCascades); | 1579 allowCascades); |
| 1580 listener.handleBinaryExpression(operator); | 1580 listener.handleBinaryExpression(operator); |
| 1581 } | 1581 } |
| 1582 info = token.info; | 1582 info = token.info; |
| 1583 tokenLevel = info.precedence; | 1583 tokenLevel = info.precedence; |
| 1584 if (level == EQUALITY_PRECEDENCE || level == RELATIONAL_PRECEDENCE) { |
| 1585 // We don't allow (a == b == c) or (a < b < c). |
| 1586 // Continue the outer loop if we have matched one equality or |
| 1587 // relational operator. |
| 1588 break; |
| 1589 } |
| 1584 } | 1590 } |
| 1585 } | 1591 } |
| 1586 return token; | 1592 return token; |
| 1587 } | 1593 } |
| 1588 | 1594 |
| 1589 Token parseCascadeExpression(Token token) { | 1595 Token parseCascadeExpression(Token token) { |
| 1590 listener.beginCascade(token); | 1596 listener.beginCascade(token); |
| 1591 assert(optional('..', token)); | 1597 assert(optional('..', token)); |
| 1592 Token cascadeOperator = token; | 1598 Token cascadeOperator = token; |
| 1593 token = token.next; | 1599 token = token.next; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1616 listener.handleAssignmentExpression(assignment); | 1622 listener.handleAssignmentExpression(assignment); |
| 1617 } | 1623 } |
| 1618 listener.endCascade(); | 1624 listener.endCascade(); |
| 1619 return token; | 1625 return token; |
| 1620 } | 1626 } |
| 1621 | 1627 |
| 1622 Token parseUnaryExpression(Token token, bool allowCascades) { | 1628 Token parseUnaryExpression(Token token, bool allowCascades) { |
| 1623 String value = token.stringValue; | 1629 String value = token.stringValue; |
| 1624 // Prefix: | 1630 // Prefix: |
| 1625 if (identical(value, '+')) { | 1631 if (identical(value, '+')) { |
| 1626 // Dart only allows "prefix plus" as an initial part of a | 1632 // Dart no longer allows prefix-plus. |
| 1627 // decimal literal. We scan it as a separate token and let | 1633 listener.reportError(token, MessageKind.UNSUPPORTED_PREFIX_PLUS); |
| 1628 // the parser listener combine it with the digits. | |
| 1629 Token next = token.next; | |
| 1630 if (identical(next.charOffset, token.charOffset + 1)) { | |
| 1631 if (identical(next.kind, INT_TOKEN)) { | |
| 1632 listener.handleLiteralInt(token); | |
| 1633 return next.next; | |
| 1634 } | |
| 1635 if (identical(next.kind, DOUBLE_TOKEN)) { | |
| 1636 listener.handleLiteralDouble(token); | |
| 1637 return next.next; | |
| 1638 } | |
| 1639 } | |
| 1640 listener.recoverableError("Unexpected token '+'", token: token); | |
| 1641 return parsePrecedenceExpression(next, POSTFIX_PRECEDENCE, | |
| 1642 allowCascades); | |
| 1643 } else if ((identical(value, '!')) || | 1634 } else if ((identical(value, '!')) || |
| 1644 (identical(value, '-')) || | 1635 (identical(value, '-')) || |
| 1645 (identical(value, '~'))) { | 1636 (identical(value, '~'))) { |
| 1646 Token operator = token; | 1637 Token operator = token; |
| 1647 // Right associative, so we recurse at the same precedence | 1638 // Right associative, so we recurse at the same precedence |
| 1648 // level. | 1639 // level. |
| 1649 token = parsePrecedenceExpression(token.next, POSTFIX_PRECEDENCE, | 1640 token = parsePrecedenceExpression(token.next, POSTFIX_PRECEDENCE, |
| 1650 allowCascades); | 1641 allowCascades); |
| 1651 listener.handleUnaryPrefixExpression(operator); | 1642 listener.handleUnaryPrefixExpression(operator); |
| 1652 } else if ((identical(value, '++')) || identical(value, '--')) { | 1643 } else if ((identical(value, '++')) || identical(value, '--')) { |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 } | 2392 } |
| 2402 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2393 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2403 return expectSemicolon(token); | 2394 return expectSemicolon(token); |
| 2404 } | 2395 } |
| 2405 | 2396 |
| 2406 Token parseEmptyStatement(Token token) { | 2397 Token parseEmptyStatement(Token token) { |
| 2407 listener.handleEmptyStatement(token); | 2398 listener.handleEmptyStatement(token); |
| 2408 return expectSemicolon(token); | 2399 return expectSemicolon(token); |
| 2409 } | 2400 } |
| 2410 } | 2401 } |
| OLD | NEW |