I am trying to remove left recursion from following grammar:
S -> id = E
S -> id [ E ] = E
E -> E [ E ]
E -> id
I tried to follow the left recursion removal algorithm that is presented at https://en.wikipedia.org/wiki/Left_recursion, but the E -> E [ E ]
line gives me problems, how should it be handled?
I do not want to get a complete solution to this, just some hints so I can actually learn how this works.
What I have tried so far is this:
E -> E [ E ]
E -> id
becomes:
E -> id E'
E' -> [ E ] E'
Which is incorrect. Am I even on the right track here ?