GateAI
Syntax-Directed Translation

GATE CSE 2026 Set 1 · Q53

MSQ2 marksMedium

Time

Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations. 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?

GATE CSE 2026 Set 1 Q53 diagram

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: A) The languages P and Q are the same; B) SDD2 is S-attributed and contains only synthesized attributes; D) The specifications of SDD1 and SDD2 are such that the same entries get added to the symbol table

Syntax-Directed Translation

Let us analyze each statement based on the definitions:

  1. Language Equivalence (Option A):

    • Grammar G1G_1:

      D→T VD \to T\,V
      T→int∣floatT \to \text{int} \mid \text{float}
      V→V1 id∣idV \to V_1\,\text{id} \mid \text{id}

      Here, VV generates one or more identifiers, id+\text{id}^+. Thus, L(G1)=(int∣float) id+L(G_1) = (\text{int} \mid \text{float})\,\text{id}^+.

    • Grammar G2G_2:

      D→D1 id∣T idD \to D_1\,\text{id} \mid T\,\text{id}
      T→int∣floatT \to \text{int} \mid \text{float}

      Here, DD expands to T id id∗=(int∣float) id+T\,\text{id}\,\text{id}^* = (\text{int} \mid \text{float})\,\text{id}^+.

    • Since both grammars generate strings composed of a type specifier followed by one or more identifiers, the languages PP and QQ are identical. Hence, (A) is true.

  2. Attribute Classification of SDD2 (Option B):

    • In SDD2, the attributes evaluated are T.typeT.\text{type} (from terminals int/float\text{int}/\text{float}) and D.typeD.\text{type} (from child D1D_1 or child TT).

    • Since every attribute is synthesized from the children in the parse tree, SDD2 contains only synthesized attributes and is an S-attributed SDD. Hence, (B) is true.

  3. Attribute Classification of SDD1 (Option C):

    • In SDD1, D.typeD.\text{type} and T.typeT.\text{type} are synthesized attributes, while V.typeV.\text{type} is an inherited attribute (V.type=T.typeV.\text{type} = T.\text{type}).

    • SDD1 contains both synthesized and inherited attributes, so it does not contain *only* inherited attributes. Hence, (C) is false.

  4. Symbol Table Entries (Option D):

    • In SDD1, the type synthesized at TT is passed down via inherited attribute V.typeV.\text{type} to all identifiers, and put(id.entry, V.type) is invoked for each identifier.

    • In SDD2, the type is propagated up synthesized via D.typeD.\text{type}, and put(id.entry, D_1.type) or put(id.entry, T.type) is invoked for each identifier.

    • In both cases, each identifier declared in the statement is entered into the symbol table with its corresponding data type. Hence, (D) is true.

Thus, statements A, B, and D are correct.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Syntax-Directed Translation previous year question is Q53 of the GATE CSE 2026 Set 1 paper. Find more GATE CSE PYQs on Syntax-Directed Translation in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Syntax-Directed Translation PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Syntax-Directed Translation in GATE CSE

Syntax-Directed Translation has 9 GATE CSE PYQs across 9 papers from 2016 to 2026. This is the only 2-mark MSQ among them, and it is the only one in GATE CSE 2026 Set 1.

How GATE tests Syntax-Directed Translation

More from GATE CSE 2026 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2026 Set 1 · Q53 · MSQ

Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations. D is the start symbol, and int, float and id are the three terminals. The non-terminal V1 is the same as V and the non-terminal D1 is the same as D. 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?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.