GATE CS 2026 Set 1 — Question 53

Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.
MSQ+2 / -0MediumS- & L-Attributed GrammarsSemantic AnalysisCompiler DesignSyntax-Directed TranslationSymbol Tables

Compiler Design → Semantic Analysis → S- & L-Attributed Grammars

Last updated

Question

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?

SDD1

Grammar (G1)Semantic Rules
D → T VD.type=T.typeD.type = T.type
V.type=T.typeV.type = T.type
TintT \rightarrow intT.type=intT.type = int
TfloatT \rightarrow floatT.type=floatT.type = float
VV1,idV \rightarrow V_1, idV1.type=V.typeV_1.type = V.type
put(id.entry,V.type)put(id.entry, V.type)
VidV \rightarrow idput(id.entry,V.type)put(id.entry, V.type)

SDD2

Grammar (G2)Semantic Rules
DD1,idD \rightarrow D_1, idD.type=D1.typeD.type = D_1.type
put(id.entry,D1.type)put(id.entry, D_1.type)
DTidD \rightarrow T idD.type=T.typeD.type = T.type
put(id.entry,T.type)put(id.entry, T.type)
TintT \rightarrow intT.type=intT.type = int
TfloatT \rightarrow floatT.type=floatT.type = float
Your answer

Select all that apply, then check your answer.

The solution stays hidden until you check.

Continue learning with Success Tracker

A step still unclear? Work through it with support

Use Success Tracker to ask about the reasoning, then try another GATE CS question to check your understanding.

AI-powered practice· Unlimited practice on eligible plans
PYQs with solutions
Attempt available previous-year questions, then compare your reasoning with the worked solution. Coverage varies by stream.
Practice that adapts
Choose a topic, work on weaker areas and bookmark questions to revisit. Your attempts feed your progress tracking.
AI doubt support
Ask follow-up questions about a step or concept while practising, instead of stopping at the final answer.

Unlimited practice is available on eligible plans. Free practice and AI usage have limits; check the current plan allowances before choosing.

This page stays readable without an account. AI responses can be wrong; check them against the solution and source material.

More questions on Semantic Analysis