Tag
#parsing
8 posts
Crafting a parser, part 1: from source to tokens
Before any grammar rule runs, a lexer turns characters into spanned tokens — and that token shape decides everything downstream.
Crafting a parser, part 2: grammars and recursive descent
One function per grammar rule, the call stack as the parse tree, and why left recursion is a trap.
compilersPart 3
Crafting a parser, part 3: designing the AST
Enums all the way down, spans on every node, and keeping semantics out of the syntax tree.
compilersPart 4
Crafting a parser, part 4: Pratt parsing and precedence
One loop and a binding-power table replace a forest of precedence functions.
compilersPart 5
Crafting a parser, part 5: error recovery and diagnostics
Report many errors per run and keep a usable tree — panic-mode recovery, sync points, and messages that don't lie.
compilersPart 6
Crafting a parser, part 6: ambiguity, lookahead, and the lexer hack
The dangling else, the less-than-versus-generics problem, and how much backtracking is honest.
compilersPart 7
Crafting a parser, part 7: resilient, incremental parsing
IDE-grade parsing: lossless trees, errors as the normal path, and reparsing only the edited subtree.
compilersPart 8
Crafting a parser, part 8: testing, snapshots, and fuzzing
Snapshot the tree, round-trip for fidelity, and fuzz to enforce the never-panic contract.