2
我在SableCC和语法定义的第一次经历。 我有以下的语法(的一部分):转移/减少与SableCC的冲突
query =
{atop} attroperator |
{query_par} l_par query r_par |
{query_and} [q1]:query logic_and [q2]:query |
{query_or} [q1]:query logic_or [q2]:query |
{query_not} logic_not query ;
我有以下错误:
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)
}
我解决了他们加入l_par和r_par所有替代它,由 方式,应该增加可读性,但有没有办法以优雅的方式来做到这一点?
谢谢。