@willbooster/tree-sitter-rust 11.0.0 → 13.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 +9 -3
- package/grammar.js +4 -1
- package/package.json +3 -3
- package/src/node-types.json +30 -15
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ This fork fixes parsing bugs and raises conformance with [The Rust Reference](ht
|
|
|
18
18
|
|
|
19
19
|
The npm package ships `tree-sitter-rust.wasm` for
|
|
20
20
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
21
|
-
browsers, and Cloudflare Workers. The parser requires version
|
|
21
|
+
browsers, and Cloudflare Workers. The parser requires version 13.0.0 or later within major version 13 of that runtime.
|
|
22
22
|
It carries the WillBooster ABI number, which upstream's `web-tree-sitter` rejects.
|
|
23
23
|
|
|
24
24
|
In Node.js and Bun, load the grammar from its path:
|
|
@@ -68,11 +68,11 @@ documentation or line documentation for fenced examples with these queries.
|
|
|
68
68
|
|
|
69
69
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-rust) and on
|
|
70
70
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
71
|
-
fuzzed with. The parser requires version
|
|
71
|
+
fuzzed with. The parser requires version 13.0.0 or later within major version 13 of that runtime; upstream's
|
|
72
72
|
`tree-sitter` crate rejects it:
|
|
73
73
|
|
|
74
74
|
```sh
|
|
75
|
-
cargo add willbooster-tree-sitter@
|
|
75
|
+
cargo add willbooster-tree-sitter@13.0.0 --rename tree-sitter
|
|
76
76
|
cargo add willbooster-tree-sitter-rust --rename tree-sitter-rust
|
|
77
77
|
```
|
|
78
78
|
|
|
@@ -81,6 +81,12 @@ let mut parser = tree_sitter::Parser::new();
|
|
|
81
81
|
parser.set_language(&tree_sitter_rust::LANGUAGE.into())?;
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
## Conditional chains
|
|
85
|
+
|
|
86
|
+
An `if` / `else if` / `else` chain is one `if_expression`. Its repeated `alternative` field contains a direct
|
|
87
|
+
`else_clause` for each `else if` and any final `else`. Conditional clauses expose `condition` and `consequence`
|
|
88
|
+
fields. The final `else` exposes only `consequence`.
|
|
89
|
+
|
|
84
90
|
## Box patterns
|
|
85
91
|
|
|
86
92
|
`box_pattern` exposes its operand through the `pattern` field, including anonymous `_` patterns.
|
package/grammar.js
CHANGED
|
@@ -1319,6 +1319,7 @@ module.exports = grammar({
|
|
|
1319
1319
|
'if',
|
|
1320
1320
|
field('condition', $._condition),
|
|
1321
1321
|
field('consequence', $.block),
|
|
1322
|
+
repeat(field('alternative', alias($._else_if_clause, $.else_clause))),
|
|
1322
1323
|
optional(field('alternative', $.else_clause))
|
|
1323
1324
|
)
|
|
1324
1325
|
),
|
|
@@ -1346,7 +1347,9 @@ module.exports = grammar({
|
|
|
1346
1347
|
|
|
1347
1348
|
_condition: ($) => choice($._expression, $.let_condition, alias($._let_chain, sym('let_chain'))),
|
|
1348
1349
|
|
|
1349
|
-
|
|
1350
|
+
_else_if_clause: ($) => seq('else', 'if', field('condition', $._condition), field('consequence', $.block)),
|
|
1351
|
+
|
|
1352
|
+
else_clause: ($) => seq('else', field('consequence', $.block)),
|
|
1350
1353
|
|
|
1351
1354
|
match_expression: ($) => seq('match', field('value', $._expression), field('body', $.match_block)),
|
|
1352
1355
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-rust",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Rust grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
49
|
"@willbooster/wb": "22.26.2",
|
|
50
|
-
"@willbooster/web-tree-sitter": "
|
|
50
|
+
"@willbooster/web-tree-sitter": "13.0.0",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
52
52
|
"lefthook": "2.2.2",
|
|
53
53
|
"oxfmt": "0.73.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"wrangler": "4.149.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"@willbooster/web-tree-sitter": "^
|
|
64
|
+
"@willbooster/web-tree-sitter": "^13.0.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@willbooster/web-tree-sitter": {
|
package/src/node-types.json
CHANGED
|
@@ -1792,20 +1792,35 @@
|
|
|
1792
1792
|
{
|
|
1793
1793
|
"type": "else_clause",
|
|
1794
1794
|
"named": true,
|
|
1795
|
-
"fields": {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1795
|
+
"fields": {
|
|
1796
|
+
"condition": {
|
|
1797
|
+
"multiple": false,
|
|
1798
|
+
"required": false,
|
|
1799
|
+
"types": [
|
|
1800
|
+
{
|
|
1801
|
+
"type": "_expression",
|
|
1802
|
+
"named": true
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
"type": "let_chain",
|
|
1806
|
+
"named": true
|
|
1807
|
+
},
|
|
1808
|
+
{
|
|
1809
|
+
"type": "let_condition",
|
|
1810
|
+
"named": true
|
|
1811
|
+
}
|
|
1812
|
+
]
|
|
1813
|
+
},
|
|
1814
|
+
"consequence": {
|
|
1815
|
+
"multiple": false,
|
|
1816
|
+
"required": true,
|
|
1817
|
+
"types": [
|
|
1818
|
+
{
|
|
1819
|
+
"type": "block",
|
|
1820
|
+
"named": true
|
|
1821
|
+
}
|
|
1822
|
+
]
|
|
1823
|
+
}
|
|
1809
1824
|
}
|
|
1810
1825
|
},
|
|
1811
1826
|
{
|
|
@@ -2711,7 +2726,7 @@
|
|
|
2711
2726
|
"named": true,
|
|
2712
2727
|
"fields": {
|
|
2713
2728
|
"alternative": {
|
|
2714
|
-
"multiple":
|
|
2729
|
+
"multiple": true,
|
|
2715
2730
|
"required": false,
|
|
2716
2731
|
"types": [
|
|
2717
2732
|
{
|
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|