diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart index b5cf0233b9e..cb0912c2c94 100644 --- a/pkg/front_end/lib/src/fasta/parser/parser.dart +++ b/pkg/front_end/lib/src/fasta/parser/parser.dart @@ -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( diff --git a/pkg/front_end/lib/src/scanner/token.dart b/pkg/front_end/lib/src/scanner/token.dart index 69ce75f8f72..acd8513e0ef 100644 --- a/pkg/front_end/lib/src/scanner/token.dart +++ b/pkg/front_end/lib/src/scanner/token.dart @@ -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"); diff --git a/pkg/front_end/test/token_test.dart b/pkg/front_end/test/token_test.dart index c0f43eff403..c2868d78fe9 100644 --- a/pkg/front_end/test/token_test.dart +++ b/pkg/front_end/test/token_test.dart @@ -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);