Compiler Design: notes and questions
For CSE/IT students
Notes for each topic, a formula sheet, practice questions and 36 past GATE questions from 10 papers (2018–2026), 35 of them solved step by step.
- previous-year questions
- 36previous-year questions
- solved step by step
- 35solved step by step
- GATE papers, 2018–2026
- 10GATE papers, 2018–2026
- topics with notes
- 6topics with notes
Foundation
Learn the subject one topic at a time. Each topic has notes, the key formulas and practice questions.
Topic notes and formulas
Notes on every topic, with the key formulas and practice.
Compiler phases and lexical analysis
A compiler translates source code in phases, and the first phase, lexical analysis, turns characters into tokens.
5 practice questions
Parsing: top-down and bottom-up parsers
Parsing turns a stream of tokens into a parse tree by following a context-free grammar, either top-down (LL, building a leftmost derivation) or bottom-up (LR, building a rightmost derivation in reverse).
5 practice questions
Syntax-directed translation
Syntax-directed translation attaches attributes and semantic rules (or embedded actions) to grammar productions so that a parser can compute values, build syntax trees, check types and emit code while it recognises the input.
5 practice questions
Runtime environments: activation records and storage allocation
Runtime environments describe how a compiled program is laid out in memory while it runs: where code, static data, the stack and the heap live, what an activation record holds, and how a procedure finds its parameters, locals and non-local names.
5 practice questions
Intermediate code generation
Intermediate code is the machine-independent form that sits between the front end and the back end of a compiler.
5 practice questions
Local optimisation and data-flow analysis
Local optimisation improves code inside a basic block (common subexpressions via a DAG, constant folding, copy propagation, dead-code removal, peephole clean-ups), while data-flow analysis computes facts such as live variables, reaching definitions, available expressions and constants across the whole control-flow graph by solving equations to a fixed point.
6 practice questions
Compiler Design formulas by topic
GATE
Past GATE questions on Compiler Design by topic and year, the full papers, practice and the GATE syllabus.
36 questions, by topic and year
How many questions each topic had in the CS papers of each year. This shows what was asked, not what will be asked. We placed each question under a topic ourselves; the exam paper does not label topics.
| Topic | 2018 | 2020 | 2022 | 2023 | 2024 | 2025 | 2026 | Total |
|---|---|---|---|---|---|---|---|---|
| Lexical analysis | 2 | 1 | · | 1 | 1 | 1 | 2 | 8 |
| Parsing | 1 | 1 | 2 | · | 4 | 3 | 2 | 13 |
| Syntax-directed translation | · | 1 | 1 | 1 | 2 | 1 | 1 | 7 |
| Runtime environments | · | · | · | · | · | · | · | 0 |
| Intermediate code | · | · | · | · | 1 | 1 | · | 2 |
| Optimisation | · | · | · | 1 | 1 | 2 | 2 | 6 |
Solved papers
GATE CSE question papers with solutions: 2026 Set 1, 2026 Set 2, 2025 Set 1, 2025 Set 2, 2024 Set 1, 2024 Set 2, 2023, 2022, 2020, 2018
GATE 2023 comes from IIT Kanpur's own copy of the paper and its answer key, which numbers the CS questions Q.11 to Q.65. For 2024, 2025 and 2026 both sessions (CS1 and CS2) are included.
31 practice questions
The GATE syllabus for Compiler Design, paper by paper
From the GATE 2027 syllabus PDF: CS Section 7, “Compiler Design”. Context-free grammars as languages, and push-down automata, are on the Theory of Computation page.
Show the GATE CS wordingHide the GATE CS wording
Lexical analysis, parsing, syntax-directed translation. Runtime environments. Intermediate code generation. Local optimisation, Data flow analyses: constant propagation, liveness analysis, common sub expression elimination.
Preparing in Kolkata? See IAE Academy’s GATE CS coaching.
Other exams
5 questions on Compiler Design from ISRO's Scientist/Engineer written test (ISRO CS 2025, ISRO CS 2023), by topic. They are not counted in the GATE numbers on this page.
IF YOU WOULD RATHER TALK IT THROUGH