pub struct ParseResult { /* private fields */ }Expand description
Successful document parse output: the AST plus the buffers it borrows from, plus any non-fatal warnings the parser collected.
Modelled on chumsky’s ParseResult: the presence of the output and the
presence of warnings are orthogonal, so both are returned side-by-side
rather than encoded into Result. #[must_use] so warnings don’t get
silently dropped.
Implementations§
Source§impl ParseResult
impl ParseResult
Sourcepub fn source(&self) -> &str
pub fn source(&self) -> &str
Borrow the preprocessed source the AST was parsed from.
Note: this is the text as seen by the grammar, after include resolution and other preprocessor transforms — not the original caller input.
Sourcepub fn take_warnings(&mut self) -> Vec<Warning>
pub fn take_warnings(&mut self) -> Vec<Warning>
Take the warnings out of this result, leaving an empty warnings
slice behind. Useful when the caller wants to route warnings
independently of the AST (e.g. attach them to an LSP diagnostic
stream while keeping the document for further borrowing). The
ParseResult keeps its AST intact — only warnings() becomes
empty.