The GATE Grind

GATE 2026 CS (CS1) – Question 53

Compiler Design · Syntax-Directed Translation · 2 marks · Multiple select

Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations:

**SDD1**:
- $D \to T \, V \quad \{ D.type = T.type; \; V.type = T.type; \}$
- $T \to int \quad \{ T.type = int; \}$
- $T \to float \quad \{ T.type = float; \}$
- $V \to V_1 \, id \quad \{ V_1.type = V.type; \; put(id.entry, V.type); \}$
- $V \to id \quad \{ put(id.entry, V.type); \}$

**SDD2**:
- $D \to D_1 \, id \quad \{ D.type = D_1.type; \; put(id.entry, D_1.type); \}$
- $D \to T \, id \quad \{ D.type = T.type; \; put(id.entry, T.type); \}$
- $T \to int \quad \{ T.type = int; \}$
- $T \to float \quad \{ T.type = float; \}$

Let P and Q be the languages specified by grammars G1 and G2, respectively. Which of the following statements is/are true?

  1. The languages P and Q are the same
  2. SDD2 is S-attributed and contains only synthesized attributes
  3. SDD1 is L-attributed and contains only inherited attributes
  4. The specifications of SDD1 and SDD2 are such that the same entries get added to the symbol table

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (A) The languages P and Q are the same; (D) The specifications of SDD1 and SDD2 are such that the same entries get added to the symbol table

Explanation

Therefore, statements (A) and (D) are true.