ruby-changes:43780
From: nobu <ko1@a...>
Date: Wed, 10 Aug 2016 22:37:08 +0900 (JST)
Subject: [ruby-changes:43780] nobu:r55853 (trunk): parse.y: rhs with rescue modifier
nobu 2016-08-10 22:37:03 +0900 (Wed, 10 Aug 2016) New Revision: 55853 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55853 Log: parse.y: rhs with rescue modifier * parse.y (command_rhs, arg_rhs): introduce new rules to reduce repeated rules with rescue modifier. Modified files: trunk/ChangeLog trunk/parse.y Index: ChangeLog =================================================================== --- ChangeLog (revision 55852) +++ ChangeLog (revision 55853) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Aug 10 22:37:01 2016 Nobuyoshi Nakada <nobu@r...> + + * parse.y (command_rhs, arg_rhs): introduce new rules to reduce + repeated rules with rescue modifier. + Wed Aug 10 17:26:43 2016 Nobuyoshi Nakada <nobu@r...> * parse.y (command_asgn): rescue modifier in command assignment Index: parse.y =================================================================== --- parse.y (revision 55852) +++ parse.y (revision 55853) @@ -862,6 +862,7 @@ static void token_info_pop_gen(struct pa https://github.com/ruby/ruby/blob/trunk/parse.y#L862 %type <node> args call_args opt_call_args %type <node> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail %type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs +%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 @@ -1348,7 +1349,7 @@ stmt : keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1349 | expr ; -command_asgn : lhs '=' command_call +command_asgn : lhs '=' command_rhs { /*%%%*/ value_expr($3); @@ -1357,30 +1358,28 @@ command_asgn : lhs '=' command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1358 $$ = dispatch2(assign, $1, $3); %*/ } - | lhs '=' command_call modifier_rescue stmt + ; + +command_rhs : command_call %prec tOP_ASGN { /*%%%*/ - NODE *resq = NEW_RESBODY(0, remove_begin($5), 0); - value_expr($3); - resq = NEW_RESCUE($3, resq, 0); - $$ = node_assign($1, resq); + value_expr($1); + $$ = $1; /*% - $3 = dispatch2(rescue_mod, $3, $5); - $$ = dispatch2(assign, $1, $3); %*/ } - | lhs '=' command_asgn + | command_call modifier_rescue stmt { /*%%%*/ - value_expr($3); - $$ = node_assign($1, $3); + value_expr($1); + $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0), 0); /*% - $$ = dispatch2(assign, $1, $3); + $$ = dispatch2(rescue_mod, $1, $3); %*/ } + | command_asgn ; - expr : command_call | expr keyword_and expr { @@ -2047,38 +2046,12 @@ reswords : keyword__LINE__ | keyword__FI https://github.com/ruby/ruby/blob/trunk/parse.y#L2046 | keyword_while | keyword_until ; -arg : lhs '=' arg +arg : lhs '=' arg_rhs { - /*%%%*/ - value_expr($3); - $$ = node_assign($1, $3); - /*% - $$ = dispatch2(assign, $1, $3); - %*/ - } - | lhs '=' arg modifier_rescue arg - { - /*%%%*/ - value_expr($3); - $3 = NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0); $$ = node_assign($1, $3); - /*% - $$ = dispatch2(assign, $1, dispatch2(rescue_mod, $3, $5)); - %*/ } - | var_lhs tOP_ASGN arg + | var_lhs tOP_ASGN arg_rhs { - value_expr($3); - $$ = new_op_assign($1, $2, $3); - } - | var_lhs tOP_ASGN arg modifier_rescue arg - { - /*%%%*/ - value_expr($3); - $3 = NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0); - /*% - $3 = dispatch2(rescue_mod, $3, $5); - %*/ $$ = new_op_assign($1, $2, $3); } | primary_value '[' opt_call_args rbracket tOP_ASGN arg @@ -2472,6 +2445,25 @@ aref_args : none https://github.com/ruby/ruby/blob/trunk/parse.y#L2445 %*/ } ; + +arg_rhs : arg %prec tOP_ASGN + { + /*%%%*/ + value_expr($1); + $$ = $1; + /*% + %*/ + } + | arg modifier_rescue arg + { + /*%%%*/ + value_expr($1); + $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0), 0); + /*% + $$ = dispatch2(rescue_mod, $1, $3); + %*/ + } + ; paren_args : '(' opt_call_args rparen { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/