Skip to content
GATEiit

GATE CSE 2026 Session 1 Q53: Compare two SDDs for type declarations

Question

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

SDD1
Grammar (G1)Semantic Rules
D→T VD \to T\ VD.type=T.typeD.type = T.type; V.type=T.typeV.type = T.type
T→intT \to intT.type=intT.type = int
T→floatT \to floatT.type=floatT.type = float
V→V1 idV \to V_1\ idV1.type=V.typeV_1.type = V.type; put(id.entry,V.type)put(id.entry, V.type)
V→idV \to idput(id.entry,V.type)put(id.entry, V.type)
SDD2
Grammar (G2)Semantic Rules
D→D1 idD \to D_1\ idD.type=D1.typeD.type = D_1.type; put(id.entry,D1.type)put(id.entry, D_1.type)
D→T idD \to T\ idD.type=T.typeD.type = T.type; put(id.entry,T.type)put(id.entry, T.type)
T→intT \to intT.type=intT.type = int
T→floatT \to floatT.type=floatT.type = float

DD is the start symbol, and intint, floatfloat and idid are the three terminals. The non-terminal V1V_1 is the same as VV and the non-terminal D1D_1 is the same as DD. Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function putput updates the symbol table with the type information for an identifier.

Let P and Q be the languages specified by grammars G1 and G2, respectively.

Which of the following statements is/are true?

Try it: multiple select: one or more correct options

Select one or more options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation

Answer: A, B, D (official GATE 2026 final answer key)

Concept used: Synthesized attributes flow up from children; inherited ones flow down or across from parent and left siblings.

First step: Both grammars generate a type keyword followed by one or more ids; in SDD1, T.type and D.type are synthesized while V.type is inherited.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2026 Session 1 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key