Trace total = price * count + tax. This is a conceptual compiler front end; a particular language may merge stages, defer checks, or use a different intermediate form.
1. Scan the source
The scanner reads characters and groups them into tokens: identifier total, assignment operator, identifiers price and count, multiplication operator, addition operator, and identifier tax. It tracks locations so diagnostics can point back to source text.
2. Parse precedence and structure
The parser applies the grammar and operator precedence. It builds an assignment node whose right side is an addition node; the addition's left child is multiplication. The tree records that multiplication happens before addition without keeping every punctuation mark.
3. Check meaning
Name resolution finds declarations for the identifiers. Type checking or dynamic-language analysis determines what operations are permitted. A statically typed compiler might reject incompatible operands now; another language may generate runtime checks.
4. Lower and execute
The compiler can lower the tree to an intermediate representation, optimize it, then emit machine code or bytecode. A bytecode interpreter dispatches instructions; a just-in-time compiler can later compile hot code. A native compiler can also leave calls to runtime helpers for allocation or dynamic operations.
The exact pipeline is implementation-specific. Crafting Interpreters offers a concrete scanner, parser, tree-walk interpreter, and bytecode VM that make each transition inspectable.