tree-sitter/script/generate-fixtures
Amaan Qureshi 99b93d83a1 feat(cli)!: add a separate build command to compile parsers
This allows users to build parsers without having to run `test` or
`parse` to invoke the compilation process, and allows them to output the
object file to wherever they like. The `build-wasm` command was merged
into this by just specifying the `--wasm` flag.
2024-03-17 05:36:30 -04:00

33 lines
738 B
Bash
Executable file

#!/usr/bin/env bash
set -e
root_dir=$PWD
if [ "$CI" == true ]; then
set -x
tree_sitter="$TREE_SITTER"
else
cargo build --release
tree_sitter=${root_dir}/target/release/tree-sitter
fi
filter_grammar_name=$1
grammars_dir=${root_dir}/test/fixtures/grammars
grammar_files=$(find "$grammars_dir" -name grammar.js | grep -v node_modules)
while read -r grammar_file; do
grammar_dir=$(dirname "$grammar_file")
grammar_name=$(basename "$grammar_dir")
if [[ -n $filter_grammar_name && "$filter_grammar_name" != "$grammar_name" ]]; then
continue
fi
echo "Regenerating ${grammar_name} parser"
(
cd "$grammar_dir"
"$tree_sitter" generate src/grammar.json --no-bindings --abi=latest
)
done <<<"$grammar_files"