Ex. Consider the following grammar G.
A → A + B|B
B → int|(A)
Which of the following grammar is equivalent to the above grammar G?
a. A -> int + B | B
B -> int | (A) | epsilon
b. A -> BA'
A' -> BA' | epsilon
B -> int | (+A)
c. A -> BA'
A' -> +BA' | epsilon
B -> int | (A)
d. None of these
Solution:
Its clear that we can remove left recursion first then our grammar g becomes,
A -> BA'
A' -> (A + B)A' | epsilon
B -> int | (A)
but the answer given is C so can anybody please tell me how A' -> (A + B)A' | epsilon becomes A' -> +BA' | epsilon ?