@willbooster/tree-sitter-zig 10.0.1 → 11.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
@@ -14,8 +14,10 @@ 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
16
  [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries that fork's own ABI
17
- number (`0x5742000c`) and loads only with that fork's runtime, version 17.0.1 or later in the 17.x series: upstream's tree-sitter runtime
18
- rejects it. It parses as the parser in upstream's 1.1.2 packages does, with these exceptions:
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:
19
21
 
20
22
  - In the ranges a `for` loop iterates over, a range end whose first token can both start an expression and continue
21
23
  the one before `..`, for example `(`, `[`, `.`, `*`, `&`, `-`, or `!` (as in `for (0..(n)) |i| {}` or
@@ -60,7 +62,7 @@ the trees that error recovery produces may change; such changes are released as
60
62
  ## Usage
61
63
 
62
64
  The npm package ships `tree-sitter-zig.wasm` for
63
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 17.0.1 or later in the 17.x series, which runs in Node.js, Bun, browsers, and Cloudflare Workers.
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
66
  In Node.js and Bun, load the grammar from its path:
65
67
 
66
68
  ```js
@@ -108,7 +110,7 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
108
110
  fuzzed with:
109
111
 
110
112
  ```sh
111
- cargo add willbooster-tree-sitter@17.0.1 --rename tree-sitter
113
+ cargo add willbooster-tree-sitter@19.1.1 --rename tree-sitter
112
114
  cargo add willbooster-tree-sitter-zig --rename tree-sitter-zig
113
115
  ```
114
116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-zig",
3
- "version": "10.0.1",
3
+ "version": "11.0.0",
4
4
  "description": "Zig grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -50,7 +50,7 @@
50
50
  "@vitest/browser-playwright": "5.0.5",
51
51
  "@willbooster/oxlint-config": "1.4.9",
52
52
  "@willbooster/wb": "23.3.0",
53
- "@willbooster/web-tree-sitter": "17.0.1",
53
+ "@willbooster/web-tree-sitter": "19.1.1",
54
54
  "conventional-changelog-conventionalcommits": "10.4.1",
55
55
  "lefthook": "2.2.2",
56
56
  "oxlint": "1.90.0",
@@ -61,7 +61,7 @@
61
61
  "wrangler": "4.156.0"
62
62
  },
63
63
  "peerDependencies": {
64
- "@willbooster/web-tree-sitter": "^17.0.1"
64
+ "@willbooster/web-tree-sitter": "^19.1.1"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@willbooster/web-tree-sitter": {
package/src/scanner.c CHANGED
@@ -22,10 +22,15 @@ void tree_sitter_zig_external_scanner_deserialize(void *payload, const char *buf
22
22
  (void)length;
23
23
  }
24
24
 
25
+ static inline bool at_eof(const TSLexer *lexer) { return lexer->lookahead == 0 && lexer->eof(lexer); }
26
+
25
27
  bool tree_sitter_zig_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
26
28
  (void)payload;
27
- if (valid_symbols[ERROR_SENTINEL]) return false;
28
- if (lexer->eof(lexer)) {
29
+ if (valid_symbols[ERROR_SENTINEL] ||
30
+ (!valid_symbols[DOC_COMMENT_CONTENT] && !valid_symbols[EMPTY_DOC_COMMENT_CONTENT])) {
31
+ return false;
32
+ }
33
+ if (at_eof(lexer)) {
29
34
  if (!valid_symbols[EMPTY_DOC_COMMENT_CONTENT]) return false;
30
35
  lexer->result_symbol = EMPTY_DOC_COMMENT_CONTENT;
31
36
  return true;
@@ -35,7 +40,7 @@ bool tree_sitter_zig_external_scanner_scan(void *payload, TSLexer *lexer, const
35
40
  int32_t character = lexer->lookahead;
36
41
  lexer->advance(lexer, false);
37
42
  if (character == '\n') break;
38
- } while (!lexer->eof(lexer));
43
+ } while (!at_eof(lexer));
39
44
  lexer->result_symbol = DOC_COMMENT_CONTENT;
40
45
  return true;
41
46
  }
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "10.0.1",
16
+ "version": "11.0.0",
17
17
  "license": "MIT",
18
18
  "description": "Zig grammar for tree-sitter",
19
19
  "authors": [