tree-sitter/cli
Douglas Creager a29c8d9264 Move allocation tracking into lib crate
We have several test cases defined in the `cli` crate that depend on the
`lib` crate's `allocation-tracking` feature.  The implementation of the
actual allocation tracker used to live in the `cli` crate, close to the
test cases that use it.  The `allocation-tracking` feature in the `lib`
crate was just used to tell the tree-sitter implementation to expect
that the allocation tracker exists, and to use it.

That pattern meant that we had a circular dependency: `cli` depends on
`lib`, but `lib` required some code that was implemented in `cli`.
That, in turn, caused linker errors — but only when compiling in certain
configurations! [1]

This patch moves all of the allocation tracking implementation into the
`lib` crate, gated on the existing `allocation-tracking` feature, which
fixes the circular dependency.

Note that this patch does **not** fix the fact that feature unification
causes the `lib` crate to be built with the `allocation-tracking`
feature enabled, even though it's not a default.  Fixing that depends on
the forthcoming version 2 feature resolver [2], or using the `dev_dep`
workaround [3] in the meantime.

[1] https://github.com/tree-sitter/tree-sitter/issues/919
[2] https://doc.rust-lang.org/nightly/cargo/reference/features.html#feature-resolver-version-2
[3] https://github.com/tree-sitter/tree-sitter/issues/919#issuecomment-777107086
2021-02-23 09:16:37 -05:00
..
benches Add query construction to benchmark 2020-06-26 15:05:27 -07:00
npm 0.18.2 2021-02-18 14:33:03 -08:00
src Move allocation tracking into lib crate 2021-02-23 09:16:37 -05:00
vendor Add a highlight subcommand 2019-02-19 12:32:03 -08:00
build.rs fix warning and use implicit return here 2020-09-15 13:22:22 -04:00
Cargo.toml Move allocation tracking into lib crate 2021-02-23 09:16:37 -05:00
README.md Update docs after Rust conversion 2019-02-05 11:34:01 -08:00

Tree-sitter CLI

Build Status Build status Crates.io

The Tree-sitter CLI allows you to develop, test, and use Tree-sitter grammars from the command line. It works on MacOS, Linux, and Windows.

Installation

You can install the tree-sitter-cli with cargo:

cargo install tree-sitter-cli

or with npm:

npm install tree-sitter-cli

You can also download a pre-built binary for your platform from the releases page.

Dependencies

The tree-sitter binary itself has no dependencies, but specific commands have dependencies that must be present at runtime:

  • To generate a parser from a grammar, you must have node on your PATH.
  • To run and test parsers, you must have a C and C++ compiler on your system.

Commands

  • generate - The tree-sitter generate command will generate a Tree-sitter parser based on the grammar in the current working directory. See the documentation for more information.

  • test - The tree-sitter test command will run the unit tests for the Tree-sitter parser in the current working directory. See the documentation for more information.

  • parse - The tree-sitter parse command will parse a file (or list of file) using Tree-sitter parsers.