Build LL(1) parsing table for grammar S -> iSeS | iS | a Task


Bulid parsing table for grammar S -&gt; iSeS | iS | a
Resolve conflicts in this table and simulate parser work for word iiaea


Problem

I know how to make a parsing table for unambiguous grammar, and how to simulate parser. However this grammar is an example of dangling else problem.

What I tried

I was tought that I should remove left recursion and left factoring. Then make a table using first and follow. Whatever I tried I got two grammar expressions in the same row of table. Please provide me some hint what to do in this situation.



After left factorization

S -&gt;  iSS' |a
S'-&gt; e S | ε




Because we will never use S' -&gt;  ε (there are no other values which can give us e in the Table except Table[S'][e] ) we can remove this production from parsing table.

Final solution
Eventually you will end up with having to choose  between $S'\to\epsilon$ and $S'\to eS$.

The grammar says that's a conflict.  But can't we deduce which is correct? What if we choose $S\to\epsilon$? Will we ever be able to match the e?