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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java

Issue 501373002: Fix for issue 20690 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ParserTestCase.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
index 58ef670085b8031f1026a9a762799b75d1b9cabf..9ae428600d3b3aaead8d3ce21473b1bd4c319eed 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/parser/Parser.java
@@ -115,6 +115,11 @@ public class Parser {
private Token currentToken;
/**
+ * A flag indicating whether the parser is currently in a function body marked as being 'async'.
+ */
+ private boolean inAsync = false;
+
+ /**
* A flag indicating whether the parser is currently in the body of a loop.
*/
private boolean inLoop = false;
@@ -4041,8 +4046,10 @@ public class Parser {
*/
private FunctionBody parseFunctionBody(boolean mayBeEmpty, ParserErrorCode emptyErrorCode,
boolean inExpression) {
+ boolean wasInAsync = inAsync;
boolean wasInLoop = inLoop;
boolean wasInSwitch = inSwitch;
+ inAsync = false;
inLoop = false;
inSwitch = false;
try {
@@ -4067,6 +4074,7 @@ public class Parser {
if (matches(TokenType.STAR)) {
star = getAndAdvance();
}
+ inAsync = true;
} else if (matchesString(SYNC)) {
keyword = getAndAdvance();
if (matches(TokenType.STAR)) {
@@ -4110,6 +4118,7 @@ public class Parser {
return new EmptyFunctionBody(createSyntheticToken(TokenType.SEMICOLON));
}
} finally {
+ inAsync = wasInAsync;
inLoop = wasInLoop;
inSwitch = wasInSwitch;
}
@@ -5027,10 +5036,13 @@ public class Parser {
reportErrorForCurrentToken(ParserErrorCode.MISSING_STATEMENT);
return new EmptyStatement(createSyntheticToken(TokenType.SEMICOLON));
}
- } else if (parseAsync && matchesString(YIELD)) {
+ } else if (inAsync && matchesString(YIELD)) {
return parseYieldStatement();
- } else if (parseAsync && matchesString(AWAIT) && tokenMatchesKeyword(peek(), Keyword.FOR)) {
- return parseForStatement();
+ } else if (inAsync && matchesString(AWAIT)) {
+ if (tokenMatchesKeyword(peek(), Keyword.FOR)) {
+ return parseForStatement();
+ }
+ return new ExpressionStatement(parseExpression(), expect(TokenType.SEMICOLON));
} else if (matches(TokenType.SEMICOLON)) {
return parseEmptyStatement();
} else if (isInitializedVariableDeclaration()) {
@@ -5969,7 +5981,7 @@ public class Parser {
} else if (matches(TokenType.PLUS)) {
reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER);
return createSyntheticIdentifier();
- } else if (parseAsync && matchesString(AWAIT)) {
+ } else if (inAsync && matchesString(AWAIT)) {
return parseAwaitExpression();
}
return parsePostfixExpression();
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/ParserTestCase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698