Skip to main content

earley_parse_with

Function earley_parse_with 

pub fn earley_parse_with(
    job: ParseJob<'_, '_>,
    transform: Option<&mut dyn ReduceCallback>,
) -> Result<ParsedTree, ParseError>
Expand description

The Earley parse entry — signature mirrors the LALR engine’s parse_with (including the postlex param) plus Earley’s ParseOptions with its ambiguity field. Flow (Algorithm Sketch): build recognizer tables from the shared model → run the [recognizer] over the [scan] strategy chosen by lexer (postlex, when present, wraps the basic token stream via the connector) → gate + run the [prioritizer] sum-cascade → [extract] by ambiguity through the per-rule [chains]. A no-parse maps to the per-lexer error class (basic: UnexpectedToken/UnexpectedEOF; dynamic: UnexpectedCharacters). Dynamic matcher construction (with its zero-width/bad-regexp GrammarError) happens earlier, in build_dynamic_matchers; this entry only borrows the built matchers.

transform: when Some, the same crate::model::ReduceCallback the LALR engine drives is fired by the per-rule extraction chain in place of the tree builder — so one trait serves both engines. (Lark gates its embedded transformer= to LALR; hyperlark’s core surfaces it on the Earley extraction path too.) None = tree-building.