Skip to content

Commit 11c2aa0

Browse files
committed
Extract arg_splat nonterminal symbol
1 parent 426f233 commit 11c2aa0

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

parse.y

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,7 @@ get_nd_args(struct parser_params *p, NODE *node)
20592059
%type <node> expr_value expr_value_do arg_value primary_value rel_expr
20602060
%type <node_fcall> fcall
20612061
%type <node> if_tail opt_else case_body case_args cases opt_rescue exc_list exc_var opt_ensure
2062-
%type <node> args call_args opt_call_args
2062+
%type <node> args arg_splat call_args opt_call_args
20632063
%type <node> paren_args opt_paren_args
20642064
%type <node_args> args_tail opt_args_tail block_args_tail opt_block_args_tail
20652065
%type <node> command_args aref_args
@@ -3784,23 +3784,12 @@ args : arg_value
37843784
/*% %*/
37853785
/*% ripper: args_add!(args_new!, $1) %*/
37863786
}
3787-
| tSTAR arg_value
3787+
| arg_splat
37883788
{
37893789
/*%%%*/
3790-
$$ = NEW_SPLAT($2, &@$);
3791-
/*% %*/
3792-
/*% ripper: args_add_star!(args_new!, $2) %*/
3793-
}
3794-
| tSTAR
3795-
{
3796-
if (!local_id(p, idFWD_REST) ||
3797-
local_id(p, idFWD_ALL)) {
3798-
compile_error(p, "no anonymous rest parameter");
3799-
}
3800-
/*%%%*/
3801-
$$ = NEW_SPLAT(NEW_LVAR(idFWD_REST, &@1), &@$);
3790+
$$ = NEW_SPLAT($arg_splat, &@$);
38023791
/*% %*/
3803-
/*% ripper: args_add_star!(args_new!, Qnil) %*/
3792+
/*% ripper: args_add_star!(args_new!, $arg_splat) %*/
38043793
}
38053794
| args ',' arg_value
38063795
{
@@ -3809,23 +3798,30 @@ args : arg_value
38093798
/*% %*/
38103799
/*% ripper: args_add!($1, $3) %*/
38113800
}
3812-
| args ',' tSTAR arg_value
3801+
| args ',' arg_splat
38133802
{
38143803
/*%%%*/
3815-
$$ = rest_arg_append(p, $1, $4, &@$);
3804+
$$ = rest_arg_append(p, $args, $arg_splat, &@$);
38163805
/*% %*/
3817-
/*% ripper: args_add_star!($1, $4) %*/
3806+
/*% ripper: args_add_star!($args, $arg_splat) %*/
38183807
}
3819-
| args ',' tSTAR
3808+
;
3809+
3810+
/* value */
3811+
arg_splat : tSTAR arg_value
3812+
{
3813+
$$ = $2;
3814+
}
3815+
| tSTAR /* none */
38203816
{
38213817
if (!local_id(p, idFWD_REST) ||
38223818
local_id(p, idFWD_ALL)) {
38233819
compile_error(p, "no anonymous rest parameter");
38243820
}
38253821
/*%%%*/
3826-
$$ = rest_arg_append(p, $1, NEW_LVAR(idFWD_REST, &@3), &@$);
3822+
$$ = NEW_LVAR(idFWD_REST, &@1);
38273823
/*% %*/
3828-
/*% ripper: args_add_star!($1, Qnil) %*/
3824+
/*% ripper: Qnil %*/
38293825
}
38303826
;
38313827

0 commit comments

Comments
 (0)