tree-sitter-sql
A general, permissive SQL grammar for tree-sitter incremental parsing
Repository Health
Technical Analysis
tree-sitter-sql (published to crates.io as tree-sitter-sequel) is a general and permissive SQL grammar for the tree-sitter parsing framework. It parses SQL source into a concrete syntax tree that updates incrementally as text changes, supporting a broad range of SQL dialects rather than locking to a single vendor.
Because it is deliberately permissive, the grammar is well suited to editor tooling, linters, and code-analysis systems that need fast, error-tolerant SQL parsing across mixed dialects. It ships bindings for multiple languages, with the Rust crate available under the name tree-sitter-sequel.
What You Get
- A general-purpose tree-sitter grammar for SQL that spans multiple dialects
- Language bindings including a Rust crate (tree-sitter-sequel) and an npm package
- Highlight and query files for editor integration
- Incremental, error-tolerant parsing suited to live editing
Common Use Cases
- Syntax highlighting for SQL in tree-sitter-based editors
- Structural navigation, folding, and selection of SQL statements
- Linting, formatting, and static analysis of SQL queries
- Language-server and code-intelligence backends for SQL
Under The Hood
Architecture - The grammar is defined in grammar.js using tree-sitter’s DSL and compiled to a C parser with an external scanner. Language bindings wrap the generated parser and expose a language() entry point that consumers register with a tree-sitter runtime. Notably, generated parser files are not committed to main and are published via the gh-pages branch.
Tech Stack - The grammar definition is JavaScript; the generated parser is C. The Rust crate is published as tree-sitter-sequel, and an npm package is published under the @derekstride scope. CI builds and tests the grammar via GitHub Actions.
Code Quality - The repository has a CI workflow, published documentation via GitHub Pages, and a test corpus for parser behavior. The permissive, multi-dialect design is a deliberate maintainability trade-off documented in the README.
API Design - Usage is a single call: import the binding and pass its language object to a tree-sitter parser. Shipped queries reduce editor glue code, and the general grammar avoids per-dialect configuration.