pub struct ParseSession(/* private fields */);Expand description
Cursor over statements parsed from one SQL source string.
Useful for SQL scripts containing multiple statements.
- Returns one statement at a time via
next. - Reports errors per statement instead of failing the whole script immediately.
- Can continue after recoverable errors.
Implementations§
Source§impl ParseSession
impl ParseSession
Sourcepub fn next(&mut self) -> ParseOutcome<ParsedStatement<'_>, ParseError<'_>>
pub fn next(&mut self) -> ParseOutcome<ParsedStatement<'_>, ParseError<'_>>
Parse and return the next statement as a tri-state outcome.
Mirrors C parser return codes directly:
ParseOutcome::Done->SYNTAQLITE_PARSE_DONEParseOutcome::Ok->SYNTAQLITE_PARSE_OKParseOutcome::Err->SYNTAQLITE_PARSE_ERROR
Sourcepub fn arena_result(&self) -> AnyParsedStatement<'_>
pub fn arena_result(&self) -> AnyParsedStatement<'_>
Return a grammar-agnostic view over the current parse arena state.
Useful for generic introspection after consuming the session.
§Examples
let parser = syntaqlite_syntax::Parser::new();
let mut session = parser.parse("SELECT 1;");
let stmt = match session.next().transpose() {
Ok(Some(stmt)) => stmt,
Ok(None) => panic!("expected statement"),
Err(err) => panic!("unexpected parse error: {err}"),
};
let _ = stmt.root();
let any = session.arena_result();
assert!(!any.root_id().is_null());