Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(338)

Side by Side Diff: pkg/front_end/lib/src/fasta/scanner/token.dart

Issue 2750863002: Complain about built-in identifiers. (Closed)
Patch Set: Address comments. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/parser.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 126
127 @override 127 @override
128 bool get isOperator => info.isOperator; 128 bool get isOperator => info.isOperator;
129
130 bool get isBuiltInIdentifier => false;
129 } 131 }
130 132
131 /** 133 /**
132 * A [SymbolToken] represents the symbol in its precedence info. 134 * A [SymbolToken] represents the symbol in its precedence info.
133 * Also used for end of file with EOF_INFO. 135 * Also used for end of file with EOF_INFO.
134 */ 136 */
135 class SymbolToken extends Token { 137 class SymbolToken extends Token {
136 final PrecedenceInfo info; 138 final PrecedenceInfo info;
137 139
138 SymbolToken(this.info, int charOffset) : super(charOffset); 140 SymbolToken(this.info, int charOffset) : super(charOffset);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 KeywordToken(this.keyword, int charOffset) : super(charOffset); 172 KeywordToken(this.keyword, int charOffset) : super(charOffset);
171 173
172 PrecedenceInfo get info => keyword.info; 174 PrecedenceInfo get info => keyword.info;
173 175
174 String get lexeme => keyword.syntax; 176 String get lexeme => keyword.syntax;
175 177
176 String get stringValue => keyword.syntax; 178 String get stringValue => keyword.syntax;
177 179
178 bool isIdentifier() => keyword.isPseudo || keyword.isBuiltIn; 180 bool isIdentifier() => keyword.isPseudo || keyword.isBuiltIn;
179 181
182 bool get isBuiltInIdentifier {
183 // TODO(ahe): Remove special case for "deferred" once dartbug.com/29069 is
184 // fixed.
185 return keyword.isBuiltIn || identical("deferred", lexeme);
186 }
187
180 String toString() => "KeywordToken($lexeme)"; 188 String toString() => "KeywordToken($lexeme)";
181 } 189 }
182 190
183 /** 191 /**
184 * A String-valued token. Represents identifiers, string literals, 192 * A String-valued token. Represents identifiers, string literals,
185 * number literals, comments, and error tokens, using the corresponding 193 * number literals, comments, and error tokens, using the corresponding
186 * precedence info. 194 * precedence info.
187 */ 195 */
188 class StringToken extends Token { 196 class StringToken extends Token {
189 /** 197 /**
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 identical(value, "<=") || 379 identical(value, "<=") ||
372 identical(value, "<") || 380 identical(value, "<") ||
373 identical(value, "&") || 381 identical(value, "&") ||
374 identical(value, "^") || 382 identical(value, "^") ||
375 identical(value, "|"); 383 identical(value, "|");
376 } 384 }
377 385
378 bool isTernaryOperator(String value) => identical(value, "[]="); 386 bool isTernaryOperator(String value) => identical(value, "[]=");
379 387
380 bool isMinusOperator(String value) => identical(value, "-"); 388 bool isMinusOperator(String value) => identical(value, "-");
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/parser/parser.dart ('k') | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698