Use user defined parameterizing rules args_tail_basic

This commit is contained in:
ydah 2025-03-13 23:23:14 +09:00 committed by Yudai Takada
parent f2483c79fe
commit 84f51eb02a
Notes: git 2025-03-13 15:20:52 +00:00

64
parse.y
View File

@ -2921,6 +2921,28 @@ rb_parser_ary_free(rb_parser_t *p, rb_parser_ary_t *ary)
}
;
%rule args_tail_basic(value) <node_args>
: f_kwarg(value) ',' f_kwrest opt_f_block_arg
{
$$ = new_args_tail(p, $1, $3, $4, &@3);
/*% ripper: [$:1, $:3, $:4] %*/
}
| f_kwarg(value) opt_f_block_arg
{
$$ = new_args_tail(p, $1, 0, $2, &@1);
/*% ripper: [$:1, Qnil, $:2] %*/
}
| f_any_kwrest opt_f_block_arg
{
$$ = new_args_tail(p, 0, $1, $2, &@1);
/*% ripper: [Qnil, $:1, $:2] %*/
}
| f_block_arg
{
$$ = new_args_tail(p, 0, 0, $1, &@1);
/*% ripper: [Qnil, Qnil, $:1] %*/
}
%rule def_endless_method(bodystmt) <node>
: defn_head[head] f_opt_paren_args[args] '=' bodystmt
{
@ -4932,26 +4954,7 @@ f_any_kwrest : f_kwrest
f_eq : {p->ctxt.in_argdef = 0;} '=';
block_args_tail : f_kwarg(primary_value) ',' f_kwrest opt_f_block_arg
{
$$ = new_args_tail(p, $1, $3, $4, &@3);
/*% ripper: [$:1, $:3, $:4] %*/
}
| f_kwarg(primary_value) opt_f_block_arg
{
$$ = new_args_tail(p, $1, 0, $2, &@1);
/*% ripper: [$:1, Qnil, $:2] %*/
}
| f_any_kwrest opt_f_block_arg
{
$$ = new_args_tail(p, 0, $1, $2, &@1);
/*% ripper: [Qnil, $:1, $:2] %*/
}
| f_block_arg
{
$$ = new_args_tail(p, 0, 0, $1, &@1);
/*% ripper: [Qnil, Qnil, $:1] %*/
}
block_args_tail : args_tail_basic(primary_value)
;
excessed_comma : ','
@ -6295,26 +6298,7 @@ f_arglist : f_paren_args
}
;
args_tail : f_kwarg(arg_value) ',' f_kwrest opt_f_block_arg
{
$$ = new_args_tail(p, $1, $3, $4, &@3);
/*% ripper: [$:1, $:3, $:4] %*/
}
| f_kwarg(arg_value) opt_f_block_arg
{
$$ = new_args_tail(p, $1, 0, $2, &@1);
/*% ripper: [$:1, Qnil, $:2] %*/
}
| f_any_kwrest opt_f_block_arg
{
$$ = new_args_tail(p, 0, $1, $2, &@1);
/*% ripper: [Qnil, $:1, $:2] %*/
}
| f_block_arg
{
$$ = new_args_tail(p, 0, 0, $1, &@1);
/*% ripper: [Qnil, Qnil, $:1] %*/
}
args_tail : args_tail_basic(arg_value)
| args_forward
{
ID fwd = $args_forward;