module
compose
Functions
rewrite_refs
Deep-copy an AST node, rewriting ref names according to a mapping. Recursively traverses the AST and replaces every `ref` node whose name appears in `name_map` with a new ref using the mapped name. All other node kinds are deep-copied unchanged. seq/alt items arrays are copied element by element so the original AST is never mutated. Used when merging rules from one grammar into another with a prefix, so that internal references point to the new prefixed names.
prefix_grammar
Add all rules from source_b into target_b with a prefix. All internal refs are rewritten to use the new prefixed names. The root rule of source_b becomes prefix-root_name in target_b.
Compose.union
Union: match either grammar a or grammar b. All rules from both grammars are added with "a-" and "b-" prefixes. Internal refs are rewritten so no broken references occur.
Compose.sequence
Sequence: match grammar a followed immediately by grammar b.
Compose.repeat_g
Repeat: match grammar g between min and max times.
Compose.optional
Optional: match grammar g or the empty string.
Compose.wrap
Wrap: surround grammar with prefix and suffix literals.
Compose.interleave
Interleave: match grammar g with sep between each occurrence. Equivalent to: g (sep g)* - one or more gs separated by sep.
Compose.annotate
Annotate: wrap a grammar with a named alias rule.