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 'keyword.dart' show Keyword; | 7 import 'keyword.dart' show Keyword; |
8 | 8 |
9 import 'precedence.dart' show BAD_INPUT_INFO, EOF_INFO, PrecedenceInfo; | 9 import 'precedence.dart' show BAD_INPUT_INFO, EOF_INFO, PrecedenceInfo; |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 return 1; | 116 return 1; |
117 } else { | 117 } else { |
118 return lexeme.length; | 118 return lexeme.length; |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 /// The character offset of the end of this token within the source text. | 122 /// The character offset of the end of this token within the source text. |
123 int get charEnd => charOffset + charCount; | 123 int get charEnd => charOffset + charCount; |
124 | 124 |
125 bool get isEof => false; | 125 bool get isEof => false; |
126 | |
127 bool get isBuiltInIdentifier => false; | |
126 } | 128 } |
127 | 129 |
128 /** | 130 /** |
129 * A [SymbolToken] represents the symbol in its precedence info. | 131 * A [SymbolToken] represents the symbol in its precedence info. |
130 * Also used for end of file with EOF_INFO. | 132 * Also used for end of file with EOF_INFO. |
131 */ | 133 */ |
132 class SymbolToken extends Token { | 134 class SymbolToken extends Token { |
133 final PrecedenceInfo info; | 135 final PrecedenceInfo info; |
134 | 136 |
135 SymbolToken(this.info, int charOffset) : super(charOffset); | 137 SymbolToken(this.info, int charOffset) : super(charOffset); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 KeywordToken(this.keyword, int charOffset) : super(charOffset); | 169 KeywordToken(this.keyword, int charOffset) : super(charOffset); |
168 | 170 |
169 PrecedenceInfo get info => keyword.info; | 171 PrecedenceInfo get info => keyword.info; |
170 | 172 |
171 String get lexeme => keyword.syntax; | 173 String get lexeme => keyword.syntax; |
172 | 174 |
173 String get stringValue => keyword.syntax; | 175 String get stringValue => keyword.syntax; |
174 | 176 |
175 bool isIdentifier() => keyword.isPseudo || keyword.isBuiltIn; | 177 bool isIdentifier() => keyword.isPseudo || keyword.isBuiltIn; |
176 | 178 |
179 bool get isBuiltInIdentifier { | |
180 return keyword.isBuiltIn || identical("deferred", lexeme); | |
danrubel
2017/03/14 15:21:43
Similar to what Paul recommended in the fasta.Keyw
ahe
2017/03/14 15:24:35
Yes. That's how I knew about this case :-)
I'll a
| |
181 } | |
182 | |
177 String toString() => "KeywordToken($lexeme)"; | 183 String toString() => "KeywordToken($lexeme)"; |
178 } | 184 } |
179 | 185 |
180 /** | 186 /** |
181 * A String-valued token. Represents identifiers, string literals, | 187 * A String-valued token. Represents identifiers, string literals, |
182 * number literals, comments, and error tokens, using the corresponding | 188 * number literals, comments, and error tokens, using the corresponding |
183 * precedence info. | 189 * precedence info. |
184 */ | 190 */ |
185 class StringToken extends Token { | 191 class StringToken extends Token { |
186 /** | 192 /** |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 identical(value, "<=") || | 374 identical(value, "<=") || |
369 identical(value, "<") || | 375 identical(value, "<") || |
370 identical(value, "&") || | 376 identical(value, "&") || |
371 identical(value, "^") || | 377 identical(value, "^") || |
372 identical(value, "|"); | 378 identical(value, "|"); |
373 } | 379 } |
374 | 380 |
375 bool isTernaryOperator(String value) => identical(value, "[]="); | 381 bool isTernaryOperator(String value) => identical(value, "[]="); |
376 | 382 |
377 bool isMinusOperator(String value) => identical(value, "-"); | 383 bool isMinusOperator(String value) => identical(value, "-"); |
OLD | NEW |