tree-sitter-graph
tree-sitter-graph. Is a Rust library and CLI that layers a graph DSL on top of tree-sitter parse trees, turning syntax nodes into arbitrary graphs with nodes, edges, and attributes.
Blurb
Construct graphs from parsed source code. Contribute to tree-sitter/tree-sitter-graph development by creating an account on GitHub.
Summary
tree-sitter gives you fast, incremental concrete syntax trees; tree-sitter-graph adds stanzas, tree-sitter query patterns plus statements that emit graph nodes, link edges, and attach attributes. That separation lets tools map many languages through shared grammar work while encoding language-specific semantics in the graph rules (control flow, data flow, name resolution, etc.).
Typical consumers are security analyzers, linters with cross-file models, and language tooling that outgrows ad hoc AST visitors. You need comfort with tree-sitter queries and the graph DSL before committing; most application teams should depend on a finished analyzer rather than embed this directly.
Details
- Depends on: tree-sitter parsers and grammars for each language you target.
- Delivery: Rust crate with optional CLI (
cargo install --features cli tree-sitter-graph); graphs can serialize to JSON for downstream tools. - Mental model: syntax nodes (from the parse) vs graph nodes (your derived model); stanzas bridge the two.
- When to skip: one-off scripts, simple formatters, or projects where tree-sitter alone plus hand-written visitors is enough.
- Pair with: tree-sitter (parser foundation); lives under Library in the Code category.