| 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 /** | 7 /** |
| 8 * An event generating parser of Dart programs. This parser expects | 8 * An event generating parser of Dart programs. This parser expects |
| 9 * all tokens in a linked list (aka a token stream). | 9 * all tokens in a linked list (aka a token stream). |
| 10 * | 10 * |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 } else { | 1524 } else { |
| 1525 return listener.expectedExpression(token); | 1525 return listener.expectedExpression(token); |
| 1526 } | 1526 } |
| 1527 } else if (identical(kind, OPEN_PAREN_TOKEN)) { | 1527 } else if (identical(kind, OPEN_PAREN_TOKEN)) { |
| 1528 return parseParenthesizedExpressionOrFunctionLiteral(token); | 1528 return parseParenthesizedExpressionOrFunctionLiteral(token); |
| 1529 } else if ((identical(kind, LT_TOKEN)) || | 1529 } else if ((identical(kind, LT_TOKEN)) || |
| 1530 (identical(kind, OPEN_SQUARE_BRACKET_TOKEN)) || | 1530 (identical(kind, OPEN_SQUARE_BRACKET_TOKEN)) || |
| 1531 (identical(kind, OPEN_CURLY_BRACKET_TOKEN)) || | 1531 (identical(kind, OPEN_CURLY_BRACKET_TOKEN)) || |
| 1532 identical(token.stringValue, '[]')) { | 1532 identical(token.stringValue, '[]')) { |
| 1533 return parseLiteralListOrMap(token); | 1533 return parseLiteralListOrMap(token); |
| 1534 } else if (identical(kind, QUESTION_TOKEN)) { | |
| 1535 return parseArgumentDefinitionTest(token); | |
| 1536 } else { | 1534 } else { |
| 1537 return listener.expectedExpression(token); | 1535 return listener.expectedExpression(token); |
| 1538 } | 1536 } |
| 1539 } | 1537 } |
| 1540 | 1538 |
| 1541 Token parseArgumentDefinitionTest(Token token) { | |
| 1542 Token questionToken = token; | |
| 1543 listener.beginArgumentDefinitionTest(questionToken); | |
| 1544 assert(optional('?', token)); | |
| 1545 token = parseIdentifier(token.next); | |
| 1546 listener.endArgumentDefinitionTest(questionToken, token); | |
| 1547 return token; | |
| 1548 } | |
| 1549 | |
| 1550 Token parseParenthesizedExpressionOrFunctionLiteral(Token token) { | 1539 Token parseParenthesizedExpressionOrFunctionLiteral(Token token) { |
| 1551 BeginGroupToken beginGroup = token; | 1540 BeginGroupToken beginGroup = token; |
| 1552 int kind = beginGroup.endGroup.next.kind; | 1541 int kind = beginGroup.endGroup.next.kind; |
| 1553 if (mayParseFunctionExpressions && | 1542 if (mayParseFunctionExpressions && |
| 1554 (identical(kind, FUNCTION_TOKEN) | 1543 (identical(kind, FUNCTION_TOKEN) |
| 1555 || identical(kind, OPEN_CURLY_BRACKET_TOKEN))) { | 1544 || identical(kind, OPEN_CURLY_BRACKET_TOKEN))) { |
| 1556 return parseUnamedFunction(token); | 1545 return parseUnamedFunction(token); |
| 1557 } else { | 1546 } else { |
| 1558 bool old = mayParseFunctionExpressions; | 1547 bool old = mayParseFunctionExpressions; |
| 1559 mayParseFunctionExpressions = true; | 1548 mayParseFunctionExpressions = true; |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2198 } | 2187 } |
| 2199 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2188 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2200 return expectSemicolon(token); | 2189 return expectSemicolon(token); |
| 2201 } | 2190 } |
| 2202 | 2191 |
| 2203 Token parseEmptyStatement(Token token) { | 2192 Token parseEmptyStatement(Token token) { |
| 2204 listener.handleEmptyStatement(token); | 2193 listener.handleEmptyStatement(token); |
| 2205 return expectSemicolon(token); | 2194 return expectSemicolon(token); |
| 2206 } | 2195 } |
| 2207 } | 2196 } |
| OLD | NEW |