Eliminating Indirect Left-Recursion
1. Arrange the nonterminals in some order A1,...,An.
A nonterminal Ai is satisfactory if it is defined in terms of
terminals and nonterminals in Ai,Ai+1,...,An.
2. Select a production Ai ::= Ajg for which j<i and
and Aj is a satisfactory nonterminal defined by
replace the production for Ai with
Ai ::= d1g | d2g |... | dkg
3. Repeat 2 until all nonterminals are satisfactory