ruby-changes:48868
From: yui-knk <ko1@a...>
Date: Sun, 3 Dec 2017 13:53:11 +0900 (JST)
Subject: [ruby-changes:48868] yui-knk:r60986 (trunk): parse.y: Fix locations of NODEs generated by cond0
yui-knk 2017-12-03 13:53:05 +0900 (Sun, 03 Dec 2017) New Revision: 60986 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60986 Log: parse.y: Fix locations of NODEs generated by cond0 * parse.y: Fix to only include a range of the first argument of cond. e.g. The locations of the NODE_MATCH2 and NODE_GVAR are fixed: ``` 1 while /#{:a}/ ``` * Before ``` NODE_MATCH2 (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 15) NODE_GVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 15) ``` * After ``` NODE_MATCH2 (line: 1, first_lineno: 1, first_column: 8, last_lineno: 1, last_column: 15) NODE_GVAR (line: 1, first_lineno: 1, first_column: 8, last_lineno: 1, last_column: 15) ``` Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 60985) +++ parse.y (revision 60986) @@ -1418,10 +1418,10 @@ stmt : keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1418 { /*%%%*/ if ($1 && nd_type($1) == NODE_BEGIN) { - $$ = NEW_WHILE(cond($3, &@$), $1->nd_body, 0); + $$ = NEW_WHILE(cond($3, &@3), $1->nd_body, 0); } else { - $$ = NEW_WHILE(cond($3, &@$), $1, 1); + $$ = NEW_WHILE(cond($3, &@3), $1, 1); } $$->nd_loc = @$; /*% @@ -1432,10 +1432,10 @@ stmt : keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1432 { /*%%%*/ if ($1 && nd_type($1) == NODE_BEGIN) { - $$ = NEW_UNTIL(cond($3, &@$), $1->nd_body, 0); + $$ = NEW_UNTIL(cond($3, &@3), $1->nd_body, 0); } else { - $$ = NEW_UNTIL(cond($3, &@$), $1, 1); + $$ = NEW_UNTIL(cond($3, &@3), $1, 1); } $$->nd_loc = @$; /*% @@ -1584,11 +1584,11 @@ expr : command_call https://github.com/ruby/ruby/blob/trunk/parse.y#L1584 } | keyword_not opt_nl expr { - $$ = call_uni_op(method_cond($3, &@$), METHOD_NOT, &@$); + $$ = call_uni_op(method_cond($3, &@3), METHOD_NOT, &@$); } | '!' command_call { - $$ = call_uni_op(method_cond($2, &@$), '!', &@$); + $$ = call_uni_op(method_cond($2, &@2), '!', &@$); } | arg ; @@ -2309,7 +2309,7 @@ arg : lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2309 } | '!' arg { - $$ = call_uni_op(method_cond($2, &@$), '!', &@$); + $$ = call_uni_op(method_cond($2, &@2), '!', &@$); } | '~' arg { @@ -2782,11 +2782,11 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2782 } | keyword_not '(' expr rparen { - $$ = call_uni_op(method_cond($3, &@$), METHOD_NOT, &@$); + $$ = call_uni_op(method_cond($3, &@3), METHOD_NOT, &@$); } | keyword_not '(' rparen { - $$ = call_uni_op(method_cond(new_nil(), &@$), METHOD_NOT, &@$); + $$ = call_uni_op(method_cond(new_nil(), &@2), METHOD_NOT, &@$); } | fcall brace_block { @@ -2844,7 +2844,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2844 k_end { /*%%%*/ - $$ = NEW_WHILE(cond($3, &@$), $6, 1); + $$ = NEW_WHILE(cond($3, &@3), $6, 1); fixpos($$, $3); $$->nd_loc = @$; /*% @@ -2856,7 +2856,7 @@ primary : literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2856 k_end { /*%%%*/ - $$ = NEW_UNTIL(cond($3, &@$), $6, 1); + $$ = NEW_UNTIL(cond($3, &@3), $6, 1); fixpos($$, $3); $$->nd_loc = @$; /*% -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/