The grammar is as follows:
E->a
E->E+E
E->S,E
E->(E)
S-> bS'
S'-> ;bS'
S'->
I have no idea how to remove the left recursion cause E contain terminals and non-terminals. And there're both left recursion and right recursion.
The grammar is as follows:
E->a
E->E+E
E->S,E
E->(E)
S-> bS'
S'-> ;bS'
S'->
I have no idea how to remove the left recursion cause E contain terminals and non-terminals. And there're both left recursion and right recursion.
First let me explain what left recursion is: Any grammar of the form
A → Aα1 | Aα2 |...|Aαn | β1 |β2|...|βn
is said to contain left recursion because the non terminal A appears on the left side of the production and as the first symbol on the right side of the production as well. Such a grammar can be converted to an equivalent form without left recursion by applying the following transformation:
A → β1A' | β2A' |...| βnA'
A' → α1A' | α2A' |...|αnA'
Putting your grammar in the same form, we get
E → E+E | a | S,E | (E)
S → bS'
S' → ;bS' | ε
We can see that left recursion occurs only in the case of the E productions, and that too only when the right side is E+E So we can make the following matchings here:
α is equivalent to +E
β1 is equivalent to a
β2 is equivalent to S,E
β3 is equivalent to (E)
Now we can directly substitute to get the following
E → aE' | S,EE' | (E)E'
E' → +EE' | ε
Note that the productions related to S and S' remain unchanged. This grammar has no left recursion.