GATE CSE 2019 Q46: Placeholders for inherited type attributes in a declaration grammar
- Compiler Design
- 2 marks
- MCQ
- −2/3 if wrong
Syllabus topic: Lexical analysis, parsing and syntax-directed translation
Question
Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let , and be the placeholders for the non-terminals D, T, L or in the following table:
| Production rule | Semantic action |
|---|---|
| .type = .type | |
| int | T.type = int |
| float | T.type = float |
| , id | .type = .type; addType(id.entry, .type) |
| id | addType(id.entry, .type) |
Which one of the following are the appropriate choices for and ?
Try it: multiple choice: exactly one correct option
Show answer and explanation
Answer: A (official GATE 2019 final answer key)
Concept used: An inherited attribute flows from a parent or left sibling to a child: the type computed at T is passed to L, and then from L down to in the list.
First step: In the type is known at T and must be handed to L; in decide which of L and already holds the type and which one receives it.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Lexical analysis, parsing and syntax-directed translation
Every PYQ on this topic →Share this question
Source: official GATE 2019 CS question paper and final answer key, organised by IIT Madras. 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 1 · Q53Compare two SDDs for type declarations
- 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