Skip to main content

parse_incremental

Function parse_incremental 

Source
pub fn parse_incremental<'a, T: ParserTrait + Clone + 'static>(
    root: T,
    text: &'a str,
    prev: Option<&PrevParseInfo>,
    bias: IncrementalBias,
) -> (Parse, PrevParseInfo)
where T::Kind: Logos<'a, Source = str>, <<T as ParserTrait>::Kind as Logos<'a>>::Extras: Default,
Expand description

Like parse_t_2 but, when prev is provided, diffs the token stream against the previous one and copies each old token’s parse-time fingerprint onto the matching new token via FatToken::set_old_kind. The A* scorer then uses bias to adjust scores for parses that agree or disagree with the previous token positions in the grammar rule stack.

Fast path: if the document is currently valid (fast parse succeeds), the fault-tolerant search and incremental diffing are skipped entirely. The fast result is returned with a PrevParseInfo marked had_errors = false, so subsequent edits receive full incremental guidance. This avoids the case where fingerprints from an error-recovery parse mislead the A* when the document later becomes valid again.