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: Anthony DeRobertis
Subject: Re: How to change default outcome of shift/reduce conflict?
Date: Mon, 14 Jan 2002 08:07:26 -0500

On Monday, January 14, 2002, at 07:30 AM, Hans Aberg wrote:

Specifically, in the rule
  x -> ANSWER expr WITH expr OR expr
is "OR" allowed in the "expr" of the "ANSWER expr WITH" part?

You have the rule wrong. That is a list of expressions, delimited by the word "or".

So, the intended parsing is that in the state derived from those rules, a reduce is to be performed on "or", not a shift. Which is, after reading the source, exactly what %prec on the rule does.


And, how do you want
  ANSWER expr WITH expr OR expr OR expr OR expr
to be interpreted? Possibilities:

ANSWER expr WITH (expr) OR (expr) OR (expr) OR (expr)

where, of course, expr above did not contain any non-parenthesis-enclosed ORs.

And the difference is very important. "answer" displays a dialogue box displaying the first expression (evaluated) giving the user the choice of clicking on any of the other expr's (evaluted). So, it is important that:

        answer "Hello, world" with "Cancel" or "OK"

becomes
        
        ANSWER expr WITH (expr) OR (expr)

which yields ywo buttons. Yes, strings are expressions... On the other hand,

        answer "Hello, world" with ("True" or "False")

would have one button.

%prec on the appropriate rule, AFAICT, does this.




reply via email to

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