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).
Crate Overview
Section titled “Crate Overview”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.
Layout
Section titled “Layout”- [
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 inexprembed statements. - [
pattern] —letandmatchpatterns; 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.
Public API Surface
Section titled “Public API Surface”Modules
Section titled “Modules”| Module | Description |
|---|---|
decl | Top-level declarations: functions, components, data models, routes, and UI. |
expr | Expression AST nodes (literals, calls, JSX, control flow). |
pattern | Patterns for let bindings and match arms. |
scalar_mapping | Scalar → Rust / TypeScript / SQLite mapping (codegen SSOT). |
span | Byte-offset source spans. |
stmt | Statement AST nodes. |
types | Surface type expressions (int, generics, function types). |
Dependency Topology
Section titled “Dependency Topology”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}Reverse Dependents (Used By)
Section titled “Reverse Dependents (Used By)”| Consumer Crate | Role |
|---|---|
vox-compiler | Direct workspace dependent |
vox-db | Direct workspace dependent |
vox-sql | Direct workspace dependent |
vox-test-harness | Direct workspace dependent |
Deep Public Symbols (Source-Anchored)
Section titled “Deep Public Symbols (Source-Anchored)”| Kind | Symbol | Signature | Source | Description |
|---|---|---|---|---|
struct | expr::Arg | pub struct Arg | crates/vox-ast/src/expr.rs#L17-L22 | Call argument: optional label (name = value) plus value expression. |
enum | expr::BinOp | pub enum BinOp | crates/vox-ast/src/expr.rs#L26-L55 | Infix operators in surface syntax (including is / isnt for reference equality). |
enum | expr::UnOp | pub enum UnOp | crates/vox-ast/src/expr.rs#L59-L64 | Unary operators |
struct | expr::MatchArm | pub struct MatchArm | crates/vox-ast/src/expr.rs#L68-L77 | A match arm: pattern [if guard] -> body |
struct | expr::JsxElement | pub struct JsxElement | crates/vox-ast/src/expr.rs#L81-L90 | A JSX element: |
struct | expr::JsxSelfClosingElement | pub struct JsxSelfClosingElement | crates/vox-ast/src/expr.rs#L94-L101 | Self-closing JSX: tag and attributes, then /> with no separate closing tag. |
struct | expr::JsxAttribute | pub struct JsxAttribute | crates/vox-ast/src/expr.rs#L105-L110 | A JSX attribute: name={expr} or name=“string” |
struct | expr::Param | pub struct Param | crates/vox-ast/src/expr.rs#L114-L123 | Parameter for functions and lambdas. |
enum | expr::StringPart | pub enum StringPart | crates/vox-ast/src/expr.rs#L127-L132 | Parts of a string interpolation. |
enum | expr::Expr | pub enum Expr | crates/vox-ast/src/expr.rs#L136 | All expression types in Vox. |
struct | expr::WorkflowVersionCall | pub struct WorkflowVersionCall | crates/vox-ast/src/expr.rs#L400-L405 | Arguments for workflow.version("change-id", min_supported, max_supported). |
fn | expr::span | pub fn span(&self) -> Span | crates/vox-ast/src/expr.rs#L409-L443 | Outermost source span for diagnostics (includes JSX and block delimiters). |
enum | pattern::Pattern | pub enum Pattern | crates/vox-ast/src/pattern.rs#L6-L21 | Pattern matching nodes for let bindings and match arms. |
fn | pattern::span | pub fn span(&self) -> Span | crates/vox-ast/src/pattern.rs#L24-L32 | — |
enum | scalar_mapping::VoxScalar | pub enum VoxScalar | crates/vox-ast/src/scalar_mapping.rs#L8-L19 | Built-in scalar type names as they appear in Vox source / HIR Named types. |
fn | scalar_mapping::parse | pub fn parse(name: &str) -> Option<Self> | crates/vox-ast/src/scalar_mapping.rs#L24-L33 | Parse a Vox scalar name; returns [None] for ADTs, Id, etc. |
fn | scalar_mapping::as_rust_type | pub fn as_rust_type(self) -> &'static str | crates/vox-ast/src/scalar_mapping.rs#L37-L45 | Rust type used in generated structs, actors, and table rows. |
fn | scalar_mapping::as_ts_primitive | pub fn as_ts_primitive(self) -> &'static str | crates/vox-ast/src/scalar_mapping.rs#L49-L56 | TypeScript primitive or keyword for JSON / client stubs (both int and float → number). |
fn | scalar_mapping::as_sqlite_affinity | pub fn as_sqlite_affinity(self) -> &'static str | crates/vox-ast/src/scalar_mapping.rs#L60-L68 | SQLite column affinity for @table generation. |
struct | span::Span | pub struct Span | crates/vox-ast/src/span.rs#L3-L6 | Source span for tracking positions in source code. |
fn | span::new | pub fn new(start: usize, end: usize) -> Self | crates/vox-ast/src/span.rs#L9-L11 | — |
fn | span::merge | pub fn merge(self, other: Span) -> Span | crates/vox-ast/src/span.rs#L13-L18 | — |
fn | span::byte_offset_to_line_col_zero_based | pub fn byte_offset_to_line_col_zero_based(text: &str, byte_index: usize) -> (u32, u32) | crates/vox-ast/src/span.rs#L26-L42 | Map 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). |
enum | stmt::Stmt | pub enum Stmt | crates/vox-ast/src/stmt.rs#L14-L59 | Statement: binding, assignment, return, or effectful expression. |
fn | stmt::span | pub fn span(&self) -> Span | crates/vox-ast/src/stmt.rs#L81-L92 | Span covering this statement for diagnostics. |
enum | types::TypeExpr | pub enum TypeExpr | crates/vox-ast/src/types.rs#L5-L28 | Type expressions in Vox source code. |
fn | types::span | pub fn span(&self) -> Span | crates/vox-ast/src/types.rs#L31-L41 | — |