2

I am new here and I have just started the compiler construction course and I am just a beginner. So my question is about removing left recursion from the following grammar:
E → E + B | E - B | (E) | B
E → B / F | B * F | (B) | F
F → id
I know the rule for removing left recursion which is
IF A → Aα | β than
A → βA'
A'→ α A'| ε
And in the above grammar there is left recursion only in the first line. I am confused about (E) because I can’t figure out if (E) is β or not. I would appreciate if someone can remove the recursion and explain it.

Thank you

(UPDATE) So i tried to eliminate the left recursion according to my understanding as follows:

E → (E)E' | BE'
E' → +BE' | -BE' | ɛ
E → B / F | B * F | (B) | F
F → id
Is it OK or am i doing it wrong

Prince
  • 21
  • 3
  • There is no production for `B` in that grammar, making all the productions which reference it useless. I suspect that the second line should have `B` as its left-hand side instead of `E`, and I suggest you verify that before spending more time on the problem. (Also this homework question has been asked and answered many times, so it would be worth doing a search of the site.) – rici Dec 11 '16 at 19:06

0 Answers0