Function to_canonical_json
pub fn to_canonical_json(
table: &ParseTable,
terminals: &[TerminalDef],
ignore: &[String],
start: &[String],
options: &SaveOptions,
) -> Result<String, SaveError>Expand description
Serialize a compiled grammar to the canonical envelope, as a pretty-printed (indent-2, key-sorted) string with a trailing newline — matching the corpus fixtures’ shape and byte-stable across repeated saves.
terminals MUST be the grammar’s terminals in lexer_conf (id) order — their
index is their memo id 0..N-1; rules follow at N..N+R-1 (the exact order
Lark’s memo_serialize walk assigns: lexer_conf.terminals then
parser_conf.rules).