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

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 11340033: Issue 5847. Parse incomplete function expression without body (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use skipTypeName() Created 8 years, 2 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 | compiler/javatests/com/google/dart/compiler/parser/ParserRecoveryTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
diff --git a/compiler/java/com/google/dart/compiler/parser/DartParser.java b/compiler/java/com/google/dart/compiler/parser/DartParser.java
index fac4bcb200b3bd2f4ffec35cb570e9ab9b6dba8e..ada0732f31d29d6d2455ac4d5ca395a44027ef5b 100644
--- a/compiler/java/com/google/dart/compiler/parser/DartParser.java
+++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java
@@ -4369,6 +4369,13 @@ public class DartParser extends CompletionHooksParserBase {
if (!optional(Token.LPAREN)) {
return false;
}
+ // if it looks as "(Type name, ....)" then it may be function expression
+ boolean hasTwoIdentifiersComma;
+ {
+ int nameOffset = skipTypeName(0);
+ hasTwoIdentifiersComma = nameOffset != -1 && peek(nameOffset + 0) == Token.IDENTIFIER
+ && peek(nameOffset + 1) == Token.COMMA;
+ }
// find matching parenthesis
int count = 1;
while (count != 0) {
@@ -4383,7 +4390,7 @@ public class DartParser extends CompletionHooksParserBase {
break;
}
}
- return (peek(0) == Token.ARROW || peek(0) == Token.LBRACE);
+ return (peek(0) == Token.ARROW || peek(0) == Token.LBRACE) || hasTwoIdentifiersComma;
} finally {
rollback();
}
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/parser/ParserRecoveryTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698