Skip to content

Commit c93f30a

Browse files
committed
Use user defined parameterizing rules mlhs
1 parent 6c8cdc9 commit c93f30a

File tree

1 file changed

+23
-32
lines changed

1 file changed

+23
-32
lines changed

parse.y

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,7 +2779,7 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
27792779
%type <node> command_asgn mrhs mrhs_arg superclass block_call block_command
27802780
%type <node_args> f_arglist f_opt_paren_args f_paren_args f_args
27812781
%type <node_args_aux> f_arg f_arg_item
2782-
%type <node> f_marg f_marg_list f_rest_marg
2782+
%type <node> f_marg f_rest_marg
27832783
%type <node_masgn> f_margs
27842784
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
27852785
%type <node_args> 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)
27882788
%type <locations_lambda_body> lambda_body
27892789
%type <node_args> f_larglist
27902790
%type <node> brace_block cmd_brace_block do_block lhs none fitem
2791-
%type <node> mlhs_head mlhs_item mlhs_node mlhs_post
2791+
%type <node> mlhs_head mlhs_item mlhs_node
27922792
%type <node_masgn> mlhs mlhs_basic mlhs_inner
27932793
%type <node> p_case_body p_cases p_top_expr p_top_expr_body
27942794
%type <node> 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)
30053005
}
30063006
;
30073007

3008+
%rule mlhs(item) <node>
3009+
: item
3010+
{
3011+
$$ = NEW_LIST($1, &@$);
3012+
/*% ripper: mlhs_add!(mlhs_new!, $:1) %*/
3013+
}
3014+
| mlhs(item) ',' item
3015+
{
3016+
$$ = list_append(p, $1, $3);
3017+
/*% ripper: mlhs_add!($:1, $:3) %*/
3018+
}
3019+
;
3020+
30083021
%rule op_asgn(rhs) <node>
30093022
: var_lhs tOP_ASGN lex_ctxt rhs
30103023
{
@@ -3600,7 +3613,7 @@ mlhs_basic : mlhs_head
36003613
$$ = NEW_MASGN($1, $3, &@$);
36013614
/*% ripper: mlhs_add_star!($:1, $:3) %*/
36023615
}
3603-
| mlhs_head tSTAR mlhs_node ',' mlhs_post
3616+
| mlhs_head tSTAR mlhs_node ',' mlhs(mlhs_item)
36043617
{
36053618
$$ = NEW_MASGN($1, NEW_POSTARG($3,$5,&@$), &@$);
36063619
/*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/
@@ -3610,7 +3623,7 @@ mlhs_basic : mlhs_head
36103623
$$ = NEW_MASGN($1, NODE_SPECIAL_NO_NAME_REST, &@$);
36113624
/*% ripper: mlhs_add_star!($:1, Qnil) %*/
36123625
}
3613-
| mlhs_head tSTAR ',' mlhs_post
3626+
| mlhs_head tSTAR ',' mlhs(mlhs_item)
36143627
{
36153628
$$ = NEW_MASGN($1, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $4, &@$), &@$);
36163629
/*% ripper: mlhs_add_post!(mlhs_add_star!($:1, Qnil), $:4) %*/
@@ -3620,7 +3633,7 @@ mlhs_basic : mlhs_head
36203633
$$ = NEW_MASGN(0, $2, &@$);
36213634
/*% ripper: mlhs_add_star!(mlhs_new!, $:2) %*/
36223635
}
3623-
| tSTAR mlhs_node ',' mlhs_post
3636+
| tSTAR mlhs_node ',' mlhs(mlhs_item)
36243637
{
36253638
$$ = NEW_MASGN(0, NEW_POSTARG($2,$4,&@$), &@$);
36263639
/*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:2), $:4) %*/
@@ -3630,7 +3643,7 @@ mlhs_basic : mlhs_head
36303643
$$ = NEW_MASGN(0, NODE_SPECIAL_NO_NAME_REST, &@$);
36313644
/*% ripper: mlhs_add_star!(mlhs_new!, Qnil) %*/
36323645
}
3633-
| tSTAR ',' mlhs_post
3646+
| tSTAR ',' mlhs(mlhs_item)
36343647
{
36353648
$$ = NEW_MASGN(0, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$);
36363649
/*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, Qnil), $:3) %*/
@@ -3657,17 +3670,6 @@ mlhs_head : mlhs_item ','
36573670
}
36583671
;
36593672

3660-
mlhs_post : mlhs_item
3661-
{
3662-
$$ = NEW_LIST($1, &@$);
3663-
/*% ripper: mlhs_add!(mlhs_new!, $:1) %*/
3664-
}
3665-
| mlhs_post ',' mlhs_item
3666-
{
3667-
$$ = list_append(p, $1, $3);
3668-
/*% ripper: mlhs_add!($:1, $:3) %*/
3669-
}
3670-
;
36713673

36723674
mlhs_node : user_or_keyword_variable
36733675
{
@@ -4877,29 +4879,18 @@ f_marg : f_norm_arg
48774879
}
48784880
;
48794881

4880-
f_marg_list : f_marg
4881-
{
4882-
$$ = NEW_LIST($1, &@$);
4883-
/*% ripper: mlhs_add!(mlhs_new!, $:1) %*/
4884-
}
4885-
| f_marg_list ',' f_marg
4886-
{
4887-
$$ = list_append(p, $1, $3);
4888-
/*% ripper: mlhs_add!($:1, $:3) %*/
4889-
}
4890-
;
48914882

4892-
f_margs : f_marg_list
4883+
f_margs : mlhs(f_marg)
48934884
{
48944885
$$ = NEW_MASGN($1, 0, &@$);
48954886
/*% ripper: $:1 %*/
48964887
}
4897-
| f_marg_list ',' f_rest_marg
4888+
| mlhs(f_marg) ',' f_rest_marg
48984889
{
48994890
$$ = NEW_MASGN($1, $3, &@$);
49004891
/*% ripper: mlhs_add_star!($:1, $:3) %*/
49014892
}
4902-
| f_marg_list ',' f_rest_marg ',' f_marg_list
4893+
| mlhs(f_marg) ',' f_rest_marg ',' mlhs(f_marg)
49034894
{
49044895
$$ = NEW_MASGN($1, NEW_POSTARG($3, $5, &@$), &@$);
49054896
/*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $:3), $:5) %*/
@@ -4909,7 +4900,7 @@ f_margs : f_marg_list
49094900
$$ = NEW_MASGN(0, $1, &@$);
49104901
/*% ripper: mlhs_add_star!(mlhs_new!, $:1) %*/
49114902
}
4912-
| f_rest_marg ',' f_marg_list
4903+
| f_rest_marg ',' mlhs(f_marg)
49134904
{
49144905
$$ = NEW_MASGN(0, NEW_POSTARG($1, $3, &@$), &@$);
49154906
/*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:1), $:3) %*/

0 commit comments

Comments
 (0)