pub fn parse_partial<'inp, L, Ctx, Lang, O, P>(
ctx: Ctx,
src: &'inp L::Source,
state: L::State,
is_final: bool,
f: P,
) -> Result<O, <Ctx::Emitter as Emitter<'inp, L, Lang>>::Error>where
L: Lexer<'inp>,
L::State: Clone,
Lang: ?Sized,
Ctx: ParseContext<'inp, L, Lang>,
Partial: SurfaceIncomplete<'inp, L, Ctx, Lang>,
P: ParseInput<'inp, L, O, Ctx, Lang, Partial>,Expand description
Opens a Sans-I/O partial parse session over src and drives the parser f — any
ParseInput<'inp, L, O, Ctx, Lang, Partial> — returning whatever
f returns.
This is the partial-mode entry point, the Partial instantiation of the same trait
vocabulary the complete-only Parse API drives at its default: a typed fn item, a named
combinator chain, or a parser written generic over its completeness parameter all satisfy the
bound (write once, run in both modes — see the input module docs). f
receives an InputRef in Partial mode set to is_final, so the
frontier rules are active while non-final: consuming across the frontier
surfaces an Incomplete on the Err channel, which the parser
propagates out. ctx supplies the emitter and cache exactly as Parse does.
The Partial: SurfaceIncomplete bound requires that the emitter’s error implements
From<Incomplete<L::Offset>> (constructing the frontier sentinel) and
MaybeIncomplete (recognizing it — the atom-layer
never-recoverable gate and the caller’s own refill check); complete parses see neither.
§The refill loop
The caller owns the buffer. Each attempt builds a fresh input over the current buffer slice, so
there is no growable source inside tokora: on an incomplete result the caller appends the
next chunk to its own buffer and calls this again over the larger slice. Inside f, parsing
under a rollback-on-drop Transaction means an incomplete attempt unwinds its emissions and
cursor cleanly before the retry — a transaction f opens, because this driver deliberately
wraps nothing. See the input module docs for the full runnable loop and the one-token
frontier-latency guarantee.
§Cost
Every attempt re-lexes the whole prefix, so cumulative lexer work across a refill loop is
Θ(Σ attempt lengths) — the triangular figure under one-token refills. This function returns
nothing that could carry a committed frontier or a cross-attempt budget, so a caller facing
untrusted arrival fragmentation should drive PartialSession instead, whose Budget bounds
exactly that sum.