Chromium Code Reviews| 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 1465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1476 final kind = token.kind; | 1476 final kind = token.kind; |
| 1477 if (identical(kind, IDENTIFIER_TOKEN)) { | 1477 if (identical(kind, IDENTIFIER_TOKEN)) { |
| 1478 return parseSendOrFunctionLiteral(token); | 1478 return parseSendOrFunctionLiteral(token); |
| 1479 } else if (identical(kind, INT_TOKEN) | 1479 } else if (identical(kind, INT_TOKEN) |
| 1480 || identical(kind, HEXADECIMAL_TOKEN)) { | 1480 || identical(kind, HEXADECIMAL_TOKEN)) { |
| 1481 return parseLiteralInt(token); | 1481 return parseLiteralInt(token); |
| 1482 } else if (identical(kind, DOUBLE_TOKEN)) { | 1482 } else if (identical(kind, DOUBLE_TOKEN)) { |
| 1483 return parseLiteralDouble(token); | 1483 return parseLiteralDouble(token); |
| 1484 } else if (identical(kind, STRING_TOKEN)) { | 1484 } else if (identical(kind, STRING_TOKEN)) { |
| 1485 return parseLiteralString(token); | 1485 return parseLiteralString(token); |
| 1486 } else if (identical(kind, HASH_TOKEN)) { | |
| 1487 return parseSymbolLiteral(token); | |
| 1486 } else if (identical(kind, KEYWORD_TOKEN)) { | 1488 } else if (identical(kind, KEYWORD_TOKEN)) { |
| 1487 final value = token.stringValue; | 1489 final value = token.stringValue; |
| 1488 if ((identical(value, 'true')) || (identical(value, 'false'))) { | 1490 if ((identical(value, 'true')) || (identical(value, 'false'))) { |
| 1489 return parseLiteralBool(token); | 1491 return parseLiteralBool(token); |
| 1490 } else if (identical(value, 'null')) { | 1492 } else if (identical(value, 'null')) { |
| 1491 return parseLiteralNull(token); | 1493 return parseLiteralNull(token); |
| 1492 } else if (identical(value, 'this')) { | 1494 } else if (identical(value, 'this')) { |
| 1493 return parseThisExpression(token); | 1495 return parseThisExpression(token); |
| 1494 } else if (identical(value, 'super')) { | 1496 } else if (identical(value, 'super')) { |
| 1495 return parseSuperExpression(token); | 1497 return parseSuperExpression(token); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1696 while (identical(token.kind, STRING_TOKEN)) { | 1698 while (identical(token.kind, STRING_TOKEN)) { |
| 1697 token = parseSingleLiteralString(token); | 1699 token = parseSingleLiteralString(token); |
| 1698 count++; | 1700 count++; |
| 1699 } | 1701 } |
| 1700 if (count > 1) { | 1702 if (count > 1) { |
| 1701 listener.handleStringJuxtaposition(count); | 1703 listener.handleStringJuxtaposition(count); |
| 1702 } | 1704 } |
| 1703 return token; | 1705 return token; |
| 1704 } | 1706 } |
| 1705 | 1707 |
| 1708 Token parseSymbolLiteral(Token token) { | |
| 1709 Token hashToken = token; | |
| 1710 listener.beginSymbolLiteral(hashToken); | |
| 1711 token = token.next; | |
| 1712 if (isUserDefinableOperator(token.stringValue)) { | |
| 1713 listener.endSymbolLiteral(hashToken, token, 0); | |
| 1714 return token.next; | |
| 1715 } else { | |
| 1716 int count = 1; | |
| 1717 token = parseIdentifier(token); | |
|
ahe
2013/08/06 12:20:55
Can you use parseQualified?
Johnni Winther
2013/09/03 12:27:50
No. Then I will get one Send instead of a NodeList
| |
| 1718 while (identical(token.stringValue, '.')) { | |
| 1719 count++; | |
| 1720 token = parseIdentifier(token.next); | |
| 1721 } | |
| 1722 listener.endSymbolLiteral(hashToken, null, count); | |
| 1723 return token; | |
| 1724 } | |
| 1725 } | |
| 1726 | |
| 1727 | |
|
ahe
2013/08/06 12:20:55
Extra line.
Johnni Winther
2013/09/03 12:27:50
Done.
| |
| 1706 /** | 1728 /** |
| 1707 * Only called when [:token.kind === STRING_TOKEN:]. | 1729 * Only called when [:token.kind === STRING_TOKEN:]. |
| 1708 */ | 1730 */ |
| 1709 Token parseSingleLiteralString(Token token) { | 1731 Token parseSingleLiteralString(Token token) { |
| 1710 listener.beginLiteralString(token); | 1732 listener.beginLiteralString(token); |
| 1711 // Parsing the prefix, for instance 'x of 'x${id}y${id}z' | 1733 // Parsing the prefix, for instance 'x of 'x${id}y${id}z' |
| 1712 token = token.next; | 1734 token = token.next; |
| 1713 int interpolationCount = 0; | 1735 int interpolationCount = 0; |
| 1714 var kind = token.kind; | 1736 var kind = token.kind; |
| 1715 while (kind != EOF_TOKEN) { | 1737 while (kind != EOF_TOKEN) { |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2167 } | 2189 } |
| 2168 listener.handleContinueStatement(hasTarget, continueKeyword, token); | 2190 listener.handleContinueStatement(hasTarget, continueKeyword, token); |
| 2169 return expectSemicolon(token); | 2191 return expectSemicolon(token); |
| 2170 } | 2192 } |
| 2171 | 2193 |
| 2172 Token parseEmptyStatement(Token token) { | 2194 Token parseEmptyStatement(Token token) { |
| 2173 listener.handleEmptyStatement(token); | 2195 listener.handleEmptyStatement(token); |
| 2174 return expectSemicolon(token); | 2196 return expectSemicolon(token); |
| 2175 } | 2197 } |
| 2176 } | 2198 } |
| OLD | NEW |