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 0067694aa15c0b30ff87ea045bbc44d6bf191d16..4a43c66fad586f13e46ecf1895e649656aff81d1 100644 |
--- a/pkg/analyzer/lib/src/generated/parser.dart |
+++ b/pkg/analyzer/lib/src/generated/parser.dart |
@@ -158,23 +158,17 @@ class Modifiers { |
* A parser used to parse tokens into an AST structure. |
*/ |
class Parser { |
- static String ASYNC = "async"; |
+ static String ASYNC = Keyword.ASYNC.syntax; |
- static String _AWAIT = "await"; |
+ static String _AWAIT = Keyword.AWAIT.syntax; |
- static String _HIDE = "hide"; |
+ static String _HIDE = Keyword.HIDE.syntax; |
- static String _OF = "of"; |
+ static String _SHOW = Keyword.SHOW.syntax; |
- static String _ON = "on"; |
+ static String SYNC = Keyword.SYNC.syntax; |
- static String _NATIVE = "native"; |
- |
- static String _SHOW = "show"; |
- |
- static String SYNC = "sync"; |
- |
- static String _YIELD = "yield"; |
+ static String _YIELD = Keyword.YIELD.syntax; |
/** |
* The source being parsed. |
@@ -1189,7 +1183,8 @@ class Parser { |
// Look for and skip over the extra-lingual 'native' specification. |
// |
NativeClause nativeClause = null; |
- if (_matchesString(_NATIVE) && _tokenMatches(_peek(), TokenType.STRING)) { |
+ if (_matchesKeyword(Keyword.NATIVE) && |
+ _tokenMatches(_peek(), TokenType.STRING)) { |
nativeClause = _parseNativeClause(); |
} |
// |
@@ -1586,9 +1581,9 @@ class Parser { |
* | 'hide' identifier (',' identifier)* |
*/ |
Combinator parseCombinator() { |
- if (_matchesString(_SHOW)) { |
+ if (_matchesKeyword(Keyword.SHOW)) { |
return astFactory.showCombinator(getAndAdvance(), parseIdentifierList()); |
- } else if (_matchesString(_HIDE)) { |
+ } else if (_matchesKeyword(Keyword.HIDE)) { |
return astFactory.hideCombinator(getAndAdvance(), parseIdentifierList()); |
} |
return null; |
@@ -1917,7 +1912,7 @@ class Parser { |
} |
return parseLibraryDirective(commentAndMetadata); |
} else if (keyword == Keyword.PART) { |
- if (_tokenMatchesString(_peek(), _OF)) { |
+ if (_tokenMatchesKeyword(_peek(), Keyword.OF)) { |
partOfDirectiveFound = true; |
return _parsePartOfDirective(commentAndMetadata); |
} else { |
@@ -2960,7 +2955,7 @@ class Parser { |
_inLoop = true; |
try { |
Token awaitKeyword = null; |
- if (_matchesString(_AWAIT)) { |
+ if (_matchesKeyword(Keyword.AWAIT)) { |
awaitKeyword = getAndAdvance(); |
} |
Token forKeyword = _expectKeyword(Keyword.FOR); |
@@ -3123,7 +3118,7 @@ class Parser { |
Token star = null; |
bool foundAsync = false; |
bool foundSync = false; |
- if (type == TokenType.IDENTIFIER) { |
+ if (type == TokenType.KEYWORD) { |
String lexeme = _currentToken.lexeme; |
if (lexeme == ASYNC) { |
foundAsync = true; |
@@ -3184,7 +3179,7 @@ class Parser { |
.emptyFunctionBody(_createSyntheticToken(TokenType.SEMICOLON)); |
} |
return astFactory.blockFunctionBody(keyword, star, parseBlock()); |
- } else if (_matchesString(_NATIVE)) { |
+ } else if (_matchesKeyword(Keyword.NATIVE)) { |
Token nativeToken = getAndAdvance(); |
StringLiteral stringLiteral = null; |
if (_matches(TokenType.STRING)) { |
@@ -3338,7 +3333,7 @@ class Parser { |
GenericFunctionType parseGenericFunctionTypeAfterReturnType( |
TypeAnnotation returnType) { |
Token functionKeyword = null; |
- if (_matchesString('Function')) { |
+ if (_matchesKeyword(Keyword.FUNCTION)) { |
functionKeyword = getAndAdvance(); |
} else if (_matchesIdentifier()) { |
_reportErrorForCurrentToken(ParserErrorCode.NAMED_FUNCTION_TYPE); |
@@ -3547,12 +3542,12 @@ class Parser { |
_reportErrorForCurrentToken( |
ParserErrorCode.MISSING_PREFIX_IN_DEFERRED_IMPORT); |
} else if (!_matches(TokenType.SEMICOLON) && |
- !_matchesString(_SHOW) && |
- !_matchesString(_HIDE)) { |
+ !_matchesKeyword(Keyword.SHOW) && |
+ !_matchesKeyword(Keyword.HIDE)) { |
Token nextToken = _peek(); |
if (_tokenMatchesKeyword(nextToken, Keyword.AS) || |
- _tokenMatchesString(nextToken, _SHOW) || |
- _tokenMatchesString(nextToken, _HIDE)) { |
+ _tokenMatchesKeyword(nextToken, Keyword.SHOW) || |
+ _tokenMatchesKeyword(nextToken, Keyword.HIDE)) { |
_reportErrorForCurrentToken( |
ParserErrorCode.UNEXPECTED_TOKEN, [_currentToken]); |
_advance(); |
@@ -3989,7 +3984,8 @@ class Parser { |
} |
} |
return parseBlock(); |
- } else if (type == TokenType.KEYWORD && !_currentToken.keyword.isBuiltIn) { |
+ } else if (type == TokenType.KEYWORD && |
+ !_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 |
@@ -4105,15 +4101,15 @@ class Parser { |
return astFactory |
.emptyStatement(_createSyntheticToken(TokenType.SEMICOLON)); |
} |
- } else if (_inGenerator && _matchesString(_YIELD)) { |
+ } else if (_inGenerator && _matchesKeyword(Keyword.YIELD)) { |
return parseYieldStatement(); |
- } else if (_inAsync && _matchesString(_AWAIT)) { |
+ } else if (_inAsync && _matchesKeyword(Keyword.AWAIT)) { |
if (_tokenMatchesKeyword(_peek(), Keyword.FOR)) { |
return parseForStatement(); |
} |
return astFactory.expressionStatement( |
parseExpression2(), _expect(TokenType.SEMICOLON)); |
- } else if (_matchesString(_AWAIT) && |
+ } else if (_matchesKeyword(Keyword.AWAIT) && |
_tokenMatchesKeyword(_peek(), Keyword.FOR)) { |
Token awaitToken = _currentToken; |
Statement statement = parseForStatement(); |
@@ -4306,7 +4302,7 @@ class Parser { |
* metadata 'part' 'of' identifier ';' |
*/ |
Directive parsePartOrPartOfDirective(CommentAndMetadata commentAndMetadata) { |
- if (_tokenMatchesString(_peek(), _OF)) { |
+ if (_tokenMatchesKeyword(_peek(), Keyword.OF)) { |
return _parsePartOfDirective(commentAndMetadata); |
} |
return _parsePartDirective(commentAndMetadata); |
@@ -4978,10 +4974,10 @@ class Parser { |
Block body = _parseBlockChecked(); |
List<CatchClause> catchClauses = <CatchClause>[]; |
Block finallyClause = null; |
- while (_matchesString(_ON) || _matchesKeyword(Keyword.CATCH)) { |
+ while (_matchesKeyword(Keyword.ON) || _matchesKeyword(Keyword.CATCH)) { |
Token onKeyword = null; |
TypeName exceptionType = null; |
- if (_matchesString(_ON)) { |
+ if (_matchesKeyword(Keyword.ON)) { |
onKeyword = getAndAdvance(); |
exceptionType = parseTypeAnnotation(false); |
} |
@@ -5241,7 +5237,7 @@ class Parser { |
} else if (type == TokenType.PLUS) { |
_reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER); |
return createSyntheticIdentifier(); |
- } else if (_inAsync && _matchesString(_AWAIT)) { |
+ } else if (_inAsync && _matchesKeyword(Keyword.AWAIT)) { |
return parseAwaitExpression(); |
} |
return parsePostfixExpression(); |
@@ -5694,7 +5690,7 @@ class Parser { |
* function type alias. |
*/ |
bool _atGenericFunctionTypeAfterReturnType(Token startToken) { |
- if (_tokenMatchesString(startToken, 'Function')) { |
+ if (_tokenMatchesKeyword(startToken, Keyword.FUNCTION)) { |
Token next = startToken.next; |
if (next != null && |
(_tokenMatches(next, TokenType.OPEN_PAREN) || |
@@ -7993,7 +7989,7 @@ class Parser { |
* Return `true` if the given [token] matches a pseudo keyword. |
*/ |
bool _tokenMatchesPseudoKeyword(Token token) => |
- token.keyword?.isBuiltIn ?? false; |
+ token.keyword?.isBuiltInOrPseudo ?? false; |
/** |
* Return `true` if the given [token] matches the given [identifier]. |