Skip to content

Build a C Compiler

Build a C compiler from scratch: lexer, recursive-descent parser, type checker, IR generation, x86-64 code generation, optimization passes (constant folding, dead code, register allocation), and linking. Builds the full pipeline like chibicc, GCC, and Clang.

advanced14 lessons4 chapters14 graded exercisesPython

No sign-up needed for lesson 1 · certificate on completion · sign up to save progress

What you’ll have built

Chapter by chapter. Every step is a graded exercise.

  • Lexing & Parsing
  • Type Checking & IR
  • Code Generation
  • Optimizations & Linking
Starts in Python — solve in the language you choose in the editor, same tests either way.

Curriculum

4 chapters, 14 lessons. Each lesson is a short read, one graded exercise, and a quiz.

  1. 1The Compiler PipelineRead · exercise · quiz
  2. 2The LexerRead · exercise · quiz
  3. 3Recursive Descent ParsingRead · exercise · quiz
  4. 4Parsing Statements & DeclarationsRead · exercise · quiz
Loading reference solution…
Build a C Compiler