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

Issue 10005040: Using annotations to help with parser recovery (Closed)

Created:
8 years, 8 months ago by zundel
Modified:
8 years, 8 months ago
CC:
reviews_dartlang.org, dart-editor-team_google.com
Visibility:
Public.

Description

Using annotations to help with parser recovery There are cases in the parser where a method is consuming tokens aren't expected at that level, but could have been used to sucessfully complete a non-terminal further up in the stack. This change adds an annotation @Terminals that is consulted when an unexpected token is encountered to determine whether or not the token should be consumed. Adding a token to @Terminals tells the parser it is OK not to consume that token, that the parser will eventually make progress. http://code.google.com/p/dart/issues/detail?id=2417 Committed: https://code.google.com/p/dart/source/detail?r=6299

Patch Set 1 : # #

Total comments: 4

Patch Set 2 : Removed unrelated file #

Unified diffs Side-by-side diffs Delta from patch set Stats (+147 lines, -19 lines) Patch
M compiler/java/com/google/dart/compiler/parser/AbstractParser.java View 5 chunks +110 lines, -18 lines 0 comments Download
M compiler/java/com/google/dart/compiler/parser/DartParser.java View 3 chunks +4 lines, -1 line 0 comments Download
A compiler/java/com/google/dart/compiler/parser/Terminals.java View 1 chunk +19 lines, -0 lines 0 comments Download
M compiler/javatests/com/google/dart/compiler/parser/ParserRecoveryTest.java View 1 chunk +14 lines, -0 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
zundel
No unit tests yet, but this does fix the problem mentioned in the issue: foo(Selector.); ...
8 years, 8 months ago (2012-04-06 17:10:20 UTC) #1
messick
Nice. DBC https://chromiumcodereview.appspot.com/10005040/diff/1010/compiler/java/com/google/dart/compiler/parser/DartParser.java File compiler/java/com/google/dart/compiler/parser/DartParser.java (right): https://chromiumcodereview.appspot.com/10005040/diff/1010/compiler/java/com/google/dart/compiler/parser/DartParser.java#newcode256 compiler/java/com/google/dart/compiler/parser/DartParser.java:256: @Terminals(tokens={Token.EOS, Token.CLASS}) INTERFACE? https://chromiumcodereview.appspot.com/10005040/diff/1010/lib/compiler/implementation/compiler.dart File lib/compiler/implementation/compiler.dart (right): ...
8 years, 8 months ago (2012-04-06 17:11:47 UTC) #2
scheglov
LGTM https://chromiumcodereview.appspot.com/10005040/diff/1010/compiler/java/com/google/dart/compiler/parser/AbstractParser.java File compiler/java/com/google/dart/compiler/parser/AbstractParser.java (right): https://chromiumcodereview.appspot.com/10005040/diff/1010/compiler/java/com/google/dart/compiler/parser/AbstractParser.java#newcode71 compiler/java/com/google/dart/compiler/parser/AbstractParser.java:71: classes.put(frame.getClassName(), null); Hm... It was null and we ...
8 years, 8 months ago (2012-04-06 18:00:11 UTC) #3
Brian Wilkerson
I like the approach, but I'm not thrilled about the implementation. (I generally have that ...
8 years, 8 months ago (2012-04-06 18:09:23 UTC) #4
zundel
https://chromiumcodereview.appspot.com/10005040/diff/1010/compiler/java/com/google/dart/compiler/parser/DartParser.java File compiler/java/com/google/dart/compiler/parser/DartParser.java (right): https://chromiumcodereview.appspot.com/10005040/diff/1010/compiler/java/com/google/dart/compiler/parser/DartParser.java#newcode256 compiler/java/com/google/dart/compiler/parser/DartParser.java:256: @Terminals(tokens={Token.EOS, Token.CLASS}) On 2012/04/06 17:11:47, messick wrote: > INTERFACE? ...
8 years, 8 months ago (2012-04-06 18:30:07 UTC) #5
Brian Wilkerson
> This is an interesting problem. INTERFACE isn't a token, its a "Builtin > Identifer", ...
8 years, 8 months ago (2012-04-06 18:57:08 UTC) #6
danrubel
Very clever approach, but I'm not comfortable with this implementation long term. LGTM as an ...
8 years, 8 months ago (2012-04-06 21:34:07 UTC) #7
messick
8 years, 8 months ago (2012-04-06 21:46:40 UTC) #8
On 2012/04/06 21:34:07, danrubel wrote:
> Very clever approach, but I'm not comfortable with this implementation long
> term. LGTM as an stop gap measure as we work on better implementation to solve
> the same problem.

Actually, could all those beginXXX() methods be used here? You'd have to record
the state in the parser, and therefore pay a cost even for successful parses.
This type of situation is what they are designed for, although I only expected
them to be used in code completion.

Powered by Google App Engine
This is Rietveld 408576698