#tree-sitter #node #tree-node #store #path #lets #facade

yak-sitter

opinionated tree-sitter facade which lets you store data visible to nodes and provides other improvements

2 unstable releases

0.4.0 Apr 1, 2024
0.3.1 Apr 1, 2024
0.3.0 Jul 18, 2023

#861 in Parser implementations

Download history 9/week @ 2024-02-23 7/week @ 2024-03-01 6/week @ 2024-03-08 2/week @ 2024-03-15 288/week @ 2024-03-29 33/week @ 2024-04-05

321 downloads per month
Used in type-sitter-lib

MIT/Apache

60KB
1K SLoC

yak-sitter: opinionated tree-sitter facade which lets you store data visible to nodes and provides other improvements

Crates.io Docs.rs

This library provides an API almost identical to tree-sitter, but with the following changes:

  • Trees can optionally store Custom data of arbitrary type, which each node can access via shared reference. Typically the custom data will contain a map of nodes to additional metadata, or a diagnostic logger (assuming all diagnostics have at least one source location). Then, you won't need to pass around this extra information to functions which deal with nodes, you can retrieve it from the nodes directly.
  • Trees store their original source code, and nodes can access their text
  • Trees also store the path they were parsed from, and nodes can access this path
  • Nodes are ordered based on their location in the tree, and nodes from different trees are ordered based on their paths.
  • TreeCursor is split into LocalTreeCursor and GlobalTreeCursor. When GlobalTreeCursor is reset to a node it can still go to parents and siblings, albeit with a performance penalty. LocalTreeCursor is the original TreeCursor since its behavior a bit confusing.
  • QueryMatches is a StreamingIterator as it should be
  • All parsed text must be valid UTF-8

The library is an attempt to integrate tree-sitter with an existing project (https://github.com/Jakobeha/nominalscript), hence the name. Regardless, if you want any changes or have any suggestions, feel free to submit a github issue or PR

Dependencies

~2.8–4MB
~74K SLoC