Related articles |
---|
An Odd Grammar Question wlm@panix3.panix.com (1998-05-15) |
Re: An Odd Grammar Question vadik@siber.com (Vadim Maslov) (1998-05-17) |
Re: An Odd Grammar Question joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-05-18) |
Re: An Odd Grammar Question chrisd@etcons.com (Chris Dodd) (1998-05-18) |
Re: An Odd Grammar Question johnmce@world.std.com (1998-05-23) |
From: | johnmce@world.std.com (John McEnerney) |
Newsgroups: | comp.compilers |
Date: | 23 May 1998 00:41:58 -0400 |
Organization: | Metrowerks, Inc. |
References: | 98-05-088 98-05-113 |
Keywords: | parse, yacc, comment |
Chris Dodd <chrisd@etcons.com> wrote:
> > I have the following odd Yacc problem. Assume that we have three kinds of
> > productions (key words are in caps):
> >
> > read -> READ some_stuff END-READ
> > if -> IF some-stuff END-IF
> > foo -> END-ALL FOO some-stuff END-FOO
> >
> > the problem is that the END-ALL terminates and replaces all of the other
> > ENDs one would expect.
I think the easiest solution is to define the READ/IF/etc -without- any
terminators, make END-READ, END-IF, and END-ALL top-level statements, and
use the semantic actions to match the ENDs or generate an error.
(There's no law that says syntax errors must detected by the parser, and
you can actually give a better error message this way)
This will avoid introducing any (additional) shift-reduce conflicts.
--
John McEnerney (mcenerney@metrowerks.com)
[I agree. You'll also be able to produce better error messages than
"syntax error". -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.