Use Cases
- Migration tools and schema analyzers
- Linters and formatters for
.surqlfiles - IDE extensions (Zed, VS Code) with syntax analysis
- Code generation from SurrealQL definitions
- CI validation of SurrealQL files
Quick Start
use parse;
let ast = parse.unwrap;
assert_eq!;
Parse DDL
let ast = parse.unwrap;
Parse type annotations
let kind = parse_kind.unwrap;
Extract schema definitions
let defs = extract_definitions.unwrap;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Check reserved keywords
assert!;
assert!;
CLI Tool
Testing
Validation deps (surrealdb, testcontainers) are dev-dependencies only — they don't leak to library consumers.
SurrealDB Compatibility
| surql-parser | SurrealDB | Status |
|---|---|---|
| 0.1.x | 3.x | Active |
Parser source is auto-synced from SurrealDB via an automated pipeline. See UPSTREAM_SYNC.md for details.
How It Works
The parser source code is extracted from SurrealDB using an AST-level Rust transformer (tools/transform/). This ensures 100% compatibility with SurrealDB's parser while removing engine-specific execution code.
The sync pipeline:
- Copies
syn/(lexer, parser) andsql/(AST types) from SurrealDB source - Rewrites imports via declarative rules (
mappings.toml) - Strips execution-layer code (318 impl blocks removed automatically)
- Validates compilation
License
Apache 2.0 — same as SurrealDB.