Skip to content

Commit 3b95a93

Browse files
committed
chore: update version
Updates the tree sitter version from 0.22.6 to latest (0.26.3). Note that the tree sitter ABI has changed between the two of these. As such, we currently explicitly ask for the 0.22.6 ABI, which is v14. Moreover, some flags have changed because tree sitter has moved to a specific config file, `tree-sitter.json`, which we haven't yet moved to. The main implication for us is that the `--no-bindings` flag has been removed and should now be controlled through this config file.
1 parent d21c9b5 commit 3b95a93

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

scripts/ocaml-tree-sitter-gen-c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ EOF
2121
exit 1
2222
}
2323

24+
tree_sitter_generate() {
25+
# Switch on tree sitter version (before/after 0.24.0) due to some
26+
# configuration changes. See
27+
# <https://github.com/tree-sitter/tree-sitter/commit/b2359e402070445181482f2e351400276d94c968>.
28+
if tree-sitter --version \
29+
| sed "s/^tree-sitter \\([0-9.]*\\).*$/0.24.0\\n\\1/" \
30+
| sort -V -C 2>/dev/null; then
31+
# Use ABI 14.
32+
# `tree-sitter.json` is required to generate with ABI 15, but we haven't
33+
# switched to using this. See also
34+
# <https://tree-sitter.github.io/tree-sitter/cli/init>
35+
tree-sitter generate --abi=14 $*
36+
else
37+
tree-sitter generate --no-bindings $*
38+
fi
39+
}
40+
2441
# Generate C source code for the grammar, in two passes:
2542
#
2643
# 1. Import files from semgrep-grammars
@@ -33,7 +50,7 @@ if [[ -e grammar.js ]]; then
3350
# consist of a local 'grammar.json' file.
3451

3552
echo "$name: Generating initial 'grammar.json' from 'grammar.js'."
36-
tree-sitter generate --no-bindings
53+
tree_sitter_generate
3754
mkdir -p src
3855
if [[ -e orig/LICENSE ]]; then cp -L orig/LICENSE src; fi
3956
if [[ -e orig/scanner.c ]]; then cp -L orig/scanner.c src; fi
@@ -76,7 +93,7 @@ ocaml-tree-sitter to-js src/grammar.json.orig grammar-rev.js.orig
7693
ocaml-tree-sitter to-js src/grammar.json grammar-rev.js
7794

7895
echo "$name: Generating definitive 'parser.c'."
79-
tree-sitter generate src/grammar.json --no-bindings
96+
tree_sitter_generate src/grammar.json
8097

8198
# Make sure we get an error in case of OOM leading to no src/parser.c
8299
test -f src/parser.c || error \

tree-sitter-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.22.6
1+
0.26.3

0 commit comments

Comments
 (0)