Skip to main content

treesitter_types/
lib.rs

1//! Core library for generating strongly-typed Rust AST types from
2//! [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) grammars.
3//!
4//! This crate reads a tree-sitter `node-types.json` file and generates Rust structs and enums
5//! that map one-to-one to the grammar's node types. It also provides the runtime traits
6//! ([`FromNode`], [`LeafNode`], [`Spanned`]) needed to convert `tree_sitter::Node` values into
7//! those typed representations.
8//!
9//! # Usage
10//!
11//! There are three ways to use the generated types:
12//!
13//! 1. **Pre-generated crates** — ready-made crates for popular languages (e.g.
14//!    [`treesitter-types-python`](https://docs.rs/treesitter-types-python),
15//!    [`treesitter-types-rust`](https://docs.rs/treesitter-types-rust)).
16//! 2. **Proc-macro** — use [`treesitter-types-macros`](https://docs.rs/treesitter-types-macros)
17//!    to generate types at compile time from your own `node-types.json`.
18//! 3. **CLI / library** — call [`codegen::generate`] or [`codegen::generate_to_string`] directly.
19
20pub mod codegen;
21pub mod runtime;
22
23pub use runtime::{FromNode, LeafNode, ParseError, Span, Spanned};
24pub use tree_sitter;