module
from.abnf
local Grammar = require "ion7.grammar"
local g = Grammar.from_abnf([[
date = year "-" month "-" day
year = 4DIGIT
month = 2DIGIT
day = 2DIGIT
]])
print(g:to_gbnf())
Functions
apply_rep
A repetition prefix produces a `{ min, max }` pair consumed by apply_rep. `min == max == nil` means "exactly one" — no rep wrapper needed.
apply_rep(rep, node)
from_abnf
Parse an ABNF string into a Builder. Only the core rules actually referenced by the user grammar are emitted; unreferenced ones stay out of the compiled GBNF. User rules with the same name as a core rule shadow the core entry.
from_abnf(source, root)
sourcestringABNF rulelist (RFC 5234 §4 syntax).
rootstring?Root rule name (default: first defined rule).
→ Builder