| 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 import '../../scanner/token.dart' show TokenType; | 8 import '../../scanner/token.dart' show TokenType; |
| 9 | 9 |
| 10 import 'token_constants.dart' show IDENTIFIER_TOKEN; | 10 import 'token_constants.dart' show IDENTIFIER_TOKEN; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 /** | 95 /** |
| 96 * The precedence level for this token. | 96 * The precedence level for this token. |
| 97 */ | 97 */ |
| 98 int get precedence => info.precedence; | 98 int get precedence => info.precedence; |
| 99 | 99 |
| 100 /** | 100 /** |
| 101 * True if this token is an identifier. Some keywords allowed as identifiers, | 101 * True if this token is an identifier. Some keywords allowed as identifiers, |
| 102 * see implementation in [KeywordToken]. | 102 * see implementation in [KeywordToken]. |
| 103 */ | 103 */ |
| 104 bool isIdentifier(); | 104 bool get isIdentifier; |
| 105 | 105 |
| 106 bool get isPseudo => false; | 106 bool get isPseudo => false; |
| 107 | 107 |
| 108 /** | 108 /** |
| 109 * Returns a textual representation of this token to be used for debugging | 109 * Returns a textual representation of this token to be used for debugging |
| 110 * purposes. The resulting string might contain information about the | 110 * purposes. The resulting string might contain information about the |
| 111 * structure of the token, for example 'StringToken(foo)' for the identifier | 111 * structure of the token, for example 'StringToken(foo)' for the identifier |
| 112 * token 'foo'. | 112 * token 'foo'. |
| 113 * | 113 * |
| 114 * Use [lexeme] for the text actually parsed by the token. | 114 * Use [lexeme] for the text actually parsed by the token. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 return eof; | 255 return eof; |
| 256 } | 256 } |
| 257 | 257 |
| 258 @override | 258 @override |
| 259 String get lexeme => info.value; | 259 String get lexeme => info.value; |
| 260 | 260 |
| 261 @override | 261 @override |
| 262 String get stringValue => info.value; | 262 String get stringValue => info.value; |
| 263 | 263 |
| 264 @override | 264 @override |
| 265 bool isIdentifier() => false; | 265 bool get isIdentifier => false; |
| 266 | 266 |
| 267 @override | 267 @override |
| 268 String toString() => "SymbolToken(${isEof ? '-eof-' : lexeme})"; | 268 String toString() => "SymbolToken(${isEof ? '-eof-' : lexeme})"; |
| 269 | 269 |
| 270 @override | 270 @override |
| 271 bool get isEof => info == analyzer.TokenType.EOF; | 271 bool get isEof => info == analyzer.TokenType.EOF; |
| 272 | 272 |
| 273 @override | 273 @override |
| 274 Token copyWithoutComments() => isEof | 274 Token copyWithoutComments() => isEof |
| 275 ? new SymbolToken.eof(charOffset) | 275 ? new SymbolToken.eof(charOffset) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 final analyzer.Keyword keyword; | 329 final analyzer.Keyword keyword; |
| 330 | 330 |
| 331 KeywordToken(this.keyword, int charOffset) : super(charOffset); | 331 KeywordToken(this.keyword, int charOffset) : super(charOffset); |
| 332 | 332 |
| 333 TokenType get info => keyword.info; | 333 TokenType get info => keyword.info; |
| 334 | 334 |
| 335 String get lexeme => keyword.lexeme; | 335 String get lexeme => keyword.lexeme; |
| 336 | 336 |
| 337 String get stringValue => keyword.lexeme; | 337 String get stringValue => keyword.lexeme; |
| 338 | 338 |
| 339 bool isIdentifier() => keyword.isPseudo || keyword.isBuiltIn; | 339 bool get isIdentifier => keyword.isPseudo || keyword.isBuiltIn; |
| 340 | 340 |
| 341 bool get isPseudo => keyword.isPseudo; | 341 bool get isPseudo => keyword.isPseudo; |
| 342 | 342 |
| 343 bool get isBuiltInIdentifier => keyword.isBuiltIn; | 343 bool get isBuiltInIdentifier => keyword.isBuiltIn; |
| 344 | 344 |
| 345 String toString() => "KeywordToken($lexeme)"; | 345 String toString() => "KeywordToken($lexeme)"; |
| 346 | 346 |
| 347 @override | 347 @override |
| 348 Token copyWithoutComments() => new KeywordToken(keyword, charOffset); | 348 Token copyWithoutComments() => new KeywordToken(keyword, charOffset); |
| 349 | 349 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 valueOrLazySubstring = | 457 valueOrLazySubstring = |
| 458 decodeUtf8(data, start, end, valueOrLazySubstring.boolValue); | 458 decodeUtf8(data, start, end, valueOrLazySubstring.boolValue); |
| 459 } | 459 } |
| 460 return valueOrLazySubstring; | 460 return valueOrLazySubstring; |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 | 463 |
| 464 /// See [Token.stringValue] for an explanation. | 464 /// See [Token.stringValue] for an explanation. |
| 465 String get stringValue => null; | 465 String get stringValue => null; |
| 466 | 466 |
| 467 bool isIdentifier() => identical(kind, IDENTIFIER_TOKEN); | 467 bool get isIdentifier => identical(kind, IDENTIFIER_TOKEN); |
| 468 | 468 |
| 469 String toString() => "StringToken($lexeme)"; | 469 String toString() => "StringToken($lexeme)"; |
| 470 | 470 |
| 471 static final StringCanonicalizer canonicalizer = new StringCanonicalizer(); | 471 static final StringCanonicalizer canonicalizer = new StringCanonicalizer(); |
| 472 | 472 |
| 473 static String canonicalizedString( | 473 static String canonicalizedString( |
| 474 String s, int start, int end, bool canonicalize) { | 474 String s, int start, int end, bool canonicalize) { |
| 475 if (!canonicalize) return s; | 475 if (!canonicalize) return s; |
| 476 return canonicalizer.canonicalize(s, start, end, false); | 476 return canonicalizer.canonicalize(s, start, end, false); |
| 477 } | 477 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 identical(value, "<=") || | 682 identical(value, "<=") || |
| 683 identical(value, "<") || | 683 identical(value, "<") || |
| 684 identical(value, "&") || | 684 identical(value, "&") || |
| 685 identical(value, "^") || | 685 identical(value, "^") || |
| 686 identical(value, "|"); | 686 identical(value, "|"); |
| 687 } | 687 } |
| 688 | 688 |
| 689 bool isTernaryOperator(String value) => identical(value, "[]="); | 689 bool isTernaryOperator(String value) => identical(value, "[]="); |
| 690 | 690 |
| 691 bool isMinusOperator(String value) => identical(value, "-"); | 691 bool isMinusOperator(String value) => identical(value, "-"); |
| OLD | NEW |