update parser to use token.isModifier
Change-Id: Iee07cbde6c45b621bb13d1774c1d9f4bd97268ea Reviewed-on: https://dart-review.googlesource.com/6840 Reviewed-by: Peter von der Ahé <ahe@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
5402179bd4
commit
9c1d97bb9c
@@ -2048,8 +2048,6 @@ class Parser {
|
||||
return expect(';', token);
|
||||
}
|
||||
|
||||
bool isModifier(Token token) => modifierOrder(token) < 127;
|
||||
|
||||
/// Provides a partial order on modifiers.
|
||||
///
|
||||
/// The order is based on the order modifiers must appear in according to the
|
||||
@@ -2075,7 +2073,7 @@ class Parser {
|
||||
}
|
||||
|
||||
Token parseModifier(Token token) {
|
||||
assert(isModifier(token));
|
||||
assert(token.isModifier);
|
||||
listener.handleModifier(token);
|
||||
return token.next;
|
||||
}
|
||||
@@ -2496,7 +2494,7 @@ class Parser {
|
||||
Token start = token;
|
||||
bool isExternal = false;
|
||||
int modifierCount = 0;
|
||||
while (isModifier(token)) {
|
||||
while (token.isModifier) {
|
||||
if (optional('external', token)) {
|
||||
isExternal = true;
|
||||
}
|
||||
@@ -2911,7 +2909,7 @@ class Parser {
|
||||
|
||||
Token parseExpressionStatementOrConstDeclaration(Token token) {
|
||||
assert(optional('const', token));
|
||||
if (isModifier(token.next)) {
|
||||
if (token.next.isModifier) {
|
||||
return parseVariablesDeclaration(token);
|
||||
} else {
|
||||
return parseType(
|
||||
|
||||
@@ -185,7 +185,7 @@ class Keyword extends TokenType {
|
||||
static const Keyword EXTENDS = const Keyword("extends", "EXTENDS");
|
||||
|
||||
static const Keyword EXTERNAL =
|
||||
const Keyword("external", "EXTERNAL", isBuiltIn: true);
|
||||
const Keyword("external", "EXTERNAL", isBuiltIn: true, isModifier: true);
|
||||
|
||||
static const Keyword FACTORY =
|
||||
const Keyword("factory", "FACTORY", isBuiltIn: true);
|
||||
@@ -272,7 +272,7 @@ class Keyword extends TokenType {
|
||||
static const Keyword TYPEDEF = const Keyword("typedef", "TYPEDEF",
|
||||
isBuiltIn: true, isTopLevelKeyword: true);
|
||||
|
||||
static const Keyword VAR = const Keyword("var", "VAR");
|
||||
static const Keyword VAR = const Keyword("var", "VAR", isModifier: true);
|
||||
|
||||
static const Keyword VOID = const Keyword("void", "VOID");
|
||||
|
||||
|
||||
@@ -177,8 +177,10 @@ class Foo {
|
||||
Keyword.ABSTRACT,
|
||||
Keyword.CONST,
|
||||
Keyword.COVARIANT,
|
||||
Keyword.EXTERNAL,
|
||||
Keyword.FINAL,
|
||||
Keyword.STATIC,
|
||||
Keyword.VAR,
|
||||
]);
|
||||
for (Keyword keyword in Keyword.values) {
|
||||
var isModifier = modifierKeywords.contains(keyword);
|
||||
|
||||
Reference in New Issue
Block a user