@willbooster/tree-sitter-rust 12.0.0 → 13.0.1
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 +6 -0
- package/grammar.js +15 -1
- package/package.json +1 -1
- package/src/node-types.json +30 -15
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
@@ -154,6 +154,7 @@ module.exports = grammar({
|
|
|
154
154
|
sym('_orphan_line_doc_comment_start'),
|
|
155
155
|
sym('_orphan_block_doc_comment_start'),
|
|
156
156
|
sym('_orphan_doc_missing_owner'),
|
|
157
|
+
sym('_trailing_type_bound_plus'),
|
|
157
158
|
],
|
|
158
159
|
|
|
159
160
|
supertypes: ($) => [
|
|
@@ -193,6 +194,7 @@ module.exports = grammar({
|
|
|
193
194
|
// Local ambiguity due to anonymous types:
|
|
194
195
|
// See https://internals.rust-lang.org/t/pre-rfc-deprecating-anonymous-parameters/3710
|
|
195
196
|
[$._type, $._pattern],
|
|
197
|
+
[$._type, $._trailing_bounded_type],
|
|
196
198
|
[$.unit_type, $.tuple_pattern],
|
|
197
199
|
[$.scoped_identifier, $.scoped_type_identifier],
|
|
198
200
|
[$.parameters, $.tuple_struct_pattern],
|
|
@@ -660,6 +662,7 @@ module.exports = grammar({
|
|
|
660
662
|
$.function_type,
|
|
661
663
|
$.dynamic_type,
|
|
662
664
|
$.bounded_type,
|
|
665
|
+
alias($._trailing_bounded_type, $.bounded_type),
|
|
663
666
|
$.macro_invocation,
|
|
664
667
|
$.never_type,
|
|
665
668
|
$.array_type,
|
|
@@ -860,6 +863,7 @@ module.exports = grammar({
|
|
|
860
863
|
$.never_type,
|
|
861
864
|
$.dynamic_type,
|
|
862
865
|
$.bounded_type,
|
|
866
|
+
alias($._trailing_bounded_type, $.bounded_type),
|
|
863
867
|
$.removed_trait_bound,
|
|
864
868
|
$.modified_trait_bound,
|
|
865
869
|
alias(choice(...primitiveTypes), sym('primitive_type'))
|
|
@@ -962,6 +966,13 @@ module.exports = grammar({
|
|
|
962
966
|
)
|
|
963
967
|
),
|
|
964
968
|
|
|
969
|
+
_trailing_bounded_type: ($) =>
|
|
970
|
+
seq(
|
|
971
|
+
choice($.dynamic_type, $.abstract_type),
|
|
972
|
+
repeat(seq('+', choice($.lifetime, $._type, $.use_bounds, prec.dynamic(-2, $.higher_ranked_trait_bound)))),
|
|
973
|
+
alias(sym('_trailing_type_bound_plus'), '+')
|
|
974
|
+
),
|
|
975
|
+
|
|
965
976
|
use_bounds: ($) =>
|
|
966
977
|
seq('use', token(prec(1, '<')), sepBy(',', choice($.lifetime, $._type_identifier)), optional(','), '>'),
|
|
967
978
|
|
|
@@ -1319,6 +1330,7 @@ module.exports = grammar({
|
|
|
1319
1330
|
'if',
|
|
1320
1331
|
field('condition', $._condition),
|
|
1321
1332
|
field('consequence', $.block),
|
|
1333
|
+
repeat(field('alternative', alias($._else_if_clause, $.else_clause))),
|
|
1322
1334
|
optional(field('alternative', $.else_clause))
|
|
1323
1335
|
)
|
|
1324
1336
|
),
|
|
@@ -1346,7 +1358,9 @@ module.exports = grammar({
|
|
|
1346
1358
|
|
|
1347
1359
|
_condition: ($) => choice($._expression, $.let_condition, alias($._let_chain, sym('let_chain'))),
|
|
1348
1360
|
|
|
1349
|
-
|
|
1361
|
+
_else_if_clause: ($) => seq('else', 'if', field('condition', $._condition), field('consequence', $.block)),
|
|
1362
|
+
|
|
1363
|
+
else_clause: ($) => seq('else', field('consequence', $.block)),
|
|
1350
1364
|
|
|
1351
1365
|
match_expression: ($) => seq('match', field('value', $._expression), field('body', $.match_block)),
|
|
1352
1366
|
|
package/package.json
CHANGED
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
|