@willbooster/tree-sitter-rust 12.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 +6 -0
- package/grammar.js +4 -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
|
@@ -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
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
|