pub struct ParseContext<'a> { /* private fields */ }Implementations§
Source§impl<'a> ParseContext<'a>
impl<'a> ParseContext<'a>
pub fn expect_identifier(&mut self) -> Result<String, ParseError>
Sourcepub fn expect_boolean_literal(&mut self) -> Result<bool, ParseError>
pub fn expect_boolean_literal(&mut self) -> Result<bool, ParseError>
Parse a boolean literal (true / false).
Unlike a fuzzy identifier comparison, any non-boolean token is reported
explicitly so that SET LOCKED = yes fails instead of silently
behaving as false.
Sourcepub fn expect_dcl_name(&mut self) -> Result<String, ParseError>
pub fn expect_dcl_name(&mut self) -> Result<String, ParseError>
Parse a DCL object name (username / space name).
Accepts identifiers, keywords, numbers, string literals and hyphenated
sequences (e.g. user-name-123, NULL, 12345, "'; DROP USER --").
pub fn expect_string_literal(&mut self) -> Result<String, ParseError>
pub fn expect_integer_literal(&mut self) -> Result<i64, ParseError>
pub fn expect_float_literal(&mut self) -> Result<f64, ParseError>
pub fn is_identifier_or_in_token(&self) -> bool
pub fn is_identifier_token(&self) -> bool
pub fn check_keyword(&mut self, keyword: &str) -> bool
Sourcepub fn check_keyword_sequence(&mut self, keywords: &[&str]) -> bool
pub fn check_keyword_sequence(&mut self, keywords: &[&str]) -> bool
Check if the next tokens match the given sequence (non-consuming)
pub fn consume_keyword(&mut self, keyword: &str) -> Result<(), ParseError>
pub fn consume_identifier(&mut self) -> Result<String, ParseError>
pub fn consume_string(&mut self) -> Result<String, ParseError>
pub fn consume_float(&mut self) -> Result<f64, ParseError>
pub fn consume_int(&mut self) -> Result<i64, ParseError>
pub fn consume_token(&mut self, token: &str) -> Result<(), ParseError>
pub fn consume_optional_token(&mut self, token: &str) -> bool
pub fn try_consume_string(&mut self) -> Option<String>
pub fn try_consume_quoted_string(&mut self) -> Option<String>
Source§impl<'a> ParseContext<'a>
impl<'a> ParseContext<'a>
pub fn new(input: &'a str) -> Self
pub fn from_string(input: String) -> Self
pub fn checkpoint(&self) -> ParseContextCheckpoint
pub fn restore(&mut self, ckpt: ParseContextCheckpoint)
pub fn set_expression_context( &mut self, expr_context: Arc<ExpressionAnalysisContext>, )
pub fn expression_context(&self) -> &Arc<ExpressionAnalysisContext> ⓘ
Sourcepub fn set_type_alias_manager(&mut self, manager: Arc<TypeAliasManager>)
pub fn set_type_alias_manager(&mut self, manager: Arc<TypeAliasManager>)
Attach the shared user-defined type-alias catalog.
Sourcepub fn resolve_named_type(&self, name: &str) -> Option<DataType>
pub fn resolve_named_type(&self, name: &str) -> Option<DataType>
Resolve a raw type name through builtin types, then user-defined
aliases. Returns None when the name denotes neither.
pub fn expression_context_clone(&self) -> Arc<ExpressionAnalysisContext> ⓘ
pub fn take_recursive_comprehension(&mut self) -> Option<RecursiveComprehension>
pub fn set_recursive_comprehension(&mut self, rc: RecursiveComprehension)
pub fn lexer(&self) -> &Lexer<'a>
pub fn lexer_mut(&mut self) -> &mut Lexer<'a>
pub fn set_compat_mode(&mut self, enabled: bool)
pub fn set_upsert_mode(&mut self, enabled: bool)
pub fn is_upsert_mode(&self) -> bool
Sourcepub fn is_edge_syntax_mode(&self) -> bool
pub fn is_edge_syntax_mode(&self) -> bool
Whether the parser is inside a DML edge statement (src -> dst)
where -> is an edge arrow rather than the JSON access operator.
Sourcepub fn with_edge_syntax_mode<T>(
&mut self,
f: impl FnOnce(&mut Self) -> Result<T, ParseError>,
) -> Result<T, ParseError>
pub fn with_edge_syntax_mode<T>( &mut self, f: impl FnOnce(&mut Self) -> Result<T, ParseError>, ) -> Result<T, ParseError>
Run f with DML edge syntax enabled, then restore the previous
mode even on error.
Sourcepub fn is_pipe_or_suppressed(&self) -> bool
pub fn is_pipe_or_suppressed(&self) -> bool
Whether | should be treated as a list-comprehension separator instead
of the bitwise-OR operator in the current parsing position.
Sourcepub fn with_pipe_or_suppression<T>(
&mut self,
value: bool,
f: impl FnOnce(&mut Self) -> Result<T, ParseError>,
) -> Result<T, ParseError>
pub fn with_pipe_or_suppression<T>( &mut self, value: bool, f: impl FnOnce(&mut Self) -> Result<T, ParseError>, ) -> Result<T, ParseError>
Run f with suppress_pipe_or forced to value, restoring the
previous setting afterwards (even on error).
pub fn enter_recursion(&mut self) -> Result<(), ParseError>
pub fn exit_recursion(&mut self)
pub fn add_error(&mut self, error: ParseError)
pub fn add_lex_error(&mut self, error: LexError)
pub fn errors(&self) -> &ParseErrors
pub fn has_errors(&self) -> bool
pub fn take_errors(&mut self) -> ParseErrors
pub fn current_position(&self) -> Position
pub fn current_span(&self) -> Span
pub fn merge_span(&self, start: Position, end: Position) -> Span
Sourcepub fn span_since(&self, start: Position) -> Span
pub fn span_since(&self, start: Position) -> Span
Span from start (usually another span’s .start) up to the current
cursor position. Replaces the end_span = ctx.current_span() /
merge_span(start, end_span.end) idiom spread across the parsers.
pub fn current_token(&self) -> &Token
pub fn next_token(&mut self)
Sourcepub fn peek_token(&mut self) -> &Token
pub fn peek_token(&mut self) -> &Token
Return the next token WITHOUT consuming it.
The lookahead is buffered in the context, so the token returned here
is the one that the next ParseContext::next_token (or
match_token / expect_token) call will consume.
pub fn match_token(&mut self, expected: TokenKind) -> bool
pub fn check_token(&self, expected: TokenKind) -> bool
pub fn expect_token(&mut self, expected: TokenKind) -> Result<(), ParseError>
pub fn is_recovery_exhausted(&self) -> bool
pub fn record_recovery(&mut self)
pub fn reset_recovery_count(&mut self)
pub fn synchronize(&mut self, scope: RecoveryScope)
pub fn try_recover( &mut self, error: ParseError, scope: RecoveryScope, ) -> Result<(), ParseError>
Sourcepub fn recover_clause<T>(
&mut self,
fallback: impl FnOnce(&mut ParseContext<'_>) -> Result<T, ParseError>,
parse: impl FnOnce(&mut ParseContext<'_>) -> Result<T, ParseError>,
) -> Result<T, ParseError>
pub fn recover_clause<T>( &mut self, fallback: impl FnOnce(&mut ParseContext<'_>) -> Result<T, ParseError>, parse: impl FnOnce(&mut ParseContext<'_>) -> Result<T, ParseError>, ) -> Result<T, ParseError>
Parse a clause body with clause-level error recovery.
On failure the error is recorded and the parser synchronizes to the
next clause boundary keyword, so the remaining clauses of the
enclosing statement are still parsed. fallback must produce a
structurally valid placeholder for the failed clause; the query is
still rejected once the collected errors are inspected by the caller.
Returns the original error, unrecorded, when the recovery limit is
reached.
pub fn consume_value(&mut self) -> Result<Value, ParseError>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ParseContext<'a>
impl<'a> !UnwindSafe for ParseContext<'a>
impl<'a> Freeze for ParseContext<'a>
impl<'a> Send for ParseContext<'a>
impl<'a> Sync for ParseContext<'a>
impl<'a> Unpin for ParseContext<'a>
impl<'a> UnsafeUnpin for ParseContext<'a>
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.