@willbooster/tree-sitter-rust 1.8.1 → 1.9.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/grammar.js +34 -11
- 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
|
),
|
|
@@ -786,7 +789,11 @@ module.exports = grammar({
|
|
|
786
789
|
seq(
|
|
787
790
|
field(
|
|
788
791
|
'type',
|
|
789
|
-
choice(
|
|
792
|
+
choice(
|
|
793
|
+
$._type_identifier,
|
|
794
|
+
alias(choice(...primitiveTypes, ...reservedIdentifiers), $.type_identifier),
|
|
795
|
+
$.scoped_identifier
|
|
796
|
+
)
|
|
790
797
|
),
|
|
791
798
|
'::',
|
|
792
799
|
field('type_arguments', $.type_arguments)
|
|
@@ -955,7 +962,7 @@ module.exports = grammar({
|
|
|
955
962
|
optional(choice($._path, $.bracketed_type, alias($.generic_type_with_turbofish, $.generic_type)))
|
|
956
963
|
),
|
|
957
964
|
'::',
|
|
958
|
-
field('name', choice($.identifier, $.super))
|
|
965
|
+
field('name', choice($.identifier, $._reserved_identifier, $.super))
|
|
959
966
|
),
|
|
960
967
|
|
|
961
968
|
scoped_type_identifier_in_expression_position: ($) =>
|
|
@@ -964,7 +971,7 @@ module.exports = grammar({
|
|
|
964
971
|
seq(
|
|
965
972
|
field('path', optional(choice($._path, alias($.generic_type_with_turbofish, $.generic_type)))),
|
|
966
973
|
'::',
|
|
967
|
-
field('name', $._type_identifier)
|
|
974
|
+
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers), $.type_identifier)))
|
|
968
975
|
)
|
|
969
976
|
),
|
|
970
977
|
|
|
@@ -977,7 +984,7 @@ module.exports = grammar({
|
|
|
977
984
|
)
|
|
978
985
|
),
|
|
979
986
|
'::',
|
|
980
|
-
field('name', $._type_identifier)
|
|
987
|
+
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers), $.type_identifier)))
|
|
981
988
|
),
|
|
982
989
|
|
|
983
990
|
range_expression: ($) =>
|
|
@@ -1257,7 +1264,13 @@ module.exports = grammar({
|
|
|
1257
1264
|
|
|
1258
1265
|
generic_pattern: ($) =>
|
|
1259
1266
|
seq(
|
|
1260
|
-
choice(
|
|
1267
|
+
choice(
|
|
1268
|
+
$.identifier,
|
|
1269
|
+
$._reserved_identifier,
|
|
1270
|
+
alias(choice(...primitiveTypes), $.identifier),
|
|
1271
|
+
$.scoped_identifier
|
|
1272
|
+
),
|
|
1273
|
+
|
|
1261
1274
|
'::',
|
|
1262
1275
|
field('type_arguments', $.type_arguments)
|
|
1263
1276
|
),
|
|
@@ -1272,6 +1285,7 @@ module.exports = grammar({
|
|
|
1272
1285
|
'type',
|
|
1273
1286
|
choice(
|
|
1274
1287
|
$.identifier,
|
|
1288
|
+
$._reserved_identifier,
|
|
1275
1289
|
alias(choice(...primitiveTypes), $.identifier),
|
|
1276
1290
|
$.scoped_identifier,
|
|
1277
1291
|
alias($.generic_type_with_turbofish, $.generic_type)
|
|
@@ -1289,7 +1303,7 @@ module.exports = grammar({
|
|
|
1289
1303
|
'type',
|
|
1290
1304
|
choice(
|
|
1291
1305
|
$._type_identifier,
|
|
1292
|
-
alias(choice(...primitiveTypes), $.type_identifier),
|
|
1306
|
+
alias(choice(...primitiveTypes, ...reservedIdentifiers), $.type_identifier),
|
|
1293
1307
|
$.scoped_type_identifier,
|
|
1294
1308
|
alias($._generic_struct_pattern_type, $.generic_type)
|
|
1295
1309
|
)
|
|
@@ -1304,7 +1318,11 @@ module.exports = grammar({
|
|
|
1304
1318
|
seq(
|
|
1305
1319
|
field(
|
|
1306
1320
|
'type',
|
|
1307
|
-
choice(
|
|
1321
|
+
choice(
|
|
1322
|
+
$._type_identifier,
|
|
1323
|
+
alias(choice(...primitiveTypes, ...reservedIdentifiers), $.type_identifier),
|
|
1324
|
+
$.scoped_type_identifier
|
|
1325
|
+
)
|
|
1308
1326
|
),
|
|
1309
1327
|
'::',
|
|
1310
1328
|
field('type_arguments', $.type_arguments)
|
|
@@ -1336,7 +1354,12 @@ module.exports = grammar({
|
|
|
1336
1354
|
|
|
1337
1355
|
ref_pattern: ($) => seq('ref', $._pattern),
|
|
1338
1356
|
|
|
1339
|
-
captured_pattern: ($) =>
|
|
1357
|
+
captured_pattern: ($) =>
|
|
1358
|
+
seq(
|
|
1359
|
+
choice($.identifier, $._reserved_identifier, alias(choice(...primitiveTypes), $.identifier)),
|
|
1360
|
+
'@',
|
|
1361
|
+
$._pattern
|
|
1362
|
+
),
|
|
1340
1363
|
|
|
1341
1364
|
reference_pattern: ($) => seq('&', optional($.mutable_specifier), $._pattern),
|
|
1342
1365
|
|
|
@@ -1481,9 +1504,9 @@ module.exports = grammar({
|
|
|
1481
1504
|
// oxlint-disable-next-line no-useless-escape -- tree-sitter's regex parser rejects an unescaped `[` in a character class.
|
|
1482
1505
|
shebang: () => /#![\r\f\t\v ]*([^\[\n].*)?\n/,
|
|
1483
1506
|
|
|
1484
|
-
_reserved_identifier: ($) => alias(choice(
|
|
1507
|
+
_reserved_identifier: ($) => alias(choice(...reservedIdentifiers, 'auto'), $.identifier),
|
|
1485
1508
|
|
|
1486
|
-
_type_identifier: ($) => alias($.identifier, $.type_identifier),
|
|
1509
|
+
_type_identifier: ($) => alias(choice($.identifier, 'auto'), $.type_identifier),
|
|
1487
1510
|
_field_identifier: ($) => alias($.identifier, $.field_identifier),
|
|
1488
1511
|
|
|
1489
1512
|
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
|