0

Given the following grammar:

1. S -> Sa
2. S -> bS
3. S -> c

As we see that this grammar is affected by left recursion and want to eliminate it from the grammar. so now want to know which solution should be correct after elimination.

Solution 1:

1. S -> cD
2. S -> bS
3. D -> aD
4. D -> epsilon

Solution 2:

1. S -> cD
2. S -> bSD
3. D -> aD
4. D -> epsilon

Dunno which one is correct but our professor is selecting the first solution based on the rule: A → A (alpha) | (beta) and i'm guessing that the second solution should be the correct

0 Answers0