ruby-changes:48789
From: yui-knk <ko1@a...>
Date: Sat, 25 Nov 2017 20:57:39 +0900 (JST)
Subject: [ruby-changes:48789] yui-knk:r60905 (trunk): parse.y: opt_arg_append
yui-knk 2017-11-25 20:57:33 +0900 (Sat, 25 Nov 2017) New Revision: 60905 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60905 Log: parse.y: opt_arg_append * parse.y (opt_arg_append): extract optional arguments append. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 60904) +++ parse.y (revision 60905) @@ -494,6 +494,7 @@ static NODE *const_decl_gen(struct parse https://github.com/ruby/ruby/blob/trunk/parse.y#L494 #define var_field(n) (n) #define backref_assign_error(n, a, location) (rb_backref_error(n), new_begin(0, location)) +static NODE *opt_arg_append(NODE*, NODE*); static NODE *kwd_append(NODE*, NODE*); static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *location); @@ -4797,13 +4798,7 @@ f_block_optarg : f_block_opt https://github.com/ruby/ruby/blob/trunk/parse.y#L4798 | f_block_optarg ',' f_block_opt { /*%%%*/ - NODE *opts = $1; - - while (opts->nd_next) { - opts = opts->nd_next; - } - opts->nd_next = $3; - $$ = $1; + $$ = opt_arg_append($1, $3); /*% $$ = rb_ary_push($1, get_value($3)); %*/ @@ -4821,13 +4816,7 @@ f_optarg : f_opt https://github.com/ruby/ruby/blob/trunk/parse.y#L4816 | f_optarg ',' f_opt { /*%%%*/ - NODE *opts = $1; - - while (opts->nd_next) { - opts = opts->nd_next; - } - opts->nd_next = $3; - $$ = $1; + $$ = opt_arg_append($1, $3); /*% $$ = rb_ary_push($1, get_value($3)); %*/ @@ -9351,6 +9340,19 @@ gettable_gen(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L9340 } static NODE * +opt_arg_append(NODE *opt_list, NODE *opt) +{ + NODE *opts = opt_list; + + while (opts->nd_next) { + opts = opts->nd_next; + } + opts->nd_next = opt; + + return opt_list; +} + +static NODE * kwd_append(NODE *kwlist, NODE *kw) { if (kwlist) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/