Expand description
Core library for generating strongly-typed Rust AST types from Tree-sitter grammars.
This crate reads a tree-sitter node-types.json file and generates Rust structs and enums
that map one-to-one to the grammar’s node types. It also provides the runtime traits
(FromNode, LeafNode, Spanned) needed to convert tree_sitter::Node values into
those typed representations.
§Usage
There are three ways to use the generated types:
- Pre-generated crates — ready-made crates for popular languages (e.g.
treesitter-types-python,treesitter-types-rust). - Proc-macro — use
treesitter-types-macrosto generate types at compile time from your ownnode-types.json. - CLI / library — call
codegen::generateorcodegen::generate_to_stringdirectly.
Re-exports§
pub use runtime::FromNode;pub use runtime::LeafNode;pub use runtime::ParseError;pub use runtime::Span;pub use runtime::Spanned;pub use tree_sitter;