@willbooster/tree-sitter-rust 14.0.0 → 14.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/grammar.js +145 -28
- package/package.json +1 -1
- package/src/node-types.json +4 -0
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -170,6 +170,10 @@ module.exports = grammar({
|
|
|
170
170
|
|
|
171
171
|
inline: ($) => [
|
|
172
172
|
$._path,
|
|
173
|
+
$._struct_expression_name,
|
|
174
|
+
$._field_initializer_name,
|
|
175
|
+
$._assignee_expression,
|
|
176
|
+
$._rest_assignee_expression,
|
|
173
177
|
$._type_identifier,
|
|
174
178
|
$._type_identifier_in_type_position,
|
|
175
179
|
$._tokens,
|
|
@@ -180,6 +184,9 @@ module.exports = grammar({
|
|
|
180
184
|
],
|
|
181
185
|
|
|
182
186
|
conflicts: ($) => [
|
|
187
|
+
[$.array_expression, $._array_assignee_expression],
|
|
188
|
+
[$.tuple_expression, $._tuple_assignee_expression],
|
|
189
|
+
[$.arguments, $._assignee_arguments],
|
|
183
190
|
[$._attributed_block_statement, $._expression_except_range],
|
|
184
191
|
[$.type_parameters, $.for_lifetimes],
|
|
185
192
|
[$.lifetime_parameter, $.for_lifetimes],
|
|
@@ -187,7 +194,6 @@ module.exports = grammar({
|
|
|
187
194
|
[$.token_tree, $.token_repetition],
|
|
188
195
|
[$.field_initializer_list, $.block],
|
|
189
196
|
[$._expression_except_range, $.shorthand_field_initializer],
|
|
190
|
-
[$._expression_except_range, $.struct_expression],
|
|
191
197
|
[$.function_modifiers, $.modified_trait_bound],
|
|
192
198
|
[$.function_modifiers, $.impl_item, $.modified_trait_bound],
|
|
193
199
|
[$.const_item, $.function_modifiers],
|
|
@@ -1224,7 +1230,7 @@ module.exports = grammar({
|
|
|
1224
1230
|
},
|
|
1225
1231
|
|
|
1226
1232
|
assignment_expression: ($) =>
|
|
1227
|
-
prec.left(PREC.assign, seq(field('left', $.
|
|
1233
|
+
prec.left(PREC.assign, seq(field('left', $._assignee_expression), '=', field('right', $._expression))),
|
|
1228
1234
|
|
|
1229
1235
|
compound_assignment_expr: ($) =>
|
|
1230
1236
|
prec.left(
|
|
@@ -1282,44 +1288,147 @@ module.exports = grammar({
|
|
|
1282
1288
|
|
|
1283
1289
|
unit_expression: () => seq('(', ')'),
|
|
1284
1290
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1291
|
+
_assignee_expression: ($) => choice($._expression, $._rest_assignee_expression),
|
|
1292
|
+
|
|
1293
|
+
_rest_assignee_expression: ($) =>
|
|
1294
|
+
choice(
|
|
1295
|
+
alias($._struct_assignee_expression, $.struct_expression),
|
|
1296
|
+
alias($._parenthesized_assignee_expression, $.parenthesized_expression),
|
|
1297
|
+
alias($._tuple_assignee_expression, $.tuple_expression),
|
|
1298
|
+
alias($._array_assignee_expression, $.array_expression),
|
|
1299
|
+
alias($._call_assignee_expression, $.call_expression)
|
|
1300
|
+
),
|
|
1301
|
+
|
|
1302
|
+
_struct_assignee_expression: ($) =>
|
|
1303
|
+
prec(
|
|
1304
|
+
-1,
|
|
1305
|
+
seq(
|
|
1306
|
+
field('name', $._struct_expression_name),
|
|
1307
|
+
field('body', alias($._assignee_field_initializer_list, $.field_initializer_list))
|
|
1308
|
+
)
|
|
1309
|
+
),
|
|
1310
|
+
|
|
1311
|
+
_parenthesized_assignee_expression: ($) =>
|
|
1312
|
+
prec(-1, seq('(', repeat(prec(PREC.call, $.attribute_item)), $._rest_assignee_expression, ')')),
|
|
1313
|
+
|
|
1314
|
+
_tuple_assignee_expression: ($) => {
|
|
1315
|
+
const ordinary = seq(repeat(prec(PREC.call, $.attribute_item)), $._expression);
|
|
1316
|
+
const rest = seq(repeat(prec(PREC.call, $.attribute_item)), $._rest_assignee_expression);
|
|
1317
|
+
const assignee = seq(repeat(prec(PREC.call, $.attribute_item)), $._assignee_expression);
|
|
1318
|
+
return prec(
|
|
1319
|
+
-1,
|
|
1320
|
+
seq(
|
|
1321
|
+
'(',
|
|
1289
1322
|
choice(
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1323
|
+
seq(rest, ',', repeat(seq(assignee, ',')), optional(assignee)),
|
|
1324
|
+
seq(repeat1(seq(ordinary, ',')), rest, repeat(seq(',', assignee)), optional(','))
|
|
1325
|
+
),
|
|
1326
|
+
')'
|
|
1327
|
+
)
|
|
1328
|
+
);
|
|
1329
|
+
},
|
|
1330
|
+
|
|
1331
|
+
_array_assignee_expression: ($) =>
|
|
1332
|
+
prec(
|
|
1333
|
+
-1,
|
|
1334
|
+
seq(
|
|
1335
|
+
'[',
|
|
1336
|
+
commaListWithRest(
|
|
1337
|
+
seq(repeat(prec(PREC.call, $.attribute_item)), $._expression),
|
|
1338
|
+
seq(repeat(prec(PREC.call, $.attribute_item)), $._rest_assignee_expression)
|
|
1339
|
+
),
|
|
1340
|
+
']'
|
|
1341
|
+
)
|
|
1342
|
+
),
|
|
1343
|
+
|
|
1344
|
+
_call_assignee_expression: ($) =>
|
|
1345
|
+
prec(
|
|
1346
|
+
PREC.call - 1,
|
|
1347
|
+
seq(
|
|
1348
|
+
field('function', $._expression_except_range),
|
|
1349
|
+
field('arguments', alias($._assignee_arguments, $.arguments))
|
|
1350
|
+
)
|
|
1351
|
+
),
|
|
1352
|
+
|
|
1353
|
+
_assignee_arguments: ($) =>
|
|
1354
|
+
prec(
|
|
1355
|
+
-1,
|
|
1356
|
+
seq(
|
|
1357
|
+
'(',
|
|
1358
|
+
commaListWithRest(
|
|
1359
|
+
seq(repeat(prec(PREC.call, $.attribute_item)), $._expression),
|
|
1360
|
+
seq(repeat(prec(PREC.call, $.attribute_item)), $._rest_assignee_expression)
|
|
1361
|
+
),
|
|
1362
|
+
')'
|
|
1363
|
+
)
|
|
1364
|
+
),
|
|
1365
|
+
|
|
1366
|
+
struct_expression: ($) => seq(field('name', $._struct_expression_name), field('body', $.field_initializer_list)),
|
|
1367
|
+
|
|
1368
|
+
_struct_expression_name: ($) =>
|
|
1369
|
+
choice(
|
|
1370
|
+
reserved('struct_name', $._type_identifier),
|
|
1371
|
+
prec.dynamic(-1, alias(choice(...primitiveTypes, ...reservedIdentifiers), sym('type_identifier'))),
|
|
1372
|
+
alias($.scoped_type_identifier_in_expression_position, $.scoped_type_identifier),
|
|
1373
|
+
$.generic_type_with_turbofish
|
|
1374
|
+
),
|
|
1375
|
+
|
|
1376
|
+
field_initializer_list: ($) => {
|
|
1377
|
+
const ordinary = choice($.shorthand_field_initializer, $.field_initializer);
|
|
1378
|
+
return seq(
|
|
1379
|
+
'{',
|
|
1380
|
+
choice(
|
|
1381
|
+
seq(optional($._ordinary_field_initializer_prefix), optional(ordinary)),
|
|
1382
|
+
seq(
|
|
1383
|
+
optional($._ordinary_field_initializer_prefix),
|
|
1384
|
+
$.base_field_initializer,
|
|
1385
|
+
repeat(seq(',', choice(ordinary, $.base_field_initializer))),
|
|
1386
|
+
optional(',')
|
|
1294
1387
|
)
|
|
1295
1388
|
),
|
|
1296
|
-
|
|
1297
|
-
)
|
|
1389
|
+
'}'
|
|
1390
|
+
);
|
|
1391
|
+
},
|
|
1298
1392
|
|
|
1299
|
-
|
|
1300
|
-
seq(
|
|
1393
|
+
_ordinary_field_initializer_prefix: ($) =>
|
|
1394
|
+
repeat1(seq(choice($.shorthand_field_initializer, $.field_initializer), ',')),
|
|
1395
|
+
|
|
1396
|
+
_assignee_field_initializer_list: ($) => {
|
|
1397
|
+
const ordinary = choice($.shorthand_field_initializer, $.field_initializer);
|
|
1398
|
+
const rest = alias($._assignee_field_initializer, $.field_initializer);
|
|
1399
|
+
return seq(
|
|
1301
1400
|
'{',
|
|
1302
|
-
|
|
1303
|
-
|
|
1401
|
+
optional($._ordinary_field_initializer_prefix),
|
|
1402
|
+
choice(
|
|
1403
|
+
$.remaining_field_pattern,
|
|
1404
|
+
seq(rest, repeat(seq(',', choice(ordinary, rest))), optional(seq(',', optional($.remaining_field_pattern))))
|
|
1405
|
+
),
|
|
1304
1406
|
'}'
|
|
1407
|
+
);
|
|
1408
|
+
},
|
|
1409
|
+
|
|
1410
|
+
_assignee_field_initializer: ($) =>
|
|
1411
|
+
prec(
|
|
1412
|
+
-1,
|
|
1413
|
+
seq(
|
|
1414
|
+
optional($._outer_attributes),
|
|
1415
|
+
field('field', $._field_initializer_name),
|
|
1416
|
+
':',
|
|
1417
|
+
field('value', $._rest_assignee_expression)
|
|
1418
|
+
)
|
|
1305
1419
|
),
|
|
1306
1420
|
|
|
1307
1421
|
shorthand_field_initializer: ($) =>
|
|
1308
1422
|
seq(optional($._outer_attributes), choice($.identifier, alias(choice(...fieldIdentifierKeywords), $.identifier))),
|
|
1309
1423
|
|
|
1310
1424
|
field_initializer: ($) =>
|
|
1311
|
-
seq(
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
alias(/[0-9][0-9_]*/, $.integer_literal)
|
|
1319
|
-
)
|
|
1320
|
-
),
|
|
1321
|
-
':',
|
|
1322
|
-
field('value', $._expression)
|
|
1425
|
+
seq(optional($._outer_attributes), field('field', $._field_initializer_name), ':', field('value', $._expression)),
|
|
1426
|
+
|
|
1427
|
+
_field_initializer_name: ($) =>
|
|
1428
|
+
choice(
|
|
1429
|
+
$._field_identifier,
|
|
1430
|
+
alias(choice(...fieldIdentifierKeywords), sym('field_identifier')),
|
|
1431
|
+
alias(/[0-9][0-9_]*/, $.integer_literal)
|
|
1323
1432
|
),
|
|
1324
1433
|
|
|
1325
1434
|
base_field_initializer: ($) => seq('..', $._expression),
|
|
@@ -1824,6 +1933,14 @@ function macroRepetitionSeparator(start, content, end) {
|
|
|
1824
1933
|
);
|
|
1825
1934
|
}
|
|
1826
1935
|
|
|
1936
|
+
/**
|
|
1937
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} ordinary
|
|
1938
|
+
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rest
|
|
1939
|
+
*/
|
|
1940
|
+
function commaListWithRest(ordinary, rest) {
|
|
1941
|
+
return seq(repeat(seq(ordinary, ',')), rest, repeat(seq(',', choice(ordinary, rest))), optional(','));
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1827
1944
|
/**
|
|
1828
1945
|
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} sep
|
|
1829
1946
|
* @param {import('@willbooster/web-tree-sitter/dsl').RuleOrLiteral} rule
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|