ArenaParser

Struct ArenaParser 

Source
pub struct ArenaParser<'arena> { /* private fields */ }
Expand description

Arena-based SQL parser.

Unlike the standard Parser, this parser allocates all AST nodes from a bump arena, resulting in:

  • O(1) allocation time (vs heap allocation overhead)
  • Better cache locality (contiguous memory)
  • Single deallocation when arena is dropped

Implementations§

Source§

impl<'arena> ArenaParser<'arena>

Source

pub fn parse_alter_table_statement( &mut self, ) -> Result<&'arena AlterTableStmt<'arena>, ParseError>

Parse ALTER TABLE statement.

Source§

impl<'arena> ArenaParser<'arena>

Source

pub fn new(tokens: Vec<Token>, arena: &'arena Bump) -> Self

Create a new arena parser from tokens.

Source

pub fn interner(&self) -> &ArenaInterner<'arena>

Returns a reference to the interner for symbol resolution during conversion.

Source

pub fn into_interner(self) -> ArenaInterner<'arena>

Consumes the parser and returns the interner.

Source

pub fn parse_sql( input: &str, arena: &'arena Bump, ) -> Result<Statement<'arena>, ParseError>

Parse SQL input string into an arena-allocated Statement.

Supports the full range of SQL statements including DML (SELECT, INSERT, UPDATE, DELETE), DDL (CREATE, DROP, ALTER), and transaction statements.

Source

pub fn parse_select( input: &str, arena: &'arena Bump, ) -> Result<&'arena SelectStmt<'arena>, ParseError>

Parse SQL input string into an arena-allocated SelectStmt.

Convenience method for when you know you’re parsing a SELECT.

Source

pub fn parse_select_with_interner( input: &str, arena: &'arena Bump, ) -> Result<(&'arena SelectStmt<'arena>, ArenaInterner<'arena>), ParseError>

Parse SQL input string into an arena-allocated SelectStmt, returning the interner too.

Use this method when you need to resolve Symbol values to strings.

Source

pub fn parse_expression_sql( input: &str, arena: &'arena Bump, ) -> Result<&'arena Expression<'arena>, ParseError>

Parse an expression and return an arena-allocated reference.

Source

pub fn parse_alter_table_sql( input: &str, arena: &'arena Bump, ) -> Result<&'arena AlterTableStmt<'arena>, ParseError>

Parse SQL input string into an arena-allocated AlterTableStmt.

Source

pub fn parse_insert( input: &str, arena: &'arena Bump, ) -> Result<&'arena InsertStmt<'arena>, ParseError>

Parse an INSERT statement into an arena-allocated InsertStmt.

Source

pub fn parse_update( input: &str, arena: &'arena Bump, ) -> Result<&'arena UpdateStmt<'arena>, ParseError>

Parse an UPDATE statement into an arena-allocated UpdateStmt.

Source

pub fn parse_delete( input: &str, arena: &'arena Bump, ) -> Result<&'arena DeleteStmt<'arena>, ParseError>

Parse a DELETE statement into an arena-allocated DeleteStmt.

Source

pub fn parse_replace( input: &str, arena: &'arena Bump, ) -> Result<&'arena InsertStmt<'arena>, ParseError>

Parse a REPLACE statement (alias for INSERT OR REPLACE) into an arena-allocated InsertStmt.

Source

pub fn parse_alter_table_sql_with_interner( input: &str, arena: &'arena Bump, ) -> Result<(&'arena AlterTableStmt<'arena>, ArenaInterner<'arena>), ParseError>

Parse an ALTER TABLE statement, returning the interner for symbol resolution.

Source

pub fn parse_delete_with_interner( input: &str, arena: &'arena Bump, ) -> Result<(&'arena DeleteStmt<'arena>, ArenaInterner<'arena>), ParseError>

Parse a DELETE statement, returning the interner for symbol resolution.

Source

pub fn parse_update_with_interner( input: &str, arena: &'arena Bump, ) -> Result<(&'arena UpdateStmt<'arena>, ArenaInterner<'arena>), ParseError>

Parse an UPDATE statement, returning the interner for symbol resolution.

Source

pub fn parse_insert_with_interner( input: &str, arena: &'arena Bump, ) -> Result<(&'arena InsertStmt<'arena>, ArenaInterner<'arena>), ParseError>

Parse an INSERT statement, returning the interner for symbol resolution.

Source

pub fn parse_replace_with_interner( input: &str, arena: &'arena Bump, ) -> Result<(&'arena InsertStmt<'arena>, ArenaInterner<'arena>), ParseError>

Parse a REPLACE statement, returning the interner for symbol resolution.

Auto Trait Implementations§

§

impl<'arena> Freeze for ArenaParser<'arena>

§

impl<'arena> !RefUnwindSafe for ArenaParser<'arena>

§

impl<'arena> !Send for ArenaParser<'arena>

§

impl<'arena> !Sync for ArenaParser<'arena>

§

impl<'arena> Unpin for ArenaParser<'arena>

§

impl<'arena> !UnwindSafe for ArenaParser<'arena>

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.

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