4

I have an assignment to correct an ambiguous BNF, but I am completely lost. I know this not a true programming question, and I will gladly delete it if it is not an appropriate question for these boards. Are there any good sites where I could learn more about BNF's? The one I am dealing with seems rather simple, but I can't find any examples or good explanations regarding BNF's. I have had some experience spotting ambiguous parse trees and other sorts of grammars, but I am completely lost on this one.

Since it is a school assignment, I am not sure I should post the BNF in question, but if anyone knows of a good site that I could look over to perhaps gain a better understanding of how to attack my question. I really just don't know where to start.

4

2 回答 2

1

一些描述上下文无关文法的 BNF 也描述了状态机(在本例中为下推自动机)。最好的方法可能是检查状态机。

作为起点,您可以查看使用此类 automata 的解析器中冲突

于 2010-09-14T00:39:21.387 回答
0

如果句子右侧有两个或多个相同的非终结符,则它是模棱两可的。例如:<expr> -> <expr> + <expr> | <事实>。右边的expr在树中可以用不同的方式导出,所以可以画出不同的树,而且是模棱两可的。

于 2012-03-31T09:00:39.040 回答