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

Unified Diff: pkg/front_end/lib/src/fasta/parser/parser.dart

Issue 2721623002: Let parser handle factory modifiers. (Closed)
Patch Set: Handle factory modifiers correctly in dart2js. Created 3 years, 10 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
Index: pkg/front_end/lib/src/fasta/parser/parser.dart
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart
index 2a58ae6dbfcc3a8c525a84b269a5f7552ef7dc96..dc89c469d2a55a9c2ec09f5dc33f383c37bceba7 100644
--- a/pkg/front_end/lib/src/fasta/parser/parser.dart
+++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -1820,24 +1820,26 @@ class Parser {
Token parseFactoryMethod(Token token) {
assert(isFactoryDeclaration(token));
Token start = token;
- Token externalModifier;
- if (identical(token.stringValue, 'external')) {
- externalModifier = token;
- token = token.next;
- }
- if (optional('const', token)) {
- token = token.next; // Skip const.
+ bool isExternal = false;
+ int modifierCount = 0;
+ while (isModifier(token)) {
+ if (optional('external', token)) {
+ isExternal = true;
+ }
+ token = parseModifier(token);
+ modifierCount++;
}
+ listener.handleModifiers(modifierCount);
Token factoryKeyword = token;
listener.beginFactoryMethod(factoryKeyword);
- token = token.next; // Skip 'factory'.
+ token = expect('factory', token);
token = parseConstructorReference(token);
token = parseFormalParameters(token);
token = parseAsyncModifier(token);
if (optional('=', token)) {
token = parseRedirectingFactoryBody(token);
} else {
- token = parseFunctionBody(token, false, externalModifier != null);
+ token = parseFunctionBody(token, false, isExternal);
}
listener.endFactoryMethod(start, token);
return token.next;

Powered by Google App Engine
This is Rietveld 408576698