OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 library fasta.scanner.token; | 5 library fasta.scanner.token; |
6 | 6 |
7 import '../../scanner/token.dart' as analyzer; | 7 import '../../scanner/token.dart' as analyzer; |
8 | 8 |
9 import 'keyword.dart' show Keyword; | 9 import 'keyword.dart' show Keyword; |
10 | 10 |
11 import 'precedence.dart' | 11 import 'precedence.dart' |
12 show | 12 show |
13 AS_INFO, | 13 AS_INFO, |
14 BAD_INPUT_INFO, | 14 BAD_INPUT_INFO, |
15 EOF_INFO, | 15 EOF_INFO, |
16 IDENTIFIER_INFO, | 16 IDENTIFIER_INFO, |
17 IS_INFO, | 17 IS_INFO, |
18 KEYWORD_INFO, | 18 KEYWORD_INFO, |
19 MULTI_LINE_COMMENT_INFO, | |
20 SINGLE_LINE_COMMENT_INFO, | |
21 PrecedenceInfo; | 19 PrecedenceInfo; |
22 | 20 |
23 import 'token_constants.dart' show IDENTIFIER_TOKEN; | 21 import 'token_constants.dart' show IDENTIFIER_TOKEN; |
24 | 22 |
25 import 'string_canonicalizer.dart'; | 23 import 'string_canonicalizer.dart'; |
26 | 24 |
27 /** | 25 /** |
28 * A token that doubles as a linked list. | 26 * A token that doubles as a linked list. |
29 */ | 27 */ |
30 abstract class Token implements analyzer.TokenWithComment { | 28 abstract class Token implements analyzer.TokenWithComment { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 249 |
252 /** | 250 /** |
253 * A [SymbolToken] represents the symbol in its precedence info. | 251 * A [SymbolToken] represents the symbol in its precedence info. |
254 * Also used for end of file with EOF_INFO. | 252 * Also used for end of file with EOF_INFO. |
255 */ | 253 */ |
256 class SymbolToken extends Token { | 254 class SymbolToken extends Token { |
257 final PrecedenceInfo info; | 255 final PrecedenceInfo info; |
258 | 256 |
259 SymbolToken(this.info, int charOffset) : super(charOffset); | 257 SymbolToken(this.info, int charOffset) : super(charOffset); |
260 | 258 |
| 259 SymbolToken.eof(int charOffset) |
| 260 : info = EOF_INFO, |
| 261 super(charOffset) { |
| 262 // EOF points to itself so there's always infinite look-ahead. |
| 263 previousToken = this; |
| 264 next = this; |
| 265 } |
| 266 |
261 String get lexeme => info.value; | 267 String get lexeme => info.value; |
262 | 268 |
263 String get stringValue => info.value; | 269 String get stringValue => info.value; |
264 | 270 |
265 bool isIdentifier() => false; | 271 bool isIdentifier() => false; |
266 | 272 |
267 String toString() => "SymbolToken($lexeme)"; | 273 String toString() => "SymbolToken(${info == EOF_INFO ? '-eof-' : lexeme})"; |
268 | 274 |
269 bool get isEof => info == EOF_INFO; | 275 bool get isEof => info == EOF_INFO; |
270 | 276 |
271 @override | 277 @override |
272 Token copyWithoutComments() => new SymbolToken(info, charOffset); | 278 Token copyWithoutComments() => new SymbolToken(info, charOffset); |
273 } | 279 } |
274 | 280 |
275 /** | 281 /** |
276 * A [BeginGroupToken] represents a symbol that may be the beginning of | 282 * A [BeginGroupToken] represents a symbol that may be the beginning of |
277 * a pair of brackets, i.e., ( { [ < or ${ | 283 * a pair of brackets, i.e., ( { [ < or ${ |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 identical(value, "<=") || | 634 identical(value, "<=") || |
629 identical(value, "<") || | 635 identical(value, "<") || |
630 identical(value, "&") || | 636 identical(value, "&") || |
631 identical(value, "^") || | 637 identical(value, "^") || |
632 identical(value, "|"); | 638 identical(value, "|"); |
633 } | 639 } |
634 | 640 |
635 bool isTernaryOperator(String value) => identical(value, "[]="); | 641 bool isTernaryOperator(String value) => identical(value, "[]="); |
636 | 642 |
637 bool isMinusOperator(String value) => identical(value, "-"); | 643 bool isMinusOperator(String value) => identical(value, "-"); |
OLD | NEW |