help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to change default outcome of shift/reduce conflict?


From: Hans Aberg
Subject: Re: How to change default outcome of shift/reduce conflict?
Date: Tue, 15 Jan 2002 15:27:04 +0100

At 06:27 -0500 2002/01/15, Anthony DeRobertis wrote:
>But that's not the full story. I've posted it before,
>but here it is again:

You wrote before:

>I'm doing a grammar for HyperTalk in bison, which has a command that looks
>takes a list of expressions, seperated by "or". An expression, however, can
>contain "or" (it's an operator). The language isn't spec'd by me, so I don't
>have the liberty of changing it.

Do you understand you right, that you have not the actual HyperTalk grammar
given, but try to fix it up, to your perception of the match the HyperTalk
language?

>answer_statement: ANSWER expr answer_btn_list
>                 ...

>answer_btn_list: WITH answer_btn_list_oneplus
>              | /* empty */

>answer_btn_list_oneplus: answer_btn_list_oneplus OR expr
>                      | expr   %prec PSEUDO_MAX

>expr contains a lot of things, expr OR expr is one of them.

This is what looks wrong to me: That both answer_btn_list_oneplus and expr
contains OR. If the grammar was not given that way, I think that you may
remove it from expr, adding instead perhaps
  expr -> "(" answer_btn_list_oneplus ")"

The second point is that in order to avoid parsing conflicts in
answer_statement, it should normally have a terminator:
  answer_statement -> ANSWER expr answer_btn_list "."
This "." may actually be given implicitly in your language, by a newline,
or writing in the statement into a box, or something.

  Hans Aberg





reply via email to

[Prev in Thread] Current Thread [Next in Thread]