How to find shift/reduce conflict in this yacc file?

后端 未结 5 684
时光说笑
时光说笑 2020-12-23 15:22

When I try to use yacc on the following file I get the error conflicts: 1 shift/reduce How can I find and fix the conflict?

/* C-Minus BNF Grammar */

%token         


        
5条回答
  •  醉酒成梦
    2020-12-23 15:40

    Ahem, the correct answer to this problem is usually: do nothing.

    Shift/reduce conflicts are expected with ambiguous grammars. They are not errors, they are conflicts.

    The conflict will be resolved by preferring shift over reduce, which just happens to solve the canonical dangling else problem.

    And bison even has an %expect n statement so that you don't get a S/R conflict warning when there are exactly n conflicts.

提交回复
热议问题