Expand description
Abstract syntax tree for squonk.
This crate holds the dialect-agnostic SQL AST: the node vocabulary (vocab),
node types (ast), dialect data (dialect), and precedence data
(precedence). It deliberately depends on nothing in the parser, so
downstream tooling (rewriters, linters, formatters) can build on the AST
without pulling in the tokenizer/parser. To parse SQL into these nodes, depend
on the squonk crate, which re-exports this one as squonk::ast and
carries the end-to-end parse → inspect → render examples.
§Design records
The architectural decisions behind this AST — the owned tree, byte-range spans,
interned identifiers, and the canonical-shape-plus-tag policy among them — are
recorded as ADRs in the repository’s
docs/adr
directory.
§Rendering
Rendering is configured by render::RenderConfig: a mode
(canonical, fully parenthesized, or redacted) and a
spelling (source-preserving or target-dialect). The
squonk crate threads these through a render::RenderCtx over a parsed
tree; see that crate for the runnable parse → render flows.
use squonk_ast::render::{RenderConfig, RenderMode, RenderSpelling};
let config = RenderConfig::default();
assert_eq!(config.mode, RenderMode::Canonical);
assert_eq!(config.spelling, RenderSpelling::PreserveSource);Re-exports§
pub use dialect::Keyword;pub use dialect::KeywordSet;pub use dialect::RESERVED_BARE_ALIAS;pub use dialect::RESERVED_COLUMN_NAME;pub use dialect::RESERVED_FUNCTION_NAME;pub use dialect::RESERVED_TYPE_NAME;pub use dialect::lookup_keyword;pub use vocab::FoldedSymbol;pub use vocab::LineIndex;pub use vocab::Meta;pub use vocab::NodeId;pub use vocab::Resolver;pub use vocab::SourceStore;pub use vocab::Span;pub use vocab::Symbol;pub use ast::*;
Modules§
- ast
- SQL AST node types (dialect-agnostic).
- dialect
- Const dialect data shared by the parser and renderer.
- generated
- @generated by
squonk-sourcegen; do not edit by hand. Regenerate withcargo run -p squonk-sourcegen. - precedence
- One binding-power table for parsing and rendering SQL expressions and set operations.
- render
- SQL rendering: the
Rendertrait,RenderCtx/RenderConfig/RenderMode, theDisplayedwrapper, and the Tier-1 canonical renderer. - serde_
depth serde-deserialize - Deserialization recursion-depth guard, available only under the
serdefeature. Format-agnostic deserialization recursion-depth guard for the AST (serdefeature). - vocab
- Foundational AST vocabulary shared by parser, renderer, and consumers.