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

Unified Diff: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart

Issue 2742233002: Fix for parsing EmptyFunctionBody with Fasta. (Closed)
Patch Set: Created 3 years, 9 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/analyzer/ast_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
index e98969bb72a7c44b949b24a194e4c98b6ab90395..bf3636b97c558fa2c8da08426c15f9e0612738cf 100644
--- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
+++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
@@ -233,6 +233,15 @@ class AstBuilder extends ScopeListener {
push(ast.expressionStatement(pop(), toAnalyzerToken(token)));
}
+ @override
+ void endEmptyFunctionBody(Token semicolon) {
+ debugEvent("EmptyFunctionBody");
+ // TODO(scheglov) Change the parser to not produce these modifiers.
+ pop(); // star
+ pop(); // async
+ push(ast.emptyFunctionBody(toAnalyzerToken(semicolon)));
+ }
+
void endFunctionBody(int count, Token beginToken, Token endToken) {
debugEvent("FunctionBody");
List statements = popList(count);
@@ -249,7 +258,9 @@ class AstBuilder extends ScopeListener {
void finishFunction(formals, asyncModifier, FunctionBody body) {
debugEvent("finishFunction");
Statement bodyStatement;
- if (body is ExpressionFunctionBody) {
+ if (body is EmptyFunctionBody) {
+ bodyStatement = ast.emptyStatement(body.semicolon);
+ } else if (body is ExpressionFunctionBody) {
bodyStatement = ast.returnStatement(null, body.expression, null);
} else {
bodyStatement = (body as BlockFunctionBody).block;

Powered by Google App Engine
This is Rietveld 408576698