vibesql/lib.rs
1//! # VibeSQL
2//!
3//! A SQL parser and semantic analyzer library with standard SQL type system.
4//!
5//! This library provides a complete SQL parsing and analysis pipeline that can be used
6//! as a middleware layer between transport and storage layers in database systems.
7//!
8//! ## Features
9//!
10//! - Full SQL lexer/tokenizer
11//! - Comprehensive AST representation
12//! - Expression, query, and statement parsing
13//! - Standard SQL type system (BIGINT, VARCHAR, DOUBLE PRECISION, etc.)
14//! - Semantic analysis with type checking
15//! - Extensible catalog with custom types, functions, and tables
16//! - Zero dependencies (standard library only)
17//!
18//! ## Quick Start
19//!
20//! ```rust
21//! use vibesql::{Parser, Analyzer};
22//!
23//! let sql = "SELECT id, name FROM users WHERE age > 21";
24//! let mut parser = Parser::new(sql);
25//! let ast = parser.parse().expect("Failed to parse SQL");
26//! ```
27//!
28//! ## Extensibility
29//!
30//! Use [`CatalogBuilder`] to create catalogs with custom functions and types:
31//!
32//! ```rust
33//! use vibesql::catalog::{CatalogBuilder, TypeRegistry};
34//! use vibesql::types::SqlType;
35//!
36//! let catalog = CatalogBuilder::new()
37//! .with_builtins()
38//! .add_scalar_function("MY_HASH", SqlType::Int64)
39//! .add_table("users", |t| {
40//! t.primary_key("id", SqlType::Int64)
41//! .column("name", SqlType::Varchar)
42//! .column("email", SqlType::Varchar)
43//! })
44//! .build();
45//! ```
46//!
47//! ## Type System
48//!
49//! VibeSQL uses standard SQL type names:
50//!
51//! | Type | Display Name |
52//! |------|--------------|
53//! | `SqlType::Bool` | BOOLEAN |
54//! | `SqlType::Int32` | INTEGER |
55//! | `SqlType::Int64` | BIGINT |
56//! | `SqlType::Float32` | REAL |
57//! | `SqlType::Float64` | DOUBLE PRECISION |
58//! | `SqlType::Varchar` | VARCHAR |
59//! | `SqlType::Varbinary` | VARBINARY |
60
61pub mod analyzer;
62pub mod ast;
63pub mod catalog;
64pub mod error;
65pub mod lexer;
66pub mod parser;
67pub mod types;
68
69// Re-export main types for convenience
70pub use analyzer::{AnalyzedQuery, Analyzer, AnalyzerError, OutputColumn};
71pub use ast::*;
72pub use catalog::{
73 Catalog, CatalogBuilder, ColumnSchema, FunctionSignature, MemoryCatalog, TableBuilder,
74 TableSchema, TableSchemaBuilder, TypeRegistry,
75};
76pub use error::{Error, Result};
77pub use lexer::{Lexer, Token, TokenKind};
78pub use parser::Parser;
79pub use types::{SqlType, Value};