inillucent_sql/lib.rs
1//! First-party lexer, parser, AST, binder, semantic rewrites, and logical and
2//! physical plans.
3//!
4//! Invariant: the SQL front end is pure. It parses, binds, plans and compiles;
5//! it opens no file, reads no page, and holds no connection. Everything it
6//! needs to know about a schema arrives through [`catalog_view::CatalogView`],
7//! which is a read-only view someone else has already built.
8//!
9//! That interface is why this crate sits *below* `inillucent-catalog` rather than
10//! above it. The catalog has to parse the CREATE text stored in
11//! `sqlite_schema` with this parser, and a crate cannot be both above and below
12//! another; the parser is the more fundamental half, so it goes underneath and
13//! the catalog implements the view.
14//!
15//! Module map, in the order SQL moves through them:
16//!
17//! - [`keyword`] - the pinned release's keyword table and its fallback rule;
18//! - [`lexer`] - bytes to tokens, zero copy, with spans;
19//! - [`precedence`] - the operator table, as data;
20//! - [`ast`] - the arena and every node kind;
21//! - [`diagnostic`] - syntax failures, with offsets;
22//! - [`parser`] - recursive descent for statements, Pratt for expressions;
23//! - [`catalog_view`] - what the binder is allowed to know about a schema;
24//! - [`bind`] - names to columns, and the bound relational tree;
25//! - [`plan`] - the logical and physical plans the compiler walks.
26
27#![forbid(unsafe_code)]
28#![deny(missing_docs)]
29#![deny(clippy::indexing_slicing)]
30#![deny(clippy::unwrap_used)]
31#![deny(clippy::expect_used)]
32#![deny(clippy::panic)]
33// Tests assert on exact values and are allowed to fail loudly; the bans above
34// exist to keep panics and wrapping out of paths that read caller input.
35#![cfg_attr(
36 test,
37 allow(
38 clippy::expect_used,
39 clippy::indexing_slicing,
40 clippy::panic,
41 clippy::unwrap_used
42 )
43)]
44
45pub mod ast;
46pub mod bind;
47pub mod catalog_view;
48pub mod correlated_in;
49pub mod cost;
50pub mod declare;
51pub mod diagnostic;
52pub mod directive;
53pub mod dml;
54pub mod foreign_key;
55pub mod function;
56pub mod keyword;
57pub mod lexer;
58pub mod parser;
59pub mod plan;
60pub mod pragma_register;
61pub mod precedence;
62pub mod rewrite;
63pub mod vtab;
64
65pub use ast::{Ast, Statement};
66pub use diagnostic::{ParseError, ParseErrorKind};
67pub use lexer::{Lexer, Span, Token, TokenKind};
68pub use parser::{
69 classify_statement, parse_expression, parse_next_statement, ParameterMap, ParsedStatement,
70 StatementClass,
71};
72
73/// The implementation phase that filled this crate in, as named by the TDD.
74pub const IMPLEMENTATION_PHASE: &str = "phase 5: lexer, parser, AST, and syntax parity";