Canonical stages of a compiler or interpreter: (1) lexical analysis — character-by-character scanning into tokens, naturally expressed as regular expressions / finite-state machines; (2) syntactical analysis — constructing an internal representation such as an abstract syntax tree (using pushdown automata over a context-free grammar); syntax errors surface here; (3) semantical analysis — checking meaning: type coherence, scopes/declarations, non-overwriting of constants; implemented as graph traversal of the AST. Rust's borrow checker lives in this phase. (4) optimization — transformations such as constant folding, constant propagation, caching common subexpressions, and loop unrolling to exploit SIMD hardware; (5) execution (interpreters iterate the instructions) or code generation (compilers emit assembly that is assembled to bytecode/machine code).