Project

General

Profile

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

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

View differences:

parse.y
1092 1092
%type <node> command_rhs arg_rhs
1093 1093
%type <node> command_asgn mrhs mrhs_arg superclass block_call block_command
1094 1094
%type <node> f_block_optarg f_block_opt
1095
%type <node> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs f_rest_marg
1095
%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
1096 1096
%type <node> assoc_list assocs assoc undef_list backref string_dvar for_var
1097 1097
%type <node> block_param opt_block_param block_param_def f_opt
1098 1098
%type <node> f_kwarg f_kw f_block_kwarg f_block_kw
......
1597 1597
		    /*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
1598 1598
		    }
1599 1599
		| arg %prec tLBRACE_ARG
1600
		| k_def ':' fname
1601
		    {
1602
			numparam_name(p, get_id($3));
1603
			local_push(p, 0);
1604
			$<id>$ = p->cur_arg;
1605
			p->cur_arg = 0;
1606
			$<ctxt>1 = p->ctxt;
1607
			p->ctxt.in_def = 1;
1608
		    }
1609
		  f_arglist_opt '=' arg
1610
		    {
1611
		    /*%%%*/
1612
			NODE *body = remove_begin($7);
1613
			reduce_nodes(p, &body);
1614
			$$ = NEW_DEFN($3, $5, body, &@$);
1615
			nd_set_line($$->nd_defn, @7.end_pos.lineno);
1616
			set_line_body(body, @1.beg_pos.lineno);
1617
		    /*% %*/
1618
		    /*% ripper: def!($3, $5, $7) %*/
1619
			local_pop(p);
1620
			p->ctxt.in_def = $<ctxt>1.in_def;
1621
			p->cur_arg = $<id>4;
1622
		    }
1623
		| k_def ':' singleton dot_or_colon {SET_LEX_STATE(EXPR_FNAME);} fname
1624
		    {
1625
			numparam_name(p, get_id($6));
1626
			$<ctxt>2 = p->ctxt;
1627
			p->ctxt.in_def = 1;
1628
			SET_LEX_STATE(EXPR_ENDFN|EXPR_LABEL); /* force for args */
1629
			local_push(p, 0);
1630
			$<id>$ = p->cur_arg;
1631
			p->cur_arg = 0;
1632
		    }
1633
		  f_arglist_opt '='
1634
		  arg
1635
		    {
1636
		    /*%%%*/
1637
			NODE *body = remove_begin($10);
1638
			reduce_nodes(p, &body);
1639
			$$ = NEW_DEFS($3, $6, $8, body, &@$);
1640
			nd_set_line($$->nd_defn, @10.end_pos.lineno);
1641
			set_line_body(body, @1.beg_pos.lineno);
1642
		    /*% %*/
1643
		    /*% ripper: defs!($3, $4, $6, $8, $10) %*/
1644
			local_pop(p);
1645
			p->ctxt.in_def = $<ctxt>2.in_def;
1646
			p->cur_arg = $<id>7;
1647
		    }
1600 1648
		;
1601 1649

  
1602 1650
expr_value	: expr
......
4804 4852
		    }
4805 4853
		;
4806 4854

  
4855
f_arglist_opt	: f_arglist
4856
	        | /* none */
4857
		    {
4858
		    /*%%%*/
4859
			$$ = new_args_tail(p, Qnone, Qnone, Qnone, &@0);
4860
			$$ = new_args(p, Qnone, Qnone, Qnone, Qnone, $$, &@0);
4861
		    /*% %*/
4862
		    /*% ripper: Qnil %*/
4863
		    }
4864
		;
4865

  
4807 4866
f_arglist	: '(' f_args rparen
4808 4867
		    {
4809 4868
		    /*%%%*/