Compiler Design

Course Outline


Welcome to Compiler Design. This course covers the theory and practice of building compilers, which translate high-level source code into efficient machine instructions.

Unit 1: Introduction to Compilers & Lexical Analysis

In this unit, we explore the fundamental architecture of a compiler, its logical phases, compiler-writing tools, lexical analysis (scanning), bootstrapping, cross-compilation, and finite automata.

Syllabus Topics Covered

  • Introduction: Compiler vs Interpreter, compiler types.
  • Phases of a Compiler: Lexical, Syntax, Semantic, IR Gen, Code Optimization, Code Generation.
  • Support Structures: Symbol Table Management and Error Handling.
  • Compiler Construction Tools: Lex/Flex, Yacc/Bison, ANTLR, LLVM.
  • Lexical Analysis: Tokens, patterns, lexemes, and the lexical analyzer role.
  • Bootstrapping & Cross-Compilation: T-Diagrams, self-hosting, cross-compilers, Canadian Cross.
  • Finite Automata: Regular expressions, NFAs (Thompson's construction), DFAs (Subset construction), and DFA Minimization (Myhill-Nerode).

Unit 3: Semantic Analysis, Symbol Tables & Runtime Environments

In this unit, we explore the semantic checking phase of compilers, mathematical formalisms for declaring language semantics, symbol table memory structures, block scopes, and dynamic runtime environments.

Syllabus Topics Covered

  • Semantic Analysis: Attribute Grammars, synthesized vs. inherited attributes, evaluation order, dependency graphs, SDDs, and SDTs.
  • Symbol Table Management: Scope management, static vs. dynamic scope, nested block scoping, symbol table operations, lists, and hash tables.
  • Runtime Environments: Memory regions layout, activation records, parameter passing (Call by Value, Reference, Value-Result, Name), and heap allocation strategies.
  • Solved PYQs: Past questions from 2023 to 2025, plus a quick revision chart.