GATE CSE 2026 Session 1 Q53: Compare two SDDs for type declarations
- Compiler Design
- 2 marks
- MSQ
- No negative marking
Question
Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations.
| Grammar (G1) | Semantic Rules |
|---|---|
| ; | |
| ; | |
| Grammar (G2) | Semantic Rules |
|---|---|
| ; | |
| ; | |
is the start symbol, and , and are the three terminals. The non-terminal is the same as and the non-terminal is the same as . Here, the subscript is used to differentiate the grammar symbols on the two sides of a production. The function 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
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
Source: official GATE 2026 Session 1 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Compiler Design PYQs
- 2026 Session 1 · Q27Classify errors in three C string declarations
- 2026 Session 1 · Q28True statements about LL(1) parsing
- 2026 Session 1 · Q42Redundant (common) subexpressions in blocks B4 and B5 of a CFG
- 2026 Session 2 · Q35Count tokens produced by a lexer for a given string
- 2026 Session 2 · Q41Shift-reduce conflicts in the LR(0) table of a grammar
- 2026 Session 2 · Q45Live variables at the exit of each block in a loop CFG