How to eliminate left recursion for the next grammar?
E := EE+|EE-|id
Using the general procedure:
A := Aa|b
translates to:
A := b|A'
A' := ϵ| Aa
Applying this to the original grammar, we get:
A = E, a = (E+|E-) and b = id
Thus:
E := id|E'
E' := ϵ|E(E+|E-)
But this grammar seems wrong because
ϵE+ -> ϵ id +
will be valid but this is an incorrect postfix expression.
source
share