@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 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 that fork's own ABI
17
- number (`0x5742000c`), which upstream's tree-sitter runtimes reject. Use that fork's runtime, version 19.1.1 or later in
18
- the 19.x series: earlier WillBooster runtimes share ABI `0x5742000c` and pass the ABI check, whereas `19.1.0+` omits
19
- unused `TSLanguage` tables (`alias_map` and `primary_state_bitmap`) that `17.x`/`18.x` runtimes and `19.0.x` Wasm
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 works as in upstream tree-sitter
59
- but is not tested here, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and
60
- the trees that error recovery produces may change; such changes are released as new major versions.
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 19.1.1 or later in the 19.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
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@19.1.1 --rename 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 # installs Chromium for the browser test
126
+ bun run test/ci-setup
128
127
  bun run build/ci
128
+ bun run verify
129
129
  bun run test
130
- script/parse-examples
131
- cargo test
130
+ cargo test --locked
132
131
  ```
133
132
 
134
- The scripts and tests generate, build, test, and parse with `script/tree-sitter`, the tree-sitter CLI of the
135
- WillBooster/tree-sitter runtime version locked in `Cargo.lock`, since the generator and the runtime of upstream's CLI are
136
- not the ones this package ships with. Its first run downloads that CLI from the runtime's GitHub Release, or builds it
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": "11.0.0",
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": "19.1.1",
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": "^19.1.1"
63
+ "@willbooster/web-tree-sitter": "^20.0.0"
65
64
  },
66
65
  "peerDependenciesMeta": {
67
66
  "@willbooster/web-tree-sitter": {
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "11.0.0",
16
+ "version": "12.0.0",
17
17
  "license": "MIT",
18
18
  "description": "Zig grammar for tree-sitter",
19
19
  "authors": [