tss-rust
Generated node type enums and metadata from tree-sitter-rust.
Usage
[]
= "0.1"
= "0.24"
= "0.24"
use NodeType;
use FromStr;
let node_type = from_str?;
assert_eq!;
assert_eq!;
Features
Default includes all metadata:
= "0.1"
Select specific metadata:
= { = "0.1", = false, = ["meta_named", "meta_fields"] }
Available metadata features:
meta_named- whether nodes are named in the grammarmeta_subtypes- possible subtypes for each nodemeta_fields- named fields nodes can havemeta_children- anonymous children nodes can havemeta_extra- extra node markersmeta_root- root node markers
How It Works
At build time, each language reads the corresponding tree-sitter-* language crate's NODE_TYPES constant and generates:
- A
NodeTypeenum with all 280 node types FromStrfor parsing node type stringsDisplayfor converting back to strings- Documentation linking to language reference (best effort, not comprehensive)
This allows a crate to ship this information as an enum type with zero runtime dependencies. All generation happens at compile time. This is useful for type safety (rather than checking for strings, as well as hopefully to demystify how tree-sitter languages work.
Licensing
MIT licensed - see LICENSE for details.