@willbooster/tree-sitter-rust 8.0.0 → 10.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 +16 -4
- package/grammar.js +7 -2
- package/package.json +1 -1
- package/queries/highlights.scm +3 -0
- package/src/node-types.json +24 -0
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -71,10 +71,9 @@ In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-
|
|
|
71
71
|
fuzzed with. The parser requires version 7.0.5 or later within major version 7 of that runtime; upstream's
|
|
72
72
|
`tree-sitter` crate rejects it:
|
|
73
73
|
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
tree-sitter-rust = { package = "willbooster-tree-sitter-rust", version = "8" }
|
|
74
|
+
```sh
|
|
75
|
+
cargo add willbooster-tree-sitter@7.0.5 --rename tree-sitter
|
|
76
|
+
cargo add willbooster-tree-sitter-rust --rename tree-sitter-rust
|
|
78
77
|
```
|
|
79
78
|
|
|
80
79
|
```rust
|
|
@@ -82,11 +81,24 @@ let mut parser = tree_sitter::Parser::new();
|
|
|
82
81
|
parser.set_language(&tree_sitter_rust::LANGUAGE.into())?;
|
|
83
82
|
```
|
|
84
83
|
|
|
84
|
+
## Box patterns
|
|
85
|
+
|
|
86
|
+
`box_pattern` exposes its operand through the `pattern` field, including anonymous `_` patterns.
|
|
87
|
+
Nested `box` patterns produce nested nodes; `box 6 | box 7` produces two boxed alternatives.
|
|
88
|
+
The `box` keyword is an anonymous token, including inside macro token trees; `r#box` remains an identifier.
|
|
89
|
+
The grammar parses this feature-gated syntax without evaluating Rust's feature attributes.
|
|
90
|
+
|
|
85
91
|
## Macros
|
|
86
92
|
|
|
87
93
|
A macro definition's anonymous `macro_rules!` node covers the `macro_rules` keyword. The `!` is a separate
|
|
88
94
|
anonymous child. A macro invocation's `macro` field contains its name, including when that name is `macro_rules`.
|
|
89
95
|
|
|
96
|
+
## Reference nodes
|
|
97
|
+
|
|
98
|
+
A joint `&&` token produces one `reference_pattern` or `reference_type` node with an anonymous `&&` child.
|
|
99
|
+
Consecutive `&` tokens separated by whitespace or comments produce nested reference nodes.
|
|
100
|
+
For a joint token, an optional lifetime and mutability describe the inner reference.
|
|
101
|
+
|
|
90
102
|
## Attributes
|
|
91
103
|
|
|
92
104
|
An attribute in an expression position can produce an `attributed_expression` node with a `value` field.
|
package/grammar.js
CHANGED
|
@@ -384,6 +384,7 @@ module.exports = grammar({
|
|
|
384
384
|
'async',
|
|
385
385
|
'await',
|
|
386
386
|
'become',
|
|
387
|
+
'box',
|
|
387
388
|
'break',
|
|
388
389
|
'const',
|
|
389
390
|
'continue',
|
|
@@ -993,7 +994,8 @@ module.exports = grammar({
|
|
|
993
994
|
field('type', $._type)
|
|
994
995
|
),
|
|
995
996
|
|
|
996
|
-
reference_type: ($) =>
|
|
997
|
+
reference_type: ($) =>
|
|
998
|
+
seq(choice('&', '&&'), optional($.lifetime), optional($.mutable_specifier), field('type', $._type)),
|
|
997
999
|
|
|
998
1000
|
pointer_type: ($) => seq('*', choice('const', $.mutable_specifier), field('type', $._type)),
|
|
999
1001
|
|
|
@@ -1460,6 +1462,7 @@ module.exports = grammar({
|
|
|
1460
1462
|
$.struct_pattern,
|
|
1461
1463
|
$._reserved_identifier,
|
|
1462
1464
|
$.ref_pattern,
|
|
1465
|
+
$.box_pattern,
|
|
1463
1466
|
$.slice_pattern,
|
|
1464
1467
|
$.captured_pattern,
|
|
1465
1468
|
$.reference_pattern,
|
|
@@ -1576,6 +1579,8 @@ module.exports = grammar({
|
|
|
1576
1579
|
|
|
1577
1580
|
ref_pattern: ($) => seq('ref', $._pattern),
|
|
1578
1581
|
|
|
1582
|
+
box_pattern: ($) => seq('box', field('pattern', $._pattern)),
|
|
1583
|
+
|
|
1579
1584
|
captured_pattern: ($) =>
|
|
1580
1585
|
seq(
|
|
1581
1586
|
choice($.identifier, $._reserved_identifier, alias(choice(...primitiveTypes), $.identifier)),
|
|
@@ -1583,7 +1588,7 @@ module.exports = grammar({
|
|
|
1583
1588
|
$._pattern
|
|
1584
1589
|
),
|
|
1585
1590
|
|
|
1586
|
-
reference_pattern: ($) => seq('&', optional($.mutable_specifier), $._pattern),
|
|
1591
|
+
reference_pattern: ($) => seq(choice('&', '&&'), optional($.mutable_specifier), $._pattern),
|
|
1587
1592
|
|
|
1588
1593
|
or_pattern: ($) => prec.left(-2, choice(seq($._pattern, '|', $._pattern), seq('|', $._pattern))),
|
|
1589
1594
|
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
|
@@ -101,6 +101,7 @@
|
|
|
101
101
|
"auto" @keyword
|
|
102
102
|
"await" @keyword
|
|
103
103
|
"become" @keyword
|
|
104
|
+
"box" @keyword
|
|
104
105
|
"break" @keyword
|
|
105
106
|
"const" @keyword
|
|
106
107
|
"continue" @keyword
|
|
@@ -162,4 +163,6 @@
|
|
|
162
163
|
|
|
163
164
|
"*" @operator
|
|
164
165
|
"&" @operator
|
|
166
|
+
(reference_type "&&" @operator)
|
|
167
|
+
(reference_pattern "&&" @operator)
|
|
165
168
|
"'" @operator
|
package/src/node-types.json
CHANGED
|
@@ -347,6 +347,10 @@
|
|
|
347
347
|
"type": "_literal_pattern",
|
|
348
348
|
"named": true
|
|
349
349
|
},
|
|
350
|
+
{
|
|
351
|
+
"type": "box_pattern",
|
|
352
|
+
"named": true
|
|
353
|
+
},
|
|
350
354
|
{
|
|
351
355
|
"type": "captured_pattern",
|
|
352
356
|
"named": true
|
|
@@ -1163,6 +1167,22 @@
|
|
|
1163
1167
|
]
|
|
1164
1168
|
}
|
|
1165
1169
|
},
|
|
1170
|
+
{
|
|
1171
|
+
"type": "box_pattern",
|
|
1172
|
+
"named": true,
|
|
1173
|
+
"fields": {
|
|
1174
|
+
"pattern": {
|
|
1175
|
+
"multiple": false,
|
|
1176
|
+
"required": true,
|
|
1177
|
+
"types": [
|
|
1178
|
+
{
|
|
1179
|
+
"type": "_pattern",
|
|
1180
|
+
"named": true
|
|
1181
|
+
}
|
|
1182
|
+
]
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
},
|
|
1166
1186
|
{
|
|
1167
1187
|
"type": "bracketed_type",
|
|
1168
1188
|
"named": true,
|
|
@@ -5723,6 +5743,10 @@
|
|
|
5723
5743
|
"type": "block",
|
|
5724
5744
|
"named": false
|
|
5725
5745
|
},
|
|
5746
|
+
{
|
|
5747
|
+
"type": "box",
|
|
5748
|
+
"named": false
|
|
5749
|
+
},
|
|
5726
5750
|
{
|
|
5727
5751
|
"type": "break",
|
|
5728
5752
|
"named": false
|
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|