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

Unified Diff: lib/compiler/implementation/scanner/parser.dart

Issue 10957060: First stab at parsing redirecting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 3 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: lib/compiler/implementation/scanner/parser.dart
diff --git a/lib/compiler/implementation/scanner/parser.dart b/lib/compiler/implementation/scanner/parser.dart
index 4f4f5ddba2aba43b2f61400ae36a5585d69f63d0..41dcc83035e84a3c49731b8fb6f5ea96d17f2a03 100644
--- a/lib/compiler/implementation/scanner/parser.dart
+++ b/lib/compiler/implementation/scanner/parser.dart
@@ -916,7 +916,11 @@ class Parser {
token = parseIdentifier(token.next);
}
token = parseFormalParameters(token);
- token = parseFunctionBody(token, false);
+ if (optional('=', token)) {
+ token = parseRedirectingFactoryBody(token);
+ } else {
+ token = parseFunctionBody(token, false);
+ }
listener.endFactoryMethod(start, period, token);
return token.next;
}
@@ -991,6 +995,21 @@ class Parser {
return isBlock ? token.next : token;
}
+ Token parseRedirectingFactoryBody(Token token) {
+ listener.beginRedirectingFactoryBody(token);
+ assert('=' === token.stringValue);
ahe 2012/10/05 08:23:20 assert(optional('=', token)); I should clean up t
Lasse Reichstein Nielsen 2012/10/09 09:46:54 Done.
+ Token equals = token;
+ token = parseType(token.next);
+ Token dot = null;
+ if (optional('.', token)) {
+ dot = token;
+ token = parseIdentifier(token.next);
+ }
+ expectSemicolon(token);
+ listener.endRedirectingFactoryBody(equals, dot, token);
+ return token;
ahe 2012/10/05 08:23:20 You should consume the semicolon token if you requ
Lasse Reichstein Nielsen 2012/10/09 09:46:54 I don't think that's compatible with parseFunction
+ }
+
Token parseFunctionBody(Token token, bool isExpression) {
if (optional(';', token)) {
listener.endFunctionBody(0, null, token);

Powered by Google App Engine
This is Rietveld 408576698