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

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

Issue 2800583002: move fasta.Keyword methods to analyzer.Keyword (Closed)
Patch Set: Created 3 years, 8 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/scanner/keyword.dart ('k') | pkg/front_end/test/token_test.dart » ('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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 /** 5 /**
6 * Defines the tokens that are produced by the scanner, used by the parser, and 6 * Defines the tokens that are produced by the scanner, used by the parser, and
7 * referenced from the [AST structure](ast.dart). 7 * referenced from the [AST structure](ast.dart).
8 */ 8 */
9 import 'dart:collection'; 9 import 'dart:collection';
10 10
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 VOID, 301 VOID,
302 WHILE, 302 WHILE,
303 WITH, 303 WITH,
304 ]; 304 ];
305 305
306 /** 306 /**
307 * A table mapping the lexemes of keywords to the corresponding keyword. 307 * A table mapping the lexemes of keywords to the corresponding keyword.
308 */ 308 */
309 static final Map<String, Keyword> keywords = _createKeywordMap(); 309 static final Map<String, Keyword> keywords = _createKeywordMap();
310 310
311 final fasta.PrecedenceInfo info;
312
313 /**
314 * A flag indicating whether the keyword is "built-in" identifier.
315 */
316 final bool isBuiltIn;
317
318 /**
319 * A flag indicating whether the keyword can be used as an identifier
320 * in some situations.
321 */
322 final bool isPseudo;
323
324 /**
325 * The lexeme for the keyword.
326 */
327 final String syntax;
328
329 /**
330 * Initialize a newly created keyword.
331 */
332 const Keyword(this.syntax,
333 {this.isBuiltIn: false,
334 this.isPseudo: false,
335 this.info: fasta.KEYWORD_INFO});
336
337 /**
338 * A flag indicating whether the keyword is "built-in" identifier.
339 * This method exists for backward compatibility and will be removed.
340 * Use [isBuiltIn] instead.
341 */
342 @deprecated
343 bool get isPseudoKeyword => isBuiltIn; // TODO (danrubel): remove this
344
311 /** 345 /**
312 * The name of the keyword type. 346 * The name of the keyword type.
313 */ 347 */
314 String get name; 348 String get name => syntax.toUpperCase();
315 349
316 /** 350 @override
317 * The lexeme for the keyword. 351 String toString() => name;
318 */
319 String get syntax;
320
321 /**
322 * A flag indicating whether the keyword is a pseudo-keyword. Pseudo keywords
323 * can be used as identifiers.
324 */
325 bool get isPseudoKeyword;
326 352
327 /** 353 /**
328 * Create a table mapping the lexemes of keywords to the corresponding keyword 354 * Create a table mapping the lexemes of keywords to the corresponding keyword
329 * and return the table that was created. 355 * and return the table that was created.
330 */ 356 */
331 static Map<String, Keyword> _createKeywordMap() { 357 static Map<String, Keyword> _createKeywordMap() {
332 LinkedHashMap<String, Keyword> result = 358 LinkedHashMap<String, Keyword> result =
333 new LinkedHashMap<String, Keyword>(); 359 new LinkedHashMap<String, Keyword>();
334 for (Keyword keyword in values) { 360 for (Keyword keyword in values) {
335 result[keyword.syntax] = keyword; 361 result[keyword.syntax] = keyword;
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 1216
1191 void set precedingComments(CommentToken comment) { 1217 void set precedingComments(CommentToken comment) {
1192 _precedingComment = comment; 1218 _precedingComment = comment;
1193 _setCommentParent(_precedingComment); 1219 _setCommentParent(_precedingComment);
1194 } 1220 }
1195 1221
1196 @override 1222 @override
1197 Token copy() => 1223 Token copy() =>
1198 new TokenWithComment(type, offset, copyComments(precedingComments)); 1224 new TokenWithComment(type, offset, copyComments(precedingComments));
1199 } 1225 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/scanner/keyword.dart ('k') | pkg/front_end/test/token_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698