List Info

Thread: Re: shift/reduce conflict with unary




Re: shift/reduce conflict with unary
country flaguser name
United Kingdom
2007-08-22 06:44:21
Actually, it turns out that the conflict is pretty obvious
even without 
the debug output. consider this input:

"5 6 +4"

How do you expect this to be scanned? Does it contain 3 
summation_expressions ("5", "6",
"+4") or 2 ("5", "6+4")?
There's an 
ambiguity - you haven't defined an expression list in an
unambiguuous way.

this is a very common problem - how do you define a list of
something 
complex? Can you define expression lists to require a
separator? How about

"5, 6, +4"  -> 3 expressions
"5, 6 +4"   -> 2 expressions



> Is
> it okay if I disregard the conflict if the grammar
works anyway?

I personally think that this is a mistake, but it is
commonly done. The 
problems are that you may not understand why there is a
conflict in the 
first place, and any subsequent maintainers certainly won't
understand; 
I prefer to try to remove the conflict.

Evan


_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

Re: shift/reduce conflict with unary
country flaguser name
United States
2007-08-22 07:11:06
But I'm not trying to list. I'm trying to do the add
operation. So the
expression "5 6 +4" wouldn't be valid. An example
of a valid operation would
be "+5 + -6 - -2" which should have an output of
1. My grammar file
currently outputs the correct result.

I agree with trying to remove the conflict but I'm putting
that on hold for
now since I can't think of how to remove it.

Thanks for trying to help.

Camille


Evan Lavelle-2 wrote:
> 
> Actually, it turns out that the conflict is pretty
obvious even without 
> the debug output. consider this input:
> 
> "5 6 +4"
> 
> How do you expect this to be scanned? Does it contain 3

> summation_expressions ("5", "6",
"+4") or 2 ("5", "6+4")?
There's an 
> ambiguity - you haven't defined an expression list in
an unambiguuous way.
> 
> this is a very common problem - how do you define a
list of something 
> complex? Can you define expression lists to require a
separator? How about
> 
> "5, 6, +4"  -> 3 expressions
> "5, 6 +4"   -> 2 expressions
> 
> 
> 
>> Is
>> it okay if I disregard the conflict if the grammar
works anyway?
> 
> I personally think that this is a mistake, but it is
commonly done. The 
> problems are that you may not understand why there is a
conflict in the 
> first place, and any subsequent maintainers certainly
won't understand; 
> I prefer to try to remove the conflict.
> 
> Evan
> 
> 
> _______________________________________________
> help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison
> 
> 

-- 
View this message in context: http://www.nabble.com/shift-reduc
e-conflict-with-unary-tf4303942.html#a12273299
Sent from the Gnu - Bison - Help mailing list archive at
Nabble.com.



_______________________________________________
help-bisongnu.org http
://lists.gnu.org/mailman/listinfo/help-bison

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )