ONLINE LEARNING

compiler design

It's all about self learning.

Learn Left Recursion

Learn Left recursion, Example of Left recursion
22 February, 2016     
A grammar is left recursive if it goes to infinite loop.
Eg: S-> (L) |a
        L->L,s|s
Eliminate the left recursion??
Ans: S->(L)|a
          L->sL'
           L'->,sL'| empty
Eg: S->A
       A->Ad| Ae | Af|aB|aC
       B->bBc|f
        C->cC|c
Eliminate the left recursion??
Ans: S->A
         A->aBA'|aCA'
          A->dA'|eA|fA'|empty
           B->bBC | f
            C->cC\c

Elimination of left recursion is important because sometime Top down parsing goes to infinite loop because of left reursion .
Left Recursive grammar will enter into the infinite loop for those parser which will uses left most derivation(TDP).

Get solution for your websites

logo