|An Odd Grammar Question firstname.lastname@example.org (1998-05-15)|
|Re: An Odd Grammar Question email@example.com (Vadim Maslov) (1998-05-17)|
|Re: An Odd Grammar Question firstname.lastname@example.org (Joachim Durchholz) (1998-05-18)|
|Re: An Odd Grammar Question email@example.com (Chris Dodd) (1998-05-18)|
|Re: An Odd Grammar Question firstname.lastname@example.org (1998-05-23)|
|From:||email@example.com (John McEnerney)|
|Date:||23 May 1998 00:41:58 -0400|
|Keywords:||parse, yacc, comment|
Chris Dodd <firstname.lastname@example.org> 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 (email@example.com)
[I agree. You'll also be able to produce better error messages than
"syntax error". -John]
Return to the
Search the comp.compilers archives again.