Compiler construction 野牛-2转移/减少冲突
我已经盯着我的代码看了一段时间了,我不知道如何解决这个问题。我已使用调试器查找问题,但我不理解错误Compiler construction 野牛-2转移/减少冲突,compiler-construction,conflict,bison,yacc,Compiler Construction,Conflict,Bison,Yacc,我已经盯着我的代码看了一段时间了,我不知道如何解决这个问题。我已使用调试器查找问题,但我不理解错误 number_constant : integer | SUBTRACT integer | SUBTRACT integer PERIOD integer | integer PERIOD integer ; digit : IN
number_constant : integer
| SUBTRACT integer
| SUBTRACT integer PERIOD integer
| integer PERIOD integer
;
digit : INTEGER
;
integer : digit
| integer digit
;
这些是输出告诉我冲突是什么的两种状态
state 38
36 number_constant: integer .
40 decimal_constant: integer . PERIOD integer
46 integer: integer . digit
INTEGER shift, and go to state 6
PERIOD shift, and go to state 55
PERIOD [reduce using rule 36 (number_constant)]
$default reduce using rule 36 (number_constant)
digit go to state 56
------------------
state 46
37 number_constant: SUBTRACT integer .
39 decimal_constant: SUBTRACT integer . PERIOD integer
46 integer: integer . digit
INTEGER shift, and go to state 6
PERIOD shift, and go to state 65
PERIOD [reduce using rule 37 (number_constant)]
$default reduce using rule 37 (number_constant)
digit go to state 56
全部输出:
提前感谢您的语法包括
27 term: value
28 | value PERIOD term
29 | value DIVIDE term
值
可以是整数
,项
可以是值
,因此整周期整数
可以是十进制常量
或项
唯一可能的解决办法是消除歧义。
23.4
应该是什么意思?在我看来,你在做我的编译器课程。在我看来,当你可以更快地直接获得它的时候,到课堂/实验室来向我寻求帮助比向stackoverflow寻求帮助更好
实际问题,我相信你现在已经发现了;由于您的作业已经交上来,一些工作是在flex中的lexer中完成的,一些工作是在bison中的解析器中完成的。flex中的令牌整数包含所有数字,bison中不应该有关于数字序列的规则。
期间可以移动或减少,bison不知道选择哪一个,请阅读有关LR解析器的信息。