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

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

Issue 2842643004: flatten Keyword into TokenType (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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 references.forEach((ref) => copy.references.add(ref.copy())); 159 references.forEach((ref) => copy.references.add(ref.copy()));
160 return copy; 160 return copy;
161 } 161 }
162 } 162 }
163 163
164 /** 164 /**
165 * The keywords in the Dart programming language. 165 * The keywords in the Dart programming language.
166 * 166 *
167 * Clients may not extend, implement or mix-in this class. 167 * Clients may not extend, implement or mix-in this class.
168 */ 168 */
169 class Keyword { 169 class Keyword extends TokenType {
170 static const Keyword ABSTRACT = const Keyword("abstract", isBuiltIn: true); 170 static const Keyword ABSTRACT =
171 const Keyword("abstract", "ABSTRACT", isBuiltIn: true);
171 172
172 static const Keyword AS = 173 static const Keyword AS = const Keyword("as", "AS",
173 const Keyword("as", info: TokenType.AS, isBuiltIn: true); 174 precedence: RELATIONAL_PRECEDENCE, isBuiltIn: true);
174 175
175 static const Keyword ASSERT = const Keyword("assert"); 176 static const Keyword ASSERT = const Keyword("assert", "ASSERT");
176 177
177 static const Keyword ASYNC = const Keyword("async", isPseudo: true); 178 static const Keyword ASYNC = const Keyword("async", "ASYNC", isPseudo: true);
178 179
179 static const Keyword AWAIT = const Keyword("await", isPseudo: true); 180 static const Keyword AWAIT = const Keyword("await", "AWAIT", isPseudo: true);
180 181
181 static const Keyword BREAK = const Keyword("break"); 182 static const Keyword BREAK = const Keyword("break", "BREAK");
182 183
183 static const Keyword CASE = const Keyword("case"); 184 static const Keyword CASE = const Keyword("case", "CASE");
184 185
185 static const Keyword CATCH = const Keyword("catch"); 186 static const Keyword CATCH = const Keyword("catch", "CATCH");
186 187
187 static const Keyword CLASS = const Keyword("class"); 188 static const Keyword CLASS = const Keyword("class", "CLASS");
188 189
189 static const Keyword CONST = const Keyword("const"); 190 static const Keyword CONST = const Keyword("const", "CONST");
190 191
191 static const Keyword CONTINUE = const Keyword("continue"); 192 static const Keyword CONTINUE = const Keyword("continue", "CONTINUE");
192 193
193 static const Keyword COVARIANT = const Keyword("covariant", isBuiltIn: true); 194 static const Keyword COVARIANT =
195 const Keyword("covariant", "COVARIANT", isBuiltIn: true);
194 196
195 static const Keyword DEFAULT = const Keyword("default"); 197 static const Keyword DEFAULT = const Keyword("default", "DEFAULT");
196 198
197 static const Keyword DEFERRED = const Keyword("deferred", isBuiltIn: true); 199 static const Keyword DEFERRED =
200 const Keyword("deferred", "DEFERRED", isBuiltIn: true);
198 201
199 static const Keyword DO = const Keyword("do"); 202 static const Keyword DO = const Keyword("do", "DO");
200 203
201 static const Keyword DYNAMIC = const Keyword("dynamic", isBuiltIn: true); 204 static const Keyword DYNAMIC =
205 const Keyword("dynamic", "DYNAMIC", isBuiltIn: true);
202 206
203 static const Keyword ELSE = const Keyword("else"); 207 static const Keyword ELSE = const Keyword("else", "ELSE");
204 208
205 static const Keyword ENUM = const Keyword("enum"); 209 static const Keyword ENUM = const Keyword("enum", "ENUM");
206 210
207 static const Keyword EXPORT = const Keyword("export", isBuiltIn: true); 211 static const Keyword EXPORT =
212 const Keyword("export", "EXPORT", isBuiltIn: true);
208 213
209 static const Keyword EXTENDS = const Keyword("extends"); 214 static const Keyword EXTENDS = const Keyword("extends", "EXTENDS");
210 215
211 static const Keyword EXTERNAL = const Keyword("external", isBuiltIn: true); 216 static const Keyword EXTERNAL =
217 const Keyword("external", "EXTERNAL", isBuiltIn: true);
212 218
213 static const Keyword FACTORY = const Keyword("factory", isBuiltIn: true); 219 static const Keyword FACTORY =
220 const Keyword("factory", "FACTORY", isBuiltIn: true);
214 221
215 static const Keyword FALSE = const Keyword("false"); 222 static const Keyword FALSE = const Keyword("false", "FALSE");
216 223
217 static const Keyword FINAL = const Keyword("final"); 224 static const Keyword FINAL = const Keyword("final", "FINAL");
218 225
219 static const Keyword FINALLY = const Keyword("finally"); 226 static const Keyword FINALLY = const Keyword("finally", "FINALLY");
220 227
221 static const Keyword FOR = const Keyword("for"); 228 static const Keyword FOR = const Keyword("for", "FOR");
222 229
223 static const Keyword FUNCTION = const Keyword("Function", isPseudo: true); 230 static const Keyword FUNCTION =
231 const Keyword("Function", "FUNCTION", isPseudo: true);
224 232
225 static const Keyword GET = const Keyword("get", isBuiltIn: true); 233 static const Keyword GET = const Keyword("get", "GET", isBuiltIn: true);
226 234
227 static const Keyword HIDE = const Keyword("hide", isPseudo: true); 235 static const Keyword HIDE = const Keyword("hide", "HIDE", isPseudo: true);
228 236
229 static const Keyword IF = const Keyword("if"); 237 static const Keyword IF = const Keyword("if", "IF");
230 238
231 static const Keyword IMPLEMENTS = 239 static const Keyword IMPLEMENTS =
232 const Keyword("implements", isBuiltIn: true); 240 const Keyword("implements", "IMPLEMENTS", isBuiltIn: true);
233 241
234 static const Keyword IMPORT = const Keyword("import", isBuiltIn: true); 242 static const Keyword IMPORT =
243 const Keyword("import", "IMPORT", isBuiltIn: true);
235 244
236 static const Keyword IN = const Keyword("in"); 245 static const Keyword IN = const Keyword("in", "IN");
237 246
238 static const Keyword IS = const Keyword("is", info: TokenType.IS); 247 static const Keyword IS =
248 const Keyword("is", "IS", precedence: RELATIONAL_PRECEDENCE);
239 249
240 static const Keyword LIBRARY = const Keyword("library", isBuiltIn: true); 250 static const Keyword LIBRARY =
251 const Keyword("library", "LIBRARY", isBuiltIn: true);
241 252
242 static const Keyword NATIVE = const Keyword("native", isPseudo: true); 253 static const Keyword NATIVE =
254 const Keyword("native", "NATIVE", isPseudo: true);
243 255
244 static const Keyword NEW = const Keyword("new"); 256 static const Keyword NEW = const Keyword("new", "NEW");
245 257
246 static const Keyword NULL = const Keyword("null"); 258 static const Keyword NULL = const Keyword("null", "NULL");
247 259
248 static const Keyword OF = const Keyword("of", isPseudo: true); 260 static const Keyword OF = const Keyword("of", "OF", isPseudo: true);
249 261
250 static const Keyword ON = const Keyword("on", isPseudo: true); 262 static const Keyword ON = const Keyword("on", "ON", isPseudo: true);
251 263
252 static const Keyword OPERATOR = const Keyword("operator", isBuiltIn: true); 264 static const Keyword OPERATOR =
265 const Keyword("operator", "OPERATOR", isBuiltIn: true);
253 266
254 static const Keyword PART = const Keyword("part", isBuiltIn: true); 267 static const Keyword PART = const Keyword("part", "PART", isBuiltIn: true);
255 268
256 static const Keyword PATCH = const Keyword("patch", isPseudo: true); 269 static const Keyword PATCH = const Keyword("patch", "PATCH", isPseudo: true);
257 270
258 static const Keyword RETHROW = const Keyword("rethrow"); 271 static const Keyword RETHROW = const Keyword("rethrow", "RETHROW");
259 272
260 static const Keyword RETURN = const Keyword("return"); 273 static const Keyword RETURN = const Keyword("return", "RETURN");
261 274
262 static const Keyword SET = const Keyword("set", isBuiltIn: true); 275 static const Keyword SET = const Keyword("set", "SET", isBuiltIn: true);
263 276
264 static const Keyword SHOW = const Keyword("show", isPseudo: true); 277 static const Keyword SHOW = const Keyword("show", "SHOW", isPseudo: true);
265 278
266 static const Keyword SOURCE = const Keyword("source", isPseudo: true); 279 static const Keyword SOURCE =
280 const Keyword("source", "SOURCE", isPseudo: true);
267 281
268 static const Keyword STATIC = const Keyword("static", isBuiltIn: true); 282 static const Keyword STATIC =
283 const Keyword("static", "STATIC", isBuiltIn: true);
269 284
270 static const Keyword SUPER = const Keyword("super"); 285 static const Keyword SUPER = const Keyword("super", "SUPER");
271 286
272 static const Keyword SWITCH = const Keyword("switch"); 287 static const Keyword SWITCH = const Keyword("switch", "SWITCH");
273 288
274 static const Keyword SYNC = const Keyword("sync", isPseudo: true); 289 static const Keyword SYNC = const Keyword("sync", "SYNC", isPseudo: true);
275 290
276 static const Keyword THIS = const Keyword("this"); 291 static const Keyword THIS = const Keyword("this", "THIS");
277 292
278 static const Keyword THROW = const Keyword("throw"); 293 static const Keyword THROW = const Keyword("throw", "THROW");
279 294
280 static const Keyword TRUE = const Keyword("true"); 295 static const Keyword TRUE = const Keyword("true", "TRUE");
281 296
282 static const Keyword TRY = const Keyword("try"); 297 static const Keyword TRY = const Keyword("try", "TRY");
283 298
284 static const Keyword TYPEDEF = const Keyword("typedef", isBuiltIn: true); 299 static const Keyword TYPEDEF =
300 const Keyword("typedef", "TYPEDEF", isBuiltIn: true);
285 301
286 static const Keyword VAR = const Keyword("var"); 302 static const Keyword VAR = const Keyword("var", "VAR");
287 303
288 static const Keyword VOID = const Keyword("void"); 304 static const Keyword VOID = const Keyword("void", "VOID");
289 305
290 static const Keyword WHILE = const Keyword("while"); 306 static const Keyword WHILE = const Keyword("while", "WHILE");
291 307
292 static const Keyword WITH = const Keyword("with"); 308 static const Keyword WITH = const Keyword("with", "WITH");
293 309
294 static const Keyword YIELD = const Keyword("yield", isPseudo: true); 310 static const Keyword YIELD = const Keyword("yield", "YIELD", isPseudo: true);
295 311
296 static const List<Keyword> values = const <Keyword>[ 312 static const List<Keyword> values = const <Keyword>[
297 ABSTRACT, 313 ABSTRACT,
298 AS, 314 AS,
299 ASSERT, 315 ASSERT,
300 ASYNC, 316 ASYNC,
301 AWAIT, 317 AWAIT,
302 BREAK, 318 BREAK,
303 CASE, 319 CASE,
304 CATCH, 320 CATCH,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 WHILE, 372 WHILE,
357 WITH, 373 WITH,
358 YIELD, 374 YIELD,
359 ]; 375 ];
360 376
361 /** 377 /**
362 * A table mapping the lexemes of keywords to the corresponding keyword. 378 * A table mapping the lexemes of keywords to the corresponding keyword.
363 */ 379 */
364 static final Map<String, Keyword> keywords = _createKeywordMap(); 380 static final Map<String, Keyword> keywords = _createKeywordMap();
365 381
366 final TokenType info;
367
368 /** 382 /**
369 * A flag indicating whether the keyword is "built-in" identifier. 383 * A flag indicating whether the keyword is "built-in" identifier.
370 */ 384 */
371 final bool isBuiltIn; 385 final bool isBuiltIn;
372 386
373 /** 387 /**
374 * A flag indicating whether the keyword can be used as an identifier 388 * A flag indicating whether the keyword can be used as an identifier
375 * in some situations. 389 * in some situations.
376 */ 390 */
377 final bool isPseudo; 391 final bool isPseudo;
378 392
379 /** 393 /**
380 * The lexeme for the keyword.
381 */
382 final String syntax;
383
384 /**
385 * Initialize a newly created keyword. 394 * Initialize a newly created keyword.
386 */ 395 */
387 const Keyword(this.syntax, 396 const Keyword(String lexeme, String name,
388 {this.isBuiltIn: false, 397 {this.isBuiltIn: false,
389 this.isPseudo: false, 398 this.isPseudo: false,
390 this.info: TokenType.KEYWORD}); 399 int precedence: NO_PRECEDENCE})
400 : super(lexeme, name, precedence, KEYWORD_TOKEN);
391 401
392 bool get isBuiltInOrPseudo => isBuiltIn || isPseudo; 402 bool get isBuiltInOrPseudo => isBuiltIn || isPseudo;
393 403
394 /** 404 /**
395 * A flag indicating whether the keyword is "built-in" identifier. 405 * A flag indicating whether the keyword is "built-in" identifier.
396 * This method exists for backward compatibility and will be removed. 406 * This method exists for backward compatibility and will be removed.
397 * Use [isBuiltIn] instead. 407 * Use [isBuiltIn] instead.
398 */ 408 */
399 @deprecated 409 @deprecated
400 bool get isPseudoKeyword => isBuiltIn; // TODO (danrubel): remove this 410 bool get isPseudoKeyword => isBuiltIn; // TODO (danrubel): remove this
401 411
402 /** 412 /**
403 * The name of the keyword type.
404 */
405 String get name => syntax.toUpperCase();
406
407 @override
408 String toString() => name;
409
410 /**
411 * Create a table mapping the lexemes of keywords to the corresponding keyword 413 * Create a table mapping the lexemes of keywords to the corresponding keyword
412 * and return the table that was created. 414 * and return the table that was created.
413 */ 415 */
414 static Map<String, Keyword> _createKeywordMap() { 416 static Map<String, Keyword> _createKeywordMap() {
415 LinkedHashMap<String, Keyword> result = 417 LinkedHashMap<String, Keyword> result =
416 new LinkedHashMap<String, Keyword>(); 418 new LinkedHashMap<String, Keyword>();
417 for (Keyword keyword in values) { 419 for (Keyword keyword in values) {
418 result[keyword.syntax] = keyword; 420 result[keyword.lexeme] = keyword;
419 } 421 }
420 return result; 422 return result;
421 } 423 }
422 } 424 }
423 425
424 /** 426 /**
425 * A token representing a keyword in the language. 427 * A token representing a keyword in the language.
426 */ 428 */
427 class KeywordToken extends SimpleToken { 429 class KeywordToken extends SimpleToken {
428 @override 430 @override
429 final Keyword keyword; 431 final Keyword keyword;
430 432
431 /** 433 /**
432 * Initialize a newly created token to represent the given [keyword] at the 434 * Initialize a newly created token to represent the given [keyword] at the
433 * given [offset]. 435 * given [offset].
434 */ 436 */
435 KeywordToken(this.keyword, int offset) : super(TokenType.KEYWORD, offset); 437 KeywordToken(this.keyword, int offset) : super(keyword, offset);
436
437 @override
438 String get lexeme => keyword.syntax;
439 438
440 @override 439 @override
441 Token copy() => new KeywordToken(keyword, offset); 440 Token copy() => new KeywordToken(keyword, offset);
442 441
443 @override 442 @override
444 // Changed return type from Keyword to Object because 443 // Changed return type from Keyword to Object because
445 // fasta considers pseudo-keywords to be keywords rather than identifiers 444 // fasta considers pseudo-keywords to be keywords rather than identifiers
446 Object value() => keyword; 445 Object value() => keyword;
447 } 446 }
448 447
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 1011
1013 static const TokenType HEXADECIMAL = const TokenType( 1012 static const TokenType HEXADECIMAL = const TokenType(
1014 'hexadecimal', 'HEXADECIMAL', NO_PRECEDENCE, HEXADECIMAL_TOKEN); 1013 'hexadecimal', 'HEXADECIMAL', NO_PRECEDENCE, HEXADECIMAL_TOKEN);
1015 1014
1016 static const TokenType IDENTIFIER = const TokenType( 1015 static const TokenType IDENTIFIER = const TokenType(
1017 'identifier', 'STRING_INT', NO_PRECEDENCE, IDENTIFIER_TOKEN); 1016 'identifier', 'STRING_INT', NO_PRECEDENCE, IDENTIFIER_TOKEN);
1018 1017
1019 static const TokenType INT = 1018 static const TokenType INT =
1020 const TokenType('int', 'INT', NO_PRECEDENCE, INT_TOKEN); 1019 const TokenType('int', 'INT', NO_PRECEDENCE, INT_TOKEN);
1021 1020
1022 static const TokenType KEYWORD =
1023 const TokenType('keyword', 'KEYWORD', NO_PRECEDENCE, KEYWORD_TOKEN);
1024
1025 static const TokenType MULTI_LINE_COMMENT = const TokenType( 1021 static const TokenType MULTI_LINE_COMMENT = const TokenType(
1026 'comment', 'MULTI_LINE_COMMENT', NO_PRECEDENCE, COMMENT_TOKEN); 1022 'comment', 'MULTI_LINE_COMMENT', NO_PRECEDENCE, COMMENT_TOKEN);
1027 1023
1028 static const TokenType SCRIPT_TAG = 1024 static const TokenType SCRIPT_TAG =
1029 const TokenType('script', 'SCRIPT_TAG', NO_PRECEDENCE, SCRIPT_TOKEN); 1025 const TokenType('script', 'SCRIPT_TAG', NO_PRECEDENCE, SCRIPT_TOKEN);
1030 1026
1031 static const TokenType SINGLE_LINE_COMMENT = const TokenType( 1027 static const TokenType SINGLE_LINE_COMMENT = const TokenType(
1032 'comment', 'SINGLE_LINE_COMMENT', NO_PRECEDENCE, COMMENT_TOKEN); 1028 'comment', 'SINGLE_LINE_COMMENT', NO_PRECEDENCE, COMMENT_TOKEN);
1033 1029
1034 static const TokenType STRING = 1030 static const TokenType STRING =
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 'GENERIC_METHOD_TYPE_LIST', 1277 'GENERIC_METHOD_TYPE_LIST',
1282 NO_PRECEDENCE, 1278 NO_PRECEDENCE,
1283 GENERIC_METHOD_TYPE_LIST_TOKEN); 1279 GENERIC_METHOD_TYPE_LIST_TOKEN);
1284 1280
1285 static const TokenType GENERIC_METHOD_TYPE_ASSIGN = const TokenType( 1281 static const TokenType GENERIC_METHOD_TYPE_ASSIGN = const TokenType(
1286 'generic_comment_assign', 1282 'generic_comment_assign',
1287 'GENERIC_METHOD_TYPE_ASSIGN', 1283 'GENERIC_METHOD_TYPE_ASSIGN',
1288 NO_PRECEDENCE, 1284 NO_PRECEDENCE,
1289 GENERIC_METHOD_TYPE_ASSIGN_TOKEN); 1285 GENERIC_METHOD_TYPE_ASSIGN_TOKEN);
1290 1286
1291 static const TokenType AS = 1287 static const TokenType AS = Keyword.AS;
1292 const TokenType('as', 'AS', RELATIONAL_PRECEDENCE, KEYWORD_TOKEN);
1293 1288
1294 static const TokenType IS = 1289 static const TokenType IS = Keyword.IS;
1295 const TokenType('is', 'IS', RELATIONAL_PRECEDENCE, KEYWORD_TOKEN);
1296 1290
1297 /** 1291 /**
1298 * Token type used by error tokens. 1292 * Token type used by error tokens.
1299 */ 1293 */
1300 static const TokenType BAD_INPUT = const TokenType( 1294 static const TokenType BAD_INPUT = const TokenType(
1301 'malformed input', 'BAD_INPUT', NO_PRECEDENCE, BAD_INPUT_TOKEN); 1295 'malformed input', 'BAD_INPUT', NO_PRECEDENCE, BAD_INPUT_TOKEN);
1302 1296
1303 /** 1297 /**
1304 * Token type used by synthetic tokens that are created during parser 1298 * Token type used by synthetic tokens that are created during parser
1305 * recovery (non-analyzer use case). 1299 * recovery (non-analyzer use case).
1306 */ 1300 */
1307 static const TokenType RECOVERY = 1301 static const TokenType RECOVERY =
1308 const TokenType('recovery', 'RECOVERY', NO_PRECEDENCE, RECOVERY_TOKEN); 1302 const TokenType('recovery', 'RECOVERY', NO_PRECEDENCE, RECOVERY_TOKEN);
1309 1303
1310 // TODO(danrubel): "all" is misleading 1304 // TODO(danrubel): "all" is misleading
1311 // because this list does not include all TokenType instances. 1305 // because this list does not include all TokenType instances.
1312 static const List<TokenType> all = const <TokenType>[ 1306 static const List<TokenType> all = const <TokenType>[
1313 TokenType.EOF, 1307 TokenType.EOF,
1314 TokenType.DOUBLE, 1308 TokenType.DOUBLE,
1315 TokenType.HEXADECIMAL, 1309 TokenType.HEXADECIMAL,
1316 TokenType.IDENTIFIER, 1310 TokenType.IDENTIFIER,
1317 TokenType.INT, 1311 TokenType.INT,
1318 TokenType.KEYWORD,
1319 TokenType.MULTI_LINE_COMMENT, 1312 TokenType.MULTI_LINE_COMMENT,
1320 TokenType.SCRIPT_TAG, 1313 TokenType.SCRIPT_TAG,
1321 TokenType.SINGLE_LINE_COMMENT, 1314 TokenType.SINGLE_LINE_COMMENT,
1322 TokenType.STRING, 1315 TokenType.STRING,
1323 TokenType.AMPERSAND, 1316 TokenType.AMPERSAND,
1324 TokenType.AMPERSAND_AMPERSAND, 1317 TokenType.AMPERSAND_AMPERSAND,
1325 TokenType.AMPERSAND_EQ, 1318 TokenType.AMPERSAND_EQ,
1326 TokenType.AT, 1319 TokenType.AT,
1327 TokenType.BANG, 1320 TokenType.BANG,
1328 TokenType.BANG_EQ, 1321 TokenType.BANG_EQ,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1464 this == TokenType.PLUS || 1457 this == TokenType.PLUS ||
1465 this == TokenType.STAR; 1458 this == TokenType.STAR;
1466 1459
1467 /** 1460 /**
1468 * Return `true` if this type of token represents an equality operator. 1461 * Return `true` if this type of token represents an equality operator.
1469 */ 1462 */
1470 bool get isEqualityOperator => 1463 bool get isEqualityOperator =>
1471 this == TokenType.BANG_EQ || this == TokenType.EQ_EQ; 1464 this == TokenType.BANG_EQ || this == TokenType.EQ_EQ;
1472 1465
1473 /** 1466 /**
1467 * Return `true` if this type of token is an identifier.
1468 */
1469 bool get isIdentifier => kind == IDENTIFIER_TOKEN;
1470
1471 /**
1474 * Return `true` if this type of token represents an increment operator. 1472 * Return `true` if this type of token represents an increment operator.
1475 */ 1473 */
1476 bool get isIncrementOperator => 1474 bool get isIncrementOperator =>
1477 this == TokenType.PLUS_PLUS || this == TokenType.MINUS_MINUS; 1475 this == TokenType.PLUS_PLUS || this == TokenType.MINUS_MINUS;
1478 1476
1479 /** 1477 /**
1478 * Return `true` if this type of token is a keyword.
1479 */
1480 bool get isKeyword => kind == KEYWORD_TOKEN;
1481
1482 /**
1480 * Return `true` if this type of token represents a multiplicative operator. 1483 * Return `true` if this type of token represents a multiplicative operator.
1481 */ 1484 */
1482 bool get isMultiplicativeOperator => precedence == MULTIPLICATIVE_PRECEDENCE; 1485 bool get isMultiplicativeOperator => precedence == MULTIPLICATIVE_PRECEDENCE;
1483 1486
1484 /** 1487 /**
1485 * Return `true` if this type of token represents a relational operator. 1488 * Return `true` if this type of token represents a relational operator.
1486 */ 1489 */
1487 bool get isRelationalOperator => 1490 bool get isRelationalOperator =>
1488 this == TokenType.LT || 1491 this == TokenType.LT ||
1489 this == TokenType.LT_EQ || 1492 this == TokenType.LT_EQ ||
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 1545
1543 void set precedingComments(CommentToken comment) { 1546 void set precedingComments(CommentToken comment) {
1544 _precedingComment = comment; 1547 _precedingComment = comment;
1545 _setCommentParent(_precedingComment); 1548 _setCommentParent(_precedingComment);
1546 } 1549 }
1547 1550
1548 @override 1551 @override
1549 Token copy() => 1552 Token copy() =>
1550 new TokenWithComment(type, offset, copyComments(precedingComments)); 1553 new TokenWithComment(type, offset, copyComments(precedingComments));
1551 } 1554 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/scanner/scanner.dart ('k') | pkg/front_end/test/precedence_info_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698