Compiler Design Syllabus
Course Overview:
This course introduces students to the theory and practice of compiler design. It covers the
principles of lexical analysis, syntax analysis, semantic analysis, intermediate code generation,
optimization, and code generation, as well as the tools and techniques for implementing these
stages.
Week 1: Introduction to Compilers
Topics:
o What is a Compiler? Definition, Functions, and Phases
o The Structure of a Compiler
o The Role of a Compiler in Programming Language Translation
o Compiler vs. Interpreter
o The Compilation Process: Lexical Analysis, Parsing, Semantic Analysis,
Optimization, Code Generation, Code Optimization
Reading:
o Chapter 1 of Compilers: Principles, Techniques, and Tools (the Dragon Book) by
Aho, Lam, Sethi, and Ullman
Week 2: Lexical Analysis
Topics:
o The Role of the Lexical Analyzer (Scanner)
o Regular Expressions and Finite Automata
o Design and Implementation of Lexical Analyzers
o Tools: Lex/Flex
o The Lexical Analyzer’s Role in Tokenization: Identifiers, Keywords, Operators
o Error Handling in Lexical Analysis
Reading:
o Chapter 3 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and
Ullman
Lab:
o Implement a simple lexical analyzer using Lex or Flex
Week 3: Syntax Analysis
Topics:
o Syntax Analysis and Parsing
o Context-Free Grammars (CFG)
o Derivations and Parse Trees
o Top-Down vs. Bottom-Up Parsing
o Parsers: LL(1) and LR(1) Parsers
o Tools: Yacc/Bison
Reading:
o Chapter 4 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and
Ullman
Lab:
o Build a simple LL(1) parser using Yacc or Bison
Week 4: Syntax-Directed Translation
Topics:
o Translation and Code Generation
o Syntax-Directed Definitions (SDD)
o Syntax-Directed Translation (SDT)
o Attribute Grammars
o Intermediate Code Generation: Abstract Syntax Tree (AST)
o Three-Address Code (TAC)
Reading:
o Chapter 6 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and
Ullman
Week 5: Semantic Analysis
Topics:
o Role of Semantic Analysis in a Compiler
o Attribute Evaluation
o Type Checking and Type Systems
o Symbol Table Construction
o Scope and Binding
o Error Handling in Semantic Analysis
Reading:
o Chapter 7 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and
Ullman
Lab:
o Implement semantic analysis for type checking and symbol table creation
Week 6: Intermediate Code Generation
Topics:
o Intermediate Representations (IR)
o Types of Intermediate Representations: Abstract Syntax Tree (AST), Three-
Address Code (TAC)
o Translating from High-Level Code to Intermediate Code
o Optimizations during Intermediate Code Generation
o Intermediate Code Generation for Control Structures (loops, conditionals)
Reading:
o Chapter 8 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and
Ullman
Lab:
o Implement a simple three-address code generator for a subset of a programming
language
Week 7: Code Optimization
Topics:
o Introduction to Code Optimization
o Basic Block and Control Flow Graph (CFG)
o Local and Global Optimizations
o Optimization Techniques: Constant Folding, Common Subexpression Elimination,
Loop Unrolling
o Register Allocation and Instruction Scheduling
Reading:
o Chapter 9 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi, and
Ullman
Week 8: Code Generation
Topics:
o The Role of Code Generation in a Compiler
o Target Machine and Instruction Set Architecture (ISA)
o Register Allocation and Instruction Selection
o Code Generation for Expressions and Control Flow
o Assembly Code Generation and Optimizations
Reading:
o Chapter 10 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi,
and Ullman
Lab:
o Implement a simple code generator that translates intermediate code to
assembly for a target machine
Week 9: Code Optimization (Advanced)
Topics:
o Advanced Optimization Techniques: Loop Optimization, Inlining, Dead Code
Elimination
o Data Flow Analysis: Reaching Definitions, Live Variable Analysis
o Optimizing Code for Performance
o Instruction Scheduling and Register Allocation
Reading:
o Chapter 11 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi,
and Ullman
Lab:
o Implement an advanced optimization pass for a compiler
Week 10: Error Handling and Debugging
Topics:
o Types of Errors: Lexical, Syntax, Semantic, Runtime
o Error Recovery in Lexical Analysis and Parsing
o Reporting Errors and Error Messages
o Debugging Techniques for Compilers
o Symbol Table Management and Error Checking
Reading:
o Chapter 13 of Compilers: Principles, Techniques, and Tools by Aho, Lam, Sethi,
and Ullman
Week 11: Compiler Construction Tools
Topics:
o Compiler Writing Tools: Lex, Yacc, Flex, Bison
o Code Generation Tools and Libraries
o Advanced Topics in Compiler Construction
o Just-in-Time Compilation (JIT)
o Implementing Garbage Collection in Compilers
Reading:
o Selected articles and papers on JIT Compilation
Lab:
o Build a small project using Lex/ Flex and Yacc/ Bison (e.g., creating a toy
language compiler)
Week 12: Case Studies and Real-World Applications
Topics:
o Case Study: Real-World Compilers (GCC, Clang, Java Compiler)
o Just-in-Time Compilers (e.g., HotSpot JVM)
o Optimization in Modern Compilers
o Applications of Compilers in Programming Language Design and Execution
Reading:
o Research papers on modern compiler optimizations and case studies