Consider the following expression grammar G: E &→ E - T T T &→ T + F F F &→ (E) id Which of the following grammars is not left recursive, but is equivalent to G?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2017 Set 2 · Q32
Time
Select one answerSingle correct
Solution
Official answer: C) E &→ TX X &→ -TX T &→ FY Y &→ +FY F &→ (E) id
ParsingTo eliminate immediate left recursion of the standard form:
where does not begin with , we replace the production rules with:
Applying this transformation to the non-terminals in grammar :
For : Here, and .
For : Here, and .
The non-terminal is not left-recursive and remains unchanged.
Combining these yields the grammar in option (C):
Distractor analysis:
(A) retains the original left-recursive rules for and .
(B) eliminates left recursion only from , but remains left-recursive.
(D) changes the language of the grammar entirely.
Thus, the correct option is (C).
Try the question first, then check your work.
Examiner trap
Apply the standard left-recursion elimination rule to both non-terminals and .
This Parsing previous year question is Q32 of the GATE CSE 2017 Set 2 paper. Find more GATE CSE PYQs on Parsing in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Parsing PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Parsing has 23 GATE CSE PYQs across 16 papers from 2012 to 2026. 11 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2017 Set 2.
How GATE tests ParsingIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.