Skip to main content

Crate treesitter_types

Crate treesitter_types 

Source
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:

  1. Pre-generated crates — ready-made crates for popular languages (e.g. treesitter-types-python, treesitter-types-rust).
  2. Proc-macro — use treesitter-types-macros to generate types at compile time from your own node-types.json.
  3. CLI / library — call codegen::generate or codegen::generate_to_string directly.

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;

Modules§

codegen
runtime