简体   繁体   English

自下而上 SLR(1) 冲突 / 两者都适用时减少

[英]Bottom - Up SLR(1) Conflict / Reduce when both applies

If I have a situation where a state in the DFA have shift/reduce conflict, where both shift and reduce applies, let the next symbol be "t" and we have the following rules如果我的情况是 DFA 中的 state 存在移位/缩减冲突,移位和缩减都适用,让下一个符号为“t”,我们有以下规则

X -> F. X -> F。

Y -> F.tG Y -> F.tG

and t belongs the follow of X What should I do in this case?而t属于X的following这种情况下该怎么办呢? I know by definition that's not an SLR(1) Grammar but according to the algorithm shown https://imgur.com/a/yxy9L48 , what should the algorithm do?我知道根据定义这不是 SLR(1) 语法,但根据显示的算法https://imgur.com/a/yxy9L48 ,算法应该做什么? Should it report an Error?它应该报告错误吗?

The algorithm says we report an error if neither (shift or reduce) applies, but what happens if both apply?该算法说,如果两者都不适用(移位或减少),我们会报告错误,但如果两者都适用,会发生什么?

You should have detected this error when you attempted to construct the parser.当您尝试构建解析器时,您应该已经检测到此错误。 The SLR parser generation algorithm must fail if there is a conflict.如果存在冲突,SLR 解析器生成算法必须失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM