nautilus-schema
nautilus-schema is the parser, validator, formatter, and editor-analysis crate for .nautilus files.
Pipeline
- Lex source text into typed tokens with spans.
- Parse tokens into a syntax tree.
- Validate the tree into a resolved
SchemaIr. - Reuse that result for formatting and editor tooling.
Main public APIs
| API | Purpose |
|---|---|
analyze(source) |
One-shot lexer + parser + validator + diagnostics bundle |
parse_schema_source(source) |
Strict parse helper for callers that want a syntax AST and want parser recovery errors to fail fast |
parse_schema_source_with_recovery(source) |
Parse helper for tools like formatters that need the AST plus recovered parse errors |
validate_schema_source(source) |
Parse + validate helper returning both AST and SchemaIr |
validate_schema(ast) |
Produces ir::SchemaIr from an AST |
format_schema(ast, source) |
Canonical formatter |
completion, hover, goto_definition |
LSP/editor features |
semantic_tokens |
Semantic-token support for editors |
Lexer, Parser |
Lower-level building blocks for callers that need stage-by-stage access |
Supported schema constructs
datasourceandgeneratorblocksmodel,enum, andtypedeclarations- scalar, enum, composite, relation, optional, and list field types
- mapped names via
@map/@@map - defaults such as
autoincrement(),uuid(),now() - relation metadata including
fields,references, and referential actions - indexes, unique constraints, checks, and computed fields
Minimal usage
[]
= { = "nautilus-orm-schema", = "../crates/nautilus-schema" }
use analyze;
let result = analyze;
for diagnostic in &result.diagnostics
if let Some = &result.ir
If you need lower-level control:
use ;
let mut lexer = new;
let mut tokens = Vecnew;
loop
let ast = new.parse_schema?;
let ir = validate_schema?;
println!;
# Ok::
Where it is used
nautilus-clifor validate / format / DB workflowsnautilus-codegenfor generation inputsnautilus-enginefor runtime model metadatanautilus-lspfor diagnostics, completion, hover, definitions, formatting, and semantic tokens
References
- GRAMMAR.md for the language grammar
tests/for parser, validator, formatter, analysis, and IR coverage
Testing