Parser

Struct Parser 

Source
pub struct Parser { /* private fields */ }
Expand description

SQL Parser - converts tokens into AST

Implementations§

Source§

impl Parser

Source

pub fn parse_create_procedure( &mut self, ) -> Result<CreateProcedureStmt, ParseError>

Parse CREATE PROCEDURE statement

Syntax: CREATE PROCEDURE proc_name ([param_list]) [characteristics] BEGIN … END;

Source

pub fn parse_create_function( &mut self, ) -> Result<CreateFunctionStmt, ParseError>

Parse CREATE FUNCTION statement

Syntax: CREATE FUNCTION func_name ([param_list]) RETURNS data_type [characteristics] BEGIN … END;

Source

pub fn parse_drop_procedure(&mut self) -> Result<DropProcedureStmt, ParseError>

Parse DROP PROCEDURE statement

Syntax: DROP PROCEDURE [IF EXISTS] proc_name;

Source

pub fn parse_drop_function(&mut self) -> Result<DropFunctionStmt, ParseError>

Parse DROP FUNCTION statement

Syntax: DROP FUNCTION [IF EXISTS] func_name;

Source

pub fn parse_call(&mut self) -> Result<CallStmt, ParseError>

Parse CALL statement

Syntax: CALL procedure_name([args]);

Source§

impl Parser

Source

pub fn parse_expression_list(&mut self) -> Result<Vec<Expression>, ParseError>

Parse a comma-separated list of expressions Used for IN (val1, val2, …) and function arguments Does NOT consume the opening or closing parentheses

Source§

impl Parser

Source

pub fn parse_show_statement(&mut self) -> Result<Statement, ParseError>

Parse SHOW statement

Source

pub fn parse_describe_statement(&mut self) -> Result<DescribeStmt, ParseError>

Parse DESCRIBE table [column_pattern]

Source

pub fn parse_explain_statement(&mut self) -> Result<ExplainStmt, ParseError>

Parse EXPLAIN [QUERY PLAN | ANALYZE] statement

Syntax: EXPLAIN [QUERY PLAN | ANALYZE] [FORMAT {TEXT | JSON}] statement

Source§

impl Parser

Source

pub fn parse_table_options(&mut self) -> Result<Vec<TableOption>, ParseError>

Parse MySQL table options for CREATE TABLE

Source§

impl Parser

Source

pub fn new(tokens: Vec<Token>) -> Self

Create a new parser from tokens

Source

pub fn parse_comma_separated_list<T, F>( &mut self, parse_item: F, ) -> Result<Vec<T>, ParseError>
where F: Fn(&mut Self) -> Result<T, ParseError>,

Parse a comma-separated list of items using a provided parser function

This is a generic helper that consolidates the common pattern of parsing comma-separated lists throughout the parser (e.g., GROUP BY expressions, ORDER BY items, identifier lists, etc.)

§Arguments
  • parse_item - Closure that parses a single item of type T
§Returns
  • Ok(Vec<T>) - Successfully parsed list of items
  • Err(ParseError) - Error parsing an item
§Example
// Parse comma-separated expressions (for GROUP BY)
let exprs = self.parse_comma_separated_list(|p| p.parse_expression())?;

// Parse comma-separated identifiers
let ids = self.parse_comma_separated_list(|p| p.parse_identifier())?;
Source

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

Parse SQL input string into a Statement

Source

pub fn parse_statement(&mut self) -> Result<Statement, ParseError>

Parse a statement

Source

pub fn parse_begin_statement(&mut self) -> Result<BeginStmt, ParseError>

Parse BEGIN [TRANSACTION] statement

Source

pub fn parse_commit_statement(&mut self) -> Result<CommitStmt, ParseError>

Parse COMMIT statement

Source

pub fn parse_rollback_statement(&mut self) -> Result<RollbackStmt, ParseError>

Parse ROLLBACK statement

Source

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

Parse ALTER TABLE statement

Source

pub fn parse_savepoint_statement(&mut self) -> Result<SavepointStmt, ParseError>

Parse SAVEPOINT statement

Source

pub fn parse_rollback_to_savepoint_statement( &mut self, ) -> Result<RollbackToSavepointStmt, ParseError>

Parse ROLLBACK TO SAVEPOINT statement

Source

pub fn parse_release_savepoint_statement( &mut self, ) -> Result<ReleaseSavepointStmt, ParseError>

Parse RELEASE SAVEPOINT statement

Source

pub fn parse_create_schema_statement( &mut self, ) -> Result<CreateSchemaStmt, ParseError>

Parse CREATE SCHEMA statement

Source

pub fn parse_drop_schema_statement( &mut self, ) -> Result<DropSchemaStmt, ParseError>

Parse DROP SCHEMA statement

Source

pub fn parse_set_schema_statement( &mut self, ) -> Result<SetSchemaStmt, ParseError>

Parse SET SCHEMA statement

Source

pub fn parse_grant_statement(&mut self) -> Result<GrantStmt, ParseError>

Parse GRANT statement

Source

pub fn parse_revoke_statement(&mut self) -> Result<RevokeStmt, ParseError>

Parse REVOKE statement

Source

pub fn parse_create_role_statement( &mut self, ) -> Result<CreateRoleStmt, ParseError>

Parse CREATE ROLE statement

Source

pub fn parse_drop_role_statement(&mut self) -> Result<DropRoleStmt, ParseError>

Parse DROP ROLE statement

Source

pub fn parse_create_domain_statement( &mut self, ) -> Result<CreateDomainStmt, ParseError>

Parse CREATE DOMAIN statement (uses full implementation from domain module)

Source

pub fn parse_drop_domain_statement( &mut self, ) -> Result<DropDomainStmt, ParseError>

Parse DROP DOMAIN statement (uses full implementation from domain module)

Source

pub fn parse_create_sequence_statement( &mut self, ) -> Result<CreateSequenceStmt, ParseError>

Parse CREATE SEQUENCE statement

Source

pub fn parse_drop_sequence_statement( &mut self, ) -> Result<DropSequenceStmt, ParseError>

Parse DROP SEQUENCE statement

Source

pub fn parse_alter_sequence_statement( &mut self, ) -> Result<AlterSequenceStmt, ParseError>

Parse ALTER SEQUENCE statement

Source

pub fn parse_create_type_statement( &mut self, ) -> Result<CreateTypeStmt, ParseError>

Parse CREATE TYPE statement

Source

pub fn parse_set_transaction_statement( &mut self, ) -> Result<SetTransactionStmt, ParseError>

Parse SET TRANSACTION statement

Source

pub fn parse_drop_type_statement(&mut self) -> Result<DropTypeStmt, ParseError>

Parse DROP TYPE statement

Source

pub fn parse_create_collation_statement( &mut self, ) -> Result<CreateCollationStmt, ParseError>

Parse CREATE COLLATION statement

Source

pub fn parse_drop_collation_statement( &mut self, ) -> Result<DropCollationStmt, ParseError>

Parse DROP COLLATION statement

Source

pub fn parse_create_character_set_statement( &mut self, ) -> Result<CreateCharacterSetStmt, ParseError>

Parse CREATE CHARACTER SET statement

Source

pub fn parse_drop_character_set_statement( &mut self, ) -> Result<DropCharacterSetStmt, ParseError>

Parse DROP CHARACTER SET statement

Source

pub fn parse_create_translation_statement( &mut self, ) -> Result<CreateTranslationStmt, ParseError>

Parse CREATE TRANSLATION statement

Source

pub fn parse_drop_translation_statement( &mut self, ) -> Result<DropTranslationStmt, ParseError>

Parse DROP TRANSLATION statement

Source

pub fn parse_create_assertion_statement( &mut self, ) -> Result<CreateAssertionStmt, ParseError>

Parse CREATE ASSERTION statement

Source

pub fn parse_drop_assertion_statement( &mut self, ) -> Result<DropAssertionStmt, ParseError>

Parse DROP ASSERTION statement

Source

pub fn parse_create_procedure_statement( &mut self, ) -> Result<CreateProcedureStmt, ParseError>

Parse CREATE PROCEDURE statement

Source

pub fn parse_drop_procedure_statement( &mut self, ) -> Result<DropProcedureStmt, ParseError>

Parse DROP PROCEDURE statement

Source

pub fn parse_create_function_statement( &mut self, ) -> Result<CreateFunctionStmt, ParseError>

Parse CREATE FUNCTION statement

Source

pub fn parse_drop_function_statement( &mut self, ) -> Result<DropFunctionStmt, ParseError>

Parse DROP FUNCTION statement

Source

pub fn parse_call_statement(&mut self) -> Result<CallStmt, ParseError>

Parse CALL statement

Auto Trait Implementations§

§

impl Freeze for Parser

§

impl RefUnwindSafe for Parser

§

impl Send for Parser

§

impl Sync for Parser

§

impl Unpin for Parser

§

impl UnwindSafe for Parser

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.