Skip to main content

Crate surrealdb_syn

Crate surrealdb_syn 

Source
Expand description

The SurrealQL lexer and parser: text in, surrealdb_sql AST out.

§Layer

This crate sits directly above the AST and below the engine. It parses against an explicit ParserSettings and knows nothing about capabilities or datastore configuration; surrealdb-core derives the settings from those and keeps the syn::parse* entry points callers use.

It owns ParseError, the failure a caller sees when a query does not parse. The engine raises it unchanged rather than restating it, so the common::LeafError impl here is what decides its public form.

§Stability

This crate is an internal implementation detail of SurrealDB with no stability guarantee. It is scheduled for deletion once the greenfield parser reaches parity and takes over the same layer, so its API surface should not grow. Depend on surrealdb or surrealdb-core instead.

Unstable!

This crate is SurrealDB internal API. It does not adhere to SemVer and its API is free to change and break code even between patch versions. If you are looking for a stable interface to the SurrealDB library please have a look at the Rust SDK.

Re-exports§

pub use self::config::ParserConfig;
pub use self::error::RenderedError;
pub use self::parser::ParseResult;
pub use self::parser::Parser;
pub use self::parser::ParserSettings;

Modules§

config
The parser’s configurable depth limits.
error
lexer
parser
Module implementing the SurrealQL parser.
token
Module specifying the token representation of the parser.

Macros§

bail
Similar to syntax_error but immediately returns the error.
syntax_error
Macro to create an parser error.

Enums§

ParseError
Why a parse did not produce an AST.

Functions§

block
Re-parses the canonical block text a catalog definition stores, for example a stored function body. Expects the input wrapped in {}.
block_for_definition
Re-parses canonical { ... } block text this engine previously rendered: Block’s own text-on-the-wire encoding and the stored function-body text (StoredFunctionDefinition.block). Both are engine-authored, so this parses under ParserSettings::STORED_TEXT — the storage wire contract’s parser profile — and requires the whole input to be consumed. Expects the input to be wrapped in {}.
block_with_settings
Parses a { ... } block under caller-chosen limits.
could_be_reserved_keyword
Takes a string and returns if it could be a reserved keyword in certain contexts.
datetime
Parse a datetime without enclosing delimiters from a string.
duration
Parse a duration from a string.
expr
Parses a single SurrealQL expression with every optional grammar enabled.
expr_for_definition
Re-parses the canonical SurrealQL text a catalog definition stores for one of its expression fields (e.g. StoredFieldDefinition.value, Permission::Specific).
expr_legacy_strand
Parses a SurrealQL expression, also parsing values found inside strings.
fields_for_definition
Re-parses the canonical SELECT-clause field-list text a catalog definition stores for one of its field-selection clauses (e.g. StoredSubscriptionDefinition.fields), under ParserSettings::STORED_TEXT — the storage wire contract’s parser profile. The whole of input must be consumed, for the reason expr_for_definition documents.
idiom
Parses a SurrealQL Idiom
idiom_for_definition
Re-parses the canonical idiom-path text a catalog definition stores for one of its indexed-column fields (e.g. StoredIndexDefinition.cols). An idiom can embed arbitrary sub-expressions (a [WHERE ...] filter part, a computed bracket index), so this parses under ParserSettings::STORED_TEXT — the storage wire contract’s parser profile — unlike idiom, which parses fresh input. The whole of input must be consumed, for the reason expr_for_definition documents.
kind
Parse a kind from a string.
kind_for_definition
Re-parses the canonical kind-grammar text a catalog definition stores for one of its type-annotated fields (e.g. StoredFieldDefinition.field_kind, StoredFunctionDefinition.args/.returns). A kind can embed a <file> bucket restriction or other experimental-gated grammar, so this parses under ParserSettings::STORED_TEXT — the storage wire contract’s parser profile — unlike kind, which parses fresh input. The whole of input must be consumed, for the reason expr_for_definition documents.
parse
Parses a SurrealQL query with every optional grammar enabled.
parse_with
Runs f against a parser over input using the default settings.
parse_with_settings
Runs f against a parser over input using the given settings.
record_id
Parse a record id.
value
Parses a SurrealQL PublicValue and parses values within strings.
value_legacy_strand
Parses a SurrealQL PublicValue and parses values within strings.