[antlr-interest] Error nodes created upon syntax error
parrt at cs.usfca.edu
Mon Dec 3 11:01:18 PST 2007
On Dec 3, 2007, at 10:54 AM, Johannes Luber wrote:
> Terence Parr wrote:
>> On Dec 3, 2007, at 5:05 AM, Johannes Luber wrote:
>>> It makes sense, but what about single deletion/insertion in
>>> normal mode?
>> Well, i've been thinking. I realize now that that mode is only of
>> academic interest. How can you execute actions without putting in
>> guards against all possible input syntax errors? That's what we
>> call a
>> parser. ;) So, upon error in a rule, you must execute no further
>> actions and immediately report error, recover, and return.
> I agree. Will you use then the Strategy pattern in your changed
> source code?
I don't know the strategy pattern (I don't really pay attention to
formal pattern names). can you be more specific?
I'm thinking about simply removing the single token insertion and
deletion and providing a faq entry that describes how to turn it back on
>>> How do we deal with an ERROR node in the next grammar? Or is then
>>> a way to emit an error message during the construction of the AST?
>> Well, presumably, you wouldn't pass the tree along to another
>> grammar...it is malformed.
> Better worded: How does this change affect the error recovery as
> described in the book?
Only where it talks about how it impressed it is with itself. ;) It
won't really affect anybody. I'm not convinced that it will actually
be worse at air recovery. It will probably actually reduce the
number of exceptions encountered upon syntax error.
More information about the antlr-interest