Chapter 4:Syntax Analysis

Removal of left recursion due to many productions .

. After the first step (substitute S by its rhs in the rules) the grammar becomes

S Aa | b

A Ac | Aad | bd | ε

. After the second step (removal of left recursion) the grammar becomes

S Aa | b

A bdA' | A'

A' cA' | adA' | ε

After the first step (substitute S by its R.H.S. in the rules), the grammar becomes

S A a | b

A A c | A a d | b d | ε

After the second step (removal of left recursion from the modified grammar obtained after the first step), the grammar becomes

S A a | b

A b d A' | A'

A' c A' | a d A' | ε