Rizin
unix-like reverse engineering framework and cli tools
|
title: Contributing
Contributors to Tree-sitter should abide by the Contributor Covenant.
To make changes to Tree-sitter, you should have:
grammar.js
files.Clone the repository:
Optionally, build the WASM library. If you skip this step, then the tree-sitter playground
command will require an internet connection. If you have emscripten installed, this will use your emcc
compiler. Otherwise, it will use Docker:
Build the Rust libraries and the CLI:
This will create the tree-sitter
CLI executable in the target/release
folder.
Before you can run the tests, you need to clone some grammars that are used for testing:
To test any changes you've made to the CLI, you can regenerate these parsers using your current CLI code:
Then you can run the tests:
Similarly, to test the WASM binding, you need to compile these parsers to WASM:
The test script has a number of useful flags. You can list them all by running script/test -h
. Here are some of the main flags:
If you want to run a specific unit test, pass its name (or part of its name) as an argument:
You can run the tests under the debugger (either lldb
or gdb
) using the -g
flag:
Part of the Tree-sitter test suite involves parsing the corpus tests for several different languages and performing randomized edits to each example in the corpus. If you just want to run the tests for a particular language, you can pass the -l
flag. And if you want to run a particular example from the corpus, you can pass the -e
flag:
The main tree-sitter/tree-sitter
repository contains the source code for several packages that are published to package registries for different languages:
tree-sitter
- A Rust binding to the core librarytree-sitter-highlight
- The syntax-highlighting librarytree-sitter-cli
- The command-line toolweb-tree-sitter
- A WASM-based JavaScript binding to the core librarytree-sitter-cli
- The command-line toolThere are also several other dependent repositories that contain other published packages:
tree-sitter/node-tree-sitter
- Node.js bindings to the core library, published as tree-sitter
on npmjs.comtree-sitter/py-tree-sitter
- Python bindings to the core library, published as tree-sitter
on PyPI.org.Publishing a new release of the CLI requires these steps:
This will determine the current version, increment the patch version number, and update the Cargo.toml
and package.json
files for the Rust and Node CLI packages. It will then create a commit and a tag for the new version. For more information about the arguments that are allowed, see the documentation for the npm version
command.
tree-sitter-cli
works by downloading the appropriate binary from the corresponding GitHub release during installation. So it's best not to publish the npm package until the binaries are uploaded.