Skip to content

Commit d2ecab0

Browse files
committed
Remove last use of sepTrailing helper
1 parent ae7ada5 commit d2ecab0

3 files changed

Lines changed: 471514 additions & 477047 deletions

File tree

grammar.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,6 @@ module.exports = grammar({
345345
$._primary,
346346
token.immediate('['),
347347
optional($._argument_list_with_trailing_comma),
348-
optional($.heredoc_body),
349348
']'
350349
)),
351350

@@ -389,13 +388,13 @@ module.exports = grammar({
389388
_argument_list_with_parens: $ => seq(
390389
token.immediate('('),
391390
optional($._argument_list_with_trailing_comma),
392-
optional($.heredoc_body),
393391
')'
394392
),
395393

396394
_argument_list_with_trailing_comma: $ => prec.right(seq(
397395
sep1($._argument, seq(',', optional($.heredoc_body))),
398-
optional(',')
396+
optional(','),
397+
optional($.heredoc_body)
399398
)),
400399

401400
_argument: $ => choice(
@@ -475,8 +474,10 @@ module.exports = grammar({
475474
_arg_or_splat_arg: $ => choice($._arg, $.splat_argument),
476475

477476
left_assignment_list: $ => $._mlhs,
478-
_mlhs: $ => prec.left(-1, sepTrailing($._mlhs, choice($._simple_mlhs, $.destructured_left_assignment), ',')),
479-
_simple_mlhs: $ => prec(-1, choice($._lhs, $.rest_assignment)),
477+
_mlhs: $ => prec.left(-1, seq(
478+
commaSep1(choice($._lhs, $.rest_assignment, $.destructured_left_assignment)),
479+
optional(',')
480+
)),
480481
destructured_left_assignment: $ => prec(-1, seq('(', $._mlhs, ')')),
481482

482483
rest_assignment: $ => prec(-1, seq('*', optional($._lhs))),
@@ -636,7 +637,6 @@ module.exports = grammar({
636637
array: $ => seq(
637638
'[',
638639
optional($._argument_list_with_trailing_comma),
639-
optional($.heredoc_body),
640640
']'
641641
),
642642

@@ -679,10 +679,6 @@ module.exports = grammar({
679679
}
680680
});
681681

682-
function sepTrailing (self, rule, separator) {
683-
return choice(rule, seq(rule, separator, optional(self)));
684-
}
685-
686682
function sep (rule, separator) {
687683
return optional(sep1(rule, separator));
688684
}

src/grammar.json

Lines changed: 53 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,18 +2047,6 @@
20472047
}
20482048
]
20492049
},
2050-
{
2051-
"type": "CHOICE",
2052-
"members": [
2053-
{
2054-
"type": "SYMBOL",
2055-
"name": "heredoc_body"
2056-
},
2057-
{
2058-
"type": "BLANK"
2059-
}
2060-
]
2061-
},
20622050
{
20632051
"type": "STRING",
20642052
"value": "]"
@@ -2429,18 +2417,6 @@
24292417
}
24302418
]
24312419
},
2432-
{
2433-
"type": "CHOICE",
2434-
"members": [
2435-
{
2436-
"type": "SYMBOL",
2437-
"name": "heredoc_body"
2438-
},
2439-
{
2440-
"type": "BLANK"
2441-
}
2442-
]
2443-
},
24442420
{
24452421
"type": "STRING",
24462422
"value": ")"
@@ -2506,6 +2482,18 @@
25062482
"type": "BLANK"
25072483
}
25082484
]
2485+
},
2486+
{
2487+
"type": "CHOICE",
2488+
"members": [
2489+
{
2490+
"type": "SYMBOL",
2491+
"name": "heredoc_body"
2492+
},
2493+
{
2494+
"type": "BLANK"
2495+
}
2496+
]
25092497
}
25102498
]
25112499
}
@@ -3378,21 +3366,8 @@
33783366
"type": "PREC_LEFT",
33793367
"value": -1,
33803368
"content": {
3381-
"type": "CHOICE",
3369+
"type": "SEQ",
33823370
"members": [
3383-
{
3384-
"type": "CHOICE",
3385-
"members": [
3386-
{
3387-
"type": "SYMBOL",
3388-
"name": "_simple_mlhs"
3389-
},
3390-
{
3391-
"type": "SYMBOL",
3392-
"name": "destructured_left_assignment"
3393-
}
3394-
]
3395-
},
33963371
{
33973372
"type": "SEQ",
33983373
"members": [
@@ -3401,52 +3376,64 @@
34013376
"members": [
34023377
{
34033378
"type": "SYMBOL",
3404-
"name": "_simple_mlhs"
3379+
"name": "_lhs"
3380+
},
3381+
{
3382+
"type": "SYMBOL",
3383+
"name": "rest_assignment"
34053384
},
34063385
{
34073386
"type": "SYMBOL",
34083387
"name": "destructured_left_assignment"
34093388
}
34103389
]
34113390
},
3391+
{
3392+
"type": "REPEAT",
3393+
"content": {
3394+
"type": "SEQ",
3395+
"members": [
3396+
{
3397+
"type": "STRING",
3398+
"value": ","
3399+
},
3400+
{
3401+
"type": "CHOICE",
3402+
"members": [
3403+
{
3404+
"type": "SYMBOL",
3405+
"name": "_lhs"
3406+
},
3407+
{
3408+
"type": "SYMBOL",
3409+
"name": "rest_assignment"
3410+
},
3411+
{
3412+
"type": "SYMBOL",
3413+
"name": "destructured_left_assignment"
3414+
}
3415+
]
3416+
}
3417+
]
3418+
}
3419+
}
3420+
]
3421+
},
3422+
{
3423+
"type": "CHOICE",
3424+
"members": [
34123425
{
34133426
"type": "STRING",
34143427
"value": ","
34153428
},
34163429
{
3417-
"type": "CHOICE",
3418-
"members": [
3419-
{
3420-
"type": "SYMBOL",
3421-
"name": "_mlhs"
3422-
},
3423-
{
3424-
"type": "BLANK"
3425-
}
3426-
]
3430+
"type": "BLANK"
34273431
}
34283432
]
34293433
}
34303434
]
34313435
}
34323436
},
3433-
"_simple_mlhs": {
3434-
"type": "PREC",
3435-
"value": -1,
3436-
"content": {
3437-
"type": "CHOICE",
3438-
"members": [
3439-
{
3440-
"type": "SYMBOL",
3441-
"name": "_lhs"
3442-
},
3443-
{
3444-
"type": "SYMBOL",
3445-
"name": "rest_assignment"
3446-
}
3447-
]
3448-
}
3449-
},
34503437
"destructured_left_assignment": {
34513438
"type": "PREC",
34523439
"value": -1,
@@ -4482,18 +4469,6 @@
44824469
}
44834470
]
44844471
},
4485-
{
4486-
"type": "CHOICE",
4487-
"members": [
4488-
{
4489-
"type": "SYMBOL",
4490-
"name": "heredoc_body"
4491-
},
4492-
{
4493-
"type": "BLANK"
4494-
}
4495-
]
4496-
},
44974472
{
44984473
"type": "STRING",
44994474
"value": "]"

0 commit comments

Comments
 (0)