Chromium Code Reviews| 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..c2aa578e7a784fdae39c308be6d7ea9dccd41291 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 = parseIdentifier(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,38 @@ 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 (identical(token.next.next.kind, EQ_TOKEN)) { |
|
ahe
2013/01/15 15:35:04
if (optional('=', token.next.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) { |
| + Token beginToken = token; |
| + listener.beginMixinApplication(token); |
| + token = parseModifiers(token); |
| + token = parseType(token); |
| + token = expect('with', token); |
| + token = parseTypeList(token); |
| + // TODO(kasperl): The endToken is one too far ahead. |
|
ahe
2013/01/15 15:35:04
That is fine. As long as you don't store it.
|
| + listener.endMixinApplication(beginToken, token); |
| + return token; |
| + } |
| + |
| Token parseReturnTypeOpt(Token token) { |
| if (identical(token.stringValue, 'void')) { |
| listener.handleVoidKeyword(token); |