Skip to main content

compile_grammar

Function compile_grammar 

pub fn compile_grammar(
    source: &str,
    options: CompileOptions<'_>,
) -> Result<CompiledGrammar, GrammarError>
Expand description

Compile .lark source. from_lark_source-style construction also routes through here.

The pipeline mirrors Lark.__init__’s build path: build_grammar (Definition-level: meta-parse → walk → %import/override → resolve_term_referencesvalidate) → Grammar.compile (terminals → rules EBNF→BNF → dedup → unused-prune) → the ordered tail edit_terminalspriority='invert'/None transform → build_rule_shape + build_lalr. The output CompiledGrammar is the same downstream shape json_loader::LoadedGrammar emits, so every proven lexer/parser stage is shared.