The GATE Grind

GATE Compiler Design: Syntax-Directed Translation – Previous Year Questions

10 GATE previous year questions on Syntax-Directed Translation (Compiler Design, Computer Science) with answers and explanations, from every paper.

  1. GATE 2016 CS Q56 (2 marks, Multiple choice) – Consider the following Syntax Directed Translation Scheme (SDTS), with non-terminals \S, A\ and terminals \a, b\. S aA print 1 S a print 2 A Sb print…
  2. GATE 2019 CS Q46 (2 marks, Multiple choice) – Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X 1, X 2, X 3, X 4, X 5, and X 6 be…
  3. GATE 2026 CS (CS1) Q53 (2 marks, Multiple select) – Consider the following two syntax-directed definitions SDD1 and SDD2 for type declarations: **SDD1**: - D T \, V \ D.type = T.type; \; V.type =…
  4. GATE 2025 CS (CS2) Q22 (1 mark, Multiple choice) – Given the following syntax directed translation rules: Rule 1: R AB\ \B.i = R.i - 1;\ A.i = B.i;\ R.i = A.i + 1;\ Rule 2: P CD\ \P.i = C.i + D.i;\ D.i…
  5. GATE 2024 CS (CS2) Q29 (1 mark, Multiple select) – Which of the following statements is/are FALSE?
  6. GATE 2024 CS (CS1) Q37 (2 marks, Multiple choice) – Consider the SDD: S→DHTU S.val=D.val+H.val+T.val+U.val; D→"M"D1 D.val=5+D1.val; D→ε D.val=−5; H→"L"H1 H.val=5*10+H1.val; H→ε H.val=−10; T→"C"T1…
  7. GATE 2023 CS Q60 (2 marks, Numerical answer) – Consider the syntax directed translation given by the following grammar and semantic rules. Here N, I, F and B are non-terminals. N is the starting…
  8. GATE 2022 CS Q65 (2 marks, Numerical answer) – Consider the following grammar along with translation rules. S S 1\ \#\ T\S.val=S 1.val * T.val\ S T\S.val=T.val\ T T 1\ \%\ R\T.val=T 1.val R.val\ T…
  9. GATE 2021 CS Q36 (2 marks, Multiple choice) – Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT)…
  10. GATE 2020 CS Q43 (2 marks, Multiple choice) – Consider the productions A → PQ and A → XY. Each of the five non-terminals A, P, Q, X, and Y has two attributes: s is a synthesized attribute, and i…