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

Unified Diff: pkg/compiler/lib/src/parser/element_listener.dart

Issue 2567133002: Add support for the new function-type syntax. (Closed)
Patch Set: Fixes after rebase. 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/compiler/lib/src/parser/element_listener.dart
diff --git a/pkg/compiler/lib/src/parser/element_listener.dart b/pkg/compiler/lib/src/parser/element_listener.dart
index fd5a243e554ff5facea7d02b516525591fb71f7c..c635dd9514020747aeaf6d4a3db1905df8cfe329 100644
--- a/pkg/compiler/lib/src/parser/element_listener.dart
+++ b/pkg/compiler/lib/src/parser/element_listener.dart
@@ -289,10 +289,18 @@ class ElementListener extends Listener {
}
@override
- void endFunctionTypeAlias(Token typedefKeyword, Token endToken) {
- popNode(); // TODO(karlklose): do not throw away typeVariables.
- Identifier name = popNode();
- popNode(); // returnType
+ void endFunctionTypeAlias(
+ Token typedefKeyword, Token equals, Token endToken) {
+ Identifier name;
+ if (equals == null) {
+ popNode(); // TODO(karlklose): do not throw away typeVariables.
+ name = popNode();
+ popNode(); // returnType
+ } else {
+ popNode(); // Function type.
+ popNode(); // TODO(karlklose): do not throw away typeVariables.
+ name = popNode();
+ }
pushElement(new PartialTypedefElement(
name.source, compilationUnitElement, typedefKeyword, endToken));
rejectBuiltInIdentifier(name);
@@ -326,13 +334,13 @@ class ElementListener extends Listener {
@override
void endMixinApplication() {
NodeList mixins = popNode();
- TypeAnnotation superclass = popNode();
+ NominalTypeAnnotation superclass = popNode();
pushNode(new MixinApplication(superclass, mixins));
}
@override
void handleVoidKeyword(Token token) {
- pushNode(new TypeAnnotation(new Identifier(token), null));
+ pushNode(new NominalTypeAnnotation(new Identifier(token), null));
}
@override
@@ -405,7 +413,7 @@ class ElementListener extends Listener {
@override
void endTypeVariable(Token token, Token extendsOrSuper) {
- TypeAnnotation bound = popNode();
+ NominalTypeAnnotation bound = popNode();
Identifier name = popNode();
pushNode(new TypeVariable(name, extendsOrSuper, bound));
rejectBuiltInIdentifier(name);
@@ -432,10 +440,21 @@ class ElementListener extends Listener {
}
@override
- void endType(Token beginToken, Token endToken) {
+ void handleType(Token beginToken, Token endToken) {
NodeList typeArguments = popNode();
Expression typeName = popNode();
- pushNode(new TypeAnnotation(typeName, typeArguments));
+ pushNode(new NominalTypeAnnotation(typeName, typeArguments));
+ }
+
+ void handleNoName(Token token) {
+ pushNode(null);
+ }
+
+ @override
+ void handleFunctionType(Token functionToken, Token endToken) {
+ popNode(); // Type parameters.
+ popNode(); // Return type.
+ pushNode(null);
}
@override
@@ -634,6 +653,10 @@ class ElementListener extends Listener {
errorCode = MessageKind.BAD_INPUT_CHARACTER;
break;
+ case ErrorKind.InvalidInlineFunctionType:
+ errorCode = MessageKind.INVALID_INLINE_FUNCTION_TYPE;
+ break;
+
case ErrorKind.InvalidSyncModifier:
errorCode = MessageKind.INVALID_SYNC_MODIFIER;
break;

Powered by Google App Engine
This is Rietveld 408576698