Skip to main content

find_grammar_errors

Function find_grammar_errors 

pub fn find_grammar_errors(
    source: &str,
    start: &str,
) -> Result<Vec<GrammarErrorReport>, ParseError>
Expand description

find_grammar_errors(text, start='start'). Parses source (Lark appends a trailing newline) error-tolerantly over the meta-grammar, collecting (UnexpectedInput, repr) pairs, then keeps the first error per line in ascending-line order.

The Err arm is the raw ParseError Lark lets propagate out of the scan (an unrecoverable recovery feed, or the $END/$END self-loop guard): Lark re-raises the underlying UnexpectedInput subclass, so we surface the same raw error rather than wrapping it as a GrammarError.