Crate rust_sitter

Source

Re-exports§

pub use tree_sitter_runtime_c2rust as tree_sitter;

Modules§

__private
DO NOT USE THIS MODULE!
errors

Structs§

Spanned
A wrapper around a value that also contains the span of the value in the source.
WithLeaf

Traits§

Extract
Defines the logic used to convert a node in a Tree Sitter tree to the corresponding Rust type.

Attribute Macros§

delimited
On Vec<_> typed fields, specifies a non-terminal that should be parsed in between the elements. The [rust_sitter::repeat] annotation must be used on the field as well.
extra
This annotation marks a node as extra, which can safely be skipped while parsing. This is useful for handling whitespace/newlines/comments.
grammar
Mark a module to be analyzed for a Rust Sitter grammar. Takes a single, unnamed argument, which specifies the name of the grammar. This name must be unique across all Rust Sitter grammars within a compilation unit.
language
Marks the top level AST node where parsing should start.
leaf
Defines a field which matches a specific token in the source string. The token can be defined by passing one of two arguments
prec
Defines a precedence level for a non-terminal that has no associativity.
prec_left
Defines a precedence level for a non-terminal that should be left-associative. For example, with subtraction we expect 1 - 2 - 3 to be parsed as (1 - 2) - 3, which corresponds to a left-associativity.
prec_right
Defines a precedence level for a non-terminal that should be right-associative. For example, with cons we could have 1 :: 2 :: 3 to be parsed as 1 :: (2 :: 3), which corresponds to a right-associativity.
repeat
On Vec<_> typed fields, specifies additional config for how the repeated elements should be parsed. In particular, this annotation takes the following named arguments:
skip
Defines a field that does not correspond to anything in the input string, such as some metadata. Takes a single, unnamed argument, which is the value used to populate the field at runtime.