pub struct Parser<'a> { /* private fields */ }
Expand description
The SurrealQL parser.
Implementations§
Source§impl Parser<'_>
impl Parser<'_>
Sourcepub async fn parse_value_table(&mut self, ctx: &mut Stk) -> ParseResult<Value>
pub async fn parse_value_table(&mut self, ctx: &mut Stk) -> ParseResult<Value>
Parsers a generic value.
A generic loose ident like foo
in for example foo.bar
can be two different values
depending on context: a table or a field the current document. This function parses loose
idents as a table, see [parse_value_field
] for parsing loose idents as fields
Source§impl Parser<'_>
impl Parser<'_>
Sourcepub async fn parse_plain_idiom(&mut self, ctx: &mut Stk) -> ParseResult<Idiom>
pub async fn parse_plain_idiom(&mut self, ctx: &mut Stk) -> ParseResult<Idiom>
Parse a idiom which can only start with a graph or an identifier. Other expressions are not allowed as start of this idiom
Source§impl Parser<'_>
impl Parser<'_>
pub async fn parse_json(&mut self, ctx: &mut Stk) -> ParseResult<Value>
Source§impl Parser<'_>
impl Parser<'_>
Sourcepub async fn parse_block(
&mut self,
ctx: &mut Stk,
start: Span,
) -> ParseResult<Block>
pub async fn parse_block( &mut self, ctx: &mut Stk, start: Span, ) -> ParseResult<Block>
Parses a block of statements
§Parser State
Expects the starting {
to have already been eaten and its span to be handed to this
functions as the start
parameter.
Source§impl Parser<'_>
impl Parser<'_>
pub async fn parse_full_subquery( &mut self, ctx: &mut Stk, ) -> ParseResult<Subquery>
Source§impl Parser<'_>
impl Parser<'_>
pub fn parse_define_database(&mut self) -> ParseResult<DefineDatabaseStatement>
pub async fn parse_define_function( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineFunctionStatement>
pub fn parse_define_user(&mut self) -> ParseResult<DefineUserStatement>
pub async fn parse_define_access( &mut self, stk: &mut Stk, ) -> ParseResult<DefineAccessStatement>
pub fn parse_define_token(&mut self) -> ParseResult<DefineAccessStatement>
pub async fn parse_define_scope( &mut self, stk: &mut Stk, ) -> ParseResult<DefineAccessStatement>
pub async fn parse_define_param( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineParamStatement>
pub async fn parse_define_table( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineTableStatement>
pub async fn parse_define_event( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineEventStatement>
pub async fn parse_define_field( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineFieldStatement>
pub async fn parse_define_index( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineIndexStatement>
pub fn parse_define_analyzer(&mut self) -> ParseResult<DefineAnalyzerStatement>
pub fn parse_define_config(&mut self) -> ParseResult<DefineConfigStatement>
pub fn parse_relation_schema(&mut self) -> ParseResult<Relation>
pub fn parse_tables(&mut self) -> ParseResult<Kind>
pub fn parse_jwt(&mut self) -> ParseResult<JwtAccess>
Source§impl Parser<'_>
impl Parser<'_>
Sourcepub async fn try_parse_data(
&mut self,
ctx: &mut Stk,
) -> ParseResult<Option<Data>>
pub async fn try_parse_data( &mut self, ctx: &mut Stk, ) -> ParseResult<Option<Data>>
Parses a data production if the next token is a data keyword. Otherwise returns None
Sourcepub async fn try_parse_output(
&mut self,
ctx: &mut Stk,
) -> ParseResult<Option<Output>>
pub async fn try_parse_output( &mut self, ctx: &mut Stk, ) -> ParseResult<Option<Output>>
Parses a statement output if the next token is return
.
Sourcepub fn try_parse_timeout(&mut self) -> ParseResult<Option<Timeout>>
pub fn try_parse_timeout(&mut self) -> ParseResult<Option<Timeout>>
Parses a statement timeout if the next token is TIMEOUT
.
pub async fn try_parse_fetch( &mut self, ctx: &mut Stk, ) -> ParseResult<Option<Fetchs>>
pub async fn try_parse_param_or_idiom_or_fields( &mut self, ctx: &mut Stk, ) -> ParseResult<Vec<Fetch>>
pub async fn try_parse_condition( &mut self, ctx: &mut Stk, ) -> ParseResult<Option<Cond>>
pub async fn try_parse_group( &mut self, ctx: &mut Stk, fields: &Fields, fields_span: Span, ) -> ParseResult<Option<Groups>>
Sourcepub async fn parse_permission(
&mut self,
stk: &mut Stk,
field: bool,
) -> ParseResult<Permissions>
pub async fn parse_permission( &mut self, stk: &mut Stk, field: bool, ) -> ParseResult<Permissions>
Parse a permissions production
§Parser State
Expects the parser to have just eaten the PERMISSIONS
keyword.
Sourcepub async fn parse_specific_permission(
&mut self,
stk: &mut Stk,
permissions: &mut Permissions,
field: bool,
) -> ParseResult<()>
pub async fn parse_specific_permission( &mut self, stk: &mut Stk, permissions: &mut Permissions, field: bool, ) -> ParseResult<()>
Parse a specific permission for a type of query
Sets the permission for a specific query on the given permission keyword.
§Parser State
Expects the parser to just have eaten the FOR
keyword.
Sourcepub async fn parse_permission_value(
&mut self,
stk: &mut Stk,
) -> ParseResult<Permission>
pub async fn parse_permission_value( &mut self, stk: &mut Stk, ) -> ParseResult<Permission>
Parses a the value for a permission for a type of query
§Parser State
Expects the parser to just have eaten either SELECT
, CREATE
, UPDATE
or DELETE
.
Sourcepub fn parse_base(&mut self, scope_allowed: bool) -> ParseResult<Base>
pub fn parse_base(&mut self, scope_allowed: bool) -> ParseResult<Base>
Parses a base
So either NAMESPACE
, DATABASE
, ROOT
, or SCOPE
if scope_allowed
is true.
§Parser state
Expects the next keyword to be a base.
Sourcepub fn parse_changefeed(&mut self) -> ParseResult<ChangeFeed>
pub fn parse_changefeed(&mut self) -> ParseResult<ChangeFeed>
Parses a changefeed production
§Parser State
Expects the parser to have already eating the CHANGEFEED
keyword
Sourcepub async fn parse_reference(&mut self, ctx: &mut Stk) -> ParseResult<Reference>
pub async fn parse_reference(&mut self, ctx: &mut Stk) -> ParseResult<Reference>
Sourcepub async fn parse_view(&mut self, stk: &mut Stk) -> ParseResult<View>
pub async fn parse_view(&mut self, stk: &mut Stk) -> ParseResult<View>
Parses a view production
§Parse State
Expects the parser to have already eaten the possible (
if the view was wrapped in
parens. Expects the next keyword to be SELECT
.
pub fn parse_distance(&mut self) -> ParseResult<Distance>
pub fn parse_vector_type(&mut self) -> ParseResult<VectorType>
pub fn parse_custom_function_name(&mut self) -> ParseResult<Ident>
Source§impl Parser<'_>
impl Parser<'_>
pub async fn parse_relate_stmt( &mut self, stk: &mut Stk, ) -> ParseResult<RelateStatement>
pub async fn parse_relation( &mut self, stk: &mut Stk, ) -> ParseResult<(Value, Value, Value)>
pub async fn parse_relate_kind(&mut self, ctx: &mut Stk) -> ParseResult<Value>
pub async fn parse_relate_value(&mut self, ctx: &mut Stk) -> ParseResult<Value>
pub async fn parse_thing_or_table( &mut self, ctx: &mut Stk, ) -> ParseResult<Value>
Source§impl Parser<'_>
impl Parser<'_>
pub async fn parse_remove_stmt( &mut self, ctx: &mut Stk, ) -> ParseResult<RemoveStatement>
Source§impl Parser<'_>
impl Parser<'_>
pub async fn parse_update_stmt( &mut self, stk: &mut Stk, ) -> ParseResult<UpdateStatement>
Source§impl Parser<'_>
impl Parser<'_>
pub async fn parse_upsert_stmt( &mut self, stk: &mut Stk, ) -> ParseResult<UpsertStatement>
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn new_with_settings(source: &'a [u8], settings: ParserSettings) -> Self
pub fn new_with_settings(source: &'a [u8], settings: ParserSettings) -> Self
Create a new parser from a give source.
pub fn with_settings(self, settings: ParserSettings) -> Self
Sourcepub fn next(&mut self) -> Token
pub fn next(&mut self) -> Token
Returns the next token and advance the parser one token forward.
Sourcepub fn next_whitespace(&mut self) -> Token
pub fn next_whitespace(&mut self) -> Token
Returns the next token and advance the parser one token forward.
This function is like next but returns whitespace tokens which are normally skipped
Sourcepub fn has_peek(&self) -> bool
pub fn has_peek(&self) -> bool
Returns if there is a token in the token buffer, meaning that a token was peeked.
Sourcepub fn pop_peek(&mut self) -> Token
pub fn pop_peek(&mut self) -> Token
Consume the current peeked value and advance the parser one token forward.
Should only be called after peeking a value.
Sourcepub fn peek_whitespace(&mut self) -> Token
pub fn peek_whitespace(&mut self) -> Token
Returns the next token without consuming it.
This function is like peek but returns whitespace tokens which are normally skipped Does not undo tokens skipped in a previous normal peek.
Sourcepub fn peek_kind(&mut self) -> TokenKind
pub fn peek_kind(&mut self) -> TokenKind
Return the token kind of the next token without consuming it.
pub fn peek1(&mut self) -> Token
Sourcepub fn peek_whitespace_token_at(&mut self, at: u8) -> Token
pub fn peek_whitespace_token_at(&mut self, at: u8) -> Token
Returns the next n’th token without consuming it.
peek_token_at(0)
is equivalent to peek
.
pub fn peek_whitespace1(&mut self) -> Token
Sourcepub fn recent_span(&mut self) -> Span
pub fn recent_span(&mut self) -> Span
Returns the span of the next token if it was already peeked, otherwise returns the token of the last consumed token.
pub fn assert_finished(&mut self) -> ParseResult<()>
Sourcepub fn eat(&mut self, token: TokenKind) -> bool
pub fn eat(&mut self, token: TokenKind) -> bool
Eat the next token if it is of the given kind. Returns whether a token was eaten.
Sourcepub fn eat_whitespace(&mut self, token: TokenKind) -> bool
pub fn eat_whitespace(&mut self, token: TokenKind) -> bool
Eat the next token if it is of the given kind. Returns whether a token was eaten.
Unlike Parser::eat
this doesn’t skip whitespace tokens
Sourcepub fn backup_after(&mut self, span: Span)
pub fn backup_after(&mut self, span: Span)
Recover the parser state to after a given span.
Sourcepub async fn parse_query(&mut self, ctx: &mut Stk) -> ParseResult<Query>
pub async fn parse_query(&mut self, ctx: &mut Stk) -> ParseResult<Query>
Parse a full query.
This is the primary entry point of the parser.
Sourcepub async fn parse_statement(&mut self, ctx: &mut Stk) -> ParseResult<Statement>
pub async fn parse_statement(&mut self, ctx: &mut Stk) -> ParseResult<Statement>
Parse a single statement.
Auto Trait Implementations§
impl<'a> Freeze for Parser<'a>
impl<'a> RefUnwindSafe for Parser<'a>
impl<'a> Send for Parser<'a>
impl<'a> Sync for Parser<'a>
impl<'a> Unpin for Parser<'a>
impl<'a> UnwindSafe for Parser<'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
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 more