StatementParser

Struct StatementParser 

Source
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: String

Accumulated input buffer.

§scan_offset: usize

Byte offset in buffer where the next scan should resume.

§stmt_start: usize

Byte offset of the start of the current (in-progress) statement.

§state: LexState

Current lexer state at scan_offset.

§block_comment_depth: usize

Depth of nested block comments.

§in_batch: bool

True when we are inside a BEGIN BATCH … APPLY BATCH block. Semicolons inside a batch do not terminate the batch statement.

Implementations§

Source§

impl StatementParser

Source

pub fn new() -> Self

Create a new empty parser.

Source

pub fn reset(&mut self)

Reset the parser, discarding any accumulated input.

Source

pub fn is_empty(&self) -> bool

Returns true if the parser has no accumulated input.

Source

pub fn remaining(&self) -> &str

Returns the remaining unparsed content in the buffer.

Source

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).

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StatementParser

Source§

fn default() -> StatementParser

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,