@willbooster/tree-sitter-zig 11.0.0 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -50
- package/package.json +3 -4
- package/tree-sitter-zig.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -13,11 +13,10 @@ Zig grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forke
|
|
|
13
13
|
to its authors and contributors. This is not an official release of that project.
|
|
14
14
|
|
|
15
15
|
This fork builds on the grammar of upstream's version 1.1.2 and generates the parser with the
|
|
16
|
-
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
loaders dereference. It parses as the parser in upstream's 1.1.2 packages does, with these exceptions:
|
|
16
|
+
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries ABI `0x5742000c`,
|
|
17
|
+
which upstream's tree-sitter runtimes reject, and is tested and supported with the WillBooster/tree-sitter runtime,
|
|
18
|
+
version 20.0.0 or later in the 20.x series. It parses as the parser in upstream's 1.1.2 packages does, with these
|
|
19
|
+
exceptions:
|
|
21
20
|
|
|
22
21
|
- In the ranges a `for` loop iterates over, a range end whose first token can both start an expression and continue
|
|
23
22
|
the one before `..`, for example `(`, `[`, `.`, `*`, `&`, `-`, or `!` (as in `for (0..(n)) |i| {}` or
|
|
@@ -55,14 +54,14 @@ loaders dereference. It parses as the parser in upstream's 1.1.2 packages does,
|
|
|
55
54
|
## Support Scope
|
|
56
55
|
|
|
57
56
|
This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
|
|
58
|
-
nodes without crashing, hanging, or taking more than linear time. Incremental parsing
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
nodes without crashing, hanging, or taking more than linear time. Incremental parsing is not supported, and no queries
|
|
58
|
+
(highlights, locals, injections, tags) are shipped. Node types, field names, and the trees that error recovery produces
|
|
59
|
+
may change; such changes are released as new major versions.
|
|
61
60
|
|
|
62
61
|
## Usage
|
|
63
62
|
|
|
64
63
|
The npm package ships `tree-sitter-zig.wasm` for
|
|
65
|
-
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version
|
|
64
|
+
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 20.0.0 or later in the 20.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
|
|
66
65
|
In Node.js and Bun, load the grammar from its path:
|
|
67
66
|
|
|
68
67
|
```js
|
|
@@ -110,7 +109,7 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
|
|
|
110
109
|
fuzzed with:
|
|
111
110
|
|
|
112
111
|
```sh
|
|
113
|
-
cargo add willbooster-tree-sitter@
|
|
112
|
+
cargo add willbooster-tree-sitter@20.0.0 --rename tree-sitter
|
|
114
113
|
cargo add willbooster-tree-sitter-zig --rename tree-sitter-zig
|
|
115
114
|
```
|
|
116
115
|
|
|
@@ -124,50 +123,16 @@ parser.set_language(&tree_sitter_zig::LANGUAGE.into())?;
|
|
|
124
123
|
```sh
|
|
125
124
|
mise install
|
|
126
125
|
bun install --frozen-lockfile
|
|
127
|
-
bun run test/ci-setup
|
|
126
|
+
bun run test/ci-setup
|
|
128
127
|
bun run build/ci
|
|
128
|
+
bun run verify
|
|
129
129
|
bun run test
|
|
130
|
-
|
|
131
|
-
cargo test
|
|
130
|
+
cargo test --locked
|
|
132
131
|
```
|
|
133
132
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
with `cargo` (whose build runs the CMake that `mise.toml` pins) when the download fails or the release has no binary that runs here. Run other CLI commands through it as
|
|
138
|
-
well (e.g. `script/tree-sitter parse file.zig`).
|
|
139
|
-
|
|
140
|
-
`bun run generate` records a fresh generation profile from the applicable `test/corpus` cases, then generates
|
|
141
|
-
compact parser tables. It would also profile files tracked in `examples/`, but this repository tracks none: upstream
|
|
142
|
-
ships neither examples nor a corpus, so the cases in `test/corpus` were written for this fork, with the trees upstream's
|
|
143
|
-
packaged parser gives them, except where the parsing differences listed above apply. Those cases pin this fork's
|
|
144
|
-
reading. The parser also embeds metadata from `tree-sitter.json`.
|
|
145
|
-
After changing a grammar, `tree-sitter.json`, or a corpus case, regenerate and commit `src/`.
|
|
146
|
-
Profiles in `.tmp/generation-profiles/` are temporary and must not be committed. `bun run build-wasm`, `bun run build/ci`,
|
|
147
|
-
and the release build regenerate the parsers before compiling them.
|
|
148
|
-
|
|
149
|
-
`bun run test` runs:
|
|
150
|
-
|
|
151
|
-
- the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
|
|
152
|
-
- a check that the real-world Zig files in `examples/` fail to parse exactly as listed in
|
|
153
|
-
`script/known-failures.txt`, while every library file from the pinned Zig 0.16 release must parse without errors.
|
|
154
|
-
The older Zig corpus retains coverage of unsupported syntax. The first run fetches the repositories and the
|
|
155
|
-
checksum-pinned Zig source archive. Their revisions are pinned in `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites it;
|
|
156
|
-
review its diff before committing;
|
|
157
|
-
- a performance check (`test/unit/performance.test.ts`) that recovering from an error on each line takes linear
|
|
158
|
-
time, since consumers parse files while they are being edited. It loads the Wasm build through
|
|
159
|
-
@willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating the parser;
|
|
160
|
-
- a check (`test/unit/runtimeVersion.test.ts`) that `@willbooster/web-tree-sitter` in `package.json` and
|
|
161
|
-
`willbooster-tree-sitter` in `Cargo.lock` are the same version, since the Wasm tests run on the former and the Rust
|
|
162
|
-
tests, the fuzzer, and the CLI on the latter;
|
|
163
|
-
- tests that load the Wasm build with @willbooster/web-tree-sitter in Chromium (`test/e2e/browser.test.ts`) and in
|
|
164
|
-
Cloudflare Workers with and without Node.js compatibility (`test/e2e/workers.test.ts`).
|
|
165
|
-
|
|
166
|
-
The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
|
|
167
|
-
by every checkout.
|
|
168
|
-
|
|
169
|
-
CI also runs these tests on Linux arm64 and macOS, where the CLI compiles the parser natively, and fuzzes the parser
|
|
170
|
-
with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
|
|
133
|
+
Run tree-sitter CLI commands through `script/tree-sitter`, such as `script/tree-sitter parse file.zig`. It runs the `WillBooster/tree-sitter` CLI at the runtime version locked in `Cargo.lock`. `@willbooster/web-tree-sitter` in `package.json` and `willbooster-tree-sitter` in `Cargo.lock` must stay at the same version (`test/unit/runtimeVersion.test.ts`).
|
|
134
|
+
|
|
135
|
+
After changing `grammar.js`, `tree-sitter.json`, or `test/corpus`, run `bun run build/ci` and commit `src/`. When a grammar change or a moved pin in `script/parse-examples` alters which real-world Zig files fail to parse, run `script/parse-examples` to update `script/known-failures.txt` and review its diff before committing.
|
|
171
136
|
|
|
172
137
|
### References
|
|
173
138
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-zig",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"description": "Zig grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"incremental",
|
|
7
6
|
"parsing",
|
|
8
7
|
"tree-sitter",
|
|
9
8
|
"zig"
|
|
@@ -50,7 +49,7 @@
|
|
|
50
49
|
"@vitest/browser-playwright": "5.0.5",
|
|
51
50
|
"@willbooster/oxlint-config": "1.4.9",
|
|
52
51
|
"@willbooster/wb": "23.3.0",
|
|
53
|
-
"@willbooster/web-tree-sitter": "
|
|
52
|
+
"@willbooster/web-tree-sitter": "20.0.0",
|
|
54
53
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
55
54
|
"lefthook": "2.2.2",
|
|
56
55
|
"oxlint": "1.90.0",
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
"wrangler": "4.156.0"
|
|
62
61
|
},
|
|
63
62
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^
|
|
63
|
+
"@willbooster/web-tree-sitter": "^20.0.0"
|
|
65
64
|
},
|
|
66
65
|
"peerDependenciesMeta": {
|
|
67
66
|
"@willbooster/web-tree-sitter": {
|
package/tree-sitter-zig.wasm
CHANGED
|
Binary file
|