CS502: Compiler Design

Offering: Sep-Dec 2020 (Virtual)

Class strength: 34

  • “Perfectly designed course structure, well planned timeline, no hasty deadlines, best classes I've ever attended, highly helpful instructor, immediate doubts clearance, interesting learning modes, highly knowledgeable group of peers, no chances of any unfair means (other courses should also follow the strategy of Manas sir), Best course and Best teacher! (p.s. I never realized that I have been spending so much efforts into the course, all thanks to the unique ways of Manas sir to make us learn.)”

  • “nothing to add Manas sir is best”

  • “The best course of this entire sem. Could be used as a standard for other courses.”

  • “ease down those assignments. bloody tough”

  • “A PERFECT course.”

  • “The teaching and assignments were really good.”

  • “The course was really great and I enjoyed it thoroughly, probably the best course I have taken thus far. Manas Sir was amazing, looking forward to taking more of his courses in the future.”

  • “[Inspired by CompL webpage] Good part of taking Manas sir's courses: you not only get to learn new things, his course becomes your absolute interest.
    Bad part of taking Manas sir's courses: the course lasts only 1 semester :(”

  • “The best online course I've had.”

  • “Glad to be a part of this course. From learning so many new concepts to enjoying the discussions and doing challenging assignments, you have been the best professor we had in the 4 years of B.Tech, and I'm NOT saying this just for the sake of filling this up. As a part of the course, you also taught us how complex problems can be solved in subtle ways, building solutions from scratch. I have learned a lot from you, even as a person, and wish you continue to be "yourself" always :)
    Immense respect!”

Note. Due to Covid-19, the course will be conducted virtually. Most classes and labs will be held over Zoom (recorded videos will be available, but you will enjoy more while attending live). Assignments and marks will as usual reside on Moodle. But offline discussions, various activities, additional learning and much more fun will be on-boarded to MS Teams. (A Marauder's map is hidden in the Wiki tab of the General channel.)

About the course

“I had a running compiler and nobody would touch it. … they carefully told me, computers could only do arithmetic; they could not do programs.”

- Grace Hopper 

A compiler is a fundamental software necessary to translate computer programs to a form that can be executed on intended machines. Designing a compiler involves learning several aspects of computer science: logic, formalism, mathematics, data structures, algorithms, programming, and so on. This course is intended as a primer to the various stages typical in the design of standard compilers, starting with the front-end stages of compilation, and giving a peek into the back-end and some recent advancements in the area. At the end of the course, students should be able to appreciate the underlying concepts in compiler design, and be motivated to learn the art of analyzing and transforming programs for performance.


1. Alfred V. Aho, Monica Lam, Ravi Sethi and Jeffrey D. Ullman. “Compilers: Principles, Techniques, and Tools”, Second Edition, Pearson Education, 2007.
2. Andrew W. Appel. “Modern Compiler Implementation in Java”, Second Edition, Cambridge University Press, 2002.


1. Keith D. Cooper and Linda Torczon. “Engineering a Compiler”, Second Edition, Morgan Kaufmann, 2011.
2. Y. N. Srikant and Priti Shankar. “The Compiler Design Handbook”, Second Edition, CRC Press, 2007.

Course structure

  • Credits: 3-0-2-4

  • Prerequisites: CS202 (Data Structures and Algorithms) and CS304 (Formal Languages and Automata Theory). Or consent of teacher.

  • Audience: Elective for CSE and EE students.

  • Instructor: Manas Thakur.

  • TA: Neeraj (d19023).

  • Slot: F (Mon 3pm, Tue 4pm, Thu 9am, Fri 10am, Sat 11am).


1. Introduction (INT)
2. Lexical analysis (LEX)
3. Syntax analysis (SYN)
4. Semantic analysis (SEM)
5. Intermediate code generation (ICG)
6. Runtime environments (RTE)
7. Code generation and optimization (CGO)
8. Advanced topics (ATS)

  • Machine learning and compiler design (MLC)

  • Interprocedural analysis (IPA)

  • Just-in-time compilation (JIT)


Dates Topic(s) Remarks
Sep 17, 18, 19 INT, LEX Logistics included on 17
Demo code from 18
Sep 21, 22, 24, 25, 26 LEX, SYN Demo code from 21
Extended class on 26 (tutorial code)
Sep 28, 29; Oct 1, 3 SYN, SEM A1 due on 3
Oct 5, 6, 8, 9, 10 SEM Notes from 6
Oct 12, 13, 15, 16 ICG Quiz on 15
A2 due on 18
Oct 19, 20, 22, 23, 24 ICG, RTE Relax on 19
Restricted doubt session on 22
Oct 26, 27, 29, 31 CGO
Nov 2, 3, 5, 6, 7 CGO Doubt session on 2
A3 due on 8
Nov 9, 10, 12, 13 CGO, MLC Saturday schedule on 12
Diwali break on 13
Nov 17, 18, 19, 20, 21 IPA, JIT Manas attending Onward! on 18
Guest lecture by Prof. V. Krishna Nandivada on 20
A4 due on 21
Nov 23 LDT Last day of teaching on 23
Dec 2 End sem on 2
Dec 9 A5 due on 9


// Compiler design offers a very uniform mix of theory and practice, and the same goes for assessment.

Theory (50%):

  • Quiz (20)

  • End sem (30)

Practice (50%):

  • A1 (10): LEX/SYN (Game of Thrones)

  • A2 (08): SEM (Not overweight, but under-tall)

  • A3 (12): ICG (Bye-bye Cheese)

  • A4 (12): CGO (Translators on Steroids)

  • A5 (08): ATS (Fly and span the sky)