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

Re: shift/reduce conflict and grouping



Pieter van der Spek wrote:
In the grammar I'm currently working on I'm getting a shift/reduce
conflict that I cannot explain
...
I cannot see any significant differences. So why does my real grammar
result in a shift/reduce conflict ?

I would need the full expression grammar to see the root of this conflict, but it is most likely due to a small oversight in one of the expression related productions.

I also have another problem. How can I create productions that are
left/right grouping (not both at the same time) ?

Yes, you can. But...


You want to make sure your grammar abides by the following guidelines:
1- unary operators have the highest precedence
2- left and right associative operators do not have the
   same precedence.

The simple example above
is left grouping (if I'm not mistaken). However, the grammar I'm working
on has operators that are right grouping. How do I model that ?

right_assoc_exp = {somename} higher_precedence_exp the_operator right_assoc_exp | {anothername} higher_precedence_exp;

Have fun!

Etienne

--
Etienne M. Gagnon, Ph.D.             http://www.info.uqam.ca/~egagnon/
SableVM:                                       http://www.sablevm.org/
SableCC:                                       http://www.sablecc.org/