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

Unified Diff: pkg/analyzer/lib/src/generated/parser.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/analyzer/lib/src/generated/error_verifier.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 96326ebd71bfa17720a10d4ee6b2672989a527d2..94baa56626a2da57b65f9a56c7906cb16dd3ac50 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -158,17 +158,17 @@ class Modifiers {
* A parser used to parse tokens into an AST structure.
*/
class Parser {
- static String ASYNC = Keyword.ASYNC.syntax;
+ static String ASYNC = Keyword.ASYNC.lexeme;
- static String _AWAIT = Keyword.AWAIT.syntax;
+ static String _AWAIT = Keyword.AWAIT.lexeme;
- static String _HIDE = Keyword.HIDE.syntax;
+ static String _HIDE = Keyword.HIDE.lexeme;
- static String _SHOW = Keyword.SHOW.syntax;
+ static String _SHOW = Keyword.SHOW.lexeme;
- static String SYNC = Keyword.SYNC.syntax;
+ static String SYNC = Keyword.SYNC.lexeme;
- static String _YIELD = Keyword.YIELD.syntax;
+ static String _YIELD = Keyword.YIELD.lexeme;
static const int _MAX_TREE_DEPTH = 300;
@@ -391,7 +391,7 @@ class Parser {
*/
SimpleIdentifier createSyntheticIdentifier({bool isDeclaration: false}) {
Token syntheticToken;
- if (_currentToken.type == TokenType.KEYWORD) {
+ if (_currentToken.type.isKeyword) {
// Consider current keyword token as an identifier.
// It is not always true, e.g. "^is T" where "^" is place the place for
// synthetic identifier. By creating SyntheticStringToken we can
@@ -585,7 +585,7 @@ class Parser {
// String get getterName
if (allowAdditionalTokens) {
if (type == TokenType.CLOSE_CURLY_BRACKET ||
- type == TokenType.KEYWORD ||
+ type.isKeyword ||
type == TokenType.IDENTIFIER ||
type == TokenType.OPEN_CURLY_BRACKET) {
return true;
@@ -3167,7 +3167,7 @@ class Parser {
Token star = null;
bool foundAsync = false;
bool foundSync = false;
- if (type == TokenType.KEYWORD) {
+ if (type.isKeyword) {
String lexeme = _currentToken.lexeme;
if (lexeme == ASYNC) {
foundAsync = true;
@@ -4033,8 +4033,7 @@ class Parser {
}
}
return parseBlock();
- } else if (type == TokenType.KEYWORD &&
- !_currentToken.keyword.isBuiltInOrPseudo) {
+ } else if (type.isKeyword && !_currentToken.keyword.isBuiltInOrPseudo) {
Keyword keyword = _currentToken.keyword;
// TODO(jwren) compute some metrics to figure out a better order for this
// if-then sequence to optimize performance
@@ -6014,7 +6013,7 @@ class Parser {
// Remove uses of this method in favor of matches?
// Pass in the error code to use to report the error?
_reportErrorForCurrentToken(
- ParserErrorCode.EXPECTED_TOKEN, [keyword.syntax]);
+ ParserErrorCode.EXPECTED_TOKEN, [keyword.lexeme]);
return _currentToken;
}
@@ -6572,7 +6571,7 @@ class Parser {
withClause = parseWithClause();
} else {
_reportErrorForCurrentToken(
- ParserErrorCode.EXPECTED_TOKEN, [Keyword.WITH.syntax]);
+ ParserErrorCode.EXPECTED_TOKEN, [Keyword.WITH.lexeme]);
}
ImplementsClause implementsClause = null;
if (_matchesKeyword(Keyword.IMPLEMENTS)) {
@@ -7570,7 +7569,7 @@ class Parser {
// TODO(brianwilkerson) Should this function also return true for valid
// top-level keywords?
bool isKeywordAfterUri(Token token) =>
- token.lexeme == Keyword.AS.syntax ||
+ token.lexeme == Keyword.AS.lexeme ||
token.lexeme == _HIDE ||
token.lexeme == _SHOW;
TokenType type = _currentToken.type;
@@ -8085,8 +8084,7 @@ class Parser {
* Return `true` if the given [token] is either an identifier or a keyword.
*/
bool _tokenMatchesIdentifierOrKeyword(Token token) =>
- _tokenMatches(token, TokenType.IDENTIFIER) ||
- _tokenMatches(token, TokenType.KEYWORD);
+ _tokenMatches(token, TokenType.IDENTIFIER) || token.type.isKeyword;
/**
* Return `true` if the given [token] matches the given [keyword].
« no previous file with comments | « pkg/analyzer/lib/src/generated/error_verifier.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698