Yacc error recovery...

3 Oct 1996 22:55:54 -0400

          From comp.compilers

Related articles
Yacc error recovery... kaz@nt.com (1996-10-03)
Re: Yacc error recovery... miano@worldnet.att.net (1996-10-06)
Re: Yacc error recovery... itz@rahul.net (1996-10-12)
Re: Yacc error recovery... creedy@mitretek.org (1996-10-24)
| List of all articles for this month |

From: kaz@nt.com
Newsgroups: comp.compilers
Date: 3 Oct 1996 22:55:54 -0400
Organization: Compilers Central
Keywords: yacc, errors, question

The normal way for a yacc-generated parser to recover using an ``error
production'' of the form A -> error b is to keep reading tokens until
a 'b' nonterminal is encountered, and then reduce by the production.

This is not very satisfactory, since at times it would be nice to either
insert tokens into the input stream, or even just have the input stream
read up to, but not including 'b'. For example, 'b' could be the non-terminal
'}', making it possible for the error recovery to read only until the end
of the enclosing scope in a C-like language.

Is there some yacc method for doing more flexible error recovery, preferrably
one that works across the various compatible parser generators?

I hate having a compiler fumble around after one parse error that could have
been easily recovered from.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.