将语法转换为 LL1 语法
我明天要复习考试,复习前几年的考试。
测试的是语法。
Expression -> Foo "+" Bar "end"
Foo -> [a-z0-9]+ | Expression
Bar -> Expression Foo | a*b*c+
我已经尝试并花了几个小时研究如何做到这一点,但无法弄清楚。
我已经考虑过用 epsilon 替换一些东西,但没有信心。
我认为我需要创建一个 Foo' 和一个 Bar',然后添加 epsilon 规则,但我不确定。
有人可以告诉我(简单地)_如何将其更改为 LL(1) 能力的语法
提前致谢
I am revising for an exam tomorrow, and going over a previous years one.
In the test was the grammar.
Expression -> Foo "+" Bar "end"
Foo -> [a-z0-9]+ | Expression
Bar -> Expression Foo | a*b*c+
I have tried and spent hours researching on how to do it, but can't figure it out.
I have had a look at replacing things with epsilion and that, but don't feel confident.
I think that I need to create a Foo' and a Bar' and then just add in the epsilon rules, but I am not sure.
Could somebody please show me (simply)_how to change it to an LL(1) capable grammar
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我记得 LL-1 语法以 1 个符号向前看。您的目标是消除歧义和左递归。您所需要的一切 - 使用左分解。首先看一下这个。
As i remember LL-1 grammar look ahead in 1 symbol. Your goal to eliminate ambiguity and left recursion. All that you need - use left factorization. Take a look this first.