@willbooster/tree-sitter-rust 1.10.0 → 1.10.2
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/grammar.js +31 -12
- package/package.json +1 -1
- package/src/node-types.json +5 -4
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -105,6 +105,7 @@ const TOKEN_TREE_NON_SPECIAL_PUNCTUATION = [
|
|
|
105
105
|
|
|
106
106
|
const primitiveTypes = [...numericTypes, 'bool', 'str', 'char'];
|
|
107
107
|
const reservedIdentifiers = ['default', 'union', 'gen', 'raw'];
|
|
108
|
+
const fieldIdentifierKeywords = [...reservedIdentifiers, ...primitiveTypes, 'auto'];
|
|
108
109
|
|
|
109
110
|
// oxlint-disable-next-line unicorn/prefer-module -- This package is CommonJS, so tree-sitter loads grammar.js as CommonJS.
|
|
110
111
|
module.exports = grammar({
|
|
@@ -142,6 +143,9 @@ module.exports = grammar({
|
|
|
142
143
|
],
|
|
143
144
|
|
|
144
145
|
conflicts: ($) => [
|
|
146
|
+
[$.field_initializer_list, $.block],
|
|
147
|
+
[$._declaration_statement, $.shorthand_field_initializer, $.field_initializer],
|
|
148
|
+
[$._expression_except_range, $.shorthand_field_initializer],
|
|
145
149
|
[$._declaration_statement, $.attributed_expression],
|
|
146
150
|
[$._expression_except_range, $.struct_expression],
|
|
147
151
|
[$.function_modifiers, $.modified_trait_bound],
|
|
@@ -996,6 +1000,10 @@ module.exports = grammar({
|
|
|
996
1000
|
prec.left(PREC.range, seq($._expression, choice('..', '...', '..='), $._expression)),
|
|
997
1001
|
prec.left(PREC.range, seq($._expression, '..')),
|
|
998
1002
|
prec.left(PREC.range, seq(choice('..', '..='), $._expression)),
|
|
1003
|
+
prec.right(
|
|
1004
|
+
PREC.range + 1,
|
|
1005
|
+
seq($._expression, choice('..', '..='), $._range_unary_endpoint_start, $._expression)
|
|
1006
|
+
),
|
|
999
1007
|
prec.right(PREC.range + 1, seq(choice('..', '..='), $._range_unary_endpoint_start, $._expression)),
|
|
1000
1008
|
prec.left(PREC.range, '..')
|
|
1001
1009
|
),
|
|
@@ -1096,7 +1104,7 @@ module.exports = grammar({
|
|
|
1096
1104
|
'name',
|
|
1097
1105
|
choice(
|
|
1098
1106
|
$._type_identifier,
|
|
1099
|
-
prec.dynamic(-1, alias(choice(...primitiveTypes), $.type_identifier)),
|
|
1107
|
+
prec.dynamic(-1, alias(choice(...primitiveTypes, ...reservedIdentifiers), $.type_identifier)),
|
|
1100
1108
|
alias($.scoped_type_identifier_in_expression_position, $.scoped_type_identifier),
|
|
1101
1109
|
$.generic_type_with_turbofish
|
|
1102
1110
|
)
|
|
@@ -1112,12 +1120,20 @@ module.exports = grammar({
|
|
|
1112
1120
|
'}'
|
|
1113
1121
|
),
|
|
1114
1122
|
|
|
1115
|
-
shorthand_field_initializer: ($) =>
|
|
1123
|
+
shorthand_field_initializer: ($) =>
|
|
1124
|
+
seq(repeat($.attribute_item), choice($.identifier, alias(choice(...fieldIdentifierKeywords), $.identifier))),
|
|
1116
1125
|
|
|
1117
1126
|
field_initializer: ($) =>
|
|
1118
1127
|
seq(
|
|
1119
1128
|
repeat($.attribute_item),
|
|
1120
|
-
field(
|
|
1129
|
+
field(
|
|
1130
|
+
'field',
|
|
1131
|
+
choice(
|
|
1132
|
+
$._field_identifier,
|
|
1133
|
+
alias(choice(...fieldIdentifierKeywords), $.field_identifier),
|
|
1134
|
+
alias(/[0-9][0-9_]*/, $.integer_literal)
|
|
1135
|
+
)
|
|
1136
|
+
),
|
|
1121
1137
|
':',
|
|
1122
1138
|
field('value', $._expression)
|
|
1123
1139
|
),
|
|
@@ -1394,15 +1410,18 @@ module.exports = grammar({
|
|
|
1394
1410
|
negative_literal: ($) => seq('-', choice($.integer_literal, $.float_literal)),
|
|
1395
1411
|
|
|
1396
1412
|
integer_literal: () =>
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1413
|
+
choice(
|
|
1414
|
+
/[0-9][0-9_]*/,
|
|
1415
|
+
token(
|
|
1416
|
+
choice(
|
|
1417
|
+
seq(
|
|
1418
|
+
choice(/[1-9][0-9_]*/, /0[0-9_]+/, /0b_*[01][01_]*/, /0o_*[0-7][0-7_]*/),
|
|
1419
|
+
optional(numericSuffixWithoutExponent)
|
|
1420
|
+
),
|
|
1421
|
+
/0[box]_+/,
|
|
1422
|
+
seq('0', optional(zeroNumericSuffix)),
|
|
1423
|
+
seq(/0x_*[0-9a-fA-F][0-9a-fA-F_]*/, optional(hexadecimalSuffix))
|
|
1424
|
+
)
|
|
1406
1425
|
)
|
|
1407
1426
|
),
|
|
1408
1427
|
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -2674,6 +2674,11 @@
|
|
|
2674
2674
|
"named": true,
|
|
2675
2675
|
"fields": {}
|
|
2676
2676
|
},
|
|
2677
|
+
{
|
|
2678
|
+
"type": "integer_literal",
|
|
2679
|
+
"named": true,
|
|
2680
|
+
"fields": {}
|
|
2681
|
+
},
|
|
2677
2682
|
{
|
|
2678
2683
|
"type": "label",
|
|
2679
2684
|
"named": true,
|
|
@@ -5590,10 +5595,6 @@
|
|
|
5590
5595
|
"type": "in",
|
|
5591
5596
|
"named": false
|
|
5592
5597
|
},
|
|
5593
|
-
{
|
|
5594
|
-
"type": "integer_literal",
|
|
5595
|
-
"named": true
|
|
5596
|
-
},
|
|
5597
5598
|
{
|
|
5598
5599
|
"type": "item",
|
|
5599
5600
|
"named": false
|
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|