Compiler Design is the smallest technical subject in GATE CS, at about 6 marks per paper, or roughly 5.8% of the 100-mark paper. It is also the fastest-growing subject by our count. We counted every compiler question in all 23 official GATE CS papers from 2014 to 2026. Compiler Design averaged 5.8 marks, ranged from 3 to 8, and rose from 5.1 marks per paper before 2021 to 6.8 after. Parsing is the biggest topic, while syntax-directed translation and data-flow optimisation have grown the most. Questions are mostly MCQs, and only 8 of 88 are rated hard. This guide covers the official 2027 syllabus, topic-by-topic numbers, five worked questions from past papers and a study order.
How we counted: we classified all 1,495 GATE CS questions from 2014 to 2026 by subject and topic, using the official papers as reproduced on Success Tracker's GATE CS PYQ archive. A 2015 question on the COCOMO effort model is software engineering, which is no longer in the syllabus, so it is excluded. A few questions appear twice in the 2015 papers on that archive, and we counted each of those only once. Confirm the syllabus on the official GATE 2027 syllabus page (IIT Madras).
GATE CS 2027 Compiler Design Syllabus
Compiler Design is Section 7 of the official GATE 2027 CS syllabus. The official text lists:
- Lexical analysis, parsing, syntax-directed translation
- Runtime environments
- Intermediate code generation
- Local optimisation
- Data flow analyses: constant propagation, liveness analysis, common sub-expression elimination
This is identical to the GATE 2026 CS syllabus. Global and loop optimisations beyond the named data-flow analyses, register allocation by graph colouring, and target code generation are not listed. For the full CS syllabus, see our GATE CS syllabus page.
How Many Marks Does Compiler Design Carry in GATE CS?
The official question paper pattern fixes marks only for General Aptitude (15) and Engineering Mathematics (13). This is what Compiler Design carried in each paper:
| Year | Marks per paper (set-wise) | % of the 100-mark paper | Questions |
|---|---|---|---|
| 2014 | 3 / 4 / 4 | 3% / 4% / 4% | 2 / 3 / 3 |
| 2015 | 8 / 4 / 5 | 8% / 4% / 5% | 5 / 3 / 3 |
| 2016 | 7 / 5 | 7% / 5% | 4 / 3 |
| 2017 | 6 / 4 | 6% / 4% | 4 / 3 |
| 2018 | 5 | 5% | 3 |
| 2019 | 6 | 6% | 4 |
| 2020 | 5 | 5% | 4 |
| 2021 | 8 / 8 | 8% / 8% | 5 / 5 |
| 2022 | 4 | 4% | 3 |
| 2023 | 8 | 8% | 5 |
| 2024 | 7 / 8 | 7% / 8% | 4 / 5 |
| 2025 | 6 / 6 | 6% / 6% | 4 / 4 |
| 2026 | 6 / 7 | 6% / 7% | 4 / 5 |
| Average (23 papers) | 5.8 | 5.8% (range 3–8%) | 3.8 |
What this means: Compiler Design used to be easy to deprioritise. In 2014 it carried just 3 or 4 marks. From 2023 onwards, though, it has carried 6 to 8 marks in every paper. With a short syllabus and repetitive question types, it now gives one of the best returns on study time in the paper. For how it compares with other subjects, see our GATE CSE subject-wise weightage analysis.
Topic-Wise Weightage: Where Compiler Design Marks Come From
We grouped the 88 Compiler Design questions by syllabus heading, with the average marks per paper across all 23 papers:
| Topic | Questions | Total marks | Avg marks per paper (23 papers) | Last asked |
|---|---|---|---|---|
| Parsing (FIRST/FOLLOW, LL(1), LR, ambiguity) | 31 | 48 | 2.1 | 2026 |
| Local optimisation and data-flow analysis | 21 | 35 | 1.5 | 2026 |
| Syntax-directed translation | 12 | 20 | 0.9 | 2026 |
| Intermediate code generation | 9 | 13 | 0.6 | 2025 |
| Runtime environments | 8 | 10 | 0.4 | 2026 |
| Lexical analysis | 5 | 6 | 0.3 | 2026 |
| Compiler phases (general) | 2 | 2 | 0.1 | 2023 |
Looking at individual topics, the most-asked across all 23 papers were basic blocks and control flow graphs (11 questions, 20 marks), LR(0) and SLR(1) parsing (6 questions, 10 marks), syntax-directed translation (5 questions, 10 marks) and FIRST and FOLLOW sets (5 questions, 8 marks).
Three patterns stand out:
- Parsing is about a third of the subject. At about 2 marks per paper, expect one LR or LL question every paper, usually counting conflicts or items, or testing which grammar class something belongs to.
- Syntax-directed translation has nearly tripled. It went from 0.5 to 1.4 marks per paper. Questions ask whether a definition is S-attributed or L-attributed, or what an SDT computes for a given input.
- Data-flow analysis is growing. Optimisation went from 1.3 to 1.8 marks per paper. Counting basic blocks and finding live variables on a control flow graph are the most common forms.
Question Types in Compiler Design
From 2021 to 2026, the 44 Compiler Design questions split into 28 MCQs, 8 MSQs and 8 NATs, carrying 43, 11 and 14 marks respectively. MCQs carried 63% of the marks, the highest MCQ share of any technical subject, so negative marking matters here. A wrong 1-mark MCQ costs 1/3 mark and a wrong 2-mark MCQ costs 2/3 mark (official marking rules). Success Tracker rates 28 Compiler Design questions as easy, 52 as medium and only 8 as hard.
Topic by Topic: What GATE Asks and How to Prepare
1. Parsing
What gets asked: FIRST and FOLLOW sets, building LL(1) tables, LR(0) and SLR(1) item sets with conflict counts, how the parser classes relate (SLR(1) ⊂ LALR(1) ⊂ CLR(1), and every LL(1) grammar is also LR(1)), ambiguity, and removing left recursion.
How to prepare: build the canonical LR(0) collection by hand for at least ten grammars. Every ε-production creates a "reduce on all terminals" item in LR(0), and that is where conflicts appear (worked example 1). Remember that a left-recursive or non-left-factored grammar cannot be LL(1), and that every SLR(1) grammar is unambiguous.
Recent PYQs: LL(1) facts (2026, MSQ), LR parsing of a CFG (2025), FIRST and FOLLOW rules (2025, MSQ).
2. Local Optimisation and Data-Flow Analysis
What gets asked: the number of basic blocks (using leaders), live variables at a point in a control flow graph, constant propagation, common sub-expression elimination, and which analysis is forward or backward.
How to prepare: learn the leader rule. A leader is the first instruction, any jump target, or the instruction right after a jump. For liveness, work backwards: in[B] = use[B] ∪ (out[B] − def[B]). Constant propagation and available expressions work forwards.
Recent PYQs: control flow graph (2026), liveness on a CFG (2026), counting basic blocks (2025, NAT).
3. Syntax-Directed Translation
What gets asked: whether rules are S-attributed or L-attributed, evaluating an SDT on an input string, and annotated parse trees.
How to prepare: an SDD is S-attributed if it uses only synthesised attributes. It is L-attributed if each inherited attribute of a child depends only on the parent's inherited attributes and on siblings to its left. Every S-attributed definition is also L-attributed. For evaluation questions, draw the parse tree and compute bottom-up.
Recent PYQs: two SDDs compared (2026, MSQ), attribute grammar statements (2024, MSQ).
4. Intermediate Code, Runtime Environments and Lexical Analysis
What gets asked: three-address code and the minimum number of temporaries, DAGs for expressions, backpatching, activation records and where variables are stored (stack, heap or static), parameter passing, and counting tokens.
How to prepare: for token counting, apply the longest-match rule and ignore whitespace (worked example 4). For storage questions, remember that locals and return addresses go on the stack, malloc memory on the heap, and static and global variables in the data segment. For DAG questions, shared sub-expressions become shared nodes.
Recent PYQs: three-address code for an expression (2024), backpatching (2025), symbol table statements (2025).
Worked Examples from Official GATE CS Papers
Each answer below matches the official answer key, as reproduced on the linked question page.
Example 1: LR(0) shift-reduce conflicts (GATE CS 2026 Set 2, Q41, 2 marks)
Question: S → ACB, A → aA | ε, C → cC | ε, B → bB | b. How many shift-reduce conflicts appear in the LR(0) table?
Solution: in LR(0), a completed item reduces on every terminal. Each state that contains both a completed item and a shift has a conflict. That happens in five states. The start state has A → • (reduce) and shifts a. The state after a has A → • again and shifts a. After A, there is C → • and a shift on c. After c, there is C → • and a shift on c. After b, there is B → b• and a shift on b. That gives 5 conflicts. Practise this question.
Example 2: S- and L-attributed rules (GATE CS 2025 Set 2, Q22, 1 mark)
Question: Rule 1 is R → AB {B.i = R.i − 1; A.i = B.i; R.i = A.i + 1}. Rule 2 is P → CD {P.i = C.i + D.i; D.i = C.i + 2}. Rule 3 is Q → EF {Q.i = E.i + F.i}. Classify each rule.
Solution: in Rule 1, A.i depends on B.i, a sibling to its right, so it is neither L-attributed nor S-attributed. In Rule 2, D.i depends on its left sibling C, which makes it L-attributed but not S-attributed. Rule 3 uses only synthesised attributes, so it is both. The correct option is C. Practise this question.
Example 3: LL(1) facts (GATE CS 2026 Set 1, Q28, 1 mark, MSQ)
Question: which are true? (A) LL(1) parsers backtrack. (B) LL(1) grammars must be left-recursive. (C) LL(1) grammars must be left-factored. (D) LL(1) parsers are more powerful than SLR parsers.
Solution: LL(1) is predictive, so there is no backtracking, and (A) is false. Left recursion makes LL(1) impossible, so (B) is false. Common prefixes block a one-symbol choice, so (C) is true. SLR handles more grammars than LL(1) in practice, so (D) is false. The answer is C only. Practise this question.
Example 4: Counting tokens (GATE CS 2026 Set 2, Q35, 1 mark, NAT)
Question: with id = letter(letter | digit)*, number = digit+ and whitespace ignored, how many tokens are in "x1 23mm 78 y 7z zz5 14A 8H AaYcD"?
Solution: using longest match, the tokens are x1 · 23, mm · 78 · y · 7, z · zz5 · 14, A · 8, H · AaYcD. A number cannot continue into letters, so "23mm" splits into 23 and mm. That gives 13 tokens. Practise this question.
Example 5: What lives on the heap (GATE CS 2026 Set 2, Q17, 1 mark)
Question: in the C runtime environment, which of these is stored on the heap: a static local variable, a local array, a malloc'd array, or a return address?
Solution: static variables go in the data segment, and local arrays and return addresses go on the stack. Only memory from malloc is on the heap, so the answer is the dynamically allocated array. Practise this question.
Study Order and Time Plan
Compiler Design takes roughly 3 to 4 weeks at 2 hours a day. Study Theory of Computation first, because grammars and automata are its foundation.
- Lexical analysis and compiler phases (2 days).
- Parsing (8–9 days): FIRST and FOLLOW, LL(1), then LR(0), SLR, CLR and LALR, with conflict counting.
- Syntax-directed translation (4 days): S- and L-attributed definitions and evaluation.
- Intermediate code and runtime environments (3 days): three-address code, DAGs, activation records and storage.
- Local optimisation and data-flow analysis (4–5 days): basic blocks, liveness, constant propagation and CSE.
- PYQ sweep (2–3 days): all 88 Compiler Design questions from 2014 to 2026 on the GATE CS PYQ archive.
For where Compiler Design fits among all the subjects, see the GATE CSE 2027 month-by-month study plan.
Best Books for GATE CS Compiler Design
| Book | Use it for |
|---|---|
| Aho, Lam, Sethi & Ullman, Compilers: Principles, Techniques, and Tools (2nd ed., "the Dragon Book") | The primary text. Read the chapters on lexical analysis, parsing, SDT, intermediate code, runtime and data-flow analysis. |
The Dragon Book goes far beyond the syllabus. Skip the chapters on instruction scheduling, parallelism and interprocedural analysis. For other subjects, see our best books for GATE CSE 2027. The full course, covering all subjects with lectures and mock tests, is on the GATE CS course page.
Common Mistakes in GATE Compiler Design
- Forgetting that LR(0) reduce items apply on every terminal, which is the source of most conflicts (Example 1).
- Calling a rule L-attributed when an inherited attribute uses a right sibling (Example 2).
- Running liveness forwards. It is a backward analysis.
- Missing the instruction after a jump when listing leaders for basic blocks.
- Merging a number and an identifier into one token when longest match splits them (Example 4).
Key Takeaways
- Compiler Design averaged 5.8 marks per paper (5.8% of the paper) across 23 official GATE CS papers (2014–2026), and 6.8 since 2021, the biggest rise of any subject.
- Parsing carries about a third of the marks. SDT nearly tripled and data-flow analysis grew.
- 63% of marks are MCQs, so negative marking matters more here than in any other subject.
- Its short syllabus and repetitive question types make it one of the best returns on study time.
Frequently Asked Questions
How many marks does Compiler Design carry in GATE CS?
The official pattern does not fix marks per CS subject. Across all 23 official GATE CS papers from 2014 to 2026, Compiler Design averaged 5.8 marks per paper, which is 5.8% of the 100-mark paper, with a range of 3 to 8. It has averaged 6.8 marks since 2021.
Which Compiler Design topics are most important for GATE CS 2027?
Parsing (about 2.2 marks per paper since 2021), local optimisation and data-flow analysis (about 1.8), and syntax-directed translation (about 1.4).
Can I skip Compiler Design for GATE CS?
It is not a good idea. Compiler Design has carried 6 to 8 marks in every paper since 2023, it has the shortest syllabus of the core subjects, and only about 9% of its questions are rated hard.
Which book is best for Compiler Design for GATE CS?
Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi and Ullman (the Dragon Book). Read only the chapters that map to the syllabus.
Is code generation in the GATE CS 2027 syllabus?
Target code generation and register allocation are not listed. The 2027 syllabus covers lexical analysis, parsing, SDT, runtime environments, intermediate code generation, local optimisation, and data-flow analyses (constant propagation, liveness and CSE).
Where can I practise GATE CS Compiler Design PYQs?
Every GATE CS question from 2014 to 2026 is free on Success Tracker's GATE CS PYQ archive, with the official answer and a worked solution.
Next in This Series
- Theory of Computation for GATE CS 2027
- Programming and Data Structures for GATE CS 2027
- Algorithms for GATE CS 2027
- GATE CSE subject-wise weightage
- GATE CS 2027 complete guide
Sources
- GATE 2027 CS Syllabus (PDF), IIT Madras: Section 7, Compiler Design
- GATE 2026 CS Syllabus (PDF), IIT Guwahati
- GATE 2027 Question Paper Pattern, IIT Madras: marks distribution and negative marking
- Official GATE CS question papers and answer keys, 2014–2026 (23 papers), as reproduced on Success Tracker. Weightage figures are The ML Hub's own count, done on 25 October 2026.