@willbooster/tree-sitter-zig 16.0.1 → 17.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
@@ -18,12 +18,10 @@ which upstream's tree-sitter runtimes reject, and is tested and supported with t
18
18
  version 23.1.0 or later in the 23.x series. It parses as the parser in upstream's 1.1.2 packages does, with these
19
19
  exceptions:
20
20
 
21
- - In the ranges a `for` loop iterates over, a range end whose first token can both start an expression and continue
22
- the one before `..`, for example `(`, `[`, `.`, `*`, `&`, `-`, or `!` (as in `for (0..(n)) |i| {}` or
23
- `for (0..&x) |i| {}`), is the right operand of a `range_expression`. Upstream's packaged parser, generated by
24
- tree-sitter CLI 0.24, lets that token continue the expression instead, on a range without an end: a call, an index,
25
- a field access, a binary expression, and so on. tree-sitter CLI 0.27 generates this fork's reading from the same
26
- grammar. This generator difference applies only to those `for`-loop range ends.
21
+ - A range outside slice brackets or a `for` operand is a syntax error. A sentinel also requires a range,
22
+ so `a[0:0]` is a syntax error. In `for (0..(n))`, `for (0..&x)`, and `for (0..-n)`, the expression
23
+ after `..` is the right operand of the range. Upstream's packaged parser can use the open range as
24
+ the start of a larger expression in these positions.
27
25
  - The names `true`, `false`, `null`, and `undefined` can label blocks in statements and expressions or name parameters.
28
26
  - Labeled blocks used as indices or slice bounds retain their `block_label` inside the expression,
29
27
  instead of splitting the label colon into an index and a sentinel.
package/grammar.js CHANGED
@@ -363,10 +363,7 @@ module.exports = grammar({
363
363
  _for_prefix: $ => seq(
364
364
  'for',
365
365
  '(',
366
- optionalCommaSep(seq(
367
- $.expression,
368
- optional(seq('..', $.expression)),
369
- )),
366
+ optionalCommaSep1(choice($.range_expression, $.expression)),
370
367
  ')',
371
368
  $.payload,
372
369
  ),
@@ -621,7 +618,6 @@ module.exports = grammar({
621
618
  $.index_expression,
622
619
  $.dereference_expression,
623
620
  $.null_coercion_expression,
624
- $.range_expression,
625
621
  $.call_expression,
626
622
  prec.right(alias($._function_prototype, $.function_signature)),
627
623
  $.identifier,
@@ -720,8 +716,13 @@ module.exports = grammar({
720
716
  index_expression: $ => prec(PREC.MEMBER, seq(
721
717
  field('object', $.expression),
722
718
  '[',
723
- field('index', $.expression),
724
- optional(seq(':', field('sentinel', $.expression))),
719
+ choice(
720
+ field('index', $.expression),
721
+ seq(
722
+ field('index', $.range_expression),
723
+ optional(seq(':', field('sentinel', $.expression))),
724
+ ),
725
+ ),
725
726
  ']',
726
727
  )),
727
728
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-zig",
3
- "version": "16.0.1",
3
+ "version": "17.0.0",
4
4
  "description": "Zig grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "parsing",
@@ -169,10 +169,6 @@
169
169
  "type": "pointer_type",
170
170
  "named": true
171
171
  },
172
- {
173
- "type": "range_expression",
174
- "named": true
175
- },
176
172
  {
177
173
  "type": "slice_type",
178
174
  "named": true
@@ -1417,6 +1413,10 @@
1417
1413
  {
1418
1414
  "type": "payload",
1419
1415
  "named": true
1416
+ },
1417
+ {
1418
+ "type": "range_expression",
1419
+ "named": true
1420
1420
  }
1421
1421
  ]
1422
1422
  }
@@ -1459,6 +1459,10 @@
1459
1459
  {
1460
1460
  "type": "payload",
1461
1461
  "named": true
1462
+ },
1463
+ {
1464
+ "type": "range_expression",
1465
+ "named": true
1462
1466
  }
1463
1467
  ]
1464
1468
  }
@@ -1755,6 +1759,10 @@
1755
1759
  {
1756
1760
  "type": "expression",
1757
1761
  "named": true
1762
+ },
1763
+ {
1764
+ "type": "range_expression",
1765
+ "named": true
1758
1766
  }
1759
1767
  ]
1760
1768
  },
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "16.0.1",
16
+ "version": "17.0.0",
17
17
  "license": "MIT",
18
18
  "description": "Zig grammar for tree-sitter",
19
19
  "authors": [