Expand description
Nautilus Schema Parser and Validator
This crate provides end-to-end processing of .nautilus schema files.
§Pipeline
Processing a schema runs in four stages:
- Lexer — converts source text into typed tokens with span tracking.
- Parser — builds a syntax
ast::Schemavia recursive descent. - Validator — performs multi-pass semantic validation and emits a fully
resolved
ir::SchemaIr. - Formatter — renders an AST back to canonical source text.
§Quick Start
The analyze function runs the full pipeline in one call and collects all
diagnostics:
ⓘ
use nautilus_schema::analyze;
let result = analyze(source);
for diag in &result.diagnostics {
eprintln!("{:?} — {}", diag.severity, diag.message);
}
if let Some(ir) = &result.ir {
println!("{} models validated", ir.models.len());
}§Visitor Pattern
The visitor module provides a trait-based visitor for flexible AST traversal:
ⓘ
use nautilus_schema::{visitor::{Visitor, walk_model}, ast::*, Result};
struct ModelCounter { count: usize }
impl Visitor for ModelCounter {
fn visit_model(&mut self, model: &ModelDecl) -> Result<()> {
self.count += 1;
walk_model(self, model)
}
}Re-exports§
pub use analysis::analyze;pub use analysis::completion;pub use analysis::completion;pub use analysis::completion_with_analysis;pub use analysis::goto_definition;pub use analysis::goto_definition;pub use analysis::goto_definition_with_analysis;pub use analysis::hover;pub use analysis::hover;pub use analysis::hover_with_analysis;pub use analysis::semantic_tokens;pub use analysis::semantic_tokens;pub use analysis::AnalysisResult;pub use analysis::CompletionItem;pub use analysis::CompletionKind;pub use analysis::HoverInfo;pub use analysis::SemanticKind;pub use analysis::SemanticToken;pub use ast::ComputedKind;pub use diagnostic::Diagnostic;pub use diagnostic::Severity;pub use formatter::format_schema;pub use parser::Parser;
Modules§
- analysis
- Top-level analysis API for
.nautilusschema files. - ast
- Abstract Syntax Tree (AST) for the nautilus schema language.
- bool_
expr - Boolean expression parser for
@checkand@@checkconstraint attributes. - diagnostic
- Diagnostic types for the analysis API.
- formatter
- Formatter: converts a
SchemaAST back to canonical.nautilussource text. - ir
- Intermediate representation (IR) of a validated schema.
- parser
- Recursive descent parser for the nautilus schema language.
- sql_
expr - Lightweight SQL expression parser for
@computedand future attribute expressions. - visitor
- Visitor pattern for traversing the AST.
Structs§
- Lexer
- Lexer for tokenizing schema source code.
- Parsed
Schema - Parsed schema plus any non-fatal parse errors recovered during parsing.
- Position
- A position in source code (line and column).
- Span
- A span in source code (byte offsets).
- Token
- A token in the schema language.
- Validated
Schema - Parsed AST together with the validated IR.
Enums§
- Schema
Error - Error type for schema operations.
- Token
Kind - Token kinds for the schema language.
Functions§
- discover_
schema_ paths - Return every
.nautilusfile directly insidedir, sorted lexicographically. - discover_
schema_ paths_ in_ current_ dir - Return every
.nautilusfile in the current working directory, sorted lexicographically. - parse_
schema_ source - Parse a schema source string strictly, failing if the parser had to recover.
- parse_
schema_ source_ with_ recovery - Parse a schema source string and return the AST plus parser recovery errors.
- resolve_
env_ url - Resolve
env(VAR_NAME)syntax in a connection URL. - validate_
schema - Validates a schema AST and produces a validated IR.
- validate_
schema_ source - Parse and validate a schema source string.
Type Aliases§
- Result
- Result type alias for schema operations.