Compiler Foundations
Pipeline
- Lexing -> Parsing -> Semantics -> IR -> Optimization -> Codegen
- Same idea, many valid designs
Tokens and lexemes
- Lexeme = exact text
- Token = kind + lexeme + position
- Positions enable helpful errors
Grammar
- Grammar defines structure
- Precedence and associativity come from the grammar
AST
- AST = meaning, not punctuation
- Drives later stages
Design choices
- Syntax, rules, errors, IR shape
- Pack tests behavior, not style
1 / 1