简体   繁体   中英

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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