Crate rust_sitter

source ·

Re-exports§

Modules§

Structs§

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

Traits§

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

Attribute Macros§

  • 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.
  • This annotation marks a node as extra, which can safely be skipped while parsing. This is useful for handling whitespace/newlines/comments.
  • 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.
  • Marks the top level AST node where parsing should start.
  • Defines a field which matches a specific token in the source string. The token can be defined by passing one of two arguments
  • Defines a precedence level for a non-terminal that has no associativity.
  • 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.
  • 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.
  • On Vec<_> typed fields, specifies additional config for how the repeated elements should be parsed. In particular, this annotation takes the following named arguments:
  • 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.