需要一些 Earley 算法的解释
如果有人能为我澄清 ono wikipedia 提到的例子:
http://en.wikipedia。 org/wiki/Earley_algorithm
考虑语法:
P → S # the start rule
S → S + M | M
M → M * T | T
T → number
和输入:
2 + 3 * 4
Earley 算法的工作原理如下:
(state no.) Production (Origin) # Comment
---------------------------------
== S(0): • 2 + 3 * 4 ==
(1) P → • S (0) # start rule
(2) S → • S + M (0) # predict from (1)
(3) S → • M (0) # predict from (1)
(4) M → • M * T (0) # predict from (3)
这只是第一组 S(0) 但我的问题是: 为什么算法在步骤 (4) 中根据 (3) 进行预测 但它忽略了(2)的预测?
我希望有人理解这个想法并可以帮助我
I would be very glad if someone can make clear for me example mentioned ono wikipedia:
http://en.wikipedia.org/wiki/Earley_algorithm
consider grammar:
P → S # the start rule
S → S + M | M
M → M * T | T
T → number
and input:
2 + 3 * 4
Earley algorithm works like this:
(state no.) Production (Origin) # Comment
---------------------------------
== S(0): • 2 + 3 * 4 ==
(1) P → • S (0) # start rule
(2) S → • S + M (0) # predict from (1)
(3) S → • M (0) # predict from (1)
(4) M → • M * T (0) # predict from (3)
this is only first set S(0) but my question is:
why algorithm is predicting from (3) in step (4)
but it ommits prediction from (2)?
I hope somebody understands idea and may help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用(2)进行预测不会产生新的产生式,因为点旁边的符号是S。因此,只会再次得到产生式(2)和(3),这不会添加信息。
Using (2) for prediction will not create new productions, because the symbol next to the dot is S. Therefore, will would only get the productions (2) and (3) again, which do not add information.