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. 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 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 V | |
| | |
SDD2
| Grammar (G2) | Semantic Rules |
|---|---|
| | |
| | |
Correct 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
Solution
1.Language Analysis:
- Grammar :
D → T V, . This generates a type followed by a comma-separated list of identifiers: . - Grammar : . This also generates a type followed by a comma-separated list of identifiers: .
- Thus, . Statement (A) is true.
- In SDD2, all attributes (, ) are synthesized. There are no inherited attributes. Therefore, SDD2 is S-attributed. Statement (B) is true.
- In SDD1, is an inherited attribute (passed from to and from to ). However, and are synthesized attributes. Since it contains both synthesized and inherited attributes, statement (C) is false because it claims it contains only inherited attributes.
- For any valid string like
int id1, id2, both SDDs will associate the typeintwith bothid1andid2and call theputfunction accordingly. Thus, the same entries are added to the symbol table. Statement (D) is true.
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
2026 Set 2 Q17In C runtime environment, which one of the following is stored in heap?2026 Set 2 Q19Consider the following three ANSI-C programs, P1, P2, and P3. P1 [code] P2 [code] **P3**…2026 Set 1 Q27Consider the following C statements: Which of the following options is/are correct? [figure]2026 Set 1 Q28Which of the following statements is/are true?2026 Set 2 Q35A lexical analyzer uses the following token definitions - - …