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

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

Issue 11878043: Start adding support for mixin application syntax. We now parse the typedef variant of mixin applic… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix broken language test. Created 7 years, 11 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: sdk/lib/_internal/compiler/implementation/scanner/parser.dart
diff --git a/sdk/lib/_internal/compiler/implementation/scanner/parser.dart b/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
index 64f712f45eaa636998c1fbc7faabd5387c6d36ef..690bcf93a44211a9ba812fb900acaf03d5fd110a 100644
--- a/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
+++ b/sdk/lib/_internal/compiler/implementation/scanner/parser.dart
@@ -52,7 +52,7 @@ class Parser {
} else if ((identical(value, 'abstract')) || (identical(value, 'class'))) {
return parseClass(token);
} else if (identical(value, 'typedef')) {
- return parseNamedFunctionAlias(token);
+ return parseTypedef(token);
} else if (identical(value, '#')) {
return parseScriptTags(token);
} else if (identical(value, 'library')) {
@@ -161,6 +161,19 @@ class Parser {
return token;
}
+ /// type (, type)*
+ Token parseTypeList(Token token) {
+ listener.beginTypeList(token);
+ token = parseType(token);
+ int count = 1;
+ while (optional(',', token)) {
+ token = parseType(token.next);
+ count++;
+ }
+ listener.endTypeList(count);
+ return token;
+ }
+
Token parsePartOrPartOf(Token token) {
assert(optional('part', token));
if (optional('of', token.next)) {
@@ -246,17 +259,36 @@ class Parser {
return parseClassBody(token);
}
- Token parseNamedFunctionAlias(Token token) {
+ Token parseTypedef(Token token) {
Token typedefKeyword = token;
- listener.beginFunctionTypeAlias(token);
- token = parseReturnTypeOpt(token.next);
- token = parseIdentifier(token);
- token = parseTypeVariablesOpt(token);
- token = parseFormalParameters(token);
- listener.endFunctionTypeAlias(typedefKeyword, token);
+ if (optional('=', peekAfterType(token.next))) {
+ listener.beginNamedMixinApplication(token);
+ token = parseIdentifier(token.next);
+ token = parseTypeVariablesOpt(token);
+ token = expect('=', token);
+ token = parseMixinApplication(token);
+ listener.endNamedMixinApplication(typedefKeyword, token);
+ } else {
+ listener.beginFunctionTypeAlias(token);
+ token = parseReturnTypeOpt(token.next);
+ token = parseIdentifier(token);
+ token = parseTypeVariablesOpt(token);
+ token = parseFormalParameters(token);
+ listener.endFunctionTypeAlias(typedefKeyword, token);
+ }
return expect(';', token);
}
+ Token parseMixinApplication(Token token) {
+ listener.beginMixinApplication(token);
+ token = parseModifiers(token);
+ token = parseType(token);
+ token = expect('with', token);
+ token = parseTypeList(token);
+ listener.endMixinApplication();
+ return token;
+ }
+
Token parseReturnTypeOpt(Token token) {
if (identical(token.stringValue, 'void')) {
listener.handleVoidKeyword(token);

Powered by Google App Engine
This is Rietveld 408576698