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

Unified Diff: pkg/front_end/lib/src/scanner/token.dart

Issue 2842213003: new TokenType and Keyword API (Closed)
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/front_end/lib/src/scanner/scanner.dart ('k') | pkg/front_end/test/scanner_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/scanner/token.dart
diff --git a/pkg/front_end/lib/src/scanner/token.dart b/pkg/front_end/lib/src/scanner/token.dart
index 6bce7b4698e3e7066ab49f749de129e04ce66e56..bb79852def499a7d91d581031944091042b34b1f 100644
--- a/pkg/front_end/lib/src/scanner/token.dart
+++ b/pkg/front_end/lib/src/scanner/token.dart
@@ -379,12 +379,12 @@ class Keyword {
/**
* The lexeme for the keyword.
*/
- final String syntax;
+ final String lexeme;
/**
* Initialize a newly created keyword.
*/
- const Keyword(this.syntax,
+ const Keyword(this.lexeme,
{this.isBuiltIn: false,
this.isPseudo: false,
this.info: TokenType.KEYWORD});
@@ -402,7 +402,15 @@ class Keyword {
/**
* The name of the keyword type.
*/
- String get name => syntax.toUpperCase();
+ String get name => lexeme.toUpperCase();
+
+ /**
+ * The lexeme for the keyword.
+ *
+ * Deprecated - use [lexeme] instead.
+ */
+ @deprecated
+ String get syntax => lexeme;
@override
String toString() => name;
@@ -415,7 +423,7 @@ class Keyword {
LinkedHashMap<String, Keyword> result =
new LinkedHashMap<String, Keyword>();
for (Keyword keyword in values) {
- result[keyword.syntax] = keyword;
+ result[keyword.lexeme] = keyword;
}
return result;
}
@@ -435,7 +443,7 @@ class KeywordToken extends SimpleToken {
KeywordToken(this.keyword, int offset) : super(TokenType.KEYWORD, offset);
@override
- String get lexeme => keyword.syntax;
+ String get lexeme => keyword.lexeme;
@override
Token copy() => new KeywordToken(keyword, offset);
@@ -1477,6 +1485,11 @@ class TokenType {
this == TokenType.PLUS_PLUS || this == TokenType.MINUS_MINUS;
/**
+ * Return `true` if this type of token is a keyword.
+ */
+ bool get isKeyword => kind == KEYWORD_TOKEN;
+
+ /**
* Return `true` if this type of token represents a multiplicative operator.
*/
bool get isMultiplicativeOperator => precedence == MULTIPLICATIVE_PRECEDENCE;
« no previous file with comments | « pkg/front_end/lib/src/scanner/scanner.dart ('k') | pkg/front_end/test/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698