Use user defined parameterizing rules mlhs
This commit is contained in:
parent
6c8cdc9c6b
commit
c93f30ab67
Notes:
git
2025-03-02 14:11:03 +00:00
55
parse.y
55
parse.y
@ -2779,7 +2779,7 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
|
|||||||
%type <node> command_asgn mrhs mrhs_arg superclass block_call block_command
|
%type <node> command_asgn mrhs mrhs_arg superclass block_call block_command
|
||||||
%type <node_args> f_arglist f_opt_paren_args f_paren_args f_args
|
%type <node_args> f_arglist f_opt_paren_args f_paren_args f_args
|
||||||
%type <node_args_aux> f_arg f_arg_item
|
%type <node_args_aux> f_arg f_arg_item
|
||||||
%type <node> f_marg f_marg_list f_rest_marg
|
%type <node> f_marg f_rest_marg
|
||||||
%type <node_masgn> f_margs
|
%type <node_masgn> f_margs
|
||||||
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
|
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
|
||||||
%type <node_args> block_param opt_block_param block_param_def
|
%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)
|
|||||||
%type <locations_lambda_body> lambda_body
|
%type <locations_lambda_body> lambda_body
|
||||||
%type <node_args> f_larglist
|
%type <node_args> f_larglist
|
||||||
%type <node> brace_block cmd_brace_block do_block lhs none fitem
|
%type <node> brace_block cmd_brace_block do_block lhs none fitem
|
||||||
%type <node> mlhs_head mlhs_item mlhs_node mlhs_post
|
%type <node> mlhs_head mlhs_item mlhs_node
|
||||||
%type <node_masgn> mlhs mlhs_basic mlhs_inner
|
%type <node_masgn> mlhs mlhs_basic mlhs_inner
|
||||||
%type <node> p_case_body p_cases p_top_expr p_top_expr_body
|
%type <node> p_case_body p_cases p_top_expr p_top_expr_body
|
||||||
%type <node> p_expr p_as p_alt p_expr_basic p_find
|
%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)
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
%rule mlhs(item) <node>
|
||||||
|
: 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) <node>
|
%rule op_asgn(rhs) <node>
|
||||||
: var_lhs tOP_ASGN lex_ctxt rhs
|
: var_lhs tOP_ASGN lex_ctxt rhs
|
||||||
{
|
{
|
||||||
@ -3600,7 +3613,7 @@ mlhs_basic : mlhs_head
|
|||||||
$$ = NEW_MASGN($1, $3, &@$);
|
$$ = NEW_MASGN($1, $3, &@$);
|
||||||
/*% ripper: mlhs_add_star!($: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,&@$), &@$);
|
$$ = NEW_MASGN($1, NEW_POSTARG($3,$5,&@$), &@$);
|
||||||
/*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $: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, &@$);
|
$$ = NEW_MASGN($1, NODE_SPECIAL_NO_NAME_REST, &@$);
|
||||||
/*% ripper: mlhs_add_star!($:1, Qnil) %*/
|
/*% 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, &@$), &@$);
|
$$ = NEW_MASGN($1, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $4, &@$), &@$);
|
||||||
/*% ripper: mlhs_add_post!(mlhs_add_star!($:1, Qnil), $:4) %*/
|
/*% ripper: mlhs_add_post!(mlhs_add_star!($:1, Qnil), $:4) %*/
|
||||||
@ -3620,7 +3633,7 @@ mlhs_basic : mlhs_head
|
|||||||
$$ = NEW_MASGN(0, $2, &@$);
|
$$ = NEW_MASGN(0, $2, &@$);
|
||||||
/*% ripper: mlhs_add_star!(mlhs_new!, $: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,&@$), &@$);
|
$$ = NEW_MASGN(0, NEW_POSTARG($2,$4,&@$), &@$);
|
||||||
/*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $: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, &@$);
|
$$ = NEW_MASGN(0, NODE_SPECIAL_NO_NAME_REST, &@$);
|
||||||
/*% ripper: mlhs_add_star!(mlhs_new!, Qnil) %*/
|
/*% 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, &@$), &@$);
|
$$ = NEW_MASGN(0, NEW_POSTARG(NODE_SPECIAL_NO_NAME_REST, $3, &@$), &@$);
|
||||||
/*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, Qnil), $: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
|
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, &@$);
|
$$ = NEW_MASGN($1, 0, &@$);
|
||||||
/*% ripper: $:1 %*/
|
/*% ripper: $:1 %*/
|
||||||
}
|
}
|
||||||
| f_marg_list ',' f_rest_marg
|
| mlhs(f_marg) ',' f_rest_marg
|
||||||
{
|
{
|
||||||
$$ = NEW_MASGN($1, $3, &@$);
|
$$ = NEW_MASGN($1, $3, &@$);
|
||||||
/*% ripper: mlhs_add_star!($: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, &@$), &@$);
|
$$ = NEW_MASGN($1, NEW_POSTARG($3, $5, &@$), &@$);
|
||||||
/*% ripper: mlhs_add_post!(mlhs_add_star!($:1, $: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, &@$);
|
$$ = NEW_MASGN(0, $1, &@$);
|
||||||
/*% ripper: mlhs_add_star!(mlhs_new!, $: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, &@$), &@$);
|
$$ = NEW_MASGN(0, NEW_POSTARG($1, $3, &@$), &@$);
|
||||||
/*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:1), $:3) %*/
|
/*% ripper: mlhs_add_post!(mlhs_add_star!(mlhs_new!, $:1), $:3) %*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user