ruby-changes:30484
From: nobu <ko1@a...>
Date: Thu, 15 Aug 2013 20:09:31 +0900 (JST)
Subject: [ruby-changes:30484] nobu:r42563 (trunk): parse.y: simplify
nobu 2013-08-15 20:09:26 +0900 (Thu, 15 Aug 2013) New Revision: 42563 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42563 Log: parse.y: simplify * parse.y (f_label): extract from f_kw and f_block_kw. * parse.y (f_opt, f_block_opt): use f_norm_arg to simlify actions. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 42562) +++ parse.y (revision 42563) @@ -781,7 +781,7 @@ static void token_info_pop(struct parser https://github.com/ruby/ruby/blob/trunk/parse.y#L781 %type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner %type <id> fsym keyword_variable user_variable sym symbol operation operation2 operation3 %type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg -%type <id> f_kwrest +%type <id> f_kwrest f_label /*%%%*/ /*% %type <val> program reswords then do dot_or_colon @@ -4593,9 +4593,16 @@ f_arg : f_arg_item https://github.com/ruby/ruby/blob/trunk/parse.y#L4593 } ; -f_kw : tLABEL arg_value + +f_label : tLABEL { arg_var(formal_argument(get_id($1))); + $$ = $1; + } + ; + +f_kw : f_label arg_value + { $$ = assignable($1, $2); /*%%%*/ $$ = NEW_KW_ARG(0, $$); @@ -4603,9 +4610,8 @@ f_kw : tLABEL arg_value https://github.com/ruby/ruby/blob/trunk/parse.y#L4610 $$ = rb_assoc_new($$, $2); %*/ } - | tLABEL + | f_label { - arg_var(formal_argument(get_id($1))); $$ = assignable($1, (NODE *)-1); /*%%%*/ $$ = NEW_KW_ARG(0, $$); @@ -4615,9 +4621,8 @@ f_kw : tLABEL arg_value https://github.com/ruby/ruby/blob/trunk/parse.y#L4621 } ; -f_block_kw : tLABEL primary_value +f_block_kw : f_label primary_value { - arg_var(formal_argument(get_id($1))); $$ = assignable($1, $2); /*%%%*/ $$ = NEW_KW_ARG(0, $$); @@ -4625,9 +4630,8 @@ f_block_kw : tLABEL primary_value https://github.com/ruby/ruby/blob/trunk/parse.y#L4630 $$ = rb_assoc_new($$, $2); %*/ } - | tLABEL + | f_label { - arg_var(formal_argument(get_id($1))); $$ = assignable($1, (NODE *)-1); /*%%%*/ $$ = NEW_KW_ARG(0, $$); @@ -4701,9 +4705,9 @@ f_kwrest : kwrest_mark tIDENTIFIER https://github.com/ruby/ruby/blob/trunk/parse.y#L4705 } ; -f_opt : tIDENTIFIER '=' arg_value +f_opt : f_norm_arg '=' arg_value { - arg_var(formal_argument(get_id($1))); + arg_var(get_id($1)); $$ = assignable($1, $3); /*%%%*/ $$ = NEW_OPT_ARG(0, $$); @@ -4713,9 +4717,9 @@ f_opt : tIDENTIFIER '=' arg_value https://github.com/ruby/ruby/blob/trunk/parse.y#L4717 } ; -f_block_opt : tIDENTIFIER '=' primary_value +f_block_opt : f_norm_arg '=' primary_value { - arg_var(formal_argument(get_id($1))); + arg_var(get_id($1)); $$ = assignable($1, $3); /*%%%*/ $$ = NEW_OPT_ARG(0, $$); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/