@willbooster/tree-sitter-rust 1.8.1 → 1.9.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/grammar.js +23 -8
- package/package.json +1 -1
- package/queries/highlights.scm +1 -0
- package/src/node-types.json +4 -0
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -104,6 +104,7 @@ const TOKEN_TREE_NON_SPECIAL_PUNCTUATION = [
|
|
|
104
104
|
];
|
|
105
105
|
|
|
106
106
|
const primitiveTypes = [...numericTypes, 'bool', 'str', 'char'];
|
|
107
|
+
const reservedIdentifiers = ['default', 'union', 'gen', 'raw'];
|
|
107
108
|
|
|
108
109
|
// oxlint-disable-next-line unicorn/prefer-module -- This package is CommonJS, so tree-sitter loads grammar.js as CommonJS.
|
|
109
110
|
module.exports = grammar({
|
|
@@ -556,6 +557,7 @@ module.exports = grammar({
|
|
|
556
557
|
optional($.visibility_modifier),
|
|
557
558
|
optional('const'),
|
|
558
559
|
optional('unsafe'),
|
|
560
|
+
optional('auto'),
|
|
559
561
|
'trait',
|
|
560
562
|
field('name', $._type_identifier),
|
|
561
563
|
field('type_parameters', optional($.type_parameters)),
|
|
@@ -755,6 +757,7 @@ module.exports = grammar({
|
|
|
755
757
|
'function',
|
|
756
758
|
choice(
|
|
757
759
|
$.identifier,
|
|
760
|
+
$._reserved_identifier,
|
|
758
761
|
alias(choice(...primitiveTypes), $.identifier),
|
|
759
762
|
$.scoped_identifier,
|
|
760
763
|
$.field_expression
|
|
@@ -774,7 +777,7 @@ module.exports = grammar({
|
|
|
774
777
|
choice(
|
|
775
778
|
$._type_identifier,
|
|
776
779
|
alias(choice(...primitiveTypes), $.type_identifier),
|
|
777
|
-
$.
|
|
780
|
+
alias(choice(...reservedIdentifiers), $.identifier),
|
|
778
781
|
$.scoped_type_identifier
|
|
779
782
|
)
|
|
780
783
|
),
|
|
@@ -955,7 +958,7 @@ module.exports = grammar({
|
|
|
955
958
|
optional(choice($._path, $.bracketed_type, alias($.generic_type_with_turbofish, $.generic_type)))
|
|
956
959
|
),
|
|
957
960
|
'::',
|
|
958
|
-
field('name', choice($.identifier, $.super))
|
|
961
|
+
field('name', choice($.identifier, $._reserved_identifier, $.super))
|
|
959
962
|
),
|
|
960
963
|
|
|
961
964
|
scoped_type_identifier_in_expression_position: ($) =>
|
|
@@ -964,7 +967,7 @@ module.exports = grammar({
|
|
|
964
967
|
seq(
|
|
965
968
|
field('path', optional(choice($._path, alias($.generic_type_with_turbofish, $.generic_type)))),
|
|
966
969
|
'::',
|
|
967
|
-
field('name', $._type_identifier)
|
|
970
|
+
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers), $.type_identifier)))
|
|
968
971
|
)
|
|
969
972
|
),
|
|
970
973
|
|
|
@@ -977,7 +980,7 @@ module.exports = grammar({
|
|
|
977
980
|
)
|
|
978
981
|
),
|
|
979
982
|
'::',
|
|
980
|
-
field('name', $._type_identifier)
|
|
983
|
+
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers), $.type_identifier)))
|
|
981
984
|
),
|
|
982
985
|
|
|
983
986
|
range_expression: ($) =>
|
|
@@ -1257,7 +1260,13 @@ module.exports = grammar({
|
|
|
1257
1260
|
|
|
1258
1261
|
generic_pattern: ($) =>
|
|
1259
1262
|
seq(
|
|
1260
|
-
choice(
|
|
1263
|
+
choice(
|
|
1264
|
+
$.identifier,
|
|
1265
|
+
$._reserved_identifier,
|
|
1266
|
+
alias(choice(...primitiveTypes), $.identifier),
|
|
1267
|
+
$.scoped_identifier
|
|
1268
|
+
),
|
|
1269
|
+
|
|
1261
1270
|
'::',
|
|
1262
1271
|
field('type_arguments', $.type_arguments)
|
|
1263
1272
|
),
|
|
@@ -1272,6 +1281,7 @@ module.exports = grammar({
|
|
|
1272
1281
|
'type',
|
|
1273
1282
|
choice(
|
|
1274
1283
|
$.identifier,
|
|
1284
|
+
$._reserved_identifier,
|
|
1275
1285
|
alias(choice(...primitiveTypes), $.identifier),
|
|
1276
1286
|
$.scoped_identifier,
|
|
1277
1287
|
alias($.generic_type_with_turbofish, $.generic_type)
|
|
@@ -1336,7 +1346,12 @@ module.exports = grammar({
|
|
|
1336
1346
|
|
|
1337
1347
|
ref_pattern: ($) => seq('ref', $._pattern),
|
|
1338
1348
|
|
|
1339
|
-
captured_pattern: ($) =>
|
|
1349
|
+
captured_pattern: ($) =>
|
|
1350
|
+
seq(
|
|
1351
|
+
choice($.identifier, $._reserved_identifier, alias(choice(...primitiveTypes), $.identifier)),
|
|
1352
|
+
'@',
|
|
1353
|
+
$._pattern
|
|
1354
|
+
),
|
|
1340
1355
|
|
|
1341
1356
|
reference_pattern: ($) => seq('&', optional($.mutable_specifier), $._pattern),
|
|
1342
1357
|
|
|
@@ -1481,9 +1496,9 @@ module.exports = grammar({
|
|
|
1481
1496
|
// oxlint-disable-next-line no-useless-escape -- tree-sitter's regex parser rejects an unescaped `[` in a character class.
|
|
1482
1497
|
shebang: () => /#![\r\f\t\v ]*([^\[\n].*)?\n/,
|
|
1483
1498
|
|
|
1484
|
-
_reserved_identifier: ($) => alias(choice(
|
|
1499
|
+
_reserved_identifier: ($) => alias(choice(...reservedIdentifiers, 'auto'), $.identifier),
|
|
1485
1500
|
|
|
1486
|
-
_type_identifier: ($) => alias($.identifier, $.type_identifier),
|
|
1501
|
+
_type_identifier: ($) => alias(choice($.identifier, 'auto'), $.type_identifier),
|
|
1487
1502
|
_field_identifier: ($) => alias($.identifier, $.field_identifier),
|
|
1488
1503
|
|
|
1489
1504
|
self: () => 'self',
|
package/package.json
CHANGED
package/queries/highlights.scm
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|