MSQ · 2 marks · Parsing

GATE CS 2025 CS-2 — Q51

Consider two grammars G1G_1 and G2G_2 with the production rules given below:

G1:S→if E then S∣if E then S else S∣aG_1: S \rightarrow \text{if } E \text{ then } S \mid \text{if } E \text{ then } S \text{ else } S \mid a
E→bE \rightarrow b

G2:S→if E then S∣MG_2: S \rightarrow \text{if } E \text{ then } S \mid M
M→if E then M else S∣cM \rightarrow \text{if } E \text{ then } M \text{ else } S \mid c
E→bE \rightarrow b

where if,then,else,a,b,c\text{if}, \text{then}, \text{else}, a, b, c are the terminals.

Which of the following option(s) is/are CORRECT?
Select all correct options