Expand description
sql-dialect-fmt-formatter — the formatting half of the toolchain.
Two layers:
doc— a grammar-agnostic pretty-printing engine (aDocIR + width-aware printer) in the Wadler → Prettier → biome/ruff lineage. Depends on nothing SQL-specific.- [
sql] — the Snowflake SQL rules that lower the parser’s lossless CST intoDocs.
[format] ties them together: parse → lower → print. Like the parser, it never panics; input
it cannot model structurally is preserved verbatim, so formatting is always content-preserving.
use sql_dialect_fmt_formatter::{format, FormatOptions};
let out = format("select a,b from t", &FormatOptions::default());
assert_eq!(out, "SELECT a, b\nFROM t;\n");§Public API stability
FormatOptions is the configuration entry point and is #[non_exhaustive]: build it from
FormatOptions::default and refine it with the with_* methods so adding future knobs stays
backwards compatible.
Modules§
- doc
- A small, self-contained pretty-printing engine in the Wadler → Prettier → rome/biome → ruff
lineage. The grammar-agnostic core is a
Docintermediate representation plus a width-aware [print]er; SQL-specific rules live in [crate::sql] and only ever buildDocs.
Macros§
Structs§
- Format
Options - Options controlling formatting. Opinionated and intentionally small.
- Print
Options - Knobs for the printer. Opinionated by design: just a target width and an indent step.
Enums§
- Dialect
- The SQL dialect a lex/parse/format request targets.
- Doc
- The pretty-printer intermediate representation.