简体   繁体   English

将语法转换为LL1语法

[英]Turn grammar into LL1 Grammar

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. 我曾经看过用epsilion代替它,但是没有信心。

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. 我认为我需要先创建Foo'和Bar',然后再添加epsilon规则,但我不确定。

Could somebody please show me (simply)_how to change it to an LL(1) capable grammar 有人可以(简单地)告诉我_如何将其更改为支持LL(1)的语法

Thanks in advance 提前致谢

As i remember LL-1 grammar look ahead in 1 symbol. 我记得LL-1语法以1个符号向前看。 Your goal to eliminate ambiguity and left recursion. 您的目标是消除歧义和左递归。 All that you need - use left factorization. 您所需的全部-使用左分解。 Take a look this first. 看看这个第一。

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

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