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_errorbut immediately returns the error. - syntax_
error - Macro to create an parser error.
Enums§
- Parse
Error - 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 underParserSettings::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), underParserSettings::STORED_TEXT— the storage wire contract’s parser profile. The whole ofinputmust be consumed, for the reasonexpr_for_definitiondocuments. - 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 underParserSettings::STORED_TEXT— the storage wire contract’s parser profile — unlikeidiom, which parses fresh input. The whole ofinputmust be consumed, for the reasonexpr_for_definitiondocuments. - 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 underParserSettings::STORED_TEXT— the storage wire contract’s parser profile — unlikekind, which parses fresh input. The whole ofinputmust be consumed, for the reasonexpr_for_definitiondocuments. - parse
- Parses a SurrealQL query with every optional grammar enabled.
- parse_
with - Runs
fagainst a parser overinputusing the default settings. - parse_
with_ settings - Runs
fagainst a parser overinputusing the given settings. - record_
id - Parse a record id.
- value
- Parses a SurrealQL
PublicValueand parses values within strings. - value_
legacy_ strand - Parses a SurrealQL
PublicValueand parses values within strings.