1
    S->(L)|a
    L->L,S|S

    //Step 1

    i=1,j=1

    //do nothing



    //Step 2 

    //Substituting S in L production by productions of S
    i=2,j=1 to 1

    S->(L)|a
    L->L,(L)|(L)|L,a|a

    //removing left recursion

    S->(L)|a

    L->aA'|(L)A'             

    A'->,(L)A'|,aA'|epsilon

But indirect recursion still there in A' production

So how to remove this or am I doing something wrong

This is a question 4.3.1 from Compilers Principles Practice and Tools

AAB
  • 11
  • 1
  • After elimination of left recursion, in deriving a parse each top-down application of a grammar rule comes with the consumption of at least one input symbol (or the removal of one nonterminal in the current item when applying the epsilon rule). That guarantees termination of the process. Compare this with a left recursive grammar. Neither is the number of NTs reduced nor is an input symbol consumed when applying a left recursive rule - no termination. In your case, you're done i think - your grammar is devoid of indirect _left_ recursion (eg A->Bx, B->Ay). – collapsar Feb 14 '15 at 00:13

0 Answers0