[前][次][番号順一覧][スレッド一覧]

ruby-changes:48635

From: yui-knk <ko1@a...>
Date: Mon, 13 Nov 2017 09:14:41 +0900 (JST)
Subject: [ruby-changes:48635] yui-knk:r60750 (trunk): Store last location of a node on RNode

yui-knk	2017-11-13 09:14:33 +0900 (Mon, 13 Nov 2017)

  New Revision: 60750

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60750

  Log:
    Store last location of a node on RNode
    
    * node.c (rb_node_init): Initialize last location with 0.
    
    * node.h (struct rb_code_range_struct): Define a structure
      which contains first location and last location of a node.
    * node.h (struct RNode): Use rb_code_range_t to store last
      location of a node.
    * node.h (nd_column, nd_set_column, nd_lineno, nd_set_lineno):
      Follow-up the change of struct RNode.
    * node.h (nd_last_column, nd_set_last_column, nd_last_lineno, nd_set_last_lineno):
      Define getter/setter macros for last location of RNode.
    
    * parse.y : Set last location of tokens.
    
    Thanks to Yusuke Endoh (mame) for design of data structures.

  Modified files:
    trunk/node.c
    trunk/node.h
    trunk/parse.y
Index: node.c
===================================================================
--- node.c	(revision 60749)
+++ node.c	(revision 60750)
@@ -1069,8 +1069,10 @@ rb_node_init(NODE *n, enum node_type typ https://github.com/ruby/ruby/blob/trunk/node.c#L1069
     n->u1.value = a0;
     n->u2.value = a1;
     n->u3.value = a2;
-    n->nd_first_loc.lineno = 0;
-    n->nd_first_loc.column = 0;
+    n->nd_loc.first_loc.lineno = 0;
+    n->nd_loc.first_loc.column = 0;
+    n->nd_loc.last_loc.lineno = 0;
+    n->nd_loc.last_loc.column = 0;
 }
 
 typedef struct node_buffer_elem_struct {
Index: node.h
===================================================================
--- node.h	(revision 60749)
+++ node.h	(revision 60750)
@@ -227,6 +227,11 @@ typedef struct rb_code_location_struct { https://github.com/ruby/ruby/blob/trunk/node.h#L227
     int column;
 } rb_code_location_t;
 
+typedef struct rb_code_range_struct {
+    rb_code_location_t first_loc;
+    rb_code_location_t last_loc;
+} rb_code_range_t;
+
 typedef struct RNode {
     VALUE flags;
     union {
@@ -251,7 +256,7 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L256
 	long cnt;
 	VALUE value;
     } u3;
-    rb_code_location_t nd_first_loc;
+    rb_code_range_t nd_loc;
 } NODE;
 
 #define RNODE(obj)  (R_CAST(RNode)(obj))
@@ -276,10 +281,15 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L281
 #define nd_set_line(n,l) \
     (n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
 
-#define nd_column(n) ((int)((n)->nd_first_loc.column))
-#define nd_set_column(n, v) ((n)->nd_first_loc.column = (v))
-#define nd_lineno(n) ((int)((n)->nd_first_loc.lineno))
-#define nd_set_lineno(n, v) ((n)->nd_first_loc.lineno = (v))
+#define nd_column(n) ((int)((n)->nd_loc.first_loc.column))
+#define nd_set_column(n, v) ((n)->nd_loc.first_loc.column = (v))
+#define nd_lineno(n) ((int)((n)->nd_loc.first_loc.lineno))
+#define nd_set_lineno(n, v) ((n)->nd_loc.first_loc.lineno = (v))
+
+#define nd_last_column(n) ((int)((n)->nd_loc.last_loc.column))
+#define nd_set_last_column(n, v) ((n)->nd_loc.last_loc.column = (v))
+#define nd_last_lineno(n) ((int)((n)->nd_loc.last_loc.lineno))
+#define nd_set_last_lineno(n, v) ((n)->nd_loc.last_loc.lineno = (v))
 
 #define nd_head  u1.node
 #define nd_alen  u2.argc
Index: parse.y
===================================================================
--- parse.y	(revision 60749)
+++ parse.y	(revision 60750)
@@ -20,6 +20,8 @@ https://github.com/ruby/ruby/blob/trunk/parse.y#L20
 #define YYDEBUG 1
 #define YYERROR_VERBOSE 1
 #define YYSTACK_USE_ALLOCA 0
+#define YYLTYPE rb_code_range_t
+#define YYLTYPE_IS_DECLARED 1
 
 #include "ruby/ruby.h"
 #include "ruby/st.h"
@@ -45,30 +47,26 @@ https://github.com/ruby/ruby/blob/trunk/parse.y#L47
 #define YYCALLOC(nelem, size)	rb_parser_calloc(parser, (nelem), (size))
 #define YYFREE(ptr)		rb_parser_free(parser, (ptr))
 #define YYFPRINTF		rb_parser_printf
+#define YY_LOCATION_PRINT(File, Loc) \
+     rb_parser_printf(parser, "%d.%d-%d.%d", \
+		      (Loc).first_loc.lineno, (Loc).first_loc.column,\
+		      (Loc).last_loc.lineno, (Loc).last_loc.column)
 #define YYLLOC_DEFAULT(Current, Rhs, N)					\
     do									\
       if (N)								\
 	{								\
-	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
-	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
-	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
-	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
+	  (Current).first_loc = YYRHSLOC(Rhs, 1).first_loc;		\
+	  (Current).last_loc  = YYRHSLOC(Rhs, N).last_loc;		\
 	}								\
       else								\
 	{								\
-	  (Current).first_line   = (Current).last_line   = 		\
-		ruby_sourceline;					\
-	  (Current).first_column = (Current).last_column = 		\
-		(int)(parser->tokp - lex_pbeg);				\
+	  (Current).first_loc.lineno = ruby_sourceline;			\
+	  (Current).first_loc.column = (int)(parser->tokp - lex_pbeg);	\
+	  (Current).last_loc.lineno = ruby_sourceline;			\
+	  (Current).last_loc.column = (int)(lex_p - lex_pbeg);		\
 	}								\
     while (0)
 
-#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
-# define YY_LOCATION_PRINT(File, Loc) \
-     rb_parser_printf(parser, "%d.%d-%d.%d", \
-		      (Loc).first_line, (Loc).first_column, \
-		      (Loc).last_line,  (Loc).last_column)
-#endif
 #undef malloc
 #undef realloc
 #undef calloc
@@ -1169,7 +1167,7 @@ program		:  { https://github.com/ruby/ruby/blob/trunk/parse.y#L1167
 				void_expr(node->nd_head);
 			    }
 			}
-			ruby_eval_tree = new_scope(0, block_append(ruby_eval_tree, $2, &@1), &@1);
+			ruby_eval_tree = new_scope(0, block_append(ruby_eval_tree, $2, &@$), &@$);
 		    /*%
 			$$ = $2;
 			parser->result = dispatch1(program, $$);
@@ -1191,7 +1189,7 @@ top_compstmt	: top_stmts opt_terms https://github.com/ruby/ruby/blob/trunk/parse.y#L1189
 top_stmts	: none
                     {
 		    /*%%%*/
-			$$ = new_begin(0, &@1);
+			$$ = new_begin(0, &@$);
 		    /*%
 			$$ = dispatch2(stmts_add, dispatch0(stmts_new),
 						  dispatch0(void_stmt));
@@ -1208,7 +1206,7 @@ top_stmts	: none https://github.com/ruby/ruby/blob/trunk/parse.y#L1206
 		| top_stmts terms top_stmt
 		    {
 		    /*%%%*/
-			$$ = block_append($1, newline_node($3), &@1);
+			$$ = block_append($1, newline_node($3), &@$);
 		    /*%
 			$$ = dispatch2(stmts_add, $1, $3);
 		    %*/
@@ -1231,10 +1229,10 @@ top_stmt	: stmt https://github.com/ruby/ruby/blob/trunk/parse.y#L1229
 		    {
 		    /*%%%*/
 			ruby_eval_tree_begin = block_append(ruby_eval_tree_begin,
-							    $4, &@1);
+							    $4, &@$);
 			/* NEW_PREEXE($4)); */
 			/* local_pop(); */
-			$$ = new_begin(0, &@1);
+			$$ = new_begin(0, &@$);
 		    /*%
 			$$ = dispatch1(BEGIN, $4);
 		    %*/
@@ -1249,23 +1247,21 @@ bodystmt	: compstmt https://github.com/ruby/ruby/blob/trunk/parse.y#L1247
 		    /*%%%*/
 			$$ = $1;
 			if ($2) {
-			    $$ = new_rescue($1, $2, $3, &@1);
+			    $$ = new_rescue($1, $2, $3, &@$);
 			}
 			else if ($3) {
 			    rb_warn0("else without rescue is useless");
-			    $$ = block_append($$, $3, &@1);
+			    $$ = block_append($$, $3, &@$);
 			}
 			if ($4) {
 			    if ($$) {
 				$$ = NEW_ENSURE($$, $4);
-				nd_set_lineno($$, @1.first_line);
-				nd_set_column($$, @1.first_column);
+				$$->nd_loc = @$;
 			    }
 			    else {
 				NODE *nil = NEW_NIL();
-				nd_set_lineno(nil, @1.first_line);
-				nd_set_column(nil, @1.first_column);
-				$$ = block_append($4, nil, &@1);
+				nil->nd_loc = @$;
+				$$ = block_append($4, nil, &@$);
 			    }
 			}
 			fixpos($$, $1);
@@ -1292,7 +1288,7 @@ compstmt	: stmts opt_terms https://github.com/ruby/ruby/blob/trunk/parse.y#L1288
 stmts		: none
                     {
 		    /*%%%*/
-			$$ = new_begin(0, &@1);
+			$$ = new_begin(0, &@$);
 		    /*%
 			$$ = dispatch2(stmts_add, dispatch0(stmts_new),
 						  dispatch0(void_stmt));
@@ -1309,7 +1305,7 @@ stmts		: none https://github.com/ruby/ruby/blob/trunk/parse.y#L1305
 		| stmts terms stmt_or_begin
 		    {
 		    /*%%%*/
-			$$ = block_append($1, newline_node($3), &@1);
+			$$ = block_append($1, newline_node($3), &@$);
 		    /*%
 			$$ = dispatch2(stmts_add, $1, $3);
 		    %*/
@@ -1336,10 +1332,10 @@ stmt_or_begin	: stmt https://github.com/ruby/ruby/blob/trunk/parse.y#L1332
 		    {
 		    /*%%%*/
 			ruby_eval_tree_begin = block_append(ruby_eval_tree_begin,
-							    $4, &@1);
+							    $4, &@$);
 			/* NEW_PREEXE($4)); */
 			/* local_pop(); */
-			$$ = new_begin(0, &@1);
+			$$ = new_begin(0, &@$);
 		    /*%
 			$$ = dispatch1(BEGIN, $4);
 		    %*/
@@ -1350,8 +1346,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1346
 		    {
 		    /*%%%*/
 			$$ = NEW_ALIAS($2, $4);
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(alias, $2, $4);
 		    %*/
@@ -1360,8 +1355,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1355
 		    {
 		    /*%%%*/
 			$$ = NEW_VALIAS($2, $3);
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(var_alias, $2, $3);
 		    %*/
@@ -1373,8 +1367,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1367
 			buf[0] = '$';
 			buf[1] = (char)$3->nd_nth;
 			$$ = NEW_VALIAS($2, rb_intern2(buf, 2));
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(var_alias, $2, $3);
 		    %*/
@@ -1383,7 +1376,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1376
 		    {
 		    /*%%%*/
 			yyerror0("can't make alias for the number variables");
-			$$ = new_begin(0, &@1);
+			$$ = new_begin(0, &@$);
 		    /*%
 			$$ = dispatch2(var_alias, $2, $3);
 			$$ = dispatch1(alias_error, $$);
@@ -1401,7 +1394,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1394
 		| stmt modifier_if expr_value
 		    {
 		    /*%%%*/
-			$$ = new_if($3, remove_begin($1), 0, &@1);
+			$$ = new_if($3, remove_begin($1), 0, &@$);
 			fixpos($$, $3);
 		    /*%
 			$$ = dispatch2(if_mod, $3, $1);
@@ -1410,7 +1403,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1403
 		| stmt modifier_unless expr_value
 		    {
 		    /*%%%*/
-			$$ = new_unless($3, remove_begin($1), 0, &@1);
+			$$ = new_unless($3, remove_begin($1), 0, &@$);
 			fixpos($$, $3);
 		    /*%
 			$$ = dispatch2(unless_mod, $3, $1);
@@ -1420,13 +1413,12 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1413
 		    {
 		    /*%%%*/
 			if ($1 && nd_type($1) == NODE_BEGIN) {
-			    $$ = NEW_WHILE(cond($3, &@1), $1->nd_body, 0);
+			    $$ = NEW_WHILE(cond($3, &@$), $1->nd_body, 0);
 			}
 			else {
-			    $$ = NEW_WHILE(cond($3, &@1), $1, 1);
+			    $$ = NEW_WHILE(cond($3, &@$), $1, 1);
 			}
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(while_mod, $3, $1);
 		    %*/
@@ -1435,13 +1427,12 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1427
 		    {
 		    /*%%%*/
 			if ($1 && nd_type($1) == NODE_BEGIN) {
-			    $$ = NEW_UNTIL(cond($3, &@1), $1->nd_body, 0);
+			    $$ = NEW_UNTIL(cond($3, &@$), $1->nd_body, 0);
 			}
 			else {
-			    $$ = NEW_UNTIL(cond($3, &@1), $1, 1);
+			    $$ = NEW_UNTIL(cond($3, &@$), $1, 1);
 			}
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(until_mod, $3, $1);
 		    %*/
@@ -1449,8 +1440,8 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1440
 		| stmt modifier_rescue stmt
 		    {
 		    /*%%%*/
-			NODE *resq = new_resbody(0, remove_begin($3), 0, &@1);
-			$$ = new_rescue(remove_begin($1), resq, 0, &@1);
+			NODE *resq = new_resbody(0, remove_begin($3), 0, &@$);
+			$$ = new_rescue(remove_begin($1), resq, 0, &@$);
 		    /*%
 			$$ = dispatch2(rescue_mod, $1, $3);
 		    %*/
@@ -1465,10 +1456,8 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1456
 			    NODE *scope = NEW_NODE(
 				NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */);
 			    $$ = NEW_POSTEXE(scope);
-			    nd_set_lineno(scope, @1.first_line);
-			    nd_set_column(scope, @1.first_column);
-			    nd_set_lineno($$, @1.first_line);
-			    nd_set_column($$, @1.first_column);
+			    scope->nd_loc = @$;
+			    $$->nd_loc = @$;
 			}
 		    /*%
 			$$ = dispatch1(END, $3);
@@ -1488,7 +1477,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1477
 		| lhs '=' mrhs
 		    {
 			value_expr($3);
-			$$ = node_assign($1, $3, &@1);
+			$$ = node_assign($1, $3, &@$);
 		    }
 		| mlhs '=' mrhs_arg
 		    {
@@ -1505,12 +1494,12 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1494
 command_asgn	: lhs '=' command_rhs
 		    {
 			value_expr($3);
-			$$ = node_assign($1, $3, &@1);
+			$$ = node_assign($1, $3, &@$);
 		    }
 		| var_lhs tOP_ASGN command_rhs
 		    {
 			value_expr($3);
-			$$ = new_op_assign($1, $2, $3, &@1);
+			$$ = new_op_assign($1, $2, $3, &@$);
 		    }
 		| primary_value '[' opt_call_args rbracket tOP_ASGN command_rhs
 		    {
@@ -1518,8 +1507,8 @@ command_asgn	: lhs '=' command_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L1507
 			NODE *args;
 
 			value_expr($6);
-			if (!$3) $3 = new_zarray(&@1);
-			args = arg_concat($3, $6, &@1);
+			if (!$3) $3 = new_zarray(&@$);
+			args = arg_concat($3, $6, &@$);
 			if ($5 == tOROP) {
 			    $5 = 0;
 			}
@@ -1528,8 +1517,7 @@ command_asgn	: lhs '=' command_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L1517
 			}
 			$$ = NEW_OP_ASGN1($1, $5, args);
 			fixpos($$, $1);
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(aref_field, $1, escape_Qundef($3));
 			$$ = dispatch3(opassign, $$, $5, $6);
@@ -1538,27 +1526,27 @@ command_asgn	: lhs '=' command_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L1526
 		| primary_value call_op tIDENTIFIER tOP_ASGN command_rhs
 		    {
 			value_expr($5);
-			$$ = new_attr_op_assign($1, $2, $3, $4, $5, &@1);
+			$$ = new_attr_op_assign($1, $2, $3, $4, $5, &@$);
 		    }
 		| primary_value call_op tCONSTANT tOP_ASGN command_rhs
 		    {
 			value_expr($5);
-			$$ = new_attr_op_assign($1, $2, $3, $4, $5, &@1);
+			$$ = new_attr_op_assign($1, $2, $3, $4, $5, &@$);
 		    }
 		| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
 		    {
-			$$ = const_path_field($1, $3, &@1);
-			$$ = new_const_op_assign($$, $4, $5, &@1);
+			$$ = const_path_field($1, $3, &@$);
+			$$ = new_const_op_assign($$, $4, $5, &@$);
 		    }
 		| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
 		    {
 			value_expr($5);
-			$$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, &@1);
+			$$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, &@$);
 		    }
 		| backref tOP_ASGN command_rhs
 		    {
 			$1 = var_field($1);
-			$$ = backref_assign_error($1, node_assign($1, $3, &@1), &@1);
+			$$ = backref_assign_error($1, node_assign($1, $3, &@$), &@$);
 		    }
 		;
 
@@ -1574,7 +1562,7 @@ command_rhs	: command_call   %prec tOP_A https://github.com/ruby/ruby/blob/trunk/parse.y#L1562
 		    {
 		    /*%%%*/
 			value_expr($1);
-			$$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &@1), 0, &@1);
+			$$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &@$), 0, &@$);
 		    /*%
 			$$ = dispatch2(rescue_mod, $1, $3);
 		    %*/
@@ -1585,19 +1573,19 @@ command_rhs	: command_call   %prec tOP_A https://github.com/ruby/ruby/blob/trunk/parse.y#L1573
 expr		: command_call
 		| expr keyword_and expr
 		    {
-			$$ = logop(idAND, $1, $3, &@1);
+			$$ = logop(idAND, $1, $3, &@$);
 		    }
 		| expr keyword_or expr
 		    {
-			$$ = logop(idOR, $1, $3, &@1);
+			$$ = logop(idOR, $1, $3, &@$);
 		    }
 		| keyword_not opt_nl expr
 		    {
-			$$ = call_uni_op(method_cond($3, &@1), METHOD_NOT, &@1);
+			$$ = call_uni_op(method_cond($3, &@$), METHOD_NOT, &@$);
 		    }
 		| '!' command_call
 		    {
-			$$ = call_uni_op(method_cond($2, &@1), '!', &@1);
+			$$ = call_uni_op(method_cond($2, &@$), '!', &@$);
 		    }
 		| arg
 		;
@@ -1621,7 +1609,7 @@ command_call	: command https://github.com/ruby/ruby/blob/trunk/parse.y#L1609
 block_command	: block_call
 		| block_call call_op2 operation2 command_args
 		    {
-			$$ = new_qcall($2, $1, $3, $4, &@1);
+			$$ = new_qcall($2, $1, $3, $4, &@$);
 		    }
 		;
 
@@ -1644,7 +1632,7 @@ cmd_brace_block	: tLBRACE_ARG https://github.com/ruby/ruby/blob/trunk/parse.y#L1632
 fcall		: operation
 		    {
 		    /*%%%*/
-			$$ = new_fcall($1, 0, &@1);
+			$$ = new_fcall($1, 0, &@$);
 			nd_set_line($$, tokline);
 		    /*%
 		    %*/
@@ -1669,25 +1657,25 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1657
 		    }
 		| primary_value call_op operation2 command_args	%prec tLOWEST
 		    {
-			$$ = new_command_qcall($2, $1, $3, $4, &@1);
+			$$ = new_command_qcall($2, $1, $3, $4, &@$);
 			fixpos($$, $1);
 		    }
 		| primary_value call_op operation2 command_args cmd_brace_block
 		    {
 			block_dup_check($4,$5);
-			$$ = new_command_qcall($2, $1, $3, $4, &@1);
+			$$ = new_command_qcall($2, $1, $3, $4, &@$);
 			$$ = method_add_block($$, $5);
 			fixpos($$, $1);
 		   }
 		| primary_value tCOLON2 operation2 command_args	%prec tLOWEST
 		    {
-			$$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@1);
+			$$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@$);
 			fixpos($$, $1);
 		    }
 		| primary_value tCOLON2 operation2 command_args cmd_brace_block
 		    {
 			block_dup_check($4,$5);
-			$$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@1);
+			$$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@$);
 			$$ = method_add_block($$, $5);
 			fixpos($$, $1);
 		   }
@@ -1696,8 +1684,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1684
 		    /*%%%*/
 			$$ = NEW_SUPER($2);
 			fixpos($$, $2);
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch1(super, $2);
 		    %*/
@@ -1705,7 +1692,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1692
 		| keyword_yield command_args
 		    {
 		    /*%%%*/
-			$$ = new_yield($2, &@1);
+			$$ = new_yield($2, &@$);
 			fixpos($$, $2);
 		    /*%
 			$$ = dispatch1(yield, $2);
@@ -1715,8 +1702,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1702
 		    {
 		    /*%%%*/
 			$$ = NEW_RETURN(ret_args($2));
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch1(return, $2);
 		    %*/
@@ -1725,8 +1711,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1711
 		    {
 		    /*%%%*/
 			$$ = NEW_BREAK(ret_args($2));
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch1(break, $2);
 		    %*/
@@ -1735,8 +1720,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1720
 		    {
 		    /*%%%*/
 			$$ = NEW_NEXT(ret_args($2));
-			nd_set_lineno($$, @1.first_line);
-			nd_set_column($$, @1.first_column);
+			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch1(next, $2);
 		    %*/
@@ -1758,7 +1742,7 @@ mlhs_inner	: mlhs_basic https://github.com/ruby/ruby/blob/trunk/parse.y#L1742
 		| tLPAREN mlhs_inner rparen
 		    {
 		    /*%%%*/
-			$$ = new_masgn(new_list($2, &@1), 0, &@1);
+			$$ = new_masgn(new_list($2, &@$), 0, &@$);
 		    /*%
 			$$ = dispatch1(mlhs_paren, $2);
 		    %*/
@@ -1768,7 +1752,7 @@ mlhs_inner	: mlhs_basic https://github.com/ruby/ruby/blob/trunk/parse.y#L1752
 mlhs_basic	: mlhs_head
 		    {
 		    /*%%%*/
-			$$ = new_masgn($1, 0, &@1);
+			$$ = new_masgn($1, 0, &@$);
 		    /*%
 			$$ = $1;
 		    %*/
@@ -1776,7 +1760,7 @@ mlhs_basic	: mlhs_head https://github.com/ruby/ruby/blob/trunk/parse.y#L1760
 		| mlhs_head mlhs_item
 		    {
 		    /*%%%*/
-			$$ = new_masgn(list_append($1,$2,&@1), 0, &@1);
+			$$ = new_masgn(list_append($1,$2,&@$), 0, &@$);
 		    /*%
 			$$ = mlhs_add($1, $2);
 		    %*/
@@ -1784,7 +1768,7 @@ mlhs_basic	: mlhs_head https://github.com/ruby/ruby/blob/trunk/parse.y#L1768
 		| mlhs_head tSTAR mlhs_node
 		    {
 		    /*%%%*/
-			$$ = new_masgn($1, $3, &@1);
+			$$ = new_masgn($1, $3, &@$);
 		    /*%
 			$$ = mlhs_add_star($1, $3);
 		    %*/
@@ -1792,7 +1776,7 @@ (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]