GateAI

GATE CSE Syntax-Directed Translation PYQs

Standard yield11.9% of Compiler Design

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.

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, 2020

    Given 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, 2022

    Given 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 marks2016

    Given 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, 2021

    Evaluate 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 marks2024

    Multi-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

A.s=f(X1.a,X2.a,…,Xn.a)A.s = f(X_1.a, X_2.a, \dots, X_n.a) for production A→X1X2…XnA \to X_1 X_2 \dots X_n

Used when verifying that an SDD contains only synthesized attributes computed exclusively from children nodes.

L-Attributed Dependency Rule

Xj.i=f(A.i,X1.a,X2.a,…,Xj−1.a)X_j.i = f(A.i, X_1.a, X_2.a, \dots, X_{j-1}.a) for production A→X1X2…XnA \to X_1 X_2 \dots X_n

Used when checking whether inherited attributes of an RHS symbol XjX_j depend strictly on parent inherited attributes or attributes of symbols strictly to its left (X1…Xj−1X_1 \dots X_{j-1}).

Binary Fractional Synthesis Recurrence

F.val=12(B.val+F1.val)F.val = \frac{1}{2}(B.val + F_1.val)

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.