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

Unified Diff: pkg/front_end/lib/src/fasta/parser/listener.dart

Issue 2968093003: Improve parsing of function expressions. (Closed)
Patch Set: Update to new message API. Created 3 years, 5 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/front_end/lib/src/fasta/parser/listener.dart
diff --git a/pkg/front_end/lib/src/fasta/parser/listener.dart b/pkg/front_end/lib/src/fasta/parser/listener.dart
index 05e409f28f10c40cb865c17108f171f13655bddc..ff12768dfb2c44122a10fd6d41c0582ee7ccbc30 100644
--- a/pkg/front_end/lib/src/fasta/parser/listener.dart
+++ b/pkg/front_end/lib/src/fasta/parser/listener.dart
@@ -254,15 +254,40 @@ class Listener {
logEvent("ForInBody");
}
- void beginFunction(Token token) {}
+ void beginNamedFunctionExpression(Token token) {}
- void endFunction(Token getOrSet, Token endToken) {
- logEvent("Function");
+ /// A named function expression which isn't legal syntax in Dart.
+ /// Useful for recovering from Javascript code being pasted into a Dart
+ /// proram, as it will interpret `function foo() {}` as a named function
+ /// expression with return type `function` and name `foo`.
+ ///
+ /// Substructures:
+ /// - Modifiers
+ /// - Return type
+ /// - Name
+ /// - Type variables
+ /// - Formals
+ /// - Initializers
+ /// - Async modifier
+ /// - Function body (block or arrow expression).
+ void endNamedFunctionExpression(Token endToken) {
+ logEvent("NamedFunctionExpression");
}
void beginFunctionDeclaration(Token token) {}
- void endFunctionDeclaration(Token token) {
+ /// A function declaration.
+ ///
+ /// Substructures:
+ /// - Modifiers
+ /// - Return type
+ /// - Name
+ /// - Type variables
+ /// - Formals
+ /// - Initializers
+ /// - Async modifier
+ /// - Function body (block or arrow expression).
+ void endFunctionDeclaration(Token endToken) {
logEvent("FunctionDeclaration");
}
@@ -776,7 +801,7 @@ class Listener {
logEvent("TypeVariables");
}
- void beginUnnamedFunction(Token token) {}
+ void beginFunctionExpression(Token token) {}
/// Handle the end of a function expression (e.g. "() { ... }").
/// Substructures:
@@ -784,8 +809,8 @@ class Listener {
/// - Formal parameters
/// - Async marker
/// - Body
- void endUnnamedFunction(Token beginToken, Token token) {
- logEvent("UnnamedFunction");
+ void endFunctionExpression(Token beginToken, Token token) {
+ logEvent("FunctionExpression");
}
void beginVariablesDeclaration(Token token) {}
« no previous file with comments | « pkg/front_end/lib/src/fasta/kernel/body_builder.dart ('k') | pkg/front_end/lib/src/fasta/parser/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698