952 views

1 Answer

2 votes
2 votes
Left recursion is eliminated by converting the grammar into a right recursive grammar.

Consider the grammar with left recursion: $A\rightarrow A\alpha/\beta$

Then we can eliminate left recursion by: $A\rightarrow\beta A’,A’\rightarrow\alpha A’/\epsilon$

Consider the given grammar:

$S\rightarrow Aa/B$

$A\rightarrow Ac/Aad/bd/\epsilon$

After removing the left recursion we get:

$S\rightarrow  Aa / B$

$A \rightarrow bdA' / A'$

$A' \rightarrow cA' / adA' / \epsilon$

Related questions

2 votes
2 votes
3 answers
1
0 votes
0 votes
1 answer
2
learner_geek asked Aug 5, 2017
1,301 views
To avoid left recursion can we do like this. I think this is incorrect way to do
2 votes
2 votes
1 answer
3
4 votes
4 votes
3 answers
4