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

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

Issue 57643006: Issue 13023. Fix for parsing 'static int operator = (5);'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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/SimpleParserTest.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 5afbc59ccd7f3b09ab982429ee1447f2a27adbf6..cb9bcd83ff880befad2e5b6e421d448c51f80e03 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
@@ -1934,14 +1934,21 @@ public class Parser {
* @return {@code true} if the given token appears to be the beginning of an operator declaration
*/
private boolean isOperator(Token startToken) {
- if (startToken.isOperator()) {
- Token token = startToken.getNext();
- while (token.isOperator()) {
- token = token.getNext();
- }
- return matches(token, TokenType.OPEN_PAREN);
+ // Accept any operator here, even if it is not user definable.
+ if (!startToken.isOperator()) {
+ return false;
}
- return false;
+ // Token "=" means that it is actually field initializer.
+ if (startToken.getType() == TokenType.EQ) {
+ return false;
+ }
+ // Consume all operator tokens.
+ Token token = startToken.getNext();
+ while (token.isOperator()) {
+ token = token.getNext();
+ }
+ // Formal parameter list is expect now.
+ return matches(token, TokenType.OPEN_PAREN);
}
/**
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/parser/SimpleParserTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698