[Top][All Lists]
[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: |
Mon, 14 Jan 2002 18:41:19 +0100 |
At 08:07 -0500 2002/01/14, Anthony DeRobertis 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".
I thought "OR" was a terminal, and "expr" a nonterminal that may expand to
contain "OR" by the rule you listed as
expr -> expr OR expr
>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.
Which is causing the shift/reduce conflicts. Your answer gives me the
impression that you may not understand how a grammar works.
>> 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.
The question is really: How do you want the rules
expr -> expr OR expr
x -> ANSWER expr WITH expr OR expr
to be applied when the expression
ANSWER expr WITH expr OR expr OR expr OR expr
appears on top of the stack?
>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.
But you have not told us whether
answer "Hello" OR "world" with "Cancel" or "OK" or "Bye"
is legal.
> Yes, strings are expressions... On the
>other hand,
>
> answer "Hello, world" with ("True" or "False")
>
>would have one button.
So then you must have yet another rule you have not told us, either
x -> ANSWER expr WITH "(" expr ")"
x -> ANSWER expr WITH expr
>%prec on the appropriate rule, AFAICT, does this.
It looks as you have not yet found the correct grammar plugged in. So if it
was given, examine its source, or if it was altered before it came to you.
I can only give my hunch of what the grammar might be (leaving it to Akim
finding an efficient one):
Your "expr" is really expression without "OR" (zip out the expr -> expr OR
expr rule). Define:
expression_OR_list:
expression {...}
| expression_OR_list expression {...}
with the semantic value a list of expression values.
Then the rule should be
x -> ANSWER expression WITH expression_OR_list {...}
If you then have a rule
expression -> "(" expression ")" {...}
then the input
ANSWER expression WITH "(" expression OR expression ")"
will produce a single button with the expression
expression OR expression
Hans Aberg
- Re: How to change default outcome of shift/reduce conflict?, (continued)
- Re: How to change default outcome of shift/reduce conflict?, Anthony DeRobertis, 2002/01/12
- Re: How to change default outcome of shift/reduce conflict?, Akim Demaille, 2002/01/12
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/12
- Re: How to change default outcome of shift/reduce conflict?, Anthony DeRobertis, 2002/01/12
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/12
- Re: How to change default outcome of shift/reduce conflict?, Akim Demaille, 2002/01/13
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/13
- Re: How to change default outcome of shift/reduce conflict?, Anthony DeRobertis, 2002/01/14
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/14
- Re: How to change default outcome of shift/reduce conflict?, Anthony DeRobertis, 2002/01/14
- Re: How to change default outcome of shift/reduce conflict?,
Hans Aberg <=
- Re: How to change default outcome of shift/reduce conflict?, Anthony DeRobertis, 2002/01/15
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/15
- Re: How to change default outcome of shift/reduce conflict?, Anthony DeRobertis, 2002/01/15
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/15
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/15
- Re: How to change default outcome of shift/reduce conflict?, Anthony DeRobertis, 2002/01/16
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/16
- Re: How to change default outcome of shift/reduce conflict?, Akim Demaille, 2002/01/17
- Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/17
- Message not available
- Re: [FC-general] Re: How to change default outcome of shift/reduce conflict?, Hans Aberg, 2002/01/15