@willbooster/tree-sitter-rust 1.10.2 → 1.10.3
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 +71 -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
|
@@ -34,6 +34,11 @@ const numericSuffixWithoutExponent = new RegExp(String.raw`[\p{XID_Start}--[eE]]
|
|
|
34
34
|
const zeroNumericSuffix = new RegExp(String.raw`[\p{XID_Start}--[eEbox]][_\p{XID_Continue}]*`, 'v');
|
|
35
35
|
const hexadecimalSuffix = new RegExp(String.raw`[\p{XID_Start}--[a-fA-F]][_\p{XID_Continue}]*`, 'v');
|
|
36
36
|
|
|
37
|
+
const nonAsciiOrRawMacroName = new RegExp(
|
|
38
|
+
String.raw`(?:[\p{XID_Start}--[\x00-\x7f]][_\p{XID_Continue}]*|[_a-zA-Z][_\p{XID_Continue}]*[\p{XID_Continue}--[\x00-\x7f]][_\p{XID_Continue}]*|r#[_\p{XID_Start}][_\p{XID_Continue}]*)`,
|
|
39
|
+
'v'
|
|
40
|
+
);
|
|
41
|
+
|
|
37
42
|
const extendedFloatTypes = ['f16', 'f128'];
|
|
38
43
|
|
|
39
44
|
const numericTypes = [
|
|
@@ -117,7 +122,7 @@ module.exports = grammar({
|
|
|
117
122
|
$.string_content,
|
|
118
123
|
$.string_close,
|
|
119
124
|
$._raw_string_literal_start,
|
|
120
|
-
$.
|
|
125
|
+
$._raw_string_literal_content,
|
|
121
126
|
$._raw_string_literal_end,
|
|
122
127
|
$._trailing_dot_float_literal,
|
|
123
128
|
$._outer_block_doc_comment_marker,
|
|
@@ -128,6 +133,7 @@ module.exports = grammar({
|
|
|
128
133
|
$._error_sentinel,
|
|
129
134
|
$._foreign_declaration_context,
|
|
130
135
|
$._foreign_declaration_start,
|
|
136
|
+
$._macro_metavariable_name,
|
|
131
137
|
],
|
|
132
138
|
|
|
133
139
|
supertypes: ($) => [$._declaration_statement, $._expression, $._type, $._literal, $._literal_pattern, $._pattern],
|
|
@@ -143,8 +149,9 @@ module.exports = grammar({
|
|
|
143
149
|
],
|
|
144
150
|
|
|
145
151
|
conflicts: ($) => [
|
|
152
|
+
[$._token_pattern, $.token_repetition_pattern],
|
|
153
|
+
[$.token_tree, $.token_repetition],
|
|
146
154
|
[$.field_initializer_list, $.block],
|
|
147
|
-
[$._declaration_statement, $.shorthand_field_initializer, $.field_initializer],
|
|
148
155
|
[$._expression_except_range, $.shorthand_field_initializer],
|
|
149
156
|
[$._declaration_statement, $.attributed_expression],
|
|
150
157
|
[$._expression_except_range, $.struct_expression],
|
|
@@ -210,7 +217,7 @@ module.exports = grammar({
|
|
|
210
217
|
const rules = seq(repeat(seq($.macro_rule, ';')), optional($.macro_rule));
|
|
211
218
|
|
|
212
219
|
return seq(
|
|
213
|
-
'macro_rules!',
|
|
220
|
+
choice('macro_rules!', seq(alias('macro_rules', 'macro_rules!'), '!')),
|
|
214
221
|
field('name', choice($.identifier, $._reserved_identifier)),
|
|
215
222
|
choice(seq('(', rules, ')', ';'), seq('[', rules, ']', ';'), seq('{', rules, '}'))
|
|
216
223
|
);
|
|
@@ -232,7 +239,8 @@ module.exports = grammar({
|
|
|
232
239
|
$.token_tree_pattern,
|
|
233
240
|
$.token_repetition_pattern,
|
|
234
241
|
$.token_binding_pattern,
|
|
235
|
-
$.
|
|
242
|
+
$._macro_metavariable,
|
|
243
|
+
'$',
|
|
236
244
|
$._non_special_token
|
|
237
245
|
),
|
|
238
246
|
|
|
@@ -243,10 +251,27 @@ module.exports = grammar({
|
|
|
243
251
|
seq('{', repeat($._token_pattern), '}')
|
|
244
252
|
),
|
|
245
253
|
|
|
246
|
-
token_binding_pattern: ($) =>
|
|
254
|
+
token_binding_pattern: ($) =>
|
|
255
|
+
prec(1, seq(field('name', $._macro_metavariable), ':', field('type', $.fragment_specifier))),
|
|
247
256
|
|
|
248
257
|
token_repetition_pattern: ($) =>
|
|
249
|
-
|
|
258
|
+
prec.dynamic(
|
|
259
|
+
2,
|
|
260
|
+
seq(
|
|
261
|
+
'$',
|
|
262
|
+
'(',
|
|
263
|
+
repeat($._token_pattern),
|
|
264
|
+
')',
|
|
265
|
+
optional(
|
|
266
|
+
macroRepetitionSeparator(
|
|
267
|
+
$._raw_string_literal_start,
|
|
268
|
+
$._raw_string_literal_content,
|
|
269
|
+
$._raw_string_literal_end
|
|
270
|
+
)
|
|
271
|
+
),
|
|
272
|
+
choice('+', '*', '?')
|
|
273
|
+
)
|
|
274
|
+
),
|
|
250
275
|
|
|
251
276
|
fragment_specifier: () =>
|
|
252
277
|
choice(
|
|
@@ -267,12 +292,29 @@ module.exports = grammar({
|
|
|
267
292
|
'vis'
|
|
268
293
|
),
|
|
269
294
|
|
|
270
|
-
_tokens: ($) => choice($.token_tree, $.token_repetition, $.
|
|
295
|
+
_tokens: ($) => choice($.token_tree, $.token_repetition, $._macro_metavariable, '$', $._non_special_token),
|
|
271
296
|
|
|
272
297
|
token_tree: ($) =>
|
|
273
298
|
choice(seq('(', repeat($._tokens), ')'), seq('[', repeat($._tokens), ']'), seq('{', repeat($._tokens), '}')),
|
|
274
299
|
|
|
275
|
-
token_repetition: ($) =>
|
|
300
|
+
token_repetition: ($) =>
|
|
301
|
+
prec.dynamic(
|
|
302
|
+
2,
|
|
303
|
+
seq(
|
|
304
|
+
'$',
|
|
305
|
+
'(',
|
|
306
|
+
repeat($._tokens),
|
|
307
|
+
')',
|
|
308
|
+
optional(
|
|
309
|
+
macroRepetitionSeparator(
|
|
310
|
+
$._raw_string_literal_start,
|
|
311
|
+
$._raw_string_literal_content,
|
|
312
|
+
$._raw_string_literal_end
|
|
313
|
+
)
|
|
314
|
+
),
|
|
315
|
+
choice('+', '*', '?')
|
|
316
|
+
)
|
|
317
|
+
),
|
|
276
318
|
|
|
277
319
|
_non_special_token: ($) =>
|
|
278
320
|
choice(
|
|
@@ -1451,7 +1493,7 @@ module.exports = grammar({
|
|
|
1451
1493
|
raw_string_literal: ($) =>
|
|
1452
1494
|
seq(
|
|
1453
1495
|
$._raw_string_literal_start,
|
|
1454
|
-
alias($.
|
|
1496
|
+
alias($._raw_string_literal_content, $.string_content),
|
|
1455
1497
|
$._raw_string_literal_end
|
|
1456
1498
|
),
|
|
1457
1499
|
|
|
@@ -1528,19 +1570,36 @@ module.exports = grammar({
|
|
|
1528
1570
|
// oxlint-disable-next-line no-useless-escape -- tree-sitter's regex parser rejects an unescaped `[` in a character class.
|
|
1529
1571
|
shebang: () => /#![\r\f\t\v ]*([^\[\n].*)?\n/,
|
|
1530
1572
|
|
|
1531
|
-
_reserved_identifier: ($) => alias(choice(...reservedIdentifiers, 'auto'), $.identifier),
|
|
1573
|
+
_reserved_identifier: ($) => alias(choice(...reservedIdentifiers, 'auto', 'macro_rules'), $.identifier),
|
|
1532
1574
|
|
|
1533
|
-
_type_identifier: ($) => alias(choice($.identifier, 'auto'), $.type_identifier),
|
|
1575
|
+
_type_identifier: ($) => alias(choice($.identifier, 'auto', 'macro_rules'), $.type_identifier),
|
|
1534
1576
|
_field_identifier: ($) => alias($.identifier, $.field_identifier),
|
|
1535
1577
|
|
|
1536
1578
|
self: () => 'self',
|
|
1537
1579
|
super: () => 'super',
|
|
1538
1580
|
crate: () => 'crate',
|
|
1539
1581
|
|
|
1540
|
-
|
|
1582
|
+
_macro_metavariable: ($) => choice($.metavariable, alias($._spaced_metavariable, $.metavariable)),
|
|
1583
|
+
_spaced_metavariable: ($) =>
|
|
1584
|
+
prec.dynamic(1, seq('$', choice($._macro_metavariable_name, token(prec(1, nonAsciiOrRawMacroName))))),
|
|
1585
|
+
metavariable: () => /\$(r#)?[_\p{XID_Start}][_\p{XID_Continue}]*/u,
|
|
1541
1586
|
},
|
|
1542
1587
|
});
|
|
1543
1588
|
|
|
1589
|
+
/**
|
|
1590
|
+
* @param {RuleOrLiteral} start
|
|
1591
|
+
* @param {RuleOrLiteral} content
|
|
1592
|
+
* @param {RuleOrLiteral} end
|
|
1593
|
+
*/
|
|
1594
|
+
function macroRepetitionSeparator(start, content, end) {
|
|
1595
|
+
return choice(
|
|
1596
|
+
/[^\s/+*?$"][^/+*?$"]*|\/(?:[^/*+*?$"][^/+*?$"]*)?|\$/,
|
|
1597
|
+
/[bc]?"(?:[^"\\]|\\[\s\S])*"/,
|
|
1598
|
+
/b?'(?:\\(?:[^xu]|u[0-9a-fA-F]{4}|u\{[0-9a-fA-F]+\}|x[0-9a-fA-F]{2})|[^\\'])'/,
|
|
1599
|
+
seq(start, content, end)
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1544
1603
|
/**
|
|
1545
1604
|
* @param {RuleOrLiteral} sep
|
|
1546
1605
|
* @param {RuleOrLiteral} rule
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -3096,6 +3096,11 @@
|
|
|
3096
3096
|
]
|
|
3097
3097
|
}
|
|
3098
3098
|
},
|
|
3099
|
+
{
|
|
3100
|
+
"type": "metavariable",
|
|
3101
|
+
"named": true,
|
|
3102
|
+
"fields": {}
|
|
3103
|
+
},
|
|
3099
3104
|
{
|
|
3100
3105
|
"type": "mod_item",
|
|
3101
3106
|
"named": true,
|
|
@@ -5631,10 +5636,6 @@
|
|
|
5631
5636
|
"type": "meta",
|
|
5632
5637
|
"named": false
|
|
5633
5638
|
},
|
|
5634
|
-
{
|
|
5635
|
-
"type": "metavariable",
|
|
5636
|
-
"named": true
|
|
5637
|
-
},
|
|
5638
5639
|
{
|
|
5639
5640
|
"type": "mod",
|
|
5640
5641
|
"named": false
|
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|