| 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 /** | 5 /** |
| 6 * An event generating parser of Dart programs. This parser expects | 6 * An event generating parser of Dart programs. This parser expects |
| 7 * all tokens in a linked list (aka a token stream). | 7 * all tokens in a linked list (aka a token stream). |
| 8 * | 8 * |
| 9 * The class [Scanner] is used to generate a token stream. See the | 9 * The class [Scanner] is used to generate a token stream. See the |
| 10 * file scanner.dart. | 10 * file scanner.dart. |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 token = parseArgumentOrIndexStar(token); | 923 token = parseArgumentOrIndexStar(token); |
| 924 } else if ((info === PLUS_PLUS_INFO) || | 924 } else if ((info === PLUS_PLUS_INFO) || |
| 925 (info === MINUS_MINUS_INFO)) { | 925 (info === MINUS_MINUS_INFO)) { |
| 926 listener.handleUnaryPostfixAssignmentExpression(token); | 926 listener.handleUnaryPostfixAssignmentExpression(token); |
| 927 token = token.next; | 927 token = token.next; |
| 928 } else { | 928 } else { |
| 929 token = listener.unexpected(token); | 929 token = listener.unexpected(token); |
| 930 } | 930 } |
| 931 } else if (info === IS_INFO) { | 931 } else if (info === IS_INFO) { |
| 932 token = parseIsOperatorRest(token); | 932 token = parseIsOperatorRest(token); |
| 933 } else if (info === AS_INFO) { |
| 934 token = parseAsOperatorRest(token); |
| 933 } else if (info === QUESTION_INFO) { | 935 } else if (info === QUESTION_INFO) { |
| 934 token = parseConditionalExpressionRest(token); | 936 token = parseConditionalExpressionRest(token); |
| 935 } else { | 937 } else { |
| 936 // Left associative, so we recurse at the next higher | 938 // Left associative, so we recurse at the next higher |
| 937 // precedence level. | 939 // precedence level. |
| 938 token = parsePrecedenceExpression(token.next, level + 1, | 940 token = parsePrecedenceExpression(token.next, level + 1, |
| 939 withoutCascades); | 941 withoutCascades); |
| 940 listener.handleBinaryExpression(operator); | 942 listener.handleBinaryExpression(operator); |
| 941 } | 943 } |
| 942 info = token.info; | 944 info = token.info; |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 Token parseIsOperatorRest(Token token) { | 1351 Token parseIsOperatorRest(Token token) { |
| 1350 assert(optional('is', token)); | 1352 assert(optional('is', token)); |
| 1351 Token operator = token; | 1353 Token operator = token; |
| 1352 Token not = null; | 1354 Token not = null; |
| 1353 if (optional('!', token.next)) { | 1355 if (optional('!', token.next)) { |
| 1354 token = token.next; | 1356 token = token.next; |
| 1355 not = token; | 1357 not = token; |
| 1356 } | 1358 } |
| 1357 token = parseType(token.next); | 1359 token = parseType(token.next); |
| 1358 listener.handleIsOperator(operator, not, token); | 1360 listener.handleIsOperator(operator, not, token); |
| 1359 if (optional('is', token)) { | 1361 if (optional('is', token) || optional('as', token)) { |
| 1360 // The is-operator cannot be chained, but it can take part of | 1362 // The is- and as-operators cannot be chained, but they can take part of |
| 1361 // expressions like: foo is Foo || foo is Bar. | 1363 // expressions like: foo is Foo || foo is Bar. |
| 1362 listener.unexpected(token); | 1364 listener.unexpected(token); |
| 1363 } | 1365 } |
| 1364 return token; | 1366 return token; |
| 1365 } | 1367 } |
| 1366 | 1368 |
| 1369 Token parseAsOperatorRest(Token token) { |
| 1370 assert(optional('as', token)); |
| 1371 Token operator = token; |
| 1372 token = parseType(token.next); |
| 1373 listener.handleAsOperator(operator, token); |
| 1374 if (optional('is', token) || optional('as', token)) { |
| 1375 // The is- and as-operators cannot be chained. |
| 1376 listener.unexpected(token); |
| 1377 } |
| 1378 return token; |
| 1379 } |
| 1380 |
| 1367 Token parseVariablesDeclaration(Token token) { | 1381 Token parseVariablesDeclaration(Token token) { |
| 1368 token = parseVariablesDeclarationNoSemicolon(token); | 1382 token = parseVariablesDeclarationNoSemicolon(token); |
| 1369 return expectSemicolon(token); | 1383 return expectSemicolon(token); |
| 1370 } | 1384 } |
| 1371 | 1385 |
| 1372 Token parseVariablesDeclarationNoSemicolon(Token token) { | 1386 Token parseVariablesDeclarationNoSemicolon(Token token) { |
| 1373 int count = 1; | 1387 int count = 1; |
| 1374 listener.beginVariablesDeclaration(token); | 1388 listener.beginVariablesDeclaration(token); |
| 1375 token = parseModifiers(token); | 1389 token = parseModifiers(token); |
| 1376 token = parseTypeOpt(token); | 1390 token = parseTypeOpt(token); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1671 } | 1685 } |
| 1672 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 1686 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 1673 return expectSemicolon(token); | 1687 return expectSemicolon(token); |
| 1674 } | 1688 } |
| 1675 | 1689 |
| 1676 Token parseEmptyStatement(Token token) { | 1690 Token parseEmptyStatement(Token token) { |
| 1677 listener.handleEmptyStatement(token); | 1691 listener.handleEmptyStatement(token); |
| 1678 return expectSemicolon(token); | 1692 return expectSemicolon(token); |
| 1679 } | 1693 } |
| 1680 } | 1694 } |
| OLD | NEW |