edited by
9,078 views
10 votes
10 votes
$\textbf{Eliminating indirect left-recursion}$

Indirect left-recursion

$S\rightarrow Aa|b$

$A\rightarrow Ac| Sd |\in$
edited by

2 Answers

Best answer
12 votes
12 votes
First find the paths where indirect recursion happens. Here indirect recursion A→Sd happening in this production.

Then put all the production of S in that variable.You get $\large A\rightarrow Ac| Aad | bd |\epsilon$

Then do the normal procedure as we remove direct left  recursion.

$S\rightarrow Aa|b$

$A\rightarrow bdA' | A'$

$A'\rightarrow cA' | adA' | \epsilon$
selected by
6 votes
6 votes
S⟶Aa | b

S⟶Sda | Aca | a | b

Removing left recursion

S⟶ bS' | aS' | AcaS'

S'⟶ daS' |∊

 

A⟶Ac | Sd | ∊

A⟶Ac | Aad | bd | ∈

A⟶bdA'

A'⟶ cA' | adA' |∊

Related questions

2 votes
2 votes
1 answer
1
shekhar chauhan asked May 31, 2016
997 views
J - Lx K - Ly L - J | K | fWhoever Answers Please Explain Methods solving such Questions .
2 votes
2 votes
1 answer
2
shekhar chauhan asked Jun 4, 2016
665 views
A >AA+/AA*/ais it eligible to be used by SR parse.If we apply SR parse on this grammar then what will be the order of activation Record in Stack
2 votes
2 votes
3 answers
3