I have the following sample question for a compilers exam and wanted to check my solution.
Convert the following grammar into an LL(1) grammar which recognises the same
language:
E -> E + T
E -> T
T -> id
T -> id()
T -> id(L)
L -> E;L
L -> E
For my answer I have
E -> T E'
E' -> + T | ε
T -> id
T -> id()
T -> id(L)
L -> E L'
L' -> ;E | ε
Can anybody verify the answer?
Edit
Ok so would it be similar to…
E -> T E'
E' -> + E | ε
T -> id
T -> id()
T -> id(L)
L -> E L'
L' -> ;E | ε
Best Answer
E -> TE'
E'-> +TE' | ε
L -> EL'
L'-> ;L | ε
you need to transform T as I did with L otherwise it will be an LL(3)