Skip to main content

parse_with_declarations_resolved

Function parse_with_declarations_resolved 

Source
pub fn parse_with_declarations_resolved(
    input: &str,
    config: impl Into<LexConfig>,
    declared: &ResolvedDeclarations,
) -> (Parse, ParseCtx)
Expand description

parse_with_declarations, additionally handing back the ParseCtx the returned tree was parsed under.

The context is not a second output so much as a witness: an incremental reparse that relexes a fragment of this text must do so under the same context, or the fragment’s tokens are not the ones the tree holds — a \newcommand the scan found makes its call sites lex differently, and a relex under a default context would silently disagree. It is free to hand back, since both passes compute it anyway (the one-pass case returns the seed it compared equal to).

The plain parse_with_declarations stays the entry point for everyone who only wants a tree.