标记如何导致冲突?
为什么具有以下规则的语法会导致冲突?
Statement | IF {...} LP BoolExp RP %prec IFX Statement { ... }
| ...
IFX 终端用于解决悬空 else 的标准技巧。我认为这在某种程度上是相关的。 删除第一个标记即可消除冲突。
野牛输出的消息是:
警告:由于冲突,规则在解析器中无用:$@2: /* 空 */
Why does a grammar with the following rule result in a conflict?
Statement | IF {...} LP BoolExp RP %prec IFX Statement { ... }
| ...
The IFX terminal is for the standard trick for resolving dangling else. I think that this is somehow related.
Removing the first marking removes the conflict.
The message bison outputs is:
warning: rule useless in parser due to conflicts: $@2: /* empty */
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
(在评论中回答)
@sarnold 写道:
但是,SO 不赞成仅使用网络链接答案。所以我在这里总结一下。
该链接指向@Hans Aberg 题为“Shift 减少由于嵌入操作导致的错误”的回复列表。概括地说,它建议:
(Answered in the comments)
@sarnold wrote:
However SO deprecates web link only answers. So I summarise here.
The link is to a list reply entitled "Shift reduce errors due to embedded actions" by @Hans Aberg. In outline it suggests: