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) |
From: | itz@rahul.net (Ian T Zimmerman) |
Newsgroups: | comp.compilers |
Date: | 12 Oct 1996 22:10:41 -0400 |
Organization: | My own fan club |
References: | 96-10-011 |
Keywords: | yacc, errors |
kaz@nt.com writes:
> 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
http://www.cosc.canterbury.ac.nz/~bruce
Best luck,
--
Ian T Zimmerman <itz@rahul.net>
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.