|Yacc error recovery... email@example.com (1996-10-03)|
|Re: Yacc error recovery... firstname.lastname@example.org (1996-10-06)|
|Re: Yacc error recovery... email@example.com (1996-10-12)|
|Re: Yacc error recovery... firstname.lastname@example.org (1996-10-24)|
|From:||email@example.com (Ian T Zimmerman)|
|Date:||12 Oct 1996 22:10:41 -0400|
|Organization:||My own fan club|
> 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.
While I understand the general direction of your article, I don't
think yours is a good example. '}' is a terminal; there is probably
some nonterminal for `scope' in the grammar (if there isn't, there
should be) and this can be used as `A' in the error production. The
`b' terminal in the production is optional, it merely restricts the
contexts where the error recovery procedure is acceptable.
> Is there some yacc method for doing more flexible error recovery, preferrably
> one that works across the various compatible parser generators?
TOPLAS vol.17 No.4 (July 95) pp. 672 and forward describes adding a
fully automated error method to Bison. The article together with
relevant source code are available on
Ian T Zimmerman <firstname.lastname@example.org>
Return to the
Search the comp.compilers archives again.