Chromium Code Reviews| Index: pkg/compiler/lib/src/parser/parser.dart |
| diff --git a/pkg/compiler/lib/src/parser/parser.dart b/pkg/compiler/lib/src/parser/parser.dart |
| index 988cbf32c63d165be72ac4250dba5fc1b794c509..b660895f1a7ce7101ae70b1a48e004221ea822f3 100644 |
| --- a/pkg/compiler/lib/src/parser/parser.dart |
| +++ b/pkg/compiler/lib/src/parser/parser.dart |
| @@ -362,12 +362,21 @@ class Parser { |
| 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.beginNewFunctionTypeAlias(token); |
| + token = parseIdentifier(token.next); |
| + token = parseTypeVariablesOpt(token); |
| + token = expect('=', token); |
| + token = parseFunctionType(token); |
| + listener.endNewFunctionTypeAlias(typedefKeyword, token); |
| + } else { |
| + listener.beginFunctionTypeAlias(token); |
| + token = parseReturnTypeOpt(token.next); |
| + token = parseIdentifier(token); |
| + token = parseTypeVariablesOpt(token); |
| + token = parseFormalParameters(token); |
| + listener.endFunctionTypeAlias(typedefKeyword, token); |
|
Siggi Cherem (dart-lang)
2016/12/12 23:20:40
a suggestion to make this match closer to what the
floitsch
2016/12/29 19:57:46
Done.
|
| + } |
| return expect(';', token); |
| } |
| @@ -813,6 +822,22 @@ class Parser { |
| return token; |
| } |
| + Token parseFunctionType(Token token) { |
| + Token begin = token; |
| + listener.beginFunctionType(token); |
| + token = parseReturnTypeOpt(token); |
| + // TODO(floitsch): don't use string comparison, but the keyword-state table |
| + // is currently not set up to deal with upper-case characters. |
|
Siggi Cherem (dart-lang)
2016/12/12 23:20:40
can this count as a reason to switch to `fun` or `
floitsch
2016/12/29 19:57:46
nice try ;)
|
| + if (token.value != "Function") { |
| + return listener.expected("Function", token); |
| + } |
| + token = token.next; |
| + token = parseTypeVariablesOpt(token); |
| + token = parseFormalParameters(token); |
| + listener.endFunctionType(begin, token); |
| + return token; |
| + } |
| + |
| Token parseTypeArgumentsOpt(Token token) { |
| return parseStuff( |
| token, |