Question
Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations.
| SDD1 Grammar (G1) | SDD1 Semantic Rules | SDD2 Grammar (G2) | SDD2 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 and be the languages specified by grammars G1 and G2, respectively.
Which of the following statements is/are true?
Official answer and solution
- Official answer
- A, B and D
- From
- Official GATE 2026 answer key
Solution
Check the languages generated by G1 and G2, classify the attributes in SDD1 and SDD2 as synthesized or inherited, and compare their symbol table updates.
- Option (A) is true: Both G1 and G2 generate the regular language (a type keyword followed by one or more identifiers).
- Option (B) is true: In SDD2, every attribute ( and ) is computed for the LHS non-terminal from attributes of its children on the RHS. Hence SDD2 contains only synthesized attributes and is S-attributed.
- Option (C) is false: Although SDD1 is L-attributed, it does not contain only inherited attributes: and are synthesized attributes (while is an inherited attribute).
- Option (D) is true: For any valid declaration string , both SDD1 and SDD2 invoke for every identifier , adding the exact same entries to the symbol table.
Options (A), (B), (D)
Selecting (C) without noticing that and in SDD1 are synthesized attributes.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 1 (CS1)
- Question
- 53 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.