pub struct StatementParser {
buffer: String,
scan_offset: usize,
stmt_start: usize,
state: LexState,
block_comment_depth: usize,
in_batch: bool,
}Expand description
Incremental statement parser.
Tracks lexer state across feed_line calls so that each call only scans
the newly appended bytes. Total work is O(n) over the lifetime of the parser,
not O(n²). See PR #151 for why this matters.
Fields§
§buffer: StringAccumulated input buffer.
scan_offset: usizeByte offset in buffer where the next scan should resume.
stmt_start: usizeByte offset of the start of the current (in-progress) statement.
state: LexStateCurrent lexer state at scan_offset.
block_comment_depth: usizeDepth of nested block comments.
in_batch: boolTrue when we are inside a BEGIN BATCH … APPLY BATCH block.
Semicolons inside a batch do not terminate the batch statement.
Implementations§
Source§impl StatementParser
impl StatementParser
Sourcepub fn feed_line(&mut self, line: &str) -> ParseResult
pub fn feed_line(&mut self, line: &str) -> ParseResult
Feed a line of input and return any complete statements.
This is the incremental entry point. Each call scans only the newly
appended bytes, preserving lexer state from the previous call.
Total work across all feed_line calls is O(n).
Sourcefn scan_for_statements(&mut self) -> ParseResult
fn scan_for_statements(&mut self) -> ParseResult
Scan from scan_offset forward for statement terminators.
Only scans newly appended bytes — does NOT re-scan from the start.
State (self.state, self.block_comment_depth) is preserved across calls.
Trait Implementations§
Source§impl Debug for StatementParser
impl Debug for StatementParser
Source§impl Default for StatementParser
impl Default for StatementParser
Source§fn default() -> StatementParser
fn default() -> StatementParser
Auto Trait Implementations§
impl Freeze for StatementParser
impl RefUnwindSafe for StatementParser
impl Send for StatementParser
impl Sync for StatementParser
impl Unpin for StatementParser
impl UnwindSafe for StatementParser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more