Pipeline

This part of the manual follows a grammar from its source form all the way to emitted target code, documenting each pass the generator runs and the data structure it produces.

The high-level chain is:

.parsuna source
     │
     │  Pass 1 — Grammar parsing
     ▼
Grammar IR        (in-memory AST of tokens and rules)
     │
     │  Pass 2 — Analysis
     ▼
AnalyzedGrammar   (Grammar plus FIRST/FOLLOW/nullable, chosen k)
     │
     │  Pass 3 — Lowering — build → layout → fuse
     ▼
StateTable        (flat state machine + lexer DFA)
     │
     │  Pass 4 — Code generation
     ▼
EmittedFile[]     (target-language source)

Each step is a pure function with a well-typed input and output — no shared mutable state, no side effects. The separation is deliberate: it means the backends are small (they only read a state table), it means the analysis is reusable (debug dumps, tree-sitter export, and code generation all share it), and it means you can reason about the generator one pass at a time.

The rest of this section treats each pass in detail.