Chromium Code Reviews| 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 2cf601c0cf9abf477c1e7cd3a07ee393803a6993..dddcdab6c9e1f270a9fc362bffbd41211732b84c 100644 |
| --- a/compiler/java/com/google/dart/compiler/parser/DartParser.java |
| +++ b/compiler/java/com/google/dart/compiler/parser/DartParser.java |
| @@ -1178,7 +1178,7 @@ public class DartParser extends CompletionHooksParserBase { |
| } |
| private DartMethodDefinition parseMethod(Modifiers modifiers, DartTypeNode returnType) { |
| - DartExpression name = null; |
| + DartExpression name = new DartIdentifier(""); |
|
zundel
2012/04/05 18:45:36
@Brian, this is a failsafe to make sure we never g
|
| if (modifiers.isFactory()) { |
| if (modifiers.isAbstract()) { |
| @@ -1219,8 +1219,30 @@ public class DartParser extends CompletionHooksParserBase { |
| && ctx.getTokenString().equals(CALL_KEYWORD)) { |
| name = done(new DartIdentifier(CALL_KEYWORD)); |
| } else { |
| - reportUnexpectedToken(position(), Token.COMMENT, operation); |
| - done(null); |
| + // Not a valid operator. Try to recover. |
| + boolean found = false; |
| + for (int i = 0; i < 4; ++i) { |
| + if (peek(i).equals(Token.LPAREN)) { |
| + found = true; |
| + break; |
| + } |
| + } |
| + StringBuilder buf = new StringBuilder(); |
| + buf.append(operation.getSyntax()); |
| + if (found) { |
| + reportError(position(), ParserErrorCode.OPERATOR_IS_NOT_USER_DEFINABLE); |
| + while(true) { |
| + Token token = peek(0); |
| + if (token.equals(Token.LPAREN)) { |
| + break; |
| + } |
| + buf.append(next().getSyntax()); |
| + } |
| + name = done(new DartIdentifier(buf.toString())); |
|
zundel
2012/04/05 18:45:36
This works hard to get a meaningful name for the m
|
| + } else { |
| + reportUnexpectedToken(position(), Token.COMMENT, operation); |
| + done(null); |
| + } |
| } |
| } else { |
| beginMethodName(); |