ruby-changes:48914
From: nobu <ko1@a...>
Date: Tue, 5 Dec 2017 22:42:51 +0900 (JST)
Subject: [ruby-changes:48914] nobu:r61032 (trunk): parse.y: nd_line of logop
nobu 2017-12-05 22:42:46 +0900 (Tue, 05 Dec 2017) New Revision: 61032 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61032 Log: parse.y: nd_line of logop * parse.y (logop): set nd_line to the logical operator location, same as non-operator method calls. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 61031) +++ parse.y (revision 61032) @@ -395,10 +395,10 @@ static NODE *new_if_gen(struct parser_pa https://github.com/ruby/ruby/blob/trunk/parse.y#L395 #define new_if(cc,left,right,location) new_if_gen(parser, (cc), (left), (right), (location)) static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*); #define new_unless(cc,left,right,location) new_unless_gen(parser, (cc), (left), (right), (location)) -static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,const YYLTYPE*); -#define logop(id,node1,node2,location) \ +static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*); +#define logop(id,node1,node2,op_loc,location) \ logop_gen(parser, ((id)==idAND||(id)==idANDOP)?NODE_AND:NODE_OR, \ - (node1), (node2), (location)) + (node1), (node2), (op_loc), (location)) static NODE *newline_node(NODE*); static void fixpos(NODE*,NODE*); @@ -634,7 +634,7 @@ static int id_is_var_gen(struct parser_p https://github.com/ruby/ruby/blob/trunk/parse.y#L634 #define call_bin_op(recv,id,arg1,op_loc,location) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1)) #define match_op(node1,node2,op_loc,location) call_bin_op((node1), idEqTilde, (node2), op_loc, location) #define call_uni_op(recv,id,location) dispatch2(unary, STATIC_ID2SYM(id), (recv)) -#define logop(id,node1,node2,location) call_bin_op((node1), (id), (node2), 0, location) +#define logop(id,node1,node2,op_loc,location) call_bin_op((node1), (id), (node2), op_loc, location) #define node_assign(node1, node2, location) dispatch2(assign, (node1), (node2)) static VALUE new_qcall_gen(struct parser_params *parser, VALUE q, VALUE r, VALUE m, VALUE a); #define new_qcall(q,r,m,a,location) new_qcall_gen(parser, (r), (q), (m), (a)) @@ -1577,11 +1577,11 @@ command_rhs : command_call %prec tOP_A https://github.com/ruby/ruby/blob/trunk/parse.y#L1577 expr : command_call | expr keyword_and expr { - $$ = logop(idAND, $1, $3, &@$); + $$ = logop(idAND, $1, $3, &@2, &@$); } | expr keyword_or expr { - $$ = logop(idOR, $1, $3, &@$); + $$ = logop(idOR, $1, $3, &@2, &@$); } | keyword_not opt_nl expr { @@ -2326,11 +2326,11 @@ arg : lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2326 } | arg tANDOP arg { - $$ = logop(idANDOP, $1, $3, &@$); + $$ = logop(idANDOP, $1, $3, &@2, &@$); } | arg tOROP arg { - $$ = logop(idOROP, $1, $3, &@$); + $$ = logop(idOROP, $1, $3, &@2, &@$); } | keyword_defined opt_nl {in_defined = 1;} arg { @@ -10590,7 +10590,8 @@ new_unless_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L10590 } static NODE* -logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right, const YYLTYPE *location) +logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right, + const YYLTYPE *op_loc, const YYLTYPE *location) { NODE *op; value_expr(left); @@ -10601,11 +10602,13 @@ logop_gen(struct parser_params *parser, https://github.com/ruby/ruby/blob/trunk/parse.y#L10602 } node->nd_2nd = NEW_NODE(type, second, right, 0); node->nd_2nd->nd_loc = *location; + nd_set_line(node->nd_2nd, op_loc->first_loc.lineno); left->nd_loc.last_loc = location->last_loc; return left; } op = NEW_NODE(type, left, right, 0); op->nd_loc = *location; + nd_set_line(op, op_loc->first_loc.lineno); return op; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/