GATE CS 2026 Set 1 | Question 53

Compiler Design › Parser · MSQ · 2 marks · Answer: A, B, D

  1. Question 53Compiler Designmsq2 marks
    Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations.
    SDD1 grammar (G1) | Semantic rules
    ------------------+----------------------------------------
    D → T V           | D.type = T.type; V.type = T.type
    T → int           | T.type = int
    T → float         | T.type = float
    V → V₁ id         | V₁.type = V.type; put(id.entry, V.type)
    V → id            | put(id.entry, V.type)
    SDD2 grammar (G2) | Semantic rules
    ------------------+-----------------------------------------
    D → D₁ id         | D.type = D₁.type; put(id.entry, D₁.type)
    D → T id          | D.type = T.type; put(id.entry, T.type)
    T → int           | T.type = int
    T → float         | T.type = float
    is the start symbol, and int, float and id 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 put 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?
    • A.
      The languages P and Q are the same
      ✓
    • B.
      SDD2 is S-attributed and contains only synthesized attributes
      ✓
    • C.
      SDD1 is L-attributed and contains only inherited attributes
    • D.
      The specifications of SDD1 and SDD2 are such that the same entries get added to the symbol table
      ✓

    Answer: A, B, D

    Solution

    Answer: A, B, D • (A) True: both generate . • (B) True: in SDD2 every attribute (D.type, T.type) is computed from children, so it is S-attributed. • (C) False: SDD1 is L-attributed, but T.type is synthesized (and so is D.type), so it does not contain "only inherited" attributes. • (D) True: both call put once per id with the declared type.

More GATE PYQ on Parser

All GATE CS Compiler Design PYQ →

Attempt GATE CS 2026 Set 1 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →