Bison 规则18和令牌添加之间的冲突已解决为reduce(添加<;UMINUS)

Bison 规则18和令牌添加之间的冲突已解决为reduce(添加<;UMINUS),bison,yacc,lex,Bison,Yacc,Lex,我和野牛一起写语法分析。我定义了一些优先权规则,如: %right EQUAL %left OR AND %left ADD SUB %left MUL DIV MOD %nonassoc UMINUS 然后我会像这样使用它们: math : math ADD math {$$ = math_add($1,$3);} | math OR math {$$ = math_or($1,$3);} | math AND math {$$ = math_and($1,$3);} | math SUB

我和野牛一起写语法分析。我定义了一些优先权规则,如:

%right EQUAL
%left OR AND
%left ADD SUB
%left MUL DIV MOD
%nonassoc UMINUS
然后我会像这样使用它们:

math
: math ADD math {$$ = math_add($1,$3);}
| math OR math {$$ = math_or($1,$3);}
| math AND math {$$ = math_and($1,$3);}
| math SUB math {$$ = math_sub($1,$3);}
| math MUL math {$$ = math_mul($1,$3);}
| math DIV math {$$ = math_div($1,$3);}
| math MOD math {$$ = math_mod($1,$3);}
| SUB math %prec UMINUS {$$ = math_unary_uminus($2);}
| PARENTHESIS math CLOSE_PARENTHESIS {$$ = $2;}
| literal {$$ =$1;}
| reference {$$ = $1;}
运行时,将生成一个.output文件,其中包含一些冲突:

state 33 
11 math: math . ADD math
12     | math . OR math
13     | math . AND math
14     | math . SUB math
15     | math . MUL math
16     | math . DIV math
17     | math . MOD math
18     | SUB math .  [ADD, SUB, MUL, DIV, MOD, OR, AND, CLOSE_PARENTHESIS]

 $default  reduce using rule 18 (math)

 Conflict between rule 18 and token ADD resolved as reduce (ADD < UMINUS).
 Conflict between rule 18 and token SUB resolved as reduce (SUB < UMINUS).
 Conflict between rule 18 and token MUL resolved as reduce (MUL < UMINUS).
 Conflict between rule 18 and token DIV resolved as reduce (DIV < UMINUS).
 Conflict between rule 18 and token MOD resolved as reduce (MOD < UMINUS).
 Conflict between rule 18 and token OR resolved as reduce (OR < UMINUS).
 Conflict between rule 18 and token AND resolved as reduce (AND < UMINUS).
状态33
11数学:数学。加上数学
12 |数学。还是数学
13 |数学。还有数学
14 |数学。副数学
15 |数学。多数学
16 |数学。分区数学
17 |数学。现代数学
18 |次级数学。[添加、SUB、MUL、DIV、MOD或,并关闭括号]
$default使用规则18减少(数学)
规则18和令牌添加之间的冲突解决为reduce(ADD

我解决不了,请帮帮我

您大概使用
-r all
选项(或
--report=all
)运行了
bison
,该选项包括
已解决的
报告(“描述轮班/解决冲突解决”)。这就是它所做的:它描述了如何使用您提供的优先规则解决移位/解决冲突

换句话说,没有问题