⚙️ Compiler Pipeline

Type a small arithmetic expression and watch the front-end of a compiler turn it into tokens, an abstract syntax tree, intermediate code and optimised output.

Source

Presets

Stats

Tokens
AST depth
Instructions
Constants folded

1 · Token stream (lexer)

2 · Abstract syntax tree (parser)

3 · Intermediate / target code (IR & codegen)

How a compiler works. The lexer scans characters into tokens (numbers, identifiers, operators). A recursive-descent parser applies the grammar — expression → term (+ −) → factor (* /) → primary (number, variable, parenthesised expression) — building an abstract syntax tree that captures operator precedence. Semantic analysis would resolve names and types; here we move to the intermediate representation, emitting three-address code. A constant-folding optimisation pass evaluates sub-expressions whose operands are all constants at compile time, shrinking the program before final code generation.