diff --git a/parse.y b/parse.y index ea7f394895..3130039c4c 100644 --- a/parse.y +++ b/parse.y @@ -2779,7 +2779,7 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary) %type command_asgn mrhs mrhs_arg superclass block_call block_command %type f_arglist f_opt_paren_args f_paren_args f_args %type f_arg f_arg_item -%type f_marg f_marg_list f_rest_marg +%type f_marg f_rest_marg %type f_margs %type assoc_list assocs assoc undef_list backref string_dvar for_var %type block_param opt_block_param block_param_def @@ -2788,7 +2788,7 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary) %type lambda_body %type f_larglist %type brace_block cmd_brace_block do_block lhs none fitem -%type mlhs_head mlhs_item mlhs_node mlhs_post +%type mlhs_head mlhs_item mlhs_node %type mlhs mlhs_basic mlhs_inner %type p_case_body p_cases p_top_expr p_top_expr_body %type p_expr p_as p_alt p_expr_basic p_find @@ -3005,6 +3005,19 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary) } ; +%rule mlhs(item) + : item + { + $$ = NEW_LIST($1, &@$); + /*% ripper: mlhs_add!(mlhs_new!, $:1) %*/ + } + | mlhs(item) ',' item + { + $$ = list_append(p, $1, $3); + /*% ripper: mlhs_add!($:1, $:3) %*/ + } + ; + %rule op_asgn(rhs) : var_lhs tOP_ASGN lex_ctxt rhs { @@ -3600,7 +3613,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN($1, $3, &@$); /*% ripper: mlhs_add_star!($:1, $:3) %*/ } - | mlhs_head tSTAR mlhs_node ',' mlhs_post + | mlhs_head tSTAR mlhs_node ',' mlhs(mlhs_item) { $$ = NEW_MASGN($1, NEW_POSTARG($3,$5,&@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/ @@ -3610,7 +3623,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN($1, NODE_SPECIAL_NO_NAME_REST, &@$); /*% ripper: mlhs_add_star!($:1, Qnil) %*/ } - | mlhs_head tSTAR ',' mlhs_post + | mlhs_head tSTAR ',' mlhs(mlhs_item) { $$ = NEW_MASGN($1, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $4, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, Qnil), $:4) %*/ @@ -3620,7 +3633,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN(0, $2, &@$); /*% ripper: mlhs_add_star!(mlhs_new!, $:2) %*/ } - | tSTAR mlhs_node ',' mlhs_post + | tSTAR mlhs_node ',' mlhs(mlhs_item) { $$ = NEW_MASGN(0, NEW_POSTARG($2,$4,&@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:2), $:4) %*/ @@ -3630,7 +3643,7 @@ mlhs_basic : mlhs_head $$ = NEW_MASGN(0, NODE_SPECIAL_NO_NAME_REST, &@$); /*% ripper: mlhs_add_star!(mlhs_new!, Qnil) %*/ } - | tSTAR ',' mlhs_post + | tSTAR ',' mlhs(mlhs_item) { $$ = NEW_MASGN(0, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, Qnil), $:3) %*/ @@ -3657,17 +3670,6 @@ mlhs_head : mlhs_item ',' } ; -mlhs_post : mlhs_item - { - $$ = NEW_LIST($1, &@$); - /*% ripper: mlhs_add!(mlhs_new!, $:1) %*/ - } - | mlhs_post ',' mlhs_item - { - $$ = list_append(p, $1, $3); - /*% ripper: mlhs_add!($:1, $:3) %*/ - } - ; mlhs_node : user_or_keyword_variable { @@ -4877,29 +4879,18 @@ f_marg : f_norm_arg } ; -f_marg_list : f_marg - { - $$ = NEW_LIST($1, &@$); - /*% ripper: mlhs_add!(mlhs_new!, $:1) %*/ - } - | f_marg_list ',' f_marg - { - $$ = list_append(p, $1, $3); - /*% ripper: mlhs_add!($:1, $:3) %*/ - } - ; -f_margs : f_marg_list +f_margs : mlhs(f_marg) { $$ = NEW_MASGN($1, 0, &@$); /*% ripper: $:1 %*/ } - | f_marg_list ',' f_rest_marg + | mlhs(f_marg) ',' f_rest_marg { $$ = NEW_MASGN($1, $3, &@$); /*% ripper: mlhs_add_star!($:1, $:3) %*/ } - | f_marg_list ',' f_rest_marg ',' f_marg_list + | mlhs(f_marg) ',' f_rest_marg ',' mlhs(f_marg) { $$ = NEW_MASGN($1, NEW_POSTARG($3, $5, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/ @@ -4909,7 +4900,7 @@ f_margs : f_marg_list $$ = NEW_MASGN(0, $1, &@$); /*% ripper: mlhs_add_star!(mlhs_new!, $:1) %*/ } - | f_rest_marg ',' f_marg_list + | f_rest_marg ',' mlhs(f_marg) { $$ = NEW_MASGN(0, NEW_POSTARG($1, $3, &@$), &@$); /*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:1), $:3) %*/