Type a branch, a subject or a topic — “round robin”, “paging”, “civil”.

Compiler Design

A compiler is a pipeline of transformations, and each one has a shape you can draw. These topics take a single expression and carry it through every phase.

Start from the beginning →

13 topics you can watch now, 11 still to come.

Foundations

What a compiler is, what it is not, and everything else that runs before your program does.

  • Bootstrapping and cross-compilers

The pipeline

The whole journey first, so every later phase has somewhere to sit.

  • Front end vs back end in depth
  • Passes and pass structure

Lexical analysis

Turning a stream of characters into a stream of words.

  • Regex to DFA for scanning

Parsing

Discovering the structure that the grammar says must be there.

  • LR(0) item sets
  • SLR, LALR and CLR

Semantic analysis

Checking the things a grammar cannot express, like types.

  • Syntax-directed translation
  • Attribute grammars

Intermediate code

A representation simple enough to optimise and easy to emit from.

  • DAG representation of a block

Optimisation and generation

Making it smaller and faster, then making it real instructions.

  • Loop optimisation
  • Instruction selection

About Compiler Design

A compiler is a long pipeline of small, well-understood transformations, and the reason the subject is worth studying is that almost every stage is a reusable idea. Lexing, parsing, building a symbol table, walking an intermediate representation, allocating registers — these turn up in linters, formatters, query engines, template systems and configuration languages.

The pipeline shape also means each phase can be understood on its own. Parsing turns a flat string into a tree using a grammar. Semantic analysis decorates the tree with meaning. Optimisation rewrites the intermediate form into something cheaper but equivalent, and the word equivalent is doing a lot of work. Code generation finally commits to a machine.

Register allocation and optimisation are where the animations matter most: both are algorithms whose intermediate states are the entire point, and both are ordinarily taught with before-and-after snapshots that skip the interesting middle.

What to know first

  • Fluency in at least one language, and curiosity about what happens to the source
  • Theory of Computation helps, particularly automata and grammars

Where it gets used

  • Writing a parser for a config or query language without inventing the theory
  • Reading compiler output and knowing which optimisation produced it
  • Understanding why some code is intrinsically hard for a compiler to speed up
Dashed entries are mapped but not animated yet. The running order is not fixed until a topic is built. Browse the other subjects.