From 9c1d97bb9cebf305cd37ebfcfb69ca11e7ffd4df Mon Sep 17 00:00:00 2001 From: Dan Rubel Date: Tue, 19 Sep 2017 20:27:03 +0000 Subject: [PATCH] update parser to use token.isModifier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iee07cbde6c45b621bb13d1774c1d9f4bd97268ea Reviewed-on: https://dart-review.googlesource.com/6840 Reviewed-by: Peter von der Ahé Reviewed-by: Brian Wilkerson Commit-Queue: Dan Rubel --- pkg/front_end/lib/src/fasta/parser/parser.dart | 8 +++----- pkg/front_end/lib/src/scanner/token.dart | 4 ++-- pkg/front_end/test/token_test.dart | 2 ++ 3 files changed, 7 insertions(+), 7 deletions(-) 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);