@willbooster/tree-sitter-rust 2.0.7 → 3.0.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/README.md +7 -6
- package/grammar.js +86 -77
- package/package.json +4 -5
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-rust/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-rust/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-rust)
|
|
10
10
|
|
|
11
11
|
Rust grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
@@ -18,7 +18,8 @@ This fork fixes parsing bugs and raises conformance with [The Rust Reference](ht
|
|
|
18
18
|
|
|
19
19
|
The npm package ships `tree-sitter-rust.wasm` for
|
|
20
20
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
21
|
-
browsers, and Cloudflare Workers. The
|
|
21
|
+
browsers, and Cloudflare Workers. The parser loads only with that runtime, version 2.0.0 or later: it carries the
|
|
22
|
+
WillBooster ABI number, which upstream's `web-tree-sitter` rejects.
|
|
22
23
|
|
|
23
24
|
In Node.js and Bun, load the grammar from its path:
|
|
24
25
|
|
|
@@ -61,12 +62,12 @@ The package also ships the queries in `queries/` and the node types in `src/node
|
|
|
61
62
|
|
|
62
63
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-rust) and on
|
|
63
64
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
64
|
-
fuzzed with. The
|
|
65
|
+
fuzzed with. The parser loads only with that runtime, version 2.0.0 or later; upstream's `tree-sitter` crate rejects it:
|
|
65
66
|
|
|
66
67
|
```toml
|
|
67
68
|
[dependencies]
|
|
68
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
69
|
-
tree-sitter-rust = { package = "willbooster-tree-sitter-rust", version = "
|
|
69
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "2" }
|
|
70
|
+
tree-sitter-rust = { package = "willbooster-tree-sitter-rust", version = "3" }
|
|
70
71
|
```
|
|
71
72
|
|
|
72
73
|
```rust
|
|
@@ -102,7 +103,7 @@ not the ones this package ships with. Its first run downloads that CLI from the
|
|
|
102
103
|
with `cargo` (whose build runs the CMake that `mise.toml` pins) when the download fails or the release has no binary that runs here. Run other CLI
|
|
103
104
|
commands through it as well (e.g. `script/tree-sitter parse file.rs`).
|
|
104
105
|
|
|
105
|
-
`bun run generate` records a fresh
|
|
106
|
+
`bun run generate` records a fresh generation profile from the applicable `test/corpus` cases and Git-tracked
|
|
106
107
|
files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar,
|
|
107
108
|
`tree-sitter.json`, a corpus case, or a tracked example,
|
|
108
109
|
regenerate and commit `src/`. Stage added or removed examples with `git add -A examples` before generation so the profile uses the intended file list.
|
package/grammar.js
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* @license MIT
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
/// <reference types="tree-sitter-cli/dsl" />
|
|
10
9
|
// @ts-check
|
|
11
10
|
|
|
11
|
+
const { alias, choice, field, grammar, optional, prec, repeat, repeat1, seq, sym, token } =
|
|
12
|
+
/** @type {typeof globalThis & import('@willbooster/web-tree-sitter/dsl').DSL} */ (globalThis);
|
|
13
|
+
|
|
12
14
|
// https://doc.rust-lang.org/reference/expressions.html#expression-precedence
|
|
13
15
|
const PREC = {
|
|
14
16
|
call: 15,
|
|
@@ -118,22 +120,22 @@ module.exports = grammar({
|
|
|
118
120
|
|
|
119
121
|
extras: ($) => [/\s/, $.line_comment, $.block_comment],
|
|
120
122
|
|
|
121
|
-
externals: (
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
externals: () => [
|
|
124
|
+
sym('string_content'),
|
|
125
|
+
sym('string_close'),
|
|
126
|
+
sym('_raw_string_literal_start'),
|
|
127
|
+
sym('_raw_string_literal_content'),
|
|
128
|
+
sym('_raw_string_literal_end'),
|
|
129
|
+
sym('_trailing_dot_float_literal'),
|
|
130
|
+
sym('_outer_block_doc_comment_marker'),
|
|
131
|
+
sym('_inner_block_doc_comment_marker'),
|
|
132
|
+
sym('_block_comment_content'),
|
|
133
|
+
sym('_line_doc_content'),
|
|
134
|
+
sym('_range_unary_endpoint_start'),
|
|
135
|
+
sym('_error_sentinel'),
|
|
136
|
+
sym('_foreign_declaration_context'),
|
|
137
|
+
sym('_foreign_declaration_start'),
|
|
138
|
+
sym('_macro_metavariable_name'),
|
|
137
139
|
],
|
|
138
140
|
|
|
139
141
|
supertypes: ($) => [$._declaration_statement, $._expression, $._type, $._literal, $._literal_pattern, $._pattern],
|
|
@@ -264,9 +266,9 @@ module.exports = grammar({
|
|
|
264
266
|
')',
|
|
265
267
|
optional(
|
|
266
268
|
macroRepetitionSeparator(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
sym('_raw_string_literal_start'),
|
|
270
|
+
sym('_raw_string_literal_content'),
|
|
271
|
+
sym('_raw_string_literal_end')
|
|
270
272
|
)
|
|
271
273
|
),
|
|
272
274
|
choice('+', '*', '?')
|
|
@@ -307,9 +309,9 @@ module.exports = grammar({
|
|
|
307
309
|
')',
|
|
308
310
|
optional(
|
|
309
311
|
macroRepetitionSeparator(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
312
|
+
sym('_raw_string_literal_start'),
|
|
313
|
+
sym('_raw_string_literal_content'),
|
|
314
|
+
sym('_raw_string_literal_end')
|
|
313
315
|
)
|
|
314
316
|
),
|
|
315
317
|
choice('+', '*', '?')
|
|
@@ -324,7 +326,7 @@ module.exports = grammar({
|
|
|
324
326
|
$.self,
|
|
325
327
|
$.super,
|
|
326
328
|
$.crate,
|
|
327
|
-
alias(choice(...primitiveTypes.filter((type) => !extendedFloatTypes.includes(type))),
|
|
329
|
+
alias(choice(...primitiveTypes.filter((type) => !extendedFloatTypes.includes(type))), sym('primitive_type')),
|
|
328
330
|
alias(choice(...extendedFloatTypes), $.identifier),
|
|
329
331
|
prec.right(repeat1(choice(...TOKEN_TREE_NON_SPECIAL_PUNCTUATION))),
|
|
330
332
|
"'",
|
|
@@ -392,11 +394,11 @@ module.exports = grammar({
|
|
|
392
394
|
// `_foreign_declaration_start` required by qualified extern items. Keep this context marker so `safe` remains
|
|
393
395
|
// an identifier outside extern blocks while qualified items still participate in declaration supertype queries.
|
|
394
396
|
_foreign_declaration_list: ($) =>
|
|
395
|
-
seq('{', repeat(seq(optional(
|
|
397
|
+
seq('{', repeat(seq(optional(sym('_foreign_declaration_context')), $._declaration_statement)), '}'),
|
|
396
398
|
|
|
397
399
|
_safe_function_signature_item: ($) =>
|
|
398
400
|
seq(
|
|
399
|
-
|
|
401
|
+
sym('_foreign_declaration_start'),
|
|
400
402
|
optional($.visibility_modifier),
|
|
401
403
|
alias($._safe_modifier, $.function_modifiers),
|
|
402
404
|
$._function_signature
|
|
@@ -408,7 +410,7 @@ module.exports = grammar({
|
|
|
408
410
|
|
|
409
411
|
_qualified_static_item: ($) =>
|
|
410
412
|
seq(
|
|
411
|
-
|
|
413
|
+
sym('_foreign_declaration_start'),
|
|
412
414
|
optional($.visibility_modifier),
|
|
413
415
|
choice('safe', 'unsafe'),
|
|
414
416
|
$._static_declaration
|
|
@@ -567,7 +569,7 @@ module.exports = grammar({
|
|
|
567
569
|
$.tuple_type,
|
|
568
570
|
$.array_type,
|
|
569
571
|
$.higher_ranked_trait_bound,
|
|
570
|
-
alias(choice(...primitiveTypes),
|
|
572
|
+
alias(choice(...primitiveTypes), sym('primitive_type'))
|
|
571
573
|
)
|
|
572
574
|
),
|
|
573
575
|
field('bounds', $.trait_bounds)
|
|
@@ -586,7 +588,7 @@ module.exports = grammar({
|
|
|
586
588
|
'trait',
|
|
587
589
|
choice(
|
|
588
590
|
$._type_identifier,
|
|
589
|
-
alias(choice(...primitiveTypes),
|
|
591
|
+
alias(choice(...primitiveTypes), sym('type_identifier')),
|
|
590
592
|
$.scoped_type_identifier,
|
|
591
593
|
$.generic_type
|
|
592
594
|
)
|
|
@@ -682,7 +684,7 @@ module.exports = grammar({
|
|
|
682
684
|
prec(
|
|
683
685
|
1,
|
|
684
686
|
seq(
|
|
685
|
-
field('name', choice($._type_identifier, alias(choice(...primitiveTypes),
|
|
687
|
+
field('name', choice($._type_identifier, alias(choice(...primitiveTypes), sym('type_identifier')))),
|
|
686
688
|
optional(field('bounds', $.trait_bounds)),
|
|
687
689
|
optional(seq('=', field('default_type', $._type)))
|
|
688
690
|
)
|
|
@@ -756,7 +758,7 @@ module.exports = grammar({
|
|
|
756
758
|
$.bounded_type,
|
|
757
759
|
$.removed_trait_bound,
|
|
758
760
|
$.modified_trait_bound,
|
|
759
|
-
alias(choice(...primitiveTypes),
|
|
761
|
+
alias(choice(...primitiveTypes), sym('primitive_type'))
|
|
760
762
|
),
|
|
761
763
|
|
|
762
764
|
bracketed_type: ($) => seq('<', choice($._type, $.qualified_type), '>'),
|
|
@@ -781,7 +783,7 @@ module.exports = grammar({
|
|
|
781
783
|
choice(
|
|
782
784
|
$._type_identifier,
|
|
783
785
|
$.scoped_type_identifier,
|
|
784
|
-
alias(choice(...primitiveTypes),
|
|
786
|
+
alias(choice(...primitiveTypes), sym('type_identifier'))
|
|
785
787
|
)
|
|
786
788
|
),
|
|
787
789
|
seq(optional($.function_modifiers), 'fn')
|
|
@@ -823,7 +825,7 @@ module.exports = grammar({
|
|
|
823
825
|
'type',
|
|
824
826
|
choice(
|
|
825
827
|
$._type_identifier,
|
|
826
|
-
alias(choice(...primitiveTypes),
|
|
828
|
+
alias(choice(...primitiveTypes), sym('type_identifier')),
|
|
827
829
|
alias(choice(...reservedIdentifiers), $.identifier),
|
|
828
830
|
$.scoped_type_identifier
|
|
829
831
|
)
|
|
@@ -838,7 +840,7 @@ module.exports = grammar({
|
|
|
838
840
|
'type',
|
|
839
841
|
choice(
|
|
840
842
|
$._type_identifier,
|
|
841
|
-
alias(choice(...primitiveTypes, ...reservedIdentifiers),
|
|
843
|
+
alias(choice(...primitiveTypes, ...reservedIdentifiers), sym('type_identifier')),
|
|
842
844
|
$.scoped_identifier
|
|
843
845
|
)
|
|
844
846
|
),
|
|
@@ -859,7 +861,7 @@ module.exports = grammar({
|
|
|
859
861
|
',',
|
|
860
862
|
choice(
|
|
861
863
|
seq(choice($._type, $.type_binding, $.lifetime, $._literal, $.block), optional($.trait_bounds)),
|
|
862
|
-
prec(1, seq(alias(choice(...primitiveTypes),
|
|
864
|
+
prec(1, seq(alias(choice(...primitiveTypes), sym('type_identifier')), $.trait_bounds))
|
|
863
865
|
)
|
|
864
866
|
),
|
|
865
867
|
optional(','),
|
|
@@ -868,7 +870,7 @@ module.exports = grammar({
|
|
|
868
870
|
|
|
869
871
|
type_binding: ($) =>
|
|
870
872
|
seq(
|
|
871
|
-
field('name', choice($._type_identifier, alias(choice(...primitiveTypes),
|
|
873
|
+
field('name', choice($._type_identifier, alias(choice(...primitiveTypes), sym('type_identifier')))),
|
|
872
874
|
field('type_arguments', optional($.type_arguments)),
|
|
873
875
|
'=',
|
|
874
876
|
field('type', $._type)
|
|
@@ -890,7 +892,7 @@ module.exports = grammar({
|
|
|
890
892
|
1,
|
|
891
893
|
choice(
|
|
892
894
|
$._type_identifier,
|
|
893
|
-
alias(choice(...primitiveTypes),
|
|
895
|
+
alias(choice(...primitiveTypes), sym('type_identifier')),
|
|
894
896
|
$.scoped_type_identifier,
|
|
895
897
|
$.removed_trait_bound,
|
|
896
898
|
$.modified_trait_bound,
|
|
@@ -912,7 +914,7 @@ module.exports = grammar({
|
|
|
912
914
|
$.higher_ranked_trait_bound,
|
|
913
915
|
$.modified_trait_bound,
|
|
914
916
|
$._type_identifier,
|
|
915
|
-
alias(choice(...primitiveTypes),
|
|
917
|
+
alias(choice(...primitiveTypes), sym('type_identifier')),
|
|
916
918
|
$.scoped_type_identifier,
|
|
917
919
|
$.generic_type,
|
|
918
920
|
$.function_type,
|
|
@@ -1021,7 +1023,7 @@ module.exports = grammar({
|
|
|
1021
1023
|
seq(
|
|
1022
1024
|
field('path', optional(choice($._path, alias($.generic_type_with_turbofish, $.generic_type)))),
|
|
1023
1025
|
'::',
|
|
1024
|
-
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers),
|
|
1026
|
+
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers), sym('type_identifier'))))
|
|
1025
1027
|
)
|
|
1026
1028
|
),
|
|
1027
1029
|
|
|
@@ -1034,7 +1036,7 @@ module.exports = grammar({
|
|
|
1034
1036
|
)
|
|
1035
1037
|
),
|
|
1036
1038
|
'::',
|
|
1037
|
-
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers),
|
|
1039
|
+
field('name', choice($._type_identifier, alias(choice(...reservedIdentifiers), sym('type_identifier'))))
|
|
1038
1040
|
),
|
|
1039
1041
|
|
|
1040
1042
|
range_expression: ($) =>
|
|
@@ -1044,9 +1046,9 @@ module.exports = grammar({
|
|
|
1044
1046
|
prec.left(PREC.range, seq(choice('..', '..='), $._expression)),
|
|
1045
1047
|
prec.right(
|
|
1046
1048
|
PREC.range + 1,
|
|
1047
|
-
seq($._expression, choice('..', '..='),
|
|
1049
|
+
seq($._expression, choice('..', '..='), sym('_range_unary_endpoint_start'), $._expression)
|
|
1048
1050
|
),
|
|
1049
|
-
prec.right(PREC.range + 1, seq(choice('..', '..='),
|
|
1051
|
+
prec.right(PREC.range + 1, seq(choice('..', '..='), sym('_range_unary_endpoint_start'), $._expression)),
|
|
1050
1052
|
prec.left(PREC.range, '..')
|
|
1051
1053
|
),
|
|
1052
1054
|
|
|
@@ -1065,7 +1067,7 @@ module.exports = grammar({
|
|
|
1065
1067
|
),
|
|
1066
1068
|
|
|
1067
1069
|
binary_expression: ($) => {
|
|
1068
|
-
/** @type {[number, RuleOrLiteral][]} */
|
|
1070
|
+
/** @type {[number, import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral][]} */
|
|
1069
1071
|
const table = [
|
|
1070
1072
|
[PREC.and, '&&'],
|
|
1071
1073
|
[PREC.or, '||'],
|
|
@@ -1146,7 +1148,7 @@ module.exports = grammar({
|
|
|
1146
1148
|
'name',
|
|
1147
1149
|
choice(
|
|
1148
1150
|
$._type_identifier,
|
|
1149
|
-
prec.dynamic(-1, alias(choice(...primitiveTypes, ...reservedIdentifiers),
|
|
1151
|
+
prec.dynamic(-1, alias(choice(...primitiveTypes, ...reservedIdentifiers), sym('type_identifier'))),
|
|
1150
1152
|
alias($.scoped_type_identifier_in_expression_position, $.scoped_type_identifier),
|
|
1151
1153
|
$.generic_type_with_turbofish
|
|
1152
1154
|
)
|
|
@@ -1172,7 +1174,7 @@ module.exports = grammar({
|
|
|
1172
1174
|
'field',
|
|
1173
1175
|
choice(
|
|
1174
1176
|
$._field_identifier,
|
|
1175
|
-
alias(choice(...fieldIdentifierKeywords),
|
|
1177
|
+
alias(choice(...fieldIdentifierKeywords), sym('field_identifier')),
|
|
1176
1178
|
alias(/[0-9][0-9_]*/, $.integer_literal)
|
|
1177
1179
|
)
|
|
1178
1180
|
),
|
|
@@ -1207,7 +1209,7 @@ module.exports = grammar({
|
|
|
1207
1209
|
)
|
|
1208
1210
|
),
|
|
1209
1211
|
|
|
1210
|
-
_condition: ($) => choice($._expression, $.let_condition, alias($._let_chain,
|
|
1212
|
+
_condition: ($) => choice($._expression, $.let_condition, alias($._let_chain, sym('let_chain'))),
|
|
1211
1213
|
|
|
1212
1214
|
else_clause: ($) => seq('else', choice($.block, $.if_expression)),
|
|
1213
1215
|
|
|
@@ -1366,7 +1368,7 @@ module.exports = grammar({
|
|
|
1366
1368
|
'type',
|
|
1367
1369
|
choice(
|
|
1368
1370
|
$._type_identifier,
|
|
1369
|
-
alias(choice(...primitiveTypes, ...reservedIdentifiers),
|
|
1371
|
+
alias(choice(...primitiveTypes, ...reservedIdentifiers), sym('type_identifier')),
|
|
1370
1372
|
$.scoped_type_identifier,
|
|
1371
1373
|
alias($._generic_struct_pattern_type, $.generic_type)
|
|
1372
1374
|
)
|
|
@@ -1383,7 +1385,7 @@ module.exports = grammar({
|
|
|
1383
1385
|
'type',
|
|
1384
1386
|
choice(
|
|
1385
1387
|
$._type_identifier,
|
|
1386
|
-
alias(choice(...primitiveTypes, ...reservedIdentifiers),
|
|
1388
|
+
alias(choice(...primitiveTypes, ...reservedIdentifiers), sym('type_identifier')),
|
|
1387
1389
|
$.scoped_type_identifier
|
|
1388
1390
|
)
|
|
1389
1391
|
),
|
|
@@ -1397,7 +1399,7 @@ module.exports = grammar({
|
|
|
1397
1399
|
optional('ref'),
|
|
1398
1400
|
optional($.mutable_specifier),
|
|
1399
1401
|
choice(
|
|
1400
|
-
field('name', alias($.identifier,
|
|
1402
|
+
field('name', alias($.identifier, sym('shorthand_field_identifier'))),
|
|
1401
1403
|
seq(field('name', $._field_identifier), ':', field('pattern', $._pattern))
|
|
1402
1404
|
)
|
|
1403
1405
|
),
|
|
@@ -1467,9 +1469,9 @@ module.exports = grammar({
|
|
|
1467
1469
|
)
|
|
1468
1470
|
),
|
|
1469
1471
|
|
|
1470
|
-
float_literal: (
|
|
1472
|
+
float_literal: () =>
|
|
1471
1473
|
choice(
|
|
1472
|
-
|
|
1474
|
+
sym('_trailing_dot_float_literal'),
|
|
1473
1475
|
token(
|
|
1474
1476
|
prec(
|
|
1475
1477
|
1,
|
|
@@ -1488,13 +1490,17 @@ module.exports = grammar({
|
|
|
1488
1490
|
),
|
|
1489
1491
|
|
|
1490
1492
|
string_literal: ($) =>
|
|
1491
|
-
seq(
|
|
1493
|
+
seq(
|
|
1494
|
+
alias(/[bc]?"/, '"'),
|
|
1495
|
+
repeat(choice($.escape_sequence, sym('string_content'))),
|
|
1496
|
+
alias(sym('string_close'), '"')
|
|
1497
|
+
),
|
|
1492
1498
|
|
|
1493
|
-
raw_string_literal: (
|
|
1499
|
+
raw_string_literal: () =>
|
|
1494
1500
|
seq(
|
|
1495
|
-
|
|
1496
|
-
alias(
|
|
1497
|
-
|
|
1501
|
+
sym('_raw_string_literal_start'),
|
|
1502
|
+
alias(sym('_raw_string_literal_content'), sym('string_content')),
|
|
1503
|
+
sym('_raw_string_literal_end')
|
|
1498
1504
|
),
|
|
1499
1505
|
|
|
1500
1506
|
char_literal: () =>
|
|
@@ -1521,15 +1527,15 @@ module.exports = grammar({
|
|
|
1521
1527
|
'//',
|
|
1522
1528
|
choice(
|
|
1523
1529
|
seq(token.immediate(prec(2, /\/\//)), /.*/),
|
|
1524
|
-
seq($._line_doc_comment_marker, field('doc', alias(
|
|
1530
|
+
seq($._line_doc_comment_marker, field('doc', alias(sym('_line_doc_content'), sym('doc_comment')))),
|
|
1525
1531
|
token.immediate(prec(1, /.*/))
|
|
1526
1532
|
)
|
|
1527
1533
|
),
|
|
1528
1534
|
|
|
1529
1535
|
_line_doc_comment_marker: ($) =>
|
|
1530
1536
|
choice(
|
|
1531
|
-
field('outer', alias($._outer_line_doc_comment_marker,
|
|
1532
|
-
field('inner', alias($._inner_line_doc_comment_marker,
|
|
1537
|
+
field('outer', alias($._outer_line_doc_comment_marker, sym('outer_doc_comment_marker'))),
|
|
1538
|
+
field('inner', alias($._inner_line_doc_comment_marker, sym('inner_doc_comment_marker')))
|
|
1533
1539
|
),
|
|
1534
1540
|
|
|
1535
1541
|
_inner_line_doc_comment_marker: () => token.immediate(prec(2, '!')),
|
|
@@ -1540,17 +1546,20 @@ module.exports = grammar({
|
|
|
1540
1546
|
'/*',
|
|
1541
1547
|
optional(
|
|
1542
1548
|
choice(
|
|
1543
|
-
seq(
|
|
1544
|
-
|
|
1549
|
+
seq(
|
|
1550
|
+
$._block_doc_comment_marker,
|
|
1551
|
+
optional(field('doc', alias(sym('_block_comment_content'), sym('doc_comment'))))
|
|
1552
|
+
),
|
|
1553
|
+
sym('_block_comment_content')
|
|
1545
1554
|
)
|
|
1546
1555
|
),
|
|
1547
1556
|
'*/'
|
|
1548
1557
|
),
|
|
1549
1558
|
|
|
1550
|
-
_block_doc_comment_marker: (
|
|
1559
|
+
_block_doc_comment_marker: () =>
|
|
1551
1560
|
choice(
|
|
1552
|
-
field('outer', alias(
|
|
1553
|
-
field('inner', alias(
|
|
1561
|
+
field('outer', alias(sym('_outer_block_doc_comment_marker'), sym('outer_doc_comment_marker'))),
|
|
1562
|
+
field('inner', alias(sym('_inner_block_doc_comment_marker'), sym('inner_doc_comment_marker')))
|
|
1554
1563
|
),
|
|
1555
1564
|
|
|
1556
1565
|
_path: ($) =>
|
|
@@ -1572,24 +1581,24 @@ module.exports = grammar({
|
|
|
1572
1581
|
|
|
1573
1582
|
_reserved_identifier: ($) => alias(choice(...reservedIdentifiers, 'auto', 'macro_rules'), $.identifier),
|
|
1574
1583
|
|
|
1575
|
-
_type_identifier: ($) => alias(choice($.identifier, 'auto', 'macro_rules'),
|
|
1576
|
-
_field_identifier: ($) => alias($.identifier,
|
|
1584
|
+
_type_identifier: ($) => alias(choice($.identifier, 'auto', 'macro_rules'), sym('type_identifier')),
|
|
1585
|
+
_field_identifier: ($) => alias($.identifier, sym('field_identifier')),
|
|
1577
1586
|
|
|
1578
1587
|
self: () => 'self',
|
|
1579
1588
|
super: () => 'super',
|
|
1580
1589
|
crate: () => 'crate',
|
|
1581
1590
|
|
|
1582
1591
|
_macro_metavariable: ($) => choice($.metavariable, alias($._spaced_metavariable, $.metavariable)),
|
|
1583
|
-
_spaced_metavariable: (
|
|
1584
|
-
prec.dynamic(1, seq('$', choice(
|
|
1592
|
+
_spaced_metavariable: () =>
|
|
1593
|
+
prec.dynamic(1, seq('$', choice(sym('_macro_metavariable_name'), token(prec(1, nonAsciiOrRawMacroName))))),
|
|
1585
1594
|
metavariable: () => /\$(r#)?[_\p{XID_Start}][_\p{XID_Continue}]*/u,
|
|
1586
1595
|
},
|
|
1587
1596
|
});
|
|
1588
1597
|
|
|
1589
1598
|
/**
|
|
1590
|
-
* @param {RuleOrLiteral} start
|
|
1591
|
-
* @param {RuleOrLiteral} content
|
|
1592
|
-
* @param {RuleOrLiteral} end
|
|
1599
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} start
|
|
1600
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} content
|
|
1601
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} end
|
|
1593
1602
|
*/
|
|
1594
1603
|
function macroRepetitionSeparator(start, content, end) {
|
|
1595
1604
|
return choice(
|
|
@@ -1601,20 +1610,20 @@ function macroRepetitionSeparator(start, content, end) {
|
|
|
1601
1610
|
}
|
|
1602
1611
|
|
|
1603
1612
|
/**
|
|
1604
|
-
* @param {RuleOrLiteral} sep
|
|
1605
|
-
* @param {RuleOrLiteral} rule
|
|
1613
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} sep
|
|
1614
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rule
|
|
1606
1615
|
*
|
|
1607
|
-
* @returns {SeqRule}
|
|
1616
|
+
* @returns {import('@willbooster/web-tree-sitter/dsl').SeqRule}
|
|
1608
1617
|
*/
|
|
1609
1618
|
function sepBy1(sep, rule) {
|
|
1610
1619
|
return seq(rule, repeat(seq(sep, rule)));
|
|
1611
1620
|
}
|
|
1612
1621
|
|
|
1613
1622
|
/**
|
|
1614
|
-
* @param {RuleOrLiteral} sep
|
|
1615
|
-
* @param {RuleOrLiteral} rule
|
|
1623
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} sep
|
|
1624
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rule
|
|
1616
1625
|
*
|
|
1617
|
-
* @returns {ChoiceRule}
|
|
1626
|
+
* @returns {import('@willbooster/web-tree-sitter/dsl').ChoiceRule}
|
|
1618
1627
|
*/
|
|
1619
1628
|
function sepBy(sep, rule) {
|
|
1620
1629
|
return optional(sepBy1(sep, rule));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-rust",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Rust grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@vitest/browser-playwright": "5.0.3",
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
|
-
"@willbooster/wb": "22.
|
|
50
|
-
"@willbooster/web-tree-sitter": "
|
|
49
|
+
"@willbooster/wb": "22.24.0",
|
|
50
|
+
"@willbooster/web-tree-sitter": "2.0.1",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
52
|
"lefthook": "2.1.16",
|
|
53
53
|
"oxfmt": "0.71.0",
|
|
@@ -56,14 +56,13 @@
|
|
|
56
56
|
"playwright": "1.63.0",
|
|
57
57
|
"semantic-release": "25.0.9",
|
|
58
58
|
"sort-package-json": "4.0.0",
|
|
59
|
-
"tree-sitter-cli": "0.27.0",
|
|
60
59
|
"typescript": "7.0.2",
|
|
61
60
|
"vite": "8.3.2",
|
|
62
61
|
"vitest": "5.0.3",
|
|
63
62
|
"wrangler": "4.147.0"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
|
-
"@willbooster/web-tree-sitter": "^
|
|
65
|
+
"@willbooster/web-tree-sitter": "^2.0.0"
|
|
67
66
|
},
|
|
68
67
|
"peerDependenciesMeta": {
|
|
69
68
|
"@willbooster/web-tree-sitter": {
|
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|