문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top