@willbooster/tree-sitter-zig 7.0.0 → 8.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
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-zig/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-zig/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-zig/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-zig/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.48.9-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.51.1-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-zig.svg)](https://crates.io/crates/willbooster-tree-sitter-zig)
10
10
 
11
11
  Zig grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -26,19 +26,19 @@ rejects it. It parses as the parser in upstream's 1.1.2 packages does, with thes
26
26
  `~x`) or only continue one (`+`, `orelse`), and so do ranges outside `for` loops.
27
27
  - A NUL character inside a token such as a string or a comment is part of that token, where upstream's lexer reports
28
28
  an error.
29
- - Multiline strings expose each `\\` line delimiter and nonempty `string_content` children. The delimiters receive
30
- the `@string.special.symbol` highlight capture. Line endings are outside the content nodes.
29
+ - Multiline strings expose each `\\` line delimiter and nonempty `string_content` children. Line endings are outside
30
+ the content nodes.
31
31
  - `///` and `//!` produce `doc_comment` and `container_doc_comment` nodes. Their `doc_comment_content` children
32
- exclude the prefix and include the line ending when present, so the injection query can combine them as Markdown.
32
+ exclude the prefix and include the line ending when present.
33
33
  An empty comment at EOF has no content child. Ordinary comments, including `////`, remain `comment` nodes.
34
- Queries that need every comment kind must match all three node types.
34
+ Code that handles every comment kind must match all three node types.
35
35
 
36
36
  - Error sets are accepted directly as container field types, and pointer, slice and array element types may be conditional.
37
37
  - `async` and `await` are ordinary identifiers. Assembly clobbers use an expression, including an anonymous struct
38
38
  initializer, as in Zig 0.16.
39
39
  - Zero-bit integers `u0` and `i0` are builtin types.
40
40
  - Quoted identifiers such as `@"hello world"` expose their content directly inside `identifier`, without a nested
41
- `string` node, so string highlighting applies only to literals.
41
+ `string` node.
42
42
  - Boolean negation is a `unary_expression`. Inferred error unions (`!T`) occur only in function return types;
43
43
  their payload includes suffixes such as calls and field access (`!List(T)` or `!ns.Result`). Explicit error
44
44
  unions (`E!T`) retain their error and payload types.
@@ -49,6 +49,13 @@ rejects it. It parses as the parser in upstream's 1.1.2 packages does, with thes
49
49
  `assignment_expression` nodes expose `left`, `operator`, and `right` fields.
50
50
  Struct field initializers produce `field_initializer` nodes with `name` and `value` fields.
51
51
 
52
+ ## Support Scope
53
+
54
+ This fork maintains only full parsing: valid input yields a correct tree, and invalid input yields `ERROR` or `MISSING`
55
+ nodes without crashing, hanging, or taking more than linear time. Incremental parsing works as in upstream tree-sitter
56
+ but is not tested here, and no queries (highlights, locals, injections, tags) are shipped. Node types, field names, and
57
+ the trees that error recovery produces may change; such changes are released as new major versions.
58
+
52
59
  ## Usage
53
60
 
54
61
  The npm package ships `tree-sitter-zig.wasm` for
@@ -92,7 +99,7 @@ const parser = new Parser();
92
99
  parser.setLanguage(await Language.load(zig));
93
100
  ```
94
101
 
95
- The package also ships `grammar.js`, the queries in `queries/`, and the node types in `src/node-types.json`.
102
+ The package also ships `grammar.js` and the node types in `src/node-types.json`.
96
103
  It includes `src/scanner.c`, which must be compiled with a parser regenerated from this grammar.
97
104
 
98
105
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-zig) and on
@@ -140,9 +147,6 @@ and the release build regenerate the parsers before compiling them.
140
147
  `bun run test` runs:
141
148
 
142
149
  - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
143
- - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
144
- edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
145
- `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
146
150
  - a check that the real-world Zig files in `examples/` fail to parse exactly as listed in
147
151
  `script/known-failures.txt`, while every library file from the pinned Zig 0.16 release must parse without errors.
148
152
  The older Zig corpus retains coverage of unsupported syntax. The first run fetches the repositories and the
@@ -158,8 +162,7 @@ and the release build regenerate the parsers before compiling them.
158
162
  Cloudflare Workers with and without Node.js compatibility (`test/e2e/workers.test.ts`).
159
163
 
160
164
  The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
161
- by every checkout; `script/fuzz-corpus` builds a parser of its own in `.tmp/fuzz` for each run and deletes it
162
- afterwards.
165
+ by every checkout.
163
166
 
164
167
  CI also runs these tests on Linux arm64 and macOS, where the CLI compiles the parser natively, and fuzzes the parser
165
168
  with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-zig",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "description": "Zig grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -16,7 +16,6 @@
16
16
  },
17
17
  "files": [
18
18
  "grammar.js",
19
- "queries/*.scm",
20
19
  "src/node-types.json",
21
20
  "src/scanner.c",
22
21
  "tree-sitter.json",
@@ -47,15 +46,15 @@
47
46
  },
48
47
  "devDependencies": {
49
48
  "@tsconfig/bun": "1.0.11",
50
- "@types/bun": "1.4.3",
49
+ "@types/bun": "1.4.4",
51
50
  "@vitest/browser-playwright": "5.0.5",
52
51
  "@willbooster/oxlint-config": "1.4.9",
53
- "@willbooster/wb": "22.29.3",
52
+ "@willbooster/wb": "22.32.3",
54
53
  "@willbooster/web-tree-sitter": "15.0.0",
55
54
  "conventional-changelog-conventionalcommits": "10.4.1",
56
55
  "lefthook": "2.2.2",
57
- "oxlint": "1.88.0",
58
- "oxlint-tsgolint": "7.0.2004",
56
+ "oxlint": "1.89.0",
57
+ "oxlint-tsgolint": "7.0.2005",
59
58
  "playwright": "1.64.1",
60
59
  "semantic-release": "25.0.9",
61
60
  "vitest": "5.0.5",
Binary file
package/tree-sitter.json CHANGED
@@ -9,13 +9,11 @@
9
9
  "file-types": [
10
10
  "zig"
11
11
  ],
12
- "highlights": "queries/highlights.scm",
13
- "injections": "queries/injections.scm",
14
12
  "injection-regex": "^zig$"
15
13
  }
16
14
  ],
17
15
  "metadata": {
18
- "version": "7.0.0",
16
+ "version": "8.0.0",
19
17
  "license": "MIT",
20
18
  "description": "Zig grammar for tree-sitter",
21
19
  "authors": [
package/queries/folds.scm DELETED
@@ -1,23 +0,0 @@
1
- [
2
- (block)
3
- (switch_expression)
4
- (initializer_list)
5
- (asm_expression)
6
- (multiline_string)
7
- (if_statement)
8
- (while_statement)
9
- (for_statement)
10
- (if_expression)
11
- (else_clause)
12
- (for_expression)
13
- (while_expression)
14
- (if_type_expression)
15
- (function_signature)
16
- (parameters)
17
- (struct_declaration)
18
- (opaque_declaration)
19
- (enum_declaration)
20
- (union_declaration)
21
- (error_set_declaration)
22
- ] @fold
23
-
@@ -1,293 +0,0 @@
1
- ; Variables
2
-
3
- (identifier) @variable
4
-
5
- ; Parameters
6
-
7
- (parameter
8
- name: (identifier) @variable.parameter)
9
-
10
- ; Types
11
-
12
- (parameter
13
- type: (identifier) @type)
14
-
15
- ((identifier) @type
16
- (#match? @type "^[A-Z_][a-zA-Z0-9_]*"))
17
-
18
- (variable_declaration
19
- (identifier) @type
20
- "="
21
- [
22
- (struct_declaration)
23
- (enum_declaration)
24
- (union_declaration)
25
- (opaque_declaration)
26
- ])
27
-
28
- [
29
- (builtin_type)
30
- "anyframe"
31
- ] @type.builtin
32
-
33
- ; Constants
34
-
35
- ((identifier) @constant
36
- (#match? @constant "^[A-Z][A-Z_0-9]+$"))
37
-
38
- [
39
- "null"
40
- "unreachable"
41
- "undefined"
42
- ] @constant.builtin
43
-
44
- (field_expression
45
- .
46
- member: (identifier) @constant)
47
-
48
- (enum_declaration
49
- (container_field
50
- type: (identifier) @constant))
51
-
52
- ; Labels
53
-
54
- (block_label (identifier) @label)
55
-
56
- (break_label (identifier) @label)
57
-
58
- ; Fields
59
-
60
- (field_initializer
61
- name: (identifier) @variable.member)
62
-
63
- (field_expression
64
- (_)
65
- member: (identifier) @variable.member)
66
-
67
- (container_field
68
- name: (identifier) @variable.member)
69
-
70
- (parameter
71
- type: (field_expression
72
- member: (identifier) @type))
73
-
74
- ; Functions
75
-
76
- (builtin_identifier) @function.builtin
77
-
78
- (call_expression
79
- function: (identifier) @function.call)
80
-
81
- (call_expression
82
- function: (field_expression
83
- member: (identifier) @function.call))
84
-
85
- (function_declaration
86
- name: (identifier) @function)
87
-
88
- ; Modules
89
-
90
- (variable_declaration
91
- (identifier) @module
92
- (builtin_function
93
- (builtin_identifier) @keyword.import
94
- (#any-of? @keyword.import "@import" "@cImport")))
95
-
96
- ; Builtins
97
-
98
- [
99
- "c"
100
- "..."
101
- ] @variable.builtin
102
-
103
- ((identifier) @variable.builtin
104
- (#eq? @variable.builtin "_"))
105
-
106
- (calling_convention
107
- (identifier) @variable.builtin)
108
-
109
- ; Keywords
110
-
111
- [
112
- "asm"
113
- "defer"
114
- "errdefer"
115
- "test"
116
- "error"
117
- "const"
118
- "var"
119
- ] @keyword
120
-
121
- [
122
- "struct"
123
- "union"
124
- "enum"
125
- "opaque"
126
- ] @keyword.type
127
-
128
- [
129
- "suspend"
130
- "nosuspend"
131
- "resume"
132
- ] @keyword.coroutine
133
-
134
- "fn" @keyword.function
135
-
136
- [
137
- "and"
138
- "or"
139
- "orelse"
140
- ] @keyword.operator
141
-
142
- "return" @keyword.return
143
-
144
- [
145
- "if"
146
- "else"
147
- "switch"
148
- ] @keyword.conditional
149
-
150
- [
151
- "for"
152
- "while"
153
- "break"
154
- "continue"
155
- ] @keyword.repeat
156
-
157
- [
158
- "usingnamespace"
159
- "export"
160
- ] @keyword.import
161
-
162
- [
163
- "try"
164
- "catch"
165
- ] @keyword.exception
166
-
167
- [
168
- "volatile"
169
- "allowzero"
170
- "noalias"
171
- "addrspace"
172
- "align"
173
- "callconv"
174
- "linksection"
175
- "pub"
176
- "inline"
177
- "noinline"
178
- "extern"
179
- "comptime"
180
- "packed"
181
- "threadlocal"
182
- ] @keyword.modifier
183
-
184
- ; Operator
185
-
186
- [
187
- "="
188
- "*="
189
- "*%="
190
- "*|="
191
- "/="
192
- "%="
193
- "+="
194
- "+%="
195
- "+|="
196
- "-="
197
- "-%="
198
- "-|="
199
- "<<="
200
- "<<|="
201
- ">>="
202
- "&="
203
- "^="
204
- "|="
205
- "!"
206
- "~"
207
- "-"
208
- "-%"
209
- "&"
210
- "=="
211
- "!="
212
- ">"
213
- ">="
214
- "<="
215
- "<"
216
- "&"
217
- "^"
218
- "|"
219
- "<<"
220
- ">>"
221
- "<<|"
222
- "+"
223
- "++"
224
- "+%"
225
- "-%"
226
- "+|"
227
- "-|"
228
- "*"
229
- "/"
230
- "%"
231
- "**"
232
- "*%"
233
- "*|"
234
- "||"
235
- ".*"
236
- ".?"
237
- "?"
238
- ".."
239
- ] @operator
240
-
241
- ; Literals
242
-
243
- (character) @character
244
-
245
- ([
246
- (string)
247
- (multiline_string)
248
- ] @string
249
- (#set! "priority" 95))
250
-
251
- (integer) @number
252
-
253
- (float) @number.float
254
-
255
- (boolean) @boolean
256
-
257
- [
258
- (string (escape_sequence) @string.escape)
259
- (character (escape_sequence) @string.escape)
260
- ]
261
-
262
- "\\\\" @string.special.symbol
263
-
264
- ; Punctuation
265
-
266
- [
267
- "["
268
- "]"
269
- "("
270
- ")"
271
- "{"
272
- "}"
273
- ] @punctuation.bracket
274
-
275
- [
276
- ";"
277
- "."
278
- ","
279
- ":"
280
- "=>"
281
- "->"
282
- ] @punctuation.delimiter
283
-
284
- (payload "|" @punctuation.bracket)
285
-
286
- ; Comments
287
-
288
- (comment) @comment @spell
289
-
290
- [
291
- (doc_comment)
292
- (container_doc_comment)
293
- ] @comment.documentation @spell
@@ -1,24 +0,0 @@
1
- [
2
- (block)
3
- (switch_expression)
4
- (initializer_list)
5
- ] @indent.begin
6
-
7
- (block
8
- "}" @indent.end)
9
-
10
- [
11
- "("
12
- ")"
13
- "["
14
- "]"
15
- "{"
16
- "}"
17
- ] @indent.branch
18
-
19
- [
20
- (comment)
21
- (doc_comment)
22
- (container_doc_comment)
23
- (multiline_string)
24
- ] @indent.ignore
@@ -1,6 +0,0 @@
1
- ((comment) @injection.content
2
- (#set! injection.language "comment"))
3
-
4
- ((doc_comment_content) @injection.content
5
- (#set! injection.language "markdown")
6
- (#set! injection.combined))