[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shift reduce conflict
Hi guys! I'm at my first experience with SableCC and grammar definition.
I have the following grammar (a part of it):
query =
{atop} attroperator |
{query_par} query |
{query_and} [q1]:query logic_and [q2]:query |
{query_or} [q1]:query logic_or [q2]:query |
{query_not} logic_not query ;
I have the following errors:
shift/reduce conflict in state [stack: PCommand TLogicNot PQuery *] on
TRPar in {
[ PQuery = PQuery * TRPar ] (shift),
[ PQuery = TLogicNot PQuery * ] followed by TRPar (reduce)
}
shift/reduce conflict in state [stack: PCommand TLogicNot PQuery *] on
TLogicAnd in {
[ PQuery = PQuery * TLogicAnd PQuery ] (shift),
[ PQuery = TLogicNot PQuery * ] followed by TLogicAnd (reduce)
}
shift/reduce conflict in state [stack: PCommand TLogicNot PQuery *] on
TLogicOr in {
[ PQuery = PQuery * TLogicOr PQuery ] (shift),
[ PQuery = TLogicNot PQuery * ] followed by TLogicOr (reduce)
}
I solved them adding l_par and r_par to all alternatives which, by the
way, should increase readability but is there a way to do it in an
elegant way?
Thanks.
Emanuele