Consider the following grammar S AB B BaAC c A Ca C b App
Consider the following grammar:
S AB
B BaAC | c
A Ca |
C b |
Apply left-recursion elimination to this grammar
Solution
We have left recursion in
B -> BaAC | c
This can be rewritten as:
B -> cB\'
B\' -> B\'aAC |
So the whole grammer wil be :
S -> AB
B -> cB\'
B\' -> B\'aAC |
A -> Ca |
C -> b |
