Project

General

Profile

Feature #16746 ยป endless-method-definition.patch

mame (Yusuke Endoh), 04/01/2020 03:26 AM

View differences:

parse.y
%type <node> command_rhs arg_rhs
%type <node> command_asgn mrhs mrhs_arg superclass block_call block_command
%type <node> f_block_optarg f_block_opt
%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs f_rest_marg
%type <node> f_arglist f_arglist_opt f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs f_rest_marg
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
%type <node> block_param opt_block_param block_param_def f_opt
%type <node> f_kwarg f_kw f_block_kwarg f_block_kw
......
/*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
}
| arg %prec tLBRACE_ARG
| k_def ':' fname
{
numparam_name(p, get_id($3));
local_push(p, 0);
$<id>$ = p->cur_arg;
p->cur_arg = 0;
$<ctxt>1 = p->ctxt;
p->ctxt.in_def = 1;
}
f_arglist_opt '=' arg
{
/*%%%*/
NODE *body = remove_begin($7);
reduce_nodes(p, &body);
$$ = NEW_DEFN($3, $5, body, &@$);
nd_set_line($$->nd_defn, @7.end_pos.lineno);
set_line_body(body, @1.beg_pos.lineno);
/*% %*/
/*% ripper: def!($3, $5, $7) %*/
local_pop(p);
p->ctxt.in_def = $<ctxt>1.in_def;
p->cur_arg = $<id>4;
}
| k_def ':' singleton dot_or_colon {SET_LEX_STATE(EXPR_FNAME);} fname
{
numparam_name(p, get_id($6));
$<ctxt>2 = p->ctxt;
p->ctxt.in_def = 1;
SET_LEX_STATE(EXPR_ENDFN|EXPR_LABEL); /* force for args */
local_push(p, 0);
$<id>$ = p->cur_arg;
p->cur_arg = 0;
}
f_arglist_opt '='
arg
{
/*%%%*/
NODE *body = remove_begin($10);
reduce_nodes(p, &body);
$$ = NEW_DEFS($3, $6, $8, body, &@$);
nd_set_line($$->nd_defn, @10.end_pos.lineno);
set_line_body(body, @1.beg_pos.lineno);
/*% %*/
/*% ripper: defs!($3, $4, $6, $8, $10) %*/
local_pop(p);
p->ctxt.in_def = $<ctxt>2.in_def;
p->cur_arg = $<id>7;
}
;
expr_value : expr
......
}
;
f_arglist_opt : f_arglist
| /* none */
{
/*%%%*/
$$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
$$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $$, &@0);
/*% %*/
/*% ripper: Qnil %*/
}
;
f_arglist : '(' f_args rparen
{
/*%%%*/
    (1-1/1)