Compilers
Turning source code into machine code, stage by stage.
The Anatomy of a Compiler
A compiler is not magic — it is a sequence of elegant, well-defined transformations that carry source text all the way to running machine code, and understanding each phase makes you a better programmer forever.
Lexical Analysis
Lexical analysis transforms raw source text into a structured stream of tokens by formalizing the language of valid words as regular expressions, then mechanically constructing recognizers via NFA-to-DFA conversion.
Parsing: Top-Down
Top-down parsing turns a context-free grammar into a working parser by predicting, from the current token alone, exactly which production rule to apply — no backtracking required.
Parsing: Bottom-Up
Bottom-up parsing transforms flat token streams into parse trees by building meaning from the leaves up, using a stack-driven automaton whose power scales from LR(0) to the full LR(1) hierarchy.
Abstract Syntax Trees & Semantic Analysis
ASTs are the moment source code becomes a data structure your compiler can reason about — semantic analysis is where that data structure learns what the program means.
Type Checking & Inference in Compilers
Type checking is the compiler's built-in proof system — a static guardian that catches whole classes of bugs before a single instruction executes.
Intermediate Representations
Intermediate Representations are the universal language compilers use to analyze, optimize, and translate programs — the crucial bridge between source code and machine reality.
Code Generation & Register Allocation
Transform the abstract syntax tree into real machine instructions — navigating the gap between infinite virtual registers and the brutal reality of a finite CPU.
Optimization
Compilers don't just translate code — they transform it into something faster, smaller, and smarter than any human would write by hand.