Expand description
surql-parser — Standalone SurrealQL parser extracted from SurrealDB.
Provides a complete SurrealQL parser without depending on the SurrealDB engine. Useful for building tools, linters, formatters, IDE extensions, and migration systems.
§Quick Start
let ast = surql_parser::parse("SELECT name, age FROM user WHERE age > 18").unwrap();
assert!(!ast.expressions.is_empty());§Sync with SurrealDB
Parser source is auto-extracted from SurrealDB via tools/transform/.
See UPSTREAM_SYNC.md for details.
Re-exports§
pub use error::Error;pub use error::Result;pub use keywords::all_keywords;pub use upstream::sql::Ast;pub use upstream::sql::expression::Expr;pub use upstream::syn::ParserSettings;pub use upstream::sql::Kind;pub use upstream::sql::Idiom;pub use upstream::sql::statements;pub use upstream::syn::error as syntax_error;pub use recovery::parse_with_recovery;pub use schema_graph::DependencyNode;pub use schema_graph::SchemaGraph;pub use filesystem::*;pub use params::*;pub use schema_lookup::*;
Modules§
- builtins_
generated - compat
- Compatibility stubs for types referenced by the upstream parser code.
- config
- Configuration constants for the parser.
- diff
- Schema diffing — compare two SchemaGraphs and report structural changes.
- doc_
urls - Auto-generated documentation URL mapping for SurrealQL. Generated from docs.surrealdb.com content on 2026-03-23.
- error
- Custom error types for the surql-parser public API.
- filesystem
- formatting
- Configurable SurrealQL formatter.
- keywords
- lint
- SurrealQL linter — static analysis for common schema issues.
- params
- recovery
- Error-recovering parser — parses valid statements even when some are broken.
- schema_
graph - Schema graph — semantic model built from SurrealQL definitions.
- schema_
lookup - upstream
- Auto-generated from SurrealDB source. DO NOT EDIT MANUALLY.
Structs§
- Parse
Diagnostic - A parse diagnostic with source location.
- Schema
Definitions
Functions§
- builtin_
function - Look up a built-in SurrealQL function by its full name (e.g.,
"string::len"). - builtins_
in_ namespace - Return all built-in functions in a given namespace (e.g.,
"string"returns allstring::*). - extract_
definitions - Extract all DEFINE statements from a SurrealQL string.
- extract_
definitions_ from_ ast - Extract definitions from pre-parsed statements (e.g., from error-recovering parser).
- format
- Format an AST back to SurrealQL string.
- is_
reserved_ keyword - Check if a string could be a reserved keyword in certain contexts.
- list_
functions - List all function names defined in a SurrealQL string.
- list_
tables - List all table names defined in a SurrealQL string.
- parse
- Parse a SurrealQL query string into an AST.
- parse_
for_ diagnostics - Parse SurrealQL and return structured diagnostics on error.
- parse_
kind - Parse a SurrealQL type annotation (e.g.,
record<user>,option<string>). - parse_
with_ settings - Parse a SurrealQL query with custom parser settings.