@willbooster/tree-sitter-zig 1.0.1 → 1.0.3
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 +7 -2
- package/grammar.js +10 -3
- package/package.json +6 -7
- package/src/node-types.json +8 -0
- package/tree-sitter-zig.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-zig/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-zig/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](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
|
|
@@ -27,6 +27,10 @@ rejects it. It parses as the parser in upstream's 1.1.2 packages does, with thes
|
|
|
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
29
|
|
|
30
|
+
- Zero-bit integers `u0` and `i0` are builtin types.
|
|
31
|
+
- Boolean negation is a `unary_expression`. Inferred error unions (`!T`) occur only in function return types;
|
|
32
|
+
their payload includes suffixes such as calls and field access (`!List(T)` or `!ns.Result`). Explicit error
|
|
33
|
+
unions (`E!T`) retain their error and payload types.
|
|
30
34
|
- Empty `struct`, `opaque`, `enum`, and `union` declarations have no fields, instead of synthesized zero-width
|
|
31
35
|
`container_field` and `identifier` nodes.
|
|
32
36
|
|
|
@@ -109,7 +113,8 @@ well (e.g. `script/tree-sitter parse file.zig`).
|
|
|
109
113
|
`bun run generate` records a fresh generation profile from the applicable `test/corpus` cases, then generates
|
|
110
114
|
compact parser tables. It would also profile files tracked in `examples/`, but this repository tracks none: upstream
|
|
111
115
|
ships neither examples nor a corpus, so the cases in `test/corpus` were written for this fork, with the trees upstream's
|
|
112
|
-
packaged parser gives them, except the
|
|
116
|
+
packaged parser gives them, except where the parsing differences listed above apply. Those cases pin this fork's
|
|
117
|
+
reading. The parser also embeds metadata from `tree-sitter.json`.
|
|
113
118
|
After changing a grammar, `tree-sitter.json`, or a corpus case, regenerate and commit `src/`.
|
|
114
119
|
Profiles in `.tmp/generation-profiles/` are temporary and must not be committed. `bun run build-wasm`, `bun run build/ci`,
|
|
115
120
|
and the release build regenerate the parsers before compiling them.
|
package/grammar.js
CHANGED
|
@@ -48,7 +48,7 @@ const builtinTypes = [
|
|
|
48
48
|
'c_longlong',
|
|
49
49
|
'c_ulonglong',
|
|
50
50
|
'c_longdouble',
|
|
51
|
-
/(i|u)[1-9][0-9]
|
|
51
|
+
/(i|u)(0|[1-9][0-9]*)/,
|
|
52
52
|
];
|
|
53
53
|
|
|
54
54
|
module.exports = grammar({
|
|
@@ -208,9 +208,16 @@ module.exports = grammar({
|
|
|
208
208
|
optional($.address_space),
|
|
209
209
|
optional($.link_section),
|
|
210
210
|
optional($.calling_convention),
|
|
211
|
-
field('type', choice(
|
|
211
|
+
field('type', choice(
|
|
212
|
+
$.type_expression,
|
|
213
|
+
$.if_type_expression,
|
|
214
|
+
$.comptime_type_expression,
|
|
215
|
+
alias($._inferred_error_union_type, $.error_union_type),
|
|
216
|
+
)),
|
|
212
217
|
),
|
|
213
218
|
|
|
219
|
+
_inferred_error_union_type: $ => prec.right(-1, seq('!', field('ok', $.type_expression))),
|
|
220
|
+
|
|
214
221
|
parameters: $ => seq('(', optionalCommaSep($.parameter), ')'),
|
|
215
222
|
|
|
216
223
|
parameter: $ => choice(
|
|
@@ -698,7 +705,7 @@ module.exports = grammar({
|
|
|
698
705
|
)),
|
|
699
706
|
|
|
700
707
|
error_union_type: $ => prec.right(2, seq(
|
|
701
|
-
|
|
708
|
+
field('error', $.type_expression),
|
|
702
709
|
'!',
|
|
703
710
|
field('ok', $.type_expression),
|
|
704
711
|
)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-zig",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Zig grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -46,17 +46,16 @@
|
|
|
46
46
|
"@vitest/browser-playwright": "5.0.3",
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
|
-
"@willbooster/wb": "22.
|
|
49
|
+
"@willbooster/wb": "22.26.1",
|
|
50
50
|
"@willbooster/web-tree-sitter": "2.0.1",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
|
-
"lefthook": "2.1
|
|
53
|
-
"oxfmt": "0.
|
|
54
|
-
"oxlint": "1.
|
|
55
|
-
"oxlint-tsgolint": "7.0.
|
|
52
|
+
"lefthook": "2.2.1",
|
|
53
|
+
"oxfmt": "0.72.0",
|
|
54
|
+
"oxlint": "1.87.0",
|
|
55
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
56
56
|
"playwright": "1.63.0",
|
|
57
57
|
"semantic-release": "25.0.9",
|
|
58
58
|
"sort-package-json": "4.0.0",
|
|
59
|
-
"typescript": "7.0.2",
|
|
60
59
|
"vitest": "5.0.3",
|
|
61
60
|
"wrangler": "4.147.0"
|
|
62
61
|
},
|
package/src/node-types.json
CHANGED
|
@@ -1486,6 +1486,10 @@
|
|
|
1486
1486
|
"type": "comptime_type_expression",
|
|
1487
1487
|
"named": true
|
|
1488
1488
|
},
|
|
1489
|
+
{
|
|
1490
|
+
"type": "error_union_type",
|
|
1491
|
+
"named": true
|
|
1492
|
+
},
|
|
1489
1493
|
{
|
|
1490
1494
|
"type": "if_type_expression",
|
|
1491
1495
|
"named": true
|
|
@@ -1550,6 +1554,10 @@
|
|
|
1550
1554
|
"type": "comptime_type_expression",
|
|
1551
1555
|
"named": true
|
|
1552
1556
|
},
|
|
1557
|
+
{
|
|
1558
|
+
"type": "error_union_type",
|
|
1559
|
+
"named": true
|
|
1560
|
+
},
|
|
1553
1561
|
{
|
|
1554
1562
|
"type": "if_type_expression",
|
|
1555
1563
|
"named": true
|
package/tree-sitter-zig.wasm
CHANGED
|
Binary file
|