Struct Parser

Source
pub struct Parser<'a> { /* private fields */ }
Expand description

The SurrealQL parser.

Implementations§

Source§

impl Parser<'_>

Source

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<'_>

Source

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<'_>

Source

pub async fn parse_json(&mut self, ctx: &mut Stk) -> ParseResult<Value>

Source§

impl Parser<'_>

Source

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<'_>

Source

pub async fn parse_full_subquery( &mut self, ctx: &mut Stk, ) -> ParseResult<Subquery>

Source§

impl Parser<'_>

Source

pub fn parse_define_database(&mut self) -> ParseResult<DefineDatabaseStatement>

Source

pub async fn parse_define_function( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineFunctionStatement>

Source

pub fn parse_define_user(&mut self) -> ParseResult<DefineUserStatement>

Source

pub async fn parse_define_access( &mut self, stk: &mut Stk, ) -> ParseResult<DefineAccessStatement>

Source

pub fn parse_define_token(&mut self) -> ParseResult<DefineAccessStatement>

Source

pub async fn parse_define_scope( &mut self, stk: &mut Stk, ) -> ParseResult<DefineAccessStatement>

Source

pub async fn parse_define_param( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineParamStatement>

Source

pub async fn parse_define_table( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineTableStatement>

Source

pub async fn parse_define_event( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineEventStatement>

Source

pub async fn parse_define_field( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineFieldStatement>

Source

pub async fn parse_define_index( &mut self, ctx: &mut Stk, ) -> ParseResult<DefineIndexStatement>

Source

pub fn parse_define_analyzer(&mut self) -> ParseResult<DefineAnalyzerStatement>

Source

pub fn parse_define_config(&mut self) -> ParseResult<DefineConfigStatement>

Source

pub fn parse_relation_schema(&mut self) -> ParseResult<Relation>

Source

pub fn parse_tables(&mut self) -> ParseResult<Kind>

Source

pub fn parse_jwt(&mut self) -> ParseResult<JwtAccess>

Source§

impl Parser<'_>

Source

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

Source

pub async fn try_parse_output( &mut self, ctx: &mut Stk, ) -> ParseResult<Option<Output>>

Parses a statement output if the next token is return.

Source

pub fn try_parse_timeout(&mut self) -> ParseResult<Option<Timeout>>

Parses a statement timeout if the next token is TIMEOUT.

Source

pub async fn try_parse_fetch( &mut self, ctx: &mut Stk, ) -> ParseResult<Option<Fetchs>>

Source

pub async fn try_parse_param_or_idiom_or_fields( &mut self, ctx: &mut Stk, ) -> ParseResult<Vec<Fetch>>

Source

pub async fn try_parse_condition( &mut self, ctx: &mut Stk, ) -> ParseResult<Option<Cond>>

Source

pub async fn try_parse_group( &mut self, ctx: &mut Stk, fields: &Fields, fields_span: Span, ) -> ParseResult<Option<Groups>>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn parse_changefeed(&mut self) -> ParseResult<ChangeFeed>

Parses a changefeed production

§Parser State

Expects the parser to have already eating the CHANGEFEED keyword

Source

pub async fn parse_reference(&mut self, ctx: &mut Stk) -> ParseResult<Reference>

Parses a reference

§Parser State

Expects the parser to have already eating the REFERENCE keyword

Source

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.

Source

pub fn parse_distance(&mut self) -> ParseResult<Distance>

Source

pub fn parse_vector_type(&mut self) -> ParseResult<VectorType>

Source

pub fn parse_custom_function_name(&mut self) -> ParseResult<Ident>

Source§

impl Parser<'_>

Source

pub async fn parse_relate_stmt( &mut self, stk: &mut Stk, ) -> ParseResult<RelateStatement>

Source

pub async fn parse_relation( &mut self, stk: &mut Stk, ) -> ParseResult<(Value, Value, Value)>

Source

pub async fn parse_relate_kind(&mut self, ctx: &mut Stk) -> ParseResult<Value>

Source

pub async fn parse_relate_value(&mut self, ctx: &mut Stk) -> ParseResult<Value>

Source

pub async fn parse_thing_or_table( &mut self, ctx: &mut Stk, ) -> ParseResult<Value>

Source§

impl Parser<'_>

Source

pub async fn parse_remove_stmt( &mut self, ctx: &mut Stk, ) -> ParseResult<RemoveStatement>

Source§

impl Parser<'_>

Source

pub async fn parse_update_stmt( &mut self, stk: &mut Stk, ) -> ParseResult<UpdateStatement>

Source§

impl Parser<'_>

Source

pub async fn parse_upsert_stmt( &mut self, stk: &mut Stk, ) -> ParseResult<UpsertStatement>

Source§

impl<'a> Parser<'a>

Source

pub fn new(source: &'a [u8]) -> Self

Create a new parser from a give source.

Source

pub fn new_with_settings(source: &'a [u8], settings: ParserSettings) -> Self

Create a new parser from a give source.

Source

pub fn with_settings(self, settings: ParserSettings) -> Self

Source

pub fn next(&mut self) -> Token

Returns the next token and advance the parser one token forward.

Source

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

Source

pub fn has_peek(&self) -> bool

Returns if there is a token in the token buffer, meaning that a token was peeked.

Source

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.

Source

pub fn peek(&mut self) -> Token

Returns the next token without consuming it.

Source

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.

Source

pub fn peek_kind(&mut self) -> TokenKind

Return the token kind of the next token without consuming it.

Source

pub fn peek1(&mut self) -> Token

Source

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.

Source

pub fn peek_whitespace1(&mut self) -> Token

Source

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.

Source

pub fn last_span(&mut self) -> Span

returns the token of the last consumed token.

Source

pub fn assert_finished(&mut self) -> ParseResult<()>

Source

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.

Source

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

Source

pub fn backup_after(&mut self, span: Span)

Recover the parser state to after a given span.

Source

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.

Source

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> 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> Instrument for T

Source§

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

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool

Source§

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

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> ParallelSend for T
where T: Send,