GATE CSE Syntax-Directed Translation PYQs
Syntax-Directed Translation (SDT/SDD) in GATE CS is consistently tested through two primary angles: theoretical classification (identifying S-attributed vs. L-a… Read the guide
- Questions
- 9
- Asked
- since 2016
- Total marks
- 16
- Marks / paper
- 0.6
9 GATE CSE Syntax-Directed Translation PYQs with solutions, from Compiler Design. Browse all GATE CSE PYQs.
Questions
Every official paper that asked this topic, newest first.
- GATE CSE 2026 Set 1 · Q53Consider 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…MSQ2 marksMediumDiagramSolve
- GATE CSE 2025 Set 2 · Q22Given the following syntax directed translation rules: Rule 1: Rule 2: Rule 3: Which ONE is the CORRECT option among the following?MCQ1 markMediumSolve
- GATE CSE 2024 Set 1 · Q37Consider the following syntax-directed definition (SDD). Given "MMLK" as the input, which one of the following options is the CORRECT value computed by the SDD (in the attribute )?MCQ2 marksMediumDiagramSolve
- GATE CSE 2024 Set 2 · Q29Which of the following statements is/are FALSE?MSQ1 markMediumSolve
- GATE CSE 2023 · Q60Consider the syntax directed translation given by the following grammar and semantic rules. Here and are non-terminals. is the starting non-terminal, and , and are lexical tokens corresponding to input letters “#”, “0” and “1”, respectively. denotes…NAT2 marksMediumSolve
- GATE CSE 2022 · Q65Consider the following grammar along with translation rules. …NAT2 marksMediumSolve
- GATE CSE 2021 Set 1 · Q26Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code: …MCQ2 marksMediumSolve
- GATE CSE 2020 · Q33Consider the productions and . Each of the five non-terminals A, P, Q, X, and Y has two attributes: is a synthesized attribute, and is an inherited attribute. Consider the following rules. Rule 1: P. = A. + 2, Q. = P.…MCQ2 marksMediumSolve
- GATE CSE 2016 Set 1 · Q46Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals and terminals . Using the above…MCQ2 marksMediumSolve
What GATE tests in Syntax-Directed Translation
Concepts, patterns, formulas and traps distilled from past papers.
Syntax-Directed Translation (SDT/SDD) in GATE CS is consistently tested through two primary angles: theoretical classification (identifying S-attributed vs. L-attributed definitions and parser traversal compatibility) and concrete evaluation (tracing attribute evaluation or action execution for a given input string). Questions routinely evaluate precedence, associativity, base conversions (e.g., binary fractions), type checking, or parse-reduction action sequences.
Core concepts
- Synthesized vs. Inherited attributes
- S-attributed SDDs (purely synthesized, bottom-up evaluable during parsing)
- L-attributed SDDs (dependency on parent inherited attributes and left-sibling attributes)
- Bottom-up reduction order and semantic action firing
- Operator precedence and associativity encoded in recursive grammar structures
- Type synthesis and inherited type distribution across declaration lists into symbol tables
- Depth-first / Left-to-right evaluation traversals and dependency graphs
Recurring question patterns
Attribute Classification (S-attributed vs. L-attributed)
CommonMCQ1.5 marks2026, 2025, 2020Given a set of production rules paired with attribute assignment equations, determine whether each rule or the overall SDD is S-attributed, L-attributed, or neither based on attribute dependencies.
Input String Evaluation / Attribute Value Computation
CommonNAT2 marks2024, 2023, 2022Given an SDD defining synthesized (and optionally inherited) numerical or structural values, construct the parse tree for a specific input string and compute the final synthesized attribute at the root.
Side-Effect / Bottom-Up Parsing Action Sequence
OccasionalMCQ2 marks2016Given an SDTS with inline print statements or symbol table updates, trace the execution sequence triggered during shift-reduce parsing (post-order reductions) of an input token stream.
Semantic Analysis & Type Checking Correctness
OccasionalMSQ2 marks2026, 2021Evaluate multi-rule SDTs for language equivalence, type declarations, or semantic actions to identify logic bugs (e.g., missing symbol-table lookup vs. hardcoded types) or compare equivalent semantic schemes.
Theoretical SDD Properties & Traversal MSQ
OccasionalMSQ1 marks2024Multi-statement questions testing foundational definitions: evaluation order (depth-first/left-to-right), LR(1) bottom-up evaluation capabilities, and side effects in attribute grammars.
Formulas GATE uses
S-Attributed Definition Condition
for production
Used when verifying that an SDD contains only synthesized attributes computed exclusively from children nodes.
L-Attributed Dependency Rule
for production
Used when checking whether inherited attributes of an RHS symbol depend strictly on parent inherited attributes or attributes of symbols strictly to its left ().
Binary Fractional Synthesis Recurrence
Used during bottom-up synthesized evaluation of right-recursive fractional bit strings.
Examiner traps in Syntax-Directed Translation
- Right-to-left attribute dependency: Overlooking that an inherited attribute of an RHS symbol depends on an attribute from a symbol to its right (invalidating L-attributed property).
- Parent synthesized attribute misuse: Mistaking an inherited attribute dependent on parent's synthesized attribute as L-attributed.
- Left vs. Right recursion evaluation order: In computing numerical values, confusing left-recursive accumulation (e.g. integer building: 2 × I1.val + B.val) with right-recursive fraction accumulation (e.g. (B.val + F1.val)/2).
- Execution order of actions in bottom-up parsers: Forgetting that actions inside or at the end of productions execute strictly upon reduction, not upon shifting tokens.
- Bypassing symbol table lookup: Assuming an SDT correctly type-checks identifiers when base productions hardcode attributes rather than querying the symbol table.
How questions are asked
- Classify grammar rules as S-attributed, L-attributed, or neither
- Compute root attribute value (NAT) for a given arithmetic/binary token stream
- Trace print action output sequence during bottom-up parsing
- Identify true/false theoretical statements about SDDs and traversals (MSQ)
- Compare two translation schemes for language and symbol-table equivalence
Paper trends
Shift from pure single-answer bottom-up print tracing to deep attribute computations (custom arithmetic, fractional conversions) formatted as numerical answer type (NAT).
2023, 2022, 2016
Rise of multi-select questions (MSQ) testing conceptual nuance (e.g., L-attributed traversals, grammar equivalence, symbol table operations).
2026, 2024
Formalization of classification questions into multi-rule dependency checks assessing LHS-to-RHS and RHS-sibling dependency directions.
2025, 2020
Difficulty notes
Easy: Direct syntactic check of single-rule attribute dependencies (S vs. L-attributed). Medium: Tracing numerical value computations with operator precedence/associativity or fractional recursions; tracing reduction-action sequences. Hard: Multi-grammar comparisons evaluating symbol table side effects alongside formal attribute classifications in an MSQ format.