@willbooster/tree-sitter-zig 1.0.3 → 1.0.4

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
@@ -27,6 +27,9 @@ 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
+ - Error sets are accepted directly as container field types, and pointer and slice element types may be conditional.
31
+ - `async` and `await` are ordinary identifiers. Assembly clobbers use an expression, including an anonymous struct
32
+ initializer, as in Zig 0.16.
30
33
  - Zero-bit integers `u0` and `i0` are builtin types.
31
34
  - Boolean negation is a `unary_expression`. Inferred error unions (`!T`) occur only in function return types;
32
35
  their payload includes suffixes such as calls and field access (`!List(T)` or `!ns.Result`). Explicit error
@@ -126,8 +129,9 @@ and the release build regenerate the parsers before compiling them.
126
129
  edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
127
130
  `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
128
131
  - a check that the real-world Zig files in `examples/` fail to parse exactly as listed in
129
- `script/known-failures.txt`. The first run clones the repositories. The example repositories are pinned to commits in
130
- `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites it;
132
+ `script/known-failures.txt`, while every library file from the pinned Zig 0.16 release must parse without errors.
133
+ The older Zig corpus retains coverage of unsupported syntax. The first run fetches the repositories and the
134
+ 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;
131
135
  review its diff before committing;
132
136
  - a performance check (`test/unit/performance.test.ts`) that recovering from an error on each line takes linear
133
137
  time, since consumers parse files while they are being edited. It loads the Wasm build through
package/grammar.js CHANGED
@@ -124,9 +124,9 @@ module.exports = grammar({
124
124
  seq(
125
125
  field('name', choice($.identifier, $._reserved_identifier, alias($.builtin_type, $.identifier))),
126
126
  ':',
127
- field('type', choice($.primary_type_expression, $.if_type_expression, $.comptime_type_expression)),
127
+ field('type', choice($.primary_type_expression, $.if_type_expression, $.comptime_type_expression, $.error_set_declaration)),
128
128
  ),
129
- field('name', choice($.primary_type_expression, $.if_type_expression, $.comptime_type_expression)),
129
+ field('name', choice($.primary_type_expression, $.if_type_expression, $.comptime_type_expression, $.error_set_declaration)),
130
130
  ),
131
131
  optional($.byte_alignment),
132
132
  optional(seq('=', $.expression)),
@@ -420,8 +420,6 @@ module.exports = grammar({
420
420
  $.unary_expression,
421
421
  $.binary_expression,
422
422
  $.comptime_expression,
423
- $.async_expression,
424
- $.await_expression,
425
423
  $.nosuspend_expression,
426
424
  $.continue_expression,
427
425
  $.resume_expression,
@@ -461,7 +459,7 @@ module.exports = grammar({
461
459
  $.expression,
462
460
  ')',
463
461
  ),
464
- asm_clobbers: $ => seq(':', optionalCommaSep(choice($.string, $.multiline_string))),
462
+ asm_clobbers: $ => seq(':', $.expression),
465
463
 
466
464
  if_expression: $ => prec.right(seq(
467
465
  $._if_prefix,
@@ -545,10 +543,6 @@ module.exports = grammar({
545
543
 
546
544
  comptime_expression: $ => prec.right(seq('comptime', $.expression)),
547
545
 
548
- async_expression: $ => prec.right(seq('async', $.expression)),
549
-
550
- await_expression: $ => prec.right(seq('await', $.expression)),
551
-
552
546
  nosuspend_expression: $ => prec.right(seq('nosuspend', $.expression)),
553
547
 
554
548
  continue_expression: $ => prec.right(seq(
@@ -667,7 +661,7 @@ module.exports = grammar({
667
661
  'volatile',
668
662
  'allowzero',
669
663
  )),
670
- $.type_expression,
664
+ choice($.type_expression, $.if_type_expression),
671
665
  )),
672
666
 
673
667
  pointer_type: $ => prec.right(1, seq(
@@ -693,7 +687,7 @@ module.exports = grammar({
693
687
  'volatile',
694
688
  'allowzero',
695
689
  )),
696
- $.type_expression,
690
+ choice($.type_expression, $.if_type_expression),
697
691
  )),
698
692
 
699
693
  array_type: $ => prec(1, seq(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-zig",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Zig grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -129,8 +129,6 @@
129
129
  ] @keyword.type
130
130
 
131
131
  [
132
- "async"
133
- "await"
134
132
  "suspend"
135
133
  "nosuspend"
136
134
  "resume"
@@ -11,14 +11,6 @@
11
11
  "type": "assignment_expression",
12
12
  "named": true
13
13
  },
14
- {
15
- "type": "async_expression",
16
- "named": true
17
- },
18
- {
19
- "type": "await_expression",
20
- "named": true
21
- },
22
14
  {
23
15
  "type": "binary_expression",
24
16
  "named": true
@@ -379,15 +371,11 @@
379
371
  "named": true,
380
372
  "fields": {},
381
373
  "children": {
382
- "multiple": true,
383
- "required": false,
374
+ "multiple": false,
375
+ "required": true,
384
376
  "types": [
385
377
  {
386
- "type": "multiline_string",
387
- "named": true
388
- },
389
- {
390
- "type": "string",
378
+ "type": "expression",
391
379
  "named": true
392
380
  }
393
381
  ]
@@ -608,36 +596,6 @@
608
596
  }
609
597
  }
610
598
  },
611
- {
612
- "type": "async_expression",
613
- "named": true,
614
- "fields": {},
615
- "children": {
616
- "multiple": false,
617
- "required": true,
618
- "types": [
619
- {
620
- "type": "expression",
621
- "named": true
622
- }
623
- ]
624
- }
625
- },
626
- {
627
- "type": "await_expression",
628
- "named": true,
629
- "fields": {},
630
- "children": {
631
- "multiple": false,
632
- "required": true,
633
- "types": [
634
- {
635
- "type": "expression",
636
- "named": true
637
- }
638
- ]
639
- }
640
- },
641
599
  {
642
600
  "type": "binary_expression",
643
601
  "named": true,
@@ -1076,6 +1034,10 @@
1076
1034
  "type": "comptime_type_expression",
1077
1035
  "named": true
1078
1036
  },
1037
+ {
1038
+ "type": "error_set_declaration",
1039
+ "named": true
1040
+ },
1079
1041
  {
1080
1042
  "type": "false",
1081
1043
  "named": false
@@ -1102,6 +1064,10 @@
1102
1064
  "type": "comptime_type_expression",
1103
1065
  "named": true
1104
1066
  },
1067
+ {
1068
+ "type": "error_set_declaration",
1069
+ "named": true
1070
+ },
1105
1071
  {
1106
1072
  "type": "if_type_expression",
1107
1073
  "named": true
@@ -2041,6 +2007,10 @@
2041
2007
  {
2042
2008
  "type": "expression",
2043
2009
  "named": true
2010
+ },
2011
+ {
2012
+ "type": "if_type_expression",
2013
+ "named": true
2044
2014
  }
2045
2015
  ]
2046
2016
  }
@@ -2128,6 +2098,10 @@
2128
2098
  "type": "byte_alignment",
2129
2099
  "named": true
2130
2100
  },
2101
+ {
2102
+ "type": "if_type_expression",
2103
+ "named": true
2104
+ },
2131
2105
  {
2132
2106
  "type": "type_expression",
2133
2107
  "named": true
@@ -2859,14 +2833,6 @@
2859
2833
  "type": "asm",
2860
2834
  "named": false
2861
2835
  },
2862
- {
2863
- "type": "async",
2864
- "named": false
2865
- },
2866
- {
2867
- "type": "await",
2868
- "named": false
2869
- },
2870
2836
  {
2871
2837
  "type": "bool",
2872
2838
  "named": false
Binary file
package/tree-sitter.json CHANGED
@@ -15,7 +15,7 @@
15
15
  }
16
16
  ],
17
17
  "metadata": {
18
- "version": "1.0.3",
18
+ "version": "1.0.4",
19
19
  "license": "MIT",
20
20
  "description": "Zig grammar for tree-sitter",
21
21
  "authors": [