Skip to content

vox-ast API Reference (generated)

Crate: vox-ast · Version: 0.6.0 · Target: Library (lib.rs)

Pure-data Vox AST: declarations, expressions, statements, patterns, type-syntax, scalar mapping, and source spans. serde-only L0 leaf extracted from vox-compiler (re-exported there as vox_compiler::ast).

Abstract syntax tree (AST) for the Vox language.

This is a standalone L0 leaf (serde-only) re-exported by vox-compiler as vox_compiler::ast, so downstream crates that only need the declaration AST (e.g. vox-db’s DDL emitter) can depend on vox-ast without pulling in the whole compiler. The parser builds these trees from tokens; the HIR phase lowers them; typeck and codegen consume HIR. The AST is lossy only where the parser chooses not to model trivia—names are not resolved: Ident and Named types carry spellings as written, and it is up to later passes to bind them to definitions.

  • [decl] — one file becomes a [decl::Module] of [decl::Decl] items (functions, tables, routes, …).
  • [expr] — expression tree inside bodies; shares [span::Span] with statements and patterns.
  • [stmt] — let / return / expression statements; blocks in expr embed statements.
  • [pattern] — let and match patterns; must align with [expr::Expr::Match] arms.
  • [types] — type syntax only (generics, fn(…) -> …); not the internal type algebra.

[crate::span] is byte offsets into the original UTF-8 source (start inclusive, end exclusive). Diagnostics and LSP use these directly; they are not grapheme- or line-aware.

See docs/src/reference/lexicon.md for naming aligned with the grammar.

ModuleDescription
declTop-level declarations: functions, components, data models, routes, and UI.
exprExpression AST nodes (literals, calls, JSX, control flow).
patternPatterns for let bindings and match arms.
scalar_mappingScalar → Rust / TypeScript / SQLite mapping (codegen SSOT).
spanByte-offset source spans.
stmtStatement AST nodes.
typesSurface type expressions (int, generics, function types).
Dependency Topology, diagram 15 nodes, 4 edges: vox-compiler → vox-ast; vox-db → vox-ast; vox-sql → vox-ast; vox-test-harness → vox-astvox-astvox-compilervox-dbvox-sqlvox-test-harness
Diagram source
graph {
direction: right
node vox_ast: "vox-ast"
node vox_compiler: "vox-compiler"
vox_compiler -> vox_ast
node vox_db: "vox-db"
vox_db -> vox_ast
node vox_sql: "vox-sql"
vox_sql -> vox_ast
node vox_test_harness: "vox-test-harness"
vox_test_harness -> vox_ast
}
Consumer CrateRole
vox-compilerDirect workspace dependent
vox-dbDirect workspace dependent
vox-sqlDirect workspace dependent
vox-test-harnessDirect workspace dependent
KindSymbolSignatureSourceDescription
structexpr::Argpub struct Argcrates/vox-ast/src/expr.rs#L17-L22Call argument: optional label (name = value) plus value expression.
enumexpr::BinOppub enum BinOpcrates/vox-ast/src/expr.rs#L26-L55Infix operators in surface syntax (including is / isnt for reference equality).
enumexpr::UnOppub enum UnOpcrates/vox-ast/src/expr.rs#L59-L64Unary operators
structexpr::MatchArmpub struct MatchArmcrates/vox-ast/src/expr.rs#L68-L77A match arm: pattern [if guard] -> body
structexpr::JsxElementpub struct JsxElementcrates/vox-ast/src/expr.rs#L81-L90A JSX element: children
structexpr::JsxSelfClosingElementpub struct JsxSelfClosingElementcrates/vox-ast/src/expr.rs#L94-L101Self-closing JSX: tag and attributes, then /> with no separate closing tag.
structexpr::JsxAttributepub struct JsxAttributecrates/vox-ast/src/expr.rs#L105-L110A JSX attribute: name={expr} or name=“string”
structexpr::Parampub struct Paramcrates/vox-ast/src/expr.rs#L114-L123Parameter for functions and lambdas.
enumexpr::StringPartpub enum StringPartcrates/vox-ast/src/expr.rs#L127-L132Parts of a string interpolation.
enumexpr::Exprpub enum Exprcrates/vox-ast/src/expr.rs#L136All expression types in Vox.
structexpr::WorkflowVersionCallpub struct WorkflowVersionCallcrates/vox-ast/src/expr.rs#L400-L405Arguments for workflow.version("change-id", min_supported, max_supported).
fnexpr::spanpub fn span(&self) -> Spancrates/vox-ast/src/expr.rs#L409-L443Outermost source span for diagnostics (includes JSX and block delimiters).
enumpattern::Patternpub enum Patterncrates/vox-ast/src/pattern.rs#L6-L21Pattern matching nodes for let bindings and match arms.
fnpattern::spanpub fn span(&self) -> Spancrates/vox-ast/src/pattern.rs#L24-L32—
enumscalar_mapping::VoxScalarpub enum VoxScalarcrates/vox-ast/src/scalar_mapping.rs#L8-L19Built-in scalar type names as they appear in Vox source / HIR Named types.
fnscalar_mapping::parsepub fn parse(name: &str) -> Option<Self>crates/vox-ast/src/scalar_mapping.rs#L24-L33Parse a Vox scalar name; returns [None] for ADTs, Id, etc.
fnscalar_mapping::as_rust_typepub fn as_rust_type(self) -> &'static strcrates/vox-ast/src/scalar_mapping.rs#L37-L45Rust type used in generated structs, actors, and table rows.
fnscalar_mapping::as_ts_primitivepub fn as_ts_primitive(self) -> &'static strcrates/vox-ast/src/scalar_mapping.rs#L49-L56TypeScript primitive or keyword for JSON / client stubs (both int and float → number).
fnscalar_mapping::as_sqlite_affinitypub fn as_sqlite_affinity(self) -> &'static strcrates/vox-ast/src/scalar_mapping.rs#L60-L68SQLite column affinity for @table generation.
structspan::Spanpub struct Spancrates/vox-ast/src/span.rs#L3-L6Source span for tracking positions in source code.
fnspan::newpub fn new(start: usize, end: usize) -> Selfcrates/vox-ast/src/span.rs#L9-L11—
fnspan::mergepub fn merge(self, other: Span) -> Spancrates/vox-ast/src/span.rs#L13-L18—
fnspan::byte_offset_to_line_col_zero_basedpub fn byte_offset_to_line_col_zero_based(text: &str, byte_index: usize) -> (u32, u32)crates/vox-ast/src/span.rs#L26-L42Map a UTF-8 byte offset into text to LSP-style 0-based line and column. Column counts Unicode scalar values on the current line (same convention as the Vox LSP before any UTF-16 code-unit adjustment).
enumstmt::Stmtpub enum Stmtcrates/vox-ast/src/stmt.rs#L14-L59Statement: binding, assignment, return, or effectful expression.
fnstmt::spanpub fn span(&self) -> Spancrates/vox-ast/src/stmt.rs#L81-L92Span covering this statement for diagnostics.
enumtypes::TypeExprpub enum TypeExprcrates/vox-ast/src/types.rs#L5-L28Type expressions in Vox source code.
fntypes::spanpub fn span(&self) -> Spancrates/vox-ast/src/types.rs#L31-L41—