module
ast.compiler
local compiler = require "ion7.grammar.ast.compiler"
local gbnf = compiler.compile(rules, "root", true)
Functions
escape_literal
Escape a raw string so it is safe to embed inside GBNF double-quoted literal syntax: backslashes and double-quotes are escaped; newline and tab are converted to their two-character escape sequences.
compile_literal
Compile a literal node to a double-quoted GBNF string.
compile_char
Compile a char-class node to a GBNF bracket expression.
compile_ref
Compile a ref node to its rule name.
compile_seq
Compile a seq node: items joined by spaces.
compile_alt
Compile an alt node: alternatives joined by " | ".
compile_rep
Compile a rep node using GBNF suffix operators or {n,m} notation.
compile_group
Compile a group node.
compile_node
Dispatch compilation to the correct handler based on node.kind.
compiler.compile
Compile a set of named rules to a GBNF string. The root rule is always placed first in the output regardless of definition order. When `whitespace` is true and a `ws` rule is missing but referenced, a default `ws ::= [ \t\n]*` rule is appended.
raises — When the root rule is not found in the rules array.