decompose_static_regions

Function decompose_static_regions 

Source
pub fn decompose_static_regions(grammar: &GrammarData) -> GrammarDecomposition
Expand description

Run the WGRAMMAR static/dynamic decomposition over an optimized grammar.

For every rule, decompose its body into alternating Segment::Static spans (fixed literals — the scaffolding, with their bytes precomputed here, once) and Segment::Dynamic spans (value slots). The grammar is only read; it is not mutated. The result is the compile-time decomposition index.

This pass runs once per compile_* call, after grammar optimization. It is cheap — a single linear walk of the AST — and its output is stored on the super::CompiledGrammar so a scheduler / matcher can consult the static/dynamic split without any per-token work.