GATE CS 2025 Set 2 | Question 51
Compiler Design › Parser · MSQ · 2 marks · Answer: C, D
- Question 51Compiler Designmsq2 marksConsider grammars and :
Which of the following option(s) is/are CORRECT?G1: S -> if E then S | if E then S else S | a E -> b G2: S -> if E then S | M M -> if E then M else S | c E -> b- A.is not LL(1) and is LL(1).
- B.is LL(1) and is not LL(1).
- C.and are not LL(1).✓
- D.and are ambiguous.✓
Answer: C, D
Solution
Answer: (C) and (D) (C) Neither grammar is LL(1). In the two -productions both begin withif, giving a FIRST/FIRST conflict. In both and also begin withif, so FIRSTFIRST — again not LL(1). (D) Both grammars exhibit the dangling-else construct and admit more than one parse tree for such inputs (per the official key), so both are ambiguous. - A.
More GATE PYQ on Parser
All GATE CS Compiler Design PYQ →Attempt GATE CS 2025 Set 2 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →