Skip to content
jiweixing edited this page Feb 3, 2020 · 10 revisions

Build a Compiler within 30 Days

Section 1: Preliminaries

Day 1: Language Introduction

  • Programming language history
  • Programming language classification
  • Some popular languages: C/C++, Java, Python, Assemble Language
  • Lab. 1: language comparison

Day 2: Compiler Introduction

  • Compiler definition
  • Typical architecture of a compiler
  • How does compiler work
  • Lab. 2: GCC running and observation

Section 2: Front End

Day 3: Language Specification

  • Syntax rules specification : CFG
  • Language Specification: take C for example

Day 4: Scanner Implementation

  • Lexeme recognization : DFM, NFM
  • Lex introduction
  • Lab. 3 : lex

Day 5: Parser Implementation

  • Program parsing: top-down
  • lab. 4: parser implementation

Day 6: Parser Implementation 2

  • Program parsing: bottom-up
  • lab. 5: Yacc implementation

Day 7: ANTLR

  • ANTLR introduction
  • Scanner & parser generation

Day 8: Parsing Tree & AST

  • Parsing tree generation based on ANTLR output
  • AST introduction
  • Parsing Tree to AST transformation
  • Lab : AST generation

Day 9: Symbol Table

  • Symbol table introduction
  • Symbol table generation
  • Lab : symbol table generation

Day 10: Semantic Analysis 1

  • Type checking
  • examples
  • lab

Day 11: Semantic Analysis 2

  • Scope checking
  • examples
  • lab

Section 3: Back End

Day 12: IR 1

  • IR introduction
  • LLVM IR
  • Java BC
  • IR definition

Day 13: IR 2

  • IR generation

Day 14: Target Code Generation 1

  • Assemble file format
  • Processor Emulator
  • Manual code generation

Day 15: Target Code Generation 2

  • Register allocation algorithm
  • Simple implementation

Day 16: Target Code Generation 3

  • Instruction Selection

Day 17: Target Code Generation 4

  • Calling Convention
  • Code generation

Section 4: Runtime System

Day 18: Introduction

  • GCC/LLVM introduction
  • Python VM introduction
  • Java VM introduction

Day 19: I/O Implementation

Day 20: Memory Management

Day 21: Exception Handling

Section 5: Optimization

Day 22: Optimization Introduction

Day 23: Control Flow Analysis 1

Day 24: Control Flow Analysis 2

Day 25: Data Flow Analysis 1

Day 26: Data Flow Analysis 2

Day 27: Constant Folding

Day 28: Dead Assignment Elimination

Day 29: Loop Optimization 1

Day 30: Loop Optimization 2