summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-03 04:53:05 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-03 04:53:05 +0000
commitfef98fdd0982da3840a1d9c50f9365ffd20e71be (patch)
tree4d046f505f905a2bd2f5b47fe0ddf84f972689fb
parente61e19a2fe86cf3afcfc87a38e66a1c5350c5563 (diff)
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) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--parse.y22
1 files changed, 11 insertions, 11 deletions
diff --git a/parse.y b/parse.y
index 33ed12fd18f..c3bb0210fd4 100644
--- a/parse.y
+++ b/parse.y
@@ -1418,10 +1418,10 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
/*%%%*/
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_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
/*%%%*/
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
}
| 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
}
| '!' arg
{
- $$ = call_uni_op(method_cond($2, &@$), '!', &@$);
+ $$ = call_uni_op(method_cond($2, &@2), '!', &@$);
}
| '~' arg
{
@@ -2782,11 +2782,11 @@ primary : literal
}
| 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
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
k_end
{
/*%%%*/
- $$ = NEW_UNTIL(cond($3, &@$), $6, 1);
+ $$ = NEW_UNTIL(cond($3, &@3), $6, 1);
fixpos($$, $3);
$$->nd_loc = @$;
/*%