CS4032 · BS elective · 4 credits

Compiler Design

Lexing, parsing, semantic analysis and code generation — how a high-level language becomes machine code.

Instructor Prof. Partha Pratim Das Term As offered Prereq CS3021

§ 1Calendar

  • Quiz 1—
  • Quiz 2—
  • End-term examination—

§ 2Previous Year Questions

No papers uploaded yet.

§ 3Resources

CS4032 · BS elective · 4 credits

Syllabus

The official course syllabus, transcribed from the IITM BS Data Science & Applications course booklet.

§ 1Course Description

This course introduces the principles and techniques of Compiler Design, including lexical analysis, syntax analysis, intermediate code generation, code optimization, and target code generation. Using formal language theory and tools such as Flex and Bison, students will implement a compiler for a subset of C while working with symbol tables, abstract syntax trees, and control flow graphs. This course shall develop the ability to design and implement language translators by combining theoretical foundations with practical compiler construction techniques.

Lectures-Tutorials-Practicals-Credits: 4-0-0-4

§ 2Faculty

§ 3Week-by-week

Week 1: Compiler basics; compiler phases, compilation environment, and Flex/Bison tools.

Week 2: Lexical analysis; tokens, regular expressions, finite automata, and Flex-based scanners.

Week 3: Basic parsing; CFGs, recursive descent, LL(1) parsing, and operator precedence.

Week 4: LR parsing; shift-reduce, LR/SLR/LALR methods, parsing tables, and Bison.

Week 5: Semantic analysis; syntax-directed translation, attribute grammars, type checking, and type inference.

Week 6: Symbol tables and runtime memory; scope management, activation records, and parameter passing.

Week 7: Intermediate code generation for expressions; ASTs, DAGs, TAC, arrays, and declarations.

Week 8: Intermediate code generation for control flow; Boolean expressions, backpatching, loops, conditionals, and procedure calls.

Week 9: Basic code optimization; CFGs, common subexpression elimination, copy propagation, dead code elimination, and peephole optimization.

Week 10: Global o ptimization; data-flow analysis, liveness, loop optimizations, and interprocedural analysis.

Week 11: Target cod e generation; instruction selection, register allocation, scheduling, and assembly generation.

Week 12: Advanced topics; garbage collection, JIT compilation, parallelizing compilers, LLVM, and modern compiler trends.