From 7a42b03b0c1f7e8b8bd45f86eca723b0012b9118 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Mon, 30 Oct 2017 13:36:20 +0000 Subject: [PATCH] Store lineno on RNode * node.c (A_NODE_HEADER): Print lineno. * node.h (nd_column, nd_set_column): Store column number with 16-bit. * node.h (nd_lineno, nd_set_lineno): Define getter/setter macros for lineno of RNode. * parse.y : Set first lineno of tokens. Thanks to takeshinoda for review. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- node.c | 2 +- node.h | 9 +- parse.y | 1319 +++++++++++++++++++++++++++++++------------------------ 3 files changed, 747 insertions(+), 583 deletions(-) diff --git a/node.c b/node.c index f4a7b6ec79..c671884094 100644 --- a/node.c +++ b/node.c @@ -23,7 +23,7 @@ #define A_LONG(val) rb_str_catf(buf, "%ld", (val)) #define A_LIT(lit) AR(rb_inspect(lit)) #define A_NODE_HEADER(node, term) \ - rb_str_catf(buf, "@ %s (line: %d, column: %d)"term, ruby_node_name(nd_type(node)), nd_line(node), nd_column(node)) + rb_str_catf(buf, "@ %s (line: %d. lineno: %d, column: %d)"term, ruby_node_name(nd_type(node)), nd_line(node), nd_lineno(node), nd_column(node)) #define A_FIELD_HEADER(len, name, term) \ rb_str_catf(buf, "+- %.*s:"term, (len), (name)) #define D_FIELD_HEADER(len, name, term) (A_INDENT, A_FIELD_HEADER(len, name, term)) diff --git a/node.h b/node.h index eca966f361..04434cb48c 100644 --- a/node.h +++ b/node.h @@ -268,8 +268,13 @@ typedef struct RNode { #define nd_line(n) (int)(((SIGNED_VALUE)RNODE(n)->flags)>>NODE_LSHIFT) #define nd_set_line(n,l) \ RNODE(n)->flags=((RNODE(n)->flags&~((VALUE)(-1)<nd_reserved) -#define nd_set_column(n, v) (RNODE(n)->nd_reserved=v) +#define nd_column(n) (int)(RNODE(n)->nd_reserved & 0xffff) +#define nd_set_column(n, v) \ + RNODE(n)->nd_reserved = (RNODE(n)->nd_reserved & ~0xffff) | ((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) + +#define nd_lineno(n) (int)((RNODE(n)->nd_reserved >> 16) & 0xffff) +#define nd_set_lineno(n, v) \ + RNODE(n)->nd_reserved = (RNODE(n)->nd_reserved & ~0xffff0000) | (((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) << 16) #define nd_head u1.node #define nd_alen u2.argc diff --git a/parse.y b/parse.y index 9a1137c43e..d83586cf57 100644 --- a/parse.y +++ b/parse.y @@ -45,6 +45,24 @@ #define YYCALLOC(nelem, size) rb_parser_calloc(parser, (nelem), (size)) #define YYFREE(ptr) rb_parser_free(parser, (ptr)) #define YYFPRINTF rb_parser_printf +#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; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + ruby_sourceline; \ + (Current).first_column = (Current).last_column = \ + (int)(parser->tokp - 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", \ @@ -375,18 +393,18 @@ set_line_body(NODE *body, int line) static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE); #define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3)) -static NODE *cond_gen(struct parser_params*,NODE*,int,int); -#define cond(node,column) cond_gen(parser, (node), FALSE, column) -#define method_cond(node,column) cond_gen(parser, (node), TRUE, column) +static NODE *cond_gen(struct parser_params*,NODE*,int,YYLTYPE*); +#define cond(node,location) cond_gen(parser, (node), FALSE, location) +#define method_cond(node,location) cond_gen(parser, (node), TRUE, location) #define new_nil() NEW_NIL() -static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*,int); -#define new_if(cc,left,right,column) new_if_gen(parser, (cc), (left), (right), (column)) -static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*,int); -#define new_unless(cc,left,right,column) new_unless_gen(parser, (cc), (left), (right), (column)) -static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,int); -#define logop(id,node1,node2,column) \ +static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*,YYLTYPE*); +#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*,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*,YYLTYPE*); +#define logop(id,node1,node2,location) \ logop_gen(parser, ((id)==idAND||(id)==idANDOP)?NODE_AND:NODE_OR, \ - (node1), (node2), (column)) + (node1), (node2), (location)) static NODE *newline_node(NODE*); static void fixpos(NODE*,NODE*); @@ -405,31 +423,31 @@ static void reduce_nodes_gen(struct parser_params*,NODE**); static void block_dup_check_gen(struct parser_params*,NODE*,NODE*); #define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2)) -static NODE *block_append_gen(struct parser_params*,NODE*,NODE*,int); -#define block_append(h,t,column) block_append_gen(parser,(h),(t),(column)) -static NODE *list_append_gen(struct parser_params*,NODE*,NODE*,int); -#define list_append(l,i,column) list_append_gen(parser,(l),(i),(column)) +static NODE *block_append_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define block_append(h,t,location) block_append_gen(parser,(h),(t),(location)) +static NODE *list_append_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define list_append(l,i,location) list_append_gen(parser,(l),(i),(location)) static NODE *list_concat(NODE*,NODE*); -static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*,int); -#define arg_append(h,t,column) arg_append_gen(parser,(h),(t),(column)) -static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*,int); -#define arg_concat(h,t,column) arg_concat_gen(parser,(h),(t),(column)) -static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*,int); -#define literal_concat(h,t,column) literal_concat_gen(parser,(h),(t),(column)) +static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define arg_append(h,t,location) arg_append_gen(parser,(h),(t),(location)) +static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define arg_concat(h,t,location) arg_concat_gen(parser,(h),(t),(location)) +static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define literal_concat(h,t,location) literal_concat_gen(parser,(h),(t),(location)) static int literal_concat0(struct parser_params *, VALUE, VALUE); -static NODE *new_evstr_gen(struct parser_params*,NODE*,int); -#define new_evstr(n, column) new_evstr_gen(parser,(n),(column)) -static NODE *evstr2dstr_gen(struct parser_params*,NODE*,int); -#define evstr2dstr(n,column) evstr2dstr_gen(parser,(n),(column)) +static NODE *new_evstr_gen(struct parser_params*,NODE*,YYLTYPE*); +#define new_evstr(n, location) new_evstr_gen(parser,(n),(location)) +static NODE *evstr2dstr_gen(struct parser_params*,NODE*,YYLTYPE*); +#define evstr2dstr(n,location) evstr2dstr_gen(parser,(n),(location)) static NODE *splat_array(NODE*); -static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*,int); -#define call_bin_op(recv,id,arg1,column) call_bin_op_gen(parser, (recv),(id),(arg1),(column)) -static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID,int); -#define call_uni_op(recv,id,column) call_uni_op_gen(parser, (recv),(id),(column)) -static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, int column); -#define new_qcall(q,r,m,a,column) new_qcall_gen(parser,q,r,m,a,column) -#define new_command_qcall(q,r,m,a,column) new_qcall_gen(parser,q,r,m,a,column) +static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*,YYLTYPE*); +#define call_bin_op(recv,id,arg1,location) call_bin_op_gen(parser, (recv),(id),(arg1),(location)) +static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID,YYLTYPE*); +#define call_uni_op(recv,id,location) call_uni_op_gen(parser, (recv),(id),(location)) +static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, YYLTYPE *location); +#define new_qcall(q,r,m,a,location) new_qcall_gen(parser,q,r,m,a,location) +#define new_command_qcall(q,r,m,a,location) new_qcall_gen(parser,q,r,m,a,location) static NODE *new_command_gen(struct parser_params*parser, NODE *m, NODE *a) {m->nd_args = a; return m;} #define new_command(m,a) new_command_gen(parser, m, a) static NODE *method_add_block_gen(struct parser_params*parser, NODE *m, NODE *b) {b->nd_iter = m; return b;} @@ -437,136 +455,136 @@ static NODE *method_add_block_gen(struct parser_params*parser, NODE *m, NODE *b) static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*); #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t)) -static NODE *new_args_tail_gen(struct parser_params*,NODE*,ID,ID,int); -#define new_args_tail(k,kr,b,column) new_args_tail_gen(parser, (k),(kr),(b),(column)) -static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, int column); -#define new_kw_arg(k,column) new_kw_arg_gen(parser, k, column) +static NODE *new_args_tail_gen(struct parser_params*,NODE*,ID,ID,YYLTYPE*); +#define new_args_tail(k,kr,b,location) new_args_tail_gen(parser, (k),(kr),(b),(location)) +static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, YYLTYPE *location); +#define new_kw_arg(k,location) new_kw_arg_gen(parser, k, location) static VALUE negate_lit_gen(struct parser_params*, VALUE); #define negate_lit(lit) negate_lit_gen(parser, lit) static NODE *ret_args_gen(struct parser_params*,NODE*); #define ret_args(node) ret_args_gen(parser, (node)) static NODE *arg_blk_pass(NODE*,NODE*); -static NODE *new_yield_gen(struct parser_params*,NODE*,int); -#define new_yield(node,column) new_yield_gen(parser, (node), (column)) -static NODE *dsym_node_gen(struct parser_params*,NODE*,int); -#define dsym_node(node,column) dsym_node_gen(parser, (node), (column)) +static NODE *new_yield_gen(struct parser_params*,NODE*,YYLTYPE*); +#define new_yield(node,location) new_yield_gen(parser, (node), (location)) +static NODE *dsym_node_gen(struct parser_params*,NODE*,YYLTYPE*); +#define dsym_node(node,location) dsym_node_gen(parser, (node), (location)) -static NODE *gettable_gen(struct parser_params*,ID,int); -#define gettable(id,column) gettable_gen(parser,(id),(column)) -static NODE *assignable_gen(struct parser_params*,ID,NODE*,int); -#define assignable(id,node,column) assignable_gen(parser, (id), (node), (column)) +static NODE *gettable_gen(struct parser_params*,ID,YYLTYPE*); +#define gettable(id,location) gettable_gen(parser,(id),(location)) +static NODE *assignable_gen(struct parser_params*,ID,NODE*,YYLTYPE*); +#define assignable(id,node,location) assignable_gen(parser, (id), (node), (location)) -static NODE *aryset_gen(struct parser_params*,NODE*,NODE*,int); -#define aryset(node1,node2,column) aryset_gen(parser, (node1), (node2), (column)) -static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID,int); -#define attrset(node,q,id,column) attrset_gen(parser, (node), (q), (id), (column)) +static NODE *aryset_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define aryset(node1,node2,location) aryset_gen(parser, (node1), (node2), (location)) +static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID,YYLTYPE*); +#define attrset(node,q,id,location) attrset_gen(parser, (node), (q), (id), (location)) static void rb_backref_error_gen(struct parser_params*,NODE*); #define rb_backref_error(n) rb_backref_error_gen(parser,(n)) -static NODE *node_assign_gen(struct parser_params*,NODE*,NODE*,int); -#define node_assign(node1, node2, column) node_assign_gen(parser, (node1), (node2), (column)) +static NODE *node_assign_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define node_assign(node1, node2, location) node_assign_gen(parser, (node1), (node2), (location)) -static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int column); -#define new_op_assign(lhs, op, rhs, column) new_op_assign_gen(parser, (lhs), (op), (rhs), (column)) -static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, int column); -#define new_attr_op_assign(lhs, type, attr, op, rhs, column) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (column)) -static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int column); -#define new_const_op_assign(lhs, op, rhs, column) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (column)) +static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, YYLTYPE *location); +#define new_op_assign(lhs, op, rhs, location) new_op_assign_gen(parser, (lhs), (op), (rhs), (location)) +static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, YYLTYPE *location); +#define new_attr_op_assign(lhs, type, attr, op, rhs, location) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (location)) +static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, YYLTYPE *location); +#define new_const_op_assign(lhs, op, rhs, location) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (location)) -static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, int column); -#define const_path_field(w, n, column) const_path_field_gen(parser, w, n, column) +static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, YYLTYPE *location); +#define const_path_field(w, n, location) const_path_field_gen(parser, w, n, location) #define top_const_field(n) NEW_COLON3(n) -static NODE *const_decl_gen(struct parser_params *parser, NODE* path, int column); -#define const_decl(path, column) const_decl_gen(parser, path, column) +static NODE *const_decl_gen(struct parser_params *parser, NODE* path, YYLTYPE *location); +#define const_decl(path, location) const_decl_gen(parser, path, location) #define var_field(n) (n) -#define backref_assign_error(n, a, column) (rb_backref_error(n), new_begin(0, column)) +#define backref_assign_error(n, a, location) (rb_backref_error(n), new_begin(0, location)) static NODE *kwd_append(NODE*, NODE*); -static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, int column); -#define new_hash(hash, column) new_hash_gen(parser, (hash), column) +static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, YYLTYPE *location); +#define new_hash(hash, location) new_hash_gen(parser, (hash), location) -static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, int column); -#define new_defined(expr, column) new_defined_gen(parser, expr, column) +static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, YYLTYPE *location); +#define new_defined(expr, location) new_defined_gen(parser, expr, location) -static NODE *new_regexp_gen(struct parser_params *, NODE *, int, int); -#define new_regexp(node, opt, column) new_regexp_gen(parser, node, opt, column) +static NODE *new_regexp_gen(struct parser_params *, NODE *, int, YYLTYPE *); +#define new_regexp(node, opt, location) new_regexp_gen(parser, node, opt, location) -static NODE *new_lit_gen(struct parser_params *parser, VALUE sym, int column); -#define new_lit(sym, column) new_lit_gen(parser, sym, column) +static NODE *new_lit_gen(struct parser_params *parser, VALUE sym, YYLTYPE *location); +#define new_lit(sym, location) new_lit_gen(parser, sym, location) -static NODE *new_list_gen(struct parser_params *parser, NODE *item, int column); -#define new_list(item, column) new_list_gen(parser, item, column) +static NODE *new_list_gen(struct parser_params *parser, NODE *item, YYLTYPE *location); +#define new_list(item, location) new_list_gen(parser, item, location) -static NODE *new_str_gen(struct parser_params *parser, VALUE str, int column); -#define new_str(s,column) new_str_gen(parser, s, column) +static NODE *new_str_gen(struct parser_params *parser, VALUE str, YYLTYPE *location); +#define new_str(s,location) new_str_gen(parser, s, location) -static NODE *new_dvar_gen(struct parser_params *parser, ID id, int column); -#define new_dvar(id, column) new_dvar_gen(parser, id, column) +static NODE *new_dvar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_dvar(id, location) new_dvar_gen(parser, id, location) -static NODE *new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, int column); -#define new_resbody(e,s,r,column) new_resbody_gen(parser, (e),(s),(r),(column)) +static NODE *new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, YYLTYPE *location); +#define new_resbody(e,s,r,location) new_resbody_gen(parser, (e),(s),(r),(location)) -static NODE *new_errinfo_gen(struct parser_params *parser, int column); -#define new_errinfo(column) new_errinfo_gen(parser, column) +static NODE *new_errinfo_gen(struct parser_params *parser, YYLTYPE *location); +#define new_errinfo(location) new_errinfo_gen(parser, location) -static NODE *new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, int column); -#define new_call(recv,mid,args,column) new_call_gen(parser, recv,mid,args,column) +static NODE *new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, YYLTYPE *location); +#define new_call(recv,mid,args,location) new_call_gen(parser, recv,mid,args,location) -static NODE *new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, int column); -#define new_fcall(mid,args,column) new_fcall_gen(parser, mid, args, column) +static NODE *new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, YYLTYPE *location); +#define new_fcall(mid,args,location) new_fcall_gen(parser, mid, args, location) -static NODE *new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, int column); -#define new_for(var,iter,body,column) new_for_gen(parser, var, iter, body, column) +static NODE *new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, YYLTYPE *location); +#define new_for(var,iter,body,location) new_for_gen(parser, var, iter, body, location) -static NODE *new_gvar_gen(struct parser_params *parser, ID id, int column); -#define new_gvar(id, column) new_gvar_gen(parser, id, column) +static NODE *new_gvar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_gvar(id, location) new_gvar_gen(parser, id, location) -static NODE *new_lvar_gen(struct parser_params *parser, ID id, int column); -#define new_lvar(id, column) new_lvar_gen(parser, id, column) +static NODE *new_lvar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_lvar(id, location) new_lvar_gen(parser, id, location) -static NODE *new_dstr_gen(struct parser_params *parser, VALUE str, int column); -#define new_dstr(s, column) new_dstr_gen(parser, s, column) +static NODE *new_dstr_gen(struct parser_params *parser, VALUE str, YYLTYPE *location); +#define new_dstr(s, location) new_dstr_gen(parser, s, location) -static NODE *new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, int column); -#define new_rescue(b,res,e,column) new_rescue_gen(parser,b,res,e,column) +static NODE *new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, YYLTYPE *location); +#define new_rescue(b,res,e,location) new_rescue_gen(parser,b,res,e,location) -static NODE *new_undef_gen(struct parser_params *parser, NODE *i, int column); -#define new_undef(i, column) new_undef_gen(parser, i, column) +static NODE *new_undef_gen(struct parser_params *parser, NODE *i, YYLTYPE *location); +#define new_undef(i, location) new_undef_gen(parser, i, location) -static NODE *new_zarray_gen(struct parser_params *parser, int column); -#define new_zarray(column) new_zarray_gen(parser, column) +static NODE *new_zarray_gen(struct parser_params *parser, YYLTYPE *location); +#define new_zarray(location) new_zarray_gen(parser, location) -static NODE *new_ivar_gen(struct parser_params *parser, ID id, int column); -#define new_ivar(id, column) new_ivar_gen(parser,id,column) +static NODE *new_ivar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_ivar(id, location) new_ivar_gen(parser,id,location) -static NODE *new_postarg_gen(struct parser_params *parser, NODE *i, NODE *v, int column); -#define new_postarg(i,v,column) new_postarg_gen(parser,i,v,column) +static NODE *new_postarg_gen(struct parser_params *parser, NODE *i, NODE *v, YYLTYPE *location); +#define new_postarg(i,v,location) new_postarg_gen(parser,i,v,location) -static NODE *new_cdecl_gen(struct parser_params *parser, ID v, NODE *val, NODE *path, int column); -#define new_cdecl(v,val,path,column) new_cdecl_gen(parser,v,val,path,column) +static NODE *new_cdecl_gen(struct parser_params *parser, ID v, NODE *val, NODE *path, YYLTYPE *location); +#define new_cdecl(v,val,path,location) new_cdecl_gen(parser,v,val,path,location) -static NODE *new_scope_gen(struct parser_params *parser, NODE *a, NODE *b, int column); -#define new_scope(a,b,column) new_scope_gen(parser,a,b,column) +static NODE *new_scope_gen(struct parser_params *parser, NODE *a, NODE *b, YYLTYPE *location); +#define new_scope(a,b,location) new_scope_gen(parser,a,b,location) -static NODE *new_begin_gen(struct parser_params *parser, NODE *b, int column); -#define new_begin(b,column) new_begin_gen(parser,b,column) +static NODE *new_begin_gen(struct parser_params *parser, NODE *b, YYLTYPE *location); +#define new_begin(b,location) new_begin_gen(parser,b,location) -static NODE *new_masgn_gen(struct parser_params *parser, NODE *l, NODE *r, int column); -#define new_masgn(l,r,column) new_masgn_gen(parser,l,r,column) +static NODE *new_masgn_gen(struct parser_params *parser, NODE *l, NODE *r, YYLTYPE *location); +#define new_masgn(l,r,location) new_masgn_gen(parser,l,r,location) -static NODE *new_xstring_gen(struct parser_params *, NODE *, int column); -#define new_xstring(node, column) new_xstring_gen(parser, node, column) +static NODE *new_xstring_gen(struct parser_params *, NODE *, YYLTYPE *location); +#define new_xstring(node, location) new_xstring_gen(parser, node, location) #define new_string1(str) (str) -static NODE *new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, int column); -#define new_brace_body(param, stmt, column) new_body_gen(parser, param, stmt, column) -#define new_do_body(param, stmt, column) new_body_gen(parser, param, stmt, column) +static NODE *new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, YYLTYPE *location); +#define new_brace_body(param, stmt, location) new_body_gen(parser, param, stmt, location) +#define new_do_body(param, stmt, location) new_body_gen(parser, param, stmt, location) -static NODE *match_op_gen(struct parser_params*,NODE*,NODE*,int); -#define match_op(node1,node2,column) match_op_gen(parser, (node1), (node2), (column)) +static NODE *match_op_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define match_op(node1,node2,location) match_op_gen(parser, (node1), (node2), (location)) static ID *local_tbl_gen(struct parser_params*); #define local_tbl() local_tbl_gen(parser) @@ -577,8 +595,8 @@ static void reg_fragment_setenc_gen(struct parser_params*, VALUE, int); #define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options)) static int reg_fragment_check_gen(struct parser_params*, VALUE, int); #define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options)) -static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, int column); -#define reg_named_capture_assign(regexp,column) reg_named_capture_assign_gen(parser,(regexp),column) +static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, YYLTYPE *location); +#define reg_named_capture_assign(regexp,location) reg_named_capture_assign_gen(parser,(regexp),location) static NODE *parser_heredoc_dedent(struct parser_params*,NODE*); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) @@ -611,49 +629,49 @@ static ID ripper_get_id(VALUE); static VALUE ripper_get_value(VALUE); #define get_value(val) ripper_get_value(val) static VALUE assignable_gen(struct parser_params*,VALUE); -#define assignable(lhs,node,column) assignable_gen(parser, (lhs)) +#define assignable(lhs,node,location) assignable_gen(parser, (lhs)) static int id_is_var_gen(struct parser_params *parser, ID id); #define id_is_var(id) id_is_var_gen(parser, (id)) -#define method_cond(node,column) (node) -#define call_bin_op(recv,id,arg1,column) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1)) -#define match_op(node1,node2,column) call_bin_op((node1), idEqTilde, (node2), -1) -#define call_uni_op(recv,id,column) dispatch2(unary, STATIC_ID2SYM(id), (recv)) -#define logop(id,node1,node2,column) call_bin_op((node1), (id), (node2), -1) -#define node_assign(node1, node2, column) dispatch2(assign, (node1), (node2)) +#define method_cond(node,location) (node) +#define call_bin_op(recv,id,arg1,location) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1)) +#define match_op(node1,node2,location) call_bin_op((node1), idEqTilde, (node2), 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), 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,column) new_qcall_gen(parser, (r), (q), (m), (a)) -#define new_command_qcall(q,r,m,a,column) dispatch4(command_call, (r), (q), (m), (a)) +#define new_qcall(q,r,m,a,location) new_qcall_gen(parser, (r), (q), (m), (a)) +#define new_command_qcall(q,r,m,a,location) dispatch4(command_call, (r), (q), (m), (a)) #define new_command_call(q,r,m,a) dispatch4(command_call, (r), (q), (m), (a)) #define new_command(m,a) dispatch2(command, (m), (a)); #define new_nil() Qnil static VALUE new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs); -#define new_op_assign(lhs, op, rhs, column) new_op_assign_gen(parser, (lhs), (op), (rhs)) +#define new_op_assign(lhs, op, rhs, location) new_op_assign_gen(parser, (lhs), (op), (rhs)) static VALUE new_attr_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE type, VALUE attr, VALUE op, VALUE rhs); -#define new_attr_op_assign(lhs, type, attr, op, rhs, column) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs)) -#define new_const_op_assign(lhs, op, rhs, column) new_op_assign(lhs, op, rhs, column) +#define new_attr_op_assign(lhs, type, attr, op, rhs, location) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs)) +#define new_const_op_assign(lhs, op, rhs, location) new_op_assign(lhs, op, rhs, location) static VALUE new_regexp_gen(struct parser_params *, VALUE, VALUE); -#define new_regexp(node, opt, column) new_regexp_gen(parser, node, opt) +#define new_regexp(node, opt, location) new_regexp_gen(parser, node, opt) static VALUE new_xstring_gen(struct parser_params *, VALUE); -#define new_xstring(str, column) new_xstring_gen(parser, str) +#define new_xstring(str, location) new_xstring_gen(parser, str) #define new_string1(str) dispatch1(string_literal, str) -#define new_brace_body(param, stmt, column) dispatch2(brace_block, escape_Qundef(param), stmt) -#define new_do_body(param, stmt, column) dispatch2(do_block, escape_Qundef(param), stmt) +#define new_brace_body(param, stmt, location) dispatch2(brace_block, escape_Qundef(param), stmt) +#define new_do_body(param, stmt, location) dispatch2(do_block, escape_Qundef(param), stmt) -#define const_path_field(w, n, column) dispatch2(const_path_field, (w), (n)) +#define const_path_field(w, n, location) dispatch2(const_path_field, (w), (n)) #define top_const_field(n) dispatch1(top_const_field, (n)) static VALUE const_decl_gen(struct parser_params *parser, VALUE path); -#define const_decl(path, column) const_decl_gen(parser, path) +#define const_decl(path, location) const_decl_gen(parser, path) static VALUE var_field_gen(struct parser_params *parser, VALUE a); #define var_field(a) var_field_gen(parser, (a)) static VALUE assign_error_gen(struct parser_params *parser, VALUE a); #define assign_error(a) assign_error_gen(parser, (a)) -#define backref_assign_error(n, a, column) assign_error(a) +#define backref_assign_error(n, a, location) assign_error(a) #define block_dup_check(n1,n2) ((void)(n1), (void)(n2)) #define fixpos(n1,n2) ((void)(n1), (void)(n2)) @@ -822,9 +840,9 @@ new_args_tail_gen(struct parser_params *parser, VALUE k, VALUE kr, VALUE b) { return (VALUE)MEMO_NEW(k, kr, b); } -#define new_args_tail(k,kr,b,column) new_args_tail_gen(parser, (k),(kr),(b)) +#define new_args_tail(k,kr,b,location) new_args_tail_gen(parser, (k),(kr),(b)) -#define new_defined(expr,column) dispatch1(defined, (expr)) +#define new_defined(expr,location) dispatch1(defined, (expr)) static VALUE parser_heredoc_dedent(struct parser_params*,VALUE); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) @@ -1111,7 +1129,7 @@ program : { void_expr(node->nd_head); } } - ruby_eval_tree = new_scope(0, block_append(ruby_eval_tree, $2, @1.first_column), @1.first_column); + ruby_eval_tree = new_scope(0, block_append(ruby_eval_tree, $2, &@1), &@1); /*% $$ = $2; parser->result = dispatch1(program, $$); @@ -1133,7 +1151,7 @@ top_compstmt : top_stmts opt_terms top_stmts : none { /*%%%*/ - $$ = new_begin(0, @1.first_column); + $$ = new_begin(0, &@1); /*% $$ = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); @@ -1150,7 +1168,7 @@ top_stmts : none | top_stmts terms top_stmt { /*%%%*/ - $$ = block_append($1, newline_node($3), @1.first_column); + $$ = block_append($1, newline_node($3), &@1); /*% $$ = dispatch2(stmts_add, $1, $3); %*/ @@ -1173,10 +1191,10 @@ top_stmt : stmt { /*%%%*/ ruby_eval_tree_begin = block_append(ruby_eval_tree_begin, - $4, @1.first_column); + $4, &@1); /* NEW_PREEXE($4)); */ /* local_pop(); */ - $$ = new_begin(0, @1.first_column); + $$ = new_begin(0, &@1); /*% $$ = dispatch1(BEGIN, $4); %*/ @@ -1191,21 +1209,23 @@ bodystmt : compstmt /*%%%*/ $$ = $1; if ($2) { - $$ = new_rescue($1, $2, $3, @1.first_column); + $$ = new_rescue($1, $2, $3, &@1); } else if ($3) { rb_warn0("else without rescue is useless"); - $$ = block_append($$, $3, @1.first_column); + $$ = block_append($$, $3, &@1); } if ($4) { if ($$) { $$ = NEW_ENSURE($$, $4); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); } else { NODE *nil = NEW_NIL(); + nd_set_lineno(nil, @1.first_line); nd_set_column(nil, @1.first_column); - $$ = block_append($4, nil, @1.first_column); + $$ = block_append($4, nil, &@1); } } fixpos($$, $1); @@ -1232,7 +1252,7 @@ compstmt : stmts opt_terms stmts : none { /*%%%*/ - $$ = new_begin(0, @1.first_column); + $$ = new_begin(0, &@1); /*% $$ = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); @@ -1249,7 +1269,7 @@ stmts : none | stmts terms stmt_or_begin { /*%%%*/ - $$ = block_append($1, newline_node($3), @1.first_column); + $$ = block_append($1, newline_node($3), &@1); /*% $$ = dispatch2(stmts_add, $1, $3); %*/ @@ -1276,10 +1296,10 @@ stmt_or_begin : stmt { /*%%%*/ ruby_eval_tree_begin = block_append(ruby_eval_tree_begin, - $4, @1.first_column); + $4, &@1); /* NEW_PREEXE($4)); */ /* local_pop(); */ - $$ = new_begin(0, @1.first_column); + $$ = new_begin(0, &@1); /*% $$ = dispatch1(BEGIN, $4); %*/ @@ -1290,6 +1310,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ $$ = NEW_ALIAS($2, $4); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(alias, $2, $4); @@ -1299,6 +1320,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ $$ = NEW_VALIAS($2, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(var_alias, $2, $3); @@ -1311,6 +1333,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem 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); /*% $$ = dispatch2(var_alias, $2, $3); @@ -1320,7 +1343,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ yyerror0("can't make alias for the number variables"); - $$ = new_begin(0, @1.first_column); + $$ = new_begin(0, &@1); /*% $$ = dispatch2(var_alias, $2, $3); $$ = dispatch1(alias_error, $$); @@ -1338,7 +1361,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | stmt modifier_if expr_value { /*%%%*/ - $$ = new_if($3, remove_begin($1), 0, @1.first_column); + $$ = new_if($3, remove_begin($1), 0, &@1); fixpos($$, $3); /*% $$ = dispatch2(if_mod, $3, $1); @@ -1347,7 +1370,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | stmt modifier_unless expr_value { /*%%%*/ - $$ = new_unless($3, remove_begin($1), 0, @1.first_column); + $$ = new_unless($3, remove_begin($1), 0, &@1); fixpos($$, $3); /*% $$ = dispatch2(unless_mod, $3, $1); @@ -1357,11 +1380,12 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ if ($1 && nd_type($1) == NODE_BEGIN) { - $$ = NEW_WHILE(cond($3, @1.first_column), $1->nd_body, 0); + $$ = NEW_WHILE(cond($3, &@1), $1->nd_body, 0); } else { - $$ = NEW_WHILE(cond($3, @1.first_column), $1, 1); + $$ = NEW_WHILE(cond($3, &@1), $1, 1); } + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(while_mod, $3, $1); @@ -1371,11 +1395,12 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ if ($1 && nd_type($1) == NODE_BEGIN) { - $$ = NEW_UNTIL(cond($3, @1.first_column), $1->nd_body, 0); + $$ = NEW_UNTIL(cond($3, &@1), $1->nd_body, 0); } else { - $$ = NEW_UNTIL(cond($3, @1.first_column), $1, 1); + $$ = NEW_UNTIL(cond($3, &@1), $1, 1); } + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(until_mod, $3, $1); @@ -1384,8 +1409,8 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | stmt modifier_rescue stmt { /*%%%*/ - NODE *resq = new_resbody(0, remove_begin($3), 0, @1.first_column); - $$ = new_rescue(remove_begin($1), resq, 0, @1.first_column); + NODE *resq = new_resbody(0, remove_begin($3), 0, &@1); + $$ = new_rescue(remove_begin($1), resq, 0, &@1); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -1400,7 +1425,9 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem 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); } /*% @@ -1421,7 +1448,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | lhs '=' mrhs { value_expr($3); - $$ = node_assign($1, $3, @1.first_column); + $$ = node_assign($1, $3, &@1); } | mlhs '=' mrhs_arg { @@ -1438,12 +1465,12 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem command_asgn : lhs '=' command_rhs { value_expr($3); - $$ = node_assign($1, $3, @1.first_column); + $$ = node_assign($1, $3, &@1); } | var_lhs tOP_ASGN command_rhs { value_expr($3); - $$ = new_op_assign($1, $2, $3, @1.first_column); + $$ = new_op_assign($1, $2, $3, &@1); } | primary_value '[' opt_call_args rbracket tOP_ASGN command_rhs { @@ -1451,8 +1478,8 @@ command_asgn : lhs '=' command_rhs NODE *args; value_expr($6); - if (!$3) $3 = new_zarray(@1.first_column); - args = arg_concat($3, $6, @1.first_column); + if (!$3) $3 = new_zarray(&@1); + args = arg_concat($3, $6, &@1); if ($5 == tOROP) { $5 = 0; } @@ -1461,6 +1488,7 @@ command_asgn : lhs '=' command_rhs } $$ = NEW_OP_ASGN1($1, $5, args); fixpos($$, $1); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); @@ -1470,27 +1498,27 @@ command_asgn : lhs '=' command_rhs | primary_value call_op tIDENTIFIER tOP_ASGN command_rhs { value_expr($5); - $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@1); } | primary_value call_op tCONSTANT tOP_ASGN command_rhs { value_expr($5); - $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@1); } | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs { - $$ = const_path_field($1, $3, @1.first_column); - $$ = new_const_op_assign($$, $4, $5, @1.first_column); + $$ = const_path_field($1, $3, &@1); + $$ = new_const_op_assign($$, $4, $5, &@1); } | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs { value_expr($5); - $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, @1.first_column); + $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, &@1); } | backref tOP_ASGN command_rhs { $1 = var_field($1); - $$ = backref_assign_error($1, node_assign($1, $3, @1.first_column), @1.first_column); + $$ = backref_assign_error($1, node_assign($1, $3, &@1), &@1); } ; @@ -1506,7 +1534,7 @@ command_rhs : command_call %prec tOP_ASGN { /*%%%*/ value_expr($1); - $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, @1.first_column), 0, @1.first_column); + $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &@1), 0, &@1); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -1517,19 +1545,19 @@ command_rhs : command_call %prec tOP_ASGN expr : command_call | expr keyword_and expr { - $$ = logop(idAND, $1, $3, @1.first_column); + $$ = logop(idAND, $1, $3, &@1); } | expr keyword_or expr { - $$ = logop(idOR, $1, $3, @1.first_column); + $$ = logop(idOR, $1, $3, &@1); } | keyword_not opt_nl expr { - $$ = call_uni_op(method_cond($3, @1.first_column), METHOD_NOT, @1.first_column); + $$ = call_uni_op(method_cond($3, &@1), METHOD_NOT, &@1); } | '!' command_call { - $$ = call_uni_op(method_cond($2, @1.first_column), '!', @1.first_column); + $$ = call_uni_op(method_cond($2, &@1), '!', &@1); } | arg ; @@ -1553,7 +1581,7 @@ command_call : command block_command : block_call | block_call call_op2 operation2 command_args { - $$ = new_qcall($2, $1, $3, $4, @1.first_column); + $$ = new_qcall($2, $1, $3, $4, &@1); } ; @@ -1576,7 +1604,7 @@ cmd_brace_block : tLBRACE_ARG fcall : operation { /*%%%*/ - $$ = new_fcall($1, 0, @1.first_column); + $$ = new_fcall($1, 0, &@1); nd_set_line($$, tokline); /*% %*/ @@ -1601,25 +1629,25 @@ command : fcall command_args %prec tLOWEST } | primary_value call_op operation2 command_args %prec tLOWEST { - $$ = new_command_qcall($2, $1, $3, $4, @1.first_column); + $$ = new_command_qcall($2, $1, $3, $4, &@1); 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.first_column); + $$ = new_command_qcall($2, $1, $3, $4, &@1); $$ = method_add_block($$, $5); fixpos($$, $1); } | primary_value tCOLON2 operation2 command_args %prec tLOWEST { - $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, @1.first_column); + $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@1); 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.first_column); + $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@1); $$ = method_add_block($$, $5); fixpos($$, $1); } @@ -1628,6 +1656,7 @@ command : fcall command_args %prec tLOWEST /*%%%*/ $$ = NEW_SUPER($2); fixpos($$, $2); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(super, $2); @@ -1636,7 +1665,7 @@ command : fcall command_args %prec tLOWEST | keyword_yield command_args { /*%%%*/ - $$ = new_yield($2, @1.first_column); + $$ = new_yield($2, &@1); fixpos($$, $2); /*% $$ = dispatch1(yield, $2); @@ -1646,6 +1675,7 @@ command : fcall command_args %prec tLOWEST { /*%%%*/ $$ = NEW_RETURN(ret_args($2)); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(return, $2); @@ -1655,6 +1685,7 @@ command : fcall command_args %prec tLOWEST { /*%%%*/ $$ = NEW_BREAK(ret_args($2)); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(break, $2); @@ -1664,7 +1695,8 @@ command : fcall command_args %prec tLOWEST { /*%%%*/ $$ = NEW_NEXT(ret_args($2)); - nd_set_column($$, @1.first_column); + nd_set_lineno($$, @1.first_line); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(next, $2); %*/ @@ -1686,7 +1718,7 @@ mlhs_inner : mlhs_basic | tLPAREN mlhs_inner rparen { /*%%%*/ - $$ = new_masgn(new_list($2, @1.first_column), 0, @1.first_column); + $$ = new_masgn(new_list($2, &@1), 0, &@1); /*% $$ = dispatch1(mlhs_paren, $2); %*/ @@ -1696,7 +1728,7 @@ mlhs_inner : mlhs_basic mlhs_basic : mlhs_head { /*%%%*/ - $$ = new_masgn($1, 0, @1.first_column); + $$ = new_masgn($1, 0, &@1); /*% $$ = $1; %*/ @@ -1704,7 +1736,7 @@ mlhs_basic : mlhs_head | mlhs_head mlhs_item { /*%%%*/ - $$ = new_masgn(list_append($1,$2,@1.first_column), 0, @1.first_column); + $$ = new_masgn(list_append($1,$2,&@1), 0, &@1); /*% $$ = mlhs_add($1, $2); %*/ @@ -1712,7 +1744,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR mlhs_node { /*%%%*/ - $$ = new_masgn($1, $3, @1.first_column); + $$ = new_masgn($1, $3, &@1); /*% $$ = mlhs_add_star($1, $3); %*/ @@ -1720,7 +1752,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR mlhs_node ',' mlhs_post { /*%%%*/ - $$ = new_masgn($1, new_postarg($3,$5,@1.first_column), @1.first_column); + $$ = new_masgn($1, new_postarg($3,$5,&@1), &@1); /*% $1 = mlhs_add_star($1, $3); $$ = mlhs_add_post($1, $5); @@ -1729,7 +1761,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR { /*%%%*/ - $$ = new_masgn($1, (NODE *)-1, @1.first_column); + $$ = new_masgn($1, (NODE *)-1, &@1); /*% $$ = mlhs_add_star($1, Qnil); %*/ @@ -1737,7 +1769,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR ',' mlhs_post { /*%%%*/ - $$ = new_masgn($1, new_postarg((NODE *)-1, $4, @1.first_column), @1.first_column); + $$ = new_masgn($1, new_postarg((NODE *)-1, $4, &@1), &@1); /*% $1 = mlhs_add_star($1, Qnil); $$ = mlhs_add_post($1, $4); @@ -1746,7 +1778,7 @@ mlhs_basic : mlhs_head | tSTAR mlhs_node { /*%%%*/ - $$ = new_masgn(0, $2, @1.first_column); + $$ = new_masgn(0, $2, &@1); /*% $$ = mlhs_add_star(mlhs_new(), $2); %*/ @@ -1754,7 +1786,7 @@ mlhs_basic : mlhs_head | tSTAR mlhs_node ',' mlhs_post { /*%%%*/ - $$ = new_masgn(0, new_postarg($2,$4,@1.first_column), @1.first_column); + $$ = new_masgn(0, new_postarg($2,$4,&@1), &@1); /*% $2 = mlhs_add_star(mlhs_new(), $2); $$ = mlhs_add_post($2, $4); @@ -1763,7 +1795,7 @@ mlhs_basic : mlhs_head | tSTAR { /*%%%*/ - $$ = new_masgn(0, (NODE *)-1, @1.first_column); + $$ = new_masgn(0, (NODE *)-1, &@1); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); %*/ @@ -1771,7 +1803,7 @@ mlhs_basic : mlhs_head | tSTAR ',' mlhs_post { /*%%%*/ - $$ = new_masgn(0, new_postarg((NODE *)-1, $3, @1.first_column), @1.first_column); + $$ = new_masgn(0, new_postarg((NODE *)-1, $3, &@1), &@1); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); $$ = mlhs_add_post($$, $3); @@ -1793,7 +1825,7 @@ mlhs_item : mlhs_node mlhs_head : mlhs_item ',' { /*%%%*/ - $$ = new_list($1, @1.first_column); + $$ = new_list($1, &@1); /*% $$ = mlhs_add(mlhs_new(), $1); %*/ @@ -1801,7 +1833,7 @@ mlhs_head : mlhs_item ',' | mlhs_head mlhs_item ',' { /*%%%*/ - $$ = list_append($1, $2, @1.first_column); + $$ = list_append($1, $2, &@1); /*% $$ = mlhs_add($1, $2); %*/ @@ -1811,7 +1843,7 @@ mlhs_head : mlhs_item ',' mlhs_post : mlhs_item { /*%%%*/ - $$ = new_list($1, @1.first_column); + $$ = new_list($1, &@1); /*% $$ = mlhs_add(mlhs_new(), $1); %*/ @@ -1819,7 +1851,7 @@ mlhs_post : mlhs_item | mlhs_post ',' mlhs_item { /*%%%*/ - $$ = list_append($1, $3, @1.first_column); + $$ = list_append($1, $3, &@1); /*% $$ = mlhs_add($1, $3); %*/ @@ -1828,16 +1860,16 @@ mlhs_post : mlhs_item mlhs_node : user_variable { - $$ = assignable(var_field($1), 0, @1.first_column); + $$ = assignable(var_field($1), 0, &@1); } | keyword_variable { - $$ = assignable(var_field($1), 0, @1.first_column); + $$ = assignable(var_field($1), 0, &@1); } | primary_value '[' opt_call_args rbracket { /*%%%*/ - $$ = aryset($1, $3, @1.first_column); + $$ = aryset($1, $3, &@1); /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); %*/ @@ -1845,7 +1877,7 @@ mlhs_node : user_variable | primary_value call_op tIDENTIFIER { /*%%%*/ - $$ = attrset($1, $2, $3, @1.first_column); + $$ = attrset($1, $2, $3, &@1); /*% $$ = dispatch3(field, $1, $2, $3); %*/ @@ -1853,7 +1885,7 @@ mlhs_node : user_variable | primary_value tCOLON2 tIDENTIFIER { /*%%%*/ - $$ = attrset($1, idCOLON2, $3, @1.first_column); + $$ = attrset($1, idCOLON2, $3, &@1); /*% $$ = dispatch2(const_path_field, $1, $3); %*/ @@ -1861,46 +1893,46 @@ mlhs_node : user_variable | primary_value call_op tCONSTANT { /*%%%*/ - $$ = attrset($1, $2, $3, @1.first_column); + $$ = attrset($1, $2, $3, &@1); /*% $$ = dispatch3(field, $1, $2, $3); %*/ } | primary_value tCOLON2 tCONSTANT { - $$ = const_decl(const_path_field($1, $3, @1.first_column), @1.first_column); + $$ = const_decl(const_path_field($1, $3, &@1), &@1); } | tCOLON3 tCONSTANT { - $$ = const_decl(top_const_field($2), @1.first_column); + $$ = const_decl(top_const_field($2), &@1); } | backref { $1 = var_field($1); - $$ = backref_assign_error($1, $1, @1.first_column); + $$ = backref_assign_error($1, $1, &@1); } ; lhs : user_variable { - $$ = assignable(var_field($1), 0, @1.first_column); + $$ = assignable(var_field($1), 0, &@1); /*%%%*/ - if (!$$) $$ = new_begin(0, @1.first_column); + if (!$$) $$ = new_begin(0, &@1); /*% %*/ } | keyword_variable { - $$ = assignable(var_field($1), 0, @1.first_column); + $$ = assignable(var_field($1), 0, &@1); /*%%%*/ - if (!$$) $$ = new_begin(0, @1.first_column); + if (!$$) $$ = new_begin(0, &@1); /*% %*/ } | primary_value '[' opt_call_args rbracket { /*%%%*/ - $$ = aryset($1, $3, @1.first_column); + $$ = aryset($1, $3, &@1); /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); %*/ @@ -1908,7 +1940,7 @@ lhs : user_variable | primary_value call_op tIDENTIFIER { /*%%%*/ - $$ = attrset($1, $2, $3, @1.first_column); + $$ = attrset($1, $2, $3, &@1); /*% $$ = dispatch3(field, $1, $2, $3); %*/ @@ -1916,7 +1948,7 @@ lhs : user_variable | primary_value tCOLON2 tIDENTIFIER { /*%%%*/ - $$ = attrset($1, idCOLON2, $3, @1.first_column); + $$ = attrset($1, idCOLON2, $3, &@1); /*% $$ = dispatch3(field, $1, ID2VAL(idCOLON2), $3); %*/ @@ -1924,23 +1956,23 @@ lhs : user_variable | primary_value call_op tCONSTANT { /*%%%*/ - $$ = attrset($1, $2, $3, @1.first_column); + $$ = attrset($1, $2, $3, &@1); /*% $$ = dispatch3(field, $1, $2, $3); %*/ } | primary_value tCOLON2 tCONSTANT { - $$ = const_decl(const_path_field($1, $3, @1.first_column), @1.first_column); + $$ = const_decl(const_path_field($1, $3, &@1), &@1); } | tCOLON3 tCONSTANT { - $$ = const_decl(top_const_field($2), @1.first_column); + $$ = const_decl(top_const_field($2), &@1); } | backref { $1 = var_field($1); - $$ = backref_assign_error($1, $1, @1.first_column); + $$ = backref_assign_error($1, $1, &@1); } ; @@ -1960,6 +1992,8 @@ cpath : tCOLON3 cname { /*%%%*/ $$ = NEW_COLON3($2); + nd_set_lineno($$, @1.first_line); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(top_const_ref, $2); %*/ @@ -1968,6 +2002,7 @@ cpath : tCOLON3 cname { /*%%%*/ $$ = NEW_COLON2(0, $$); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(const_ref, $1); @@ -1977,6 +2012,7 @@ cpath : tCOLON3 cname { /*%%%*/ $$ = NEW_COLON2($1, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(const_path_ref, $1, $3); @@ -2006,7 +2042,7 @@ fsym : fname fitem : fsym { /*%%%*/ - $$ = new_lit(ID2SYM($1), @1.first_column); + $$ = new_lit(ID2SYM($1), &@1); /*% $$ = dispatch1(symbol_literal, $1); %*/ @@ -2017,7 +2053,7 @@ fitem : fsym undef_list : fitem { /*%%%*/ - $$ = new_undef($1, @1.first_column); + $$ = new_undef($1, &@1); /*% $$ = rb_ary_new3(1, get_value($1)); %*/ @@ -2025,8 +2061,8 @@ undef_list : fitem | undef_list ',' {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ - NODE *undef = new_undef($4, @1.first_column); - $$ = block_append($1, undef, @1.first_column); + NODE *undef = new_undef($4, &@1); + $$ = block_append($1, undef, &@1); /*% rb_ary_push($1, get_value($4)); %*/ @@ -2081,11 +2117,11 @@ reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__ arg : lhs '=' arg_rhs { - $$ = node_assign($1, $3, @1.first_column); + $$ = node_assign($1, $3, &@1); } | var_lhs tOP_ASGN arg_rhs { - $$ = new_op_assign($1, $2, $3, @1.first_column); + $$ = new_op_assign($1, $2, $3, &@1); } | primary_value '[' opt_call_args rbracket tOP_ASGN arg_rhs { @@ -2093,13 +2129,14 @@ arg : lhs '=' arg_rhs NODE *args; value_expr($6); - if (!$3) $3 = new_zarray(@1.first_column); + if (!$3) $3 = new_zarray(&@1); if (nd_type($3) == NODE_BLOCK_PASS) { args = NEW_ARGSCAT($3, $6); + nd_set_lineno(args, @1.first_line); nd_set_column(args, @1.first_column); } else { - args = arg_concat($3, $6, @1.first_column); + args = arg_concat($3, $6, &@1); } if ($5 == tOROP) { $5 = 0; @@ -2109,6 +2146,7 @@ arg : lhs '=' arg_rhs } $$ = NEW_OP_ASGN1($1, $5, args); fixpos($$, $1); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $1 = dispatch2(aref_field, $1, escape_Qundef($3)); @@ -2118,32 +2156,32 @@ arg : lhs '=' arg_rhs | primary_value call_op tIDENTIFIER tOP_ASGN arg_rhs { value_expr($5); - $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@1); } | primary_value call_op tCONSTANT tOP_ASGN arg_rhs { value_expr($5); - $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, &@1); } | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs { value_expr($5); - $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, @1.first_column); + $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, &@1); } | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs { - $$ = const_path_field($1, $3, @1.first_column); - $$ = new_const_op_assign($$, $4, $5, @1.first_column); + $$ = const_path_field($1, $3, &@1); + $$ = new_const_op_assign($$, $4, $5, &@1); } | tCOLON3 tCONSTANT tOP_ASGN arg_rhs { $$ = top_const_field($2); - $$ = new_const_op_assign($$, $3, $4, @1.first_column); + $$ = new_const_op_assign($$, $3, $4, &@1); } | backref tOP_ASGN arg_rhs { $1 = var_field($1); - $$ = backref_assign_error($1, new_op_assign($1, $2, $3, @1.first_column), @1.first_column); + $$ = backref_assign_error($1, new_op_assign($1, $2, $3, &@1), &@1); } | arg tDOT2 arg { @@ -2151,6 +2189,7 @@ arg : lhs '=' arg_rhs value_expr($1); value_expr($3); $$ = NEW_DOT2($1, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(dot2, $1, $3); @@ -2162,6 +2201,7 @@ arg : lhs '=' arg_rhs value_expr($1); value_expr($3); $$ = NEW_DOT3($1, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(dot3, $1, $3); @@ -2169,111 +2209,111 @@ arg : lhs '=' arg_rhs } | arg '+' arg { - $$ = call_bin_op($1, '+', $3, @1.first_column); + $$ = call_bin_op($1, '+', $3, &@1); } | arg '-' arg { - $$ = call_bin_op($1, '-', $3, @1.first_column); + $$ = call_bin_op($1, '-', $3, &@1); } | arg '*' arg { - $$ = call_bin_op($1, '*', $3, @1.first_column); + $$ = call_bin_op($1, '*', $3, &@1); } | arg '/' arg { - $$ = call_bin_op($1, '/', $3, @1.first_column); + $$ = call_bin_op($1, '/', $3, &@1); } | arg '%' arg { - $$ = call_bin_op($1, '%', $3, @1.first_column); + $$ = call_bin_op($1, '%', $3, &@1); } | arg tPOW arg { - $$ = call_bin_op($1, idPow, $3, @1.first_column); + $$ = call_bin_op($1, idPow, $3, &@1); } | tUMINUS_NUM simple_numeric tPOW arg { - $$ = call_uni_op(call_bin_op($2, idPow, $4, @1.first_column), idUMinus, @1.first_column); + $$ = call_uni_op(call_bin_op($2, idPow, $4, &@1), idUMinus, &@1); } | tUPLUS arg { - $$ = call_uni_op($2, idUPlus, @1.first_column); + $$ = call_uni_op($2, idUPlus, &@1); } | tUMINUS arg { - $$ = call_uni_op($2, idUMinus, @1.first_column); + $$ = call_uni_op($2, idUMinus, &@1); } | arg '|' arg { - $$ = call_bin_op($1, '|', $3, @1.first_column); + $$ = call_bin_op($1, '|', $3, &@1); } | arg '^' arg { - $$ = call_bin_op($1, '^', $3, @1.first_column); + $$ = call_bin_op($1, '^', $3, &@1); } | arg '&' arg { - $$ = call_bin_op($1, '&', $3, @1.first_column); + $$ = call_bin_op($1, '&', $3, &@1); } | arg tCMP arg { - $$ = call_bin_op($1, idCmp, $3, @1.first_column); + $$ = call_bin_op($1, idCmp, $3, &@1); } | rel_expr %prec tCMP | arg tEQ arg { - $$ = call_bin_op($1, idEq, $3, @1.first_column); + $$ = call_bin_op($1, idEq, $3, &@1); } | arg tEQQ arg { - $$ = call_bin_op($1, idEqq, $3, @1.first_column); + $$ = call_bin_op($1, idEqq, $3, &@1); } | arg tNEQ arg { - $$ = call_bin_op($1, idNeq, $3, @1.first_column); + $$ = call_bin_op($1, idNeq, $3, &@1); } | arg tMATCH arg { - $$ = match_op($1, $3, @1.first_column); + $$ = match_op($1, $3, &@1); } | arg tNMATCH arg { - $$ = call_bin_op($1, idNeqTilde, $3, @1.first_column); + $$ = call_bin_op($1, idNeqTilde, $3, &@1); } | '!' arg { - $$ = call_uni_op(method_cond($2, @1.first_column), '!', @1.first_column); + $$ = call_uni_op(method_cond($2, &@1), '!', &@1); } | '~' arg { - $$ = call_uni_op($2, '~', @1.first_column); + $$ = call_uni_op($2, '~', &@1); } | arg tLSHFT arg { - $$ = call_bin_op($1, idLTLT, $3, @1.first_column); + $$ = call_bin_op($1, idLTLT, $3, &@1); } | arg tRSHFT arg { - $$ = call_bin_op($1, idGTGT, $3, @1.first_column); + $$ = call_bin_op($1, idGTGT, $3, &@1); } | arg tANDOP arg { - $$ = logop(idANDOP, $1, $3, @1.first_column); + $$ = logop(idANDOP, $1, $3, &@1); } | arg tOROP arg { - $$ = logop(idOROP, $1, $3, @1.first_column); + $$ = logop(idOROP, $1, $3, &@1); } | keyword_defined opt_nl {in_defined = 1;} arg { in_defined = 0; - $$ = new_defined($4, @1.first_column); + $$ = new_defined($4, &@1); } | arg '?' arg opt_nl ':' arg { /*%%%*/ value_expr($1); - $$ = new_if($1, $3, $6, @1.first_column); + $$ = new_if($1, $3, $6, &@1); fixpos($$, $1); /*% $$ = dispatch3(ifop, $1, $3, $6); @@ -2293,12 +2333,12 @@ relop : '>' {$$ = '>';} rel_expr : arg relop arg %prec '>' { - $$ = call_bin_op($1, $2, $3, @1.first_column); + $$ = call_bin_op($1, $2, $3, &@1); } | rel_expr relop arg %prec '>' { rb_warning1("comparison '%s' after comparison", WARN_ID($2)); - $$ = call_bin_op($1, $2, $3, @1.first_column); + $$ = call_bin_op($1, $2, $3, &@1); } ; @@ -2322,7 +2362,7 @@ aref_args : none | args ',' assocs trailer { /*%%%*/ - $$ = $3 ? arg_append($1, new_hash($3, @1.first_column), @1.first_column) : $1; + $$ = $3 ? arg_append($1, new_hash($3, &@1), &@1) : $1; /*% $$ = arg_add_assocs($1, $3); %*/ @@ -2330,7 +2370,7 @@ aref_args : none | assocs trailer { /*%%%*/ - $$ = $1 ? new_list(new_hash($1, @1.first_column), @1.first_column) : 0; + $$ = $1 ? new_list(new_hash($1, &@1), &@1) : 0; /*% $$ = arg_add_assocs(arg_new(), $1); %*/ @@ -2349,7 +2389,7 @@ arg_rhs : arg %prec tOP_ASGN { /*%%%*/ value_expr($1); - $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, @1.first_column), 0, @1.first_column); + $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &@1), 0, &@1); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -2379,7 +2419,7 @@ opt_call_args : none | args ',' assocs ',' { /*%%%*/ - $$ = $3 ? arg_append($1, new_hash($3, @1.first_column), @1.first_column) : $1; + $$ = $3 ? arg_append($1, new_hash($3, &@1), &@1) : $1; /*% $$ = arg_add_assocs($1, $3); %*/ @@ -2387,7 +2427,7 @@ opt_call_args : none | assocs ',' { /*%%%*/ - $$ = $1 ? new_list(new_hash($1, @1.first_column), @1.first_column) : 0; + $$ = $1 ? new_list(new_hash($1, &@1), &@1) : 0; /*% $$ = arg_add_assocs(arg_new(), $1); %*/ @@ -2398,7 +2438,7 @@ call_args : command { /*%%%*/ value_expr($1); - $$ = new_list($1, @1.first_column); + $$ = new_list($1, &@1); /*% $$ = arg_add(arg_new(), $1); %*/ @@ -2414,7 +2454,7 @@ call_args : command | assocs opt_block_arg { /*%%%*/ - $$ = $1 ? new_list(new_hash($1, @1.first_column), @1.first_column) : 0; + $$ = $1 ? new_list(new_hash($1, &@1), &@1) : 0; $$ = arg_blk_pass($$, $2); /*% $$ = arg_add_assocs(arg_new(), $1); @@ -2424,7 +2464,7 @@ call_args : command | args ',' assocs opt_block_arg { /*%%%*/ - $$ = $3 ? arg_append($1, new_hash($3, @1.first_column), @1.first_column) : $1; + $$ = $3 ? arg_append($1, new_hash($3, &@1), &@1) : $1; $$ = arg_blk_pass($$, $4); /*% $$ = arg_add_optblock(arg_add_assocs($1, $3), $4); @@ -2455,6 +2495,7 @@ block_arg : tAMPER arg_value { /*%%%*/ $$ = NEW_BLOCK_PASS($2); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = $2; @@ -2475,7 +2516,7 @@ opt_block_arg : ',' block_arg args : arg_value { /*%%%*/ - $$ = new_list($1, @1.first_column); + $$ = new_list($1, &@1); /*% $$ = arg_add(arg_new(), $1); %*/ @@ -2484,6 +2525,7 @@ args : arg_value { /*%%%*/ $$ = NEW_SPLAT($2); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = arg_add_star(arg_new(), $2); @@ -2494,10 +2536,10 @@ args : arg_value /*%%%*/ NODE *n1; if ((n1 = splat_array($1)) != 0) { - $$ = list_append(n1, $3, @1.first_column); + $$ = list_append(n1, $3, &@1); } else { - $$ = arg_append($1, $3, @1.first_column); + $$ = arg_append($1, $3, &@1); } /*% $$ = arg_add($1, $3); @@ -2511,7 +2553,7 @@ args : arg_value $$ = list_concat(n1, $4); } else { - $$ = arg_concat($1, $4, @1.first_column); + $$ = arg_concat($1, $4, &@1); } /*% $$ = arg_add_star($1, $4); @@ -2528,10 +2570,10 @@ mrhs : args ',' arg_value /*%%%*/ NODE *n1; if ((n1 = splat_array($1)) != 0) { - $$ = list_append(n1, $3, @1.first_column); + $$ = list_append(n1, $3, &@1); } else { - $$ = arg_append($1, $3, @1.first_column); + $$ = arg_append($1, $3, &@1); } /*% $$ = mrhs_add(args2mrhs($1), $3); @@ -2546,7 +2588,7 @@ mrhs : args ',' arg_value $$ = list_concat(n1, $4); } else { - $$ = arg_concat($1, $4, @1.first_column); + $$ = arg_concat($1, $4, &@1); } /*% $$ = mrhs_add_star(args2mrhs($1), $4); @@ -2556,6 +2598,7 @@ mrhs : args ',' arg_value { /*%%%*/ $$ = NEW_SPLAT($2); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = mrhs_add_star(mrhs_new(), $2); @@ -2576,7 +2619,7 @@ primary : literal | tFID { /*%%%*/ - $$ = new_fcall($1, 0, @1.first_column); + $$ = new_fcall($1, 0, &@1); /*% $$ = method_arg(dispatch1(fcall, $1), arg_new()); %*/ @@ -2597,11 +2640,12 @@ primary : literal /*%%%*/ if ($3 == NULL) { $$ = NEW_NIL(); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); } else { set_line_body($3, $2); - $$ = new_begin($3, @1.first_column); + $$ = new_begin($3, &@1); } nd_set_line($$, $2); /*% @@ -2611,7 +2655,7 @@ primary : literal | tLPAREN_ARG {SET_LEX_STATE(EXPR_ENDARG);} rparen { /*%%%*/ - $$ = new_begin(0, @1.first_column); + $$ = new_begin(0, &@1); /*% $$ = dispatch1(paren, 0); %*/ @@ -2642,6 +2686,7 @@ primary : literal { /*%%%*/ $$ = NEW_COLON2($1, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(const_path_ref, $1, $3); @@ -2651,6 +2696,7 @@ primary : literal { /*%%%*/ $$ = NEW_COLON3($2); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(top_const_ref, $2); @@ -2660,7 +2706,7 @@ primary : literal { /*%%%*/ if ($2 == 0) { - $$ = new_zarray(@1.first_column); /* zero length array*/ + $$ = new_zarray(&@1); /* zero length array*/ } else { $$ = $2; @@ -2672,7 +2718,7 @@ primary : literal | tLBRACE assoc_list '}' { /*%%%*/ - $$ = new_hash($2, @1.first_column); + $$ = new_hash($2, &@1); $$->nd_alen = TRUE; /*% $$ = dispatch1(hash, escape_Qundef($2)); @@ -2682,6 +2728,7 @@ primary : literal { /*%%%*/ $$ = NEW_RETURN(0); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch0(return0); @@ -2690,7 +2737,7 @@ primary : literal | keyword_yield '(' call_args rparen { /*%%%*/ - $$ = new_yield($3, @1.first_column); + $$ = new_yield($3, &@1); /*% $$ = dispatch1(yield, dispatch1(paren, $3)); %*/ @@ -2699,6 +2746,7 @@ primary : literal { /*%%%*/ $$ = NEW_YIELD(0); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(yield, dispatch1(paren, arg_new())); @@ -2708,6 +2756,7 @@ primary : literal { /*%%%*/ $$ = NEW_YIELD(0); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch0(yield0); @@ -2716,15 +2765,15 @@ primary : literal | keyword_defined opt_nl '(' {in_defined = 1;} expr rparen { in_defined = 0; - $$ = new_defined($5, @1.first_column); + $$ = new_defined($5, &@1); } | keyword_not '(' expr rparen { - $$ = call_uni_op(method_cond($3, @1.first_column), METHOD_NOT, @1.first_column); + $$ = call_uni_op(method_cond($3, &@1), METHOD_NOT, &@1); } | keyword_not '(' rparen { - $$ = call_uni_op(method_cond(new_nil(), @1.first_column), METHOD_NOT, @1.first_column); + $$ = call_uni_op(method_cond(new_nil(), &@1), METHOD_NOT, &@1); } | fcall brace_block { @@ -2757,7 +2806,7 @@ primary : literal k_end { /*%%%*/ - $$ = new_if($2, $4, $5, @1.first_column); + $$ = new_if($2, $4, $5, &@1); fixpos($$, $2); /*% $$ = dispatch3(if, $2, $4, escape_Qundef($5)); @@ -2769,7 +2818,7 @@ primary : literal k_end { /*%%%*/ - $$ = new_unless($2, $4, $5, @1.first_column); + $$ = new_unless($2, $4, $5, &@1); fixpos($$, $2); /*% $$ = dispatch3(unless, $2, $4, escape_Qundef($5)); @@ -2780,8 +2829,9 @@ primary : literal k_end { /*%%%*/ - $$ = NEW_WHILE(cond($3, @1.first_column), $6, 1); + $$ = NEW_WHILE(cond($3, &@1), $6, 1); fixpos($$, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(while, $3, $6); @@ -2792,8 +2842,9 @@ primary : literal k_end { /*%%%*/ - $$ = NEW_UNTIL(cond($3, @1.first_column), $6, 1); + $$ = NEW_UNTIL(cond($3, &@1), $6, 1); fixpos($$, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(until, $3, $6); @@ -2806,6 +2857,7 @@ primary : literal /*%%%*/ $$ = NEW_CASE($2, $4); fixpos($$, $2); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(case, $2, $4); @@ -2816,6 +2868,7 @@ primary : literal /*%%%*/ $$ = NEW_CASE(0, $3); nd_set_line($3, $1); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(case, Qnil, $3); @@ -2845,30 +2898,31 @@ primary : literal switch (nd_type($2)) { case NODE_MASGN: - m->nd_next = node_assign($2, new_for(new_dvar(id, @1.first_column), 0, 0, @1.first_column), @1.first_column); - args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, @1.first_column)); + m->nd_next = node_assign($2, new_for(new_dvar(id, &@1), 0, 0, &@1), &@1); + args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@1)); break; case NODE_LASGN: case NODE_DASGN: case NODE_DASGN_CURR: - $2->nd_value = new_dvar(id, @1.first_column); + $2->nd_value = new_dvar(id, &@1); m->nd_plen = 1; m->nd_next = $2; - args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0, @1.first_column)); + args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0, &@1)); break; default: { - NODE *masgn = new_masgn(new_list($2, @1.first_column), 0, @1.first_column); - m->nd_next = node_assign(masgn, new_dvar(id, @1.first_column), @1.first_column); - args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, @1.first_column)); + NODE *masgn = new_masgn(new_list($2, &@1), 0, &@1); + m->nd_next = node_assign(masgn, new_dvar(id, &@1), &@1); + args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@1)); break; } } add_mark_object((VALUE)rb_imemo_alloc_new((VALUE)tbl, 0, 0, 0)); scope = NEW_NODE(NODE_SCOPE, tbl, $8, args); + nd_set_lineno(scope, @1.first_line); nd_set_column(scope, @1.first_column); tbl[0] = 1; tbl[1] = id; - $$ = new_for(0, $5, scope, @1.first_column); + $$ = new_for(0, $5, scope, &@1); fixpos($$, $2); /*% $$ = dispatch3(for, $2, $5, $8); @@ -2889,9 +2943,11 @@ primary : literal { /*%%%*/ $$ = NEW_CLASS($2, $5, $3); + nd_set_lineno($$->nd_body, @1.first_line); nd_set_column($$->nd_body, @1.first_column); set_line_body($5, $4); nd_set_line($$, $4); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch3(class, $2, $3, $5); @@ -2911,9 +2967,11 @@ primary : literal { /*%%%*/ $$ = NEW_SCLASS($3, $6); + nd_set_lineno($$->nd_body, @1.first_line); nd_set_column($$->nd_body, @1.first_column); set_line_body($6, nd_line($3)); fixpos($$, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(sclass, $3, $6); @@ -2937,9 +2995,11 @@ primary : literal { /*%%%*/ $$ = NEW_MODULE($2, $4); + nd_set_lineno($$->nd_body, @1.first_line); nd_set_column($$->nd_body, @1.first_column); set_line_body($4, $3); nd_set_line($$, $3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch2(module, $2, $4); @@ -2964,9 +3024,11 @@ primary : literal NODE *body = remove_begin($6); reduce_nodes(&body); $$ = NEW_DEFN($2, $5, body, METHOD_VISI_PRIVATE); + nd_set_lineno($$->nd_defn, @1.first_line); nd_set_column($$->nd_defn, @1.first_column); set_line_body(body, $1); nd_set_line($$, $1); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch3(def, $2, $5, $6); @@ -2992,9 +3054,11 @@ primary : literal NODE *body = remove_begin($8); reduce_nodes(&body); $$ = NEW_DEFS($2, $5, $7, body); + nd_set_lineno($$->nd_defn, @1.first_line); nd_set_column($$->nd_defn, @1.first_column); set_line_body(body, $1); nd_set_line($$, $1); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch5(defs, $2, $3, $5, $7, $8); @@ -3007,6 +3071,7 @@ primary : literal { /*%%%*/ $$ = NEW_BREAK(0); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(break, arg_new()); @@ -3016,6 +3081,7 @@ primary : literal { /*%%%*/ $$ = NEW_NEXT(0); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(next, arg_new()); @@ -3025,6 +3091,7 @@ primary : literal { /*%%%*/ $$ = NEW_REDO(); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch0(redo); @@ -3034,6 +3101,7 @@ primary : literal { /*%%%*/ $$ = NEW_RETRY(); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch0(retry); @@ -3154,7 +3222,7 @@ if_tail : opt_else if_tail { /*%%%*/ - $$ = new_if($2, $4, $5, @1.first_column); + $$ = new_if($2, $4, $5, &@1); fixpos($$, $2); /*% $$ = dispatch3(elsif, $2, $4, escape_Qundef($5)); @@ -3179,7 +3247,7 @@ for_var : lhs f_marg : f_norm_arg { - $$ = assignable($1, 0, @1.first_column); + $$ = assignable($1, 0, &@1); /*%%%*/ /*% %*/ @@ -3197,7 +3265,7 @@ f_marg : f_norm_arg f_marg_list : f_marg { /*%%%*/ - $$ = new_list($1, @1.first_column); + $$ = new_list($1, &@1); /*% $$ = mlhs_add(mlhs_new(), $1); %*/ @@ -3205,7 +3273,7 @@ f_marg_list : f_marg | f_marg_list ',' f_marg { /*%%%*/ - $$ = list_append($1, $3, @1.first_column); + $$ = list_append($1, $3, &@1); /*% $$ = mlhs_add($1, $3); %*/ @@ -3215,25 +3283,25 @@ f_marg_list : f_marg f_margs : f_marg_list { /*%%%*/ - $$ = new_masgn($1, 0, @1.first_column); + $$ = new_masgn($1, 0, &@1); /*% $$ = $1; %*/ } | f_marg_list ',' tSTAR f_norm_arg { - $$ = assignable($4, 0, @1.first_column); + $$ = assignable($4, 0, &@1); /*%%%*/ - $$ = new_masgn($1, $$, @1.first_column); + $$ = new_masgn($1, $$, &@1); /*% $$ = mlhs_add_star($1, $$); %*/ } | f_marg_list ',' tSTAR f_norm_arg ',' f_marg_list { - $$ = assignable($4, 0, @1.first_column); + $$ = assignable($4, 0, &@1); /*%%%*/ - $$ = new_masgn($1, new_postarg($$, $6, @1.first_column), @1.first_column); + $$ = new_masgn($1, new_postarg($$, $6, &@1), &@1); /*% $$ = mlhs_add_star($1, $$); $$ = mlhs_add_post($$, $6); @@ -3242,7 +3310,7 @@ f_margs : f_marg_list | f_marg_list ',' tSTAR { /*%%%*/ - $$ = new_masgn($1, (NODE *)-1, @1.first_column); + $$ = new_masgn($1, (NODE *)-1, &@1); /*% $$ = mlhs_add_star($1, Qnil); %*/ @@ -3250,7 +3318,7 @@ f_margs : f_marg_list | f_marg_list ',' tSTAR ',' f_marg_list { /*%%%*/ - $$ = new_masgn($1, new_postarg((NODE *)-1, $5, @1.first_column), @1.first_column); + $$ = new_masgn($1, new_postarg((NODE *)-1, $5, &@1), &@1); /*% $$ = mlhs_add_star($1, Qnil); $$ = mlhs_add_post($$, $5); @@ -3258,18 +3326,18 @@ f_margs : f_marg_list } | tSTAR f_norm_arg { - $$ = assignable($2, 0, @1.first_column); + $$ = assignable($2, 0, &@1); /*%%%*/ - $$ = new_masgn(0, $$, @1.first_column); + $$ = new_masgn(0, $$, &@1); /*% $$ = mlhs_add_star(mlhs_new(), $$); %*/ } | tSTAR f_norm_arg ',' f_marg_list { - $$ = assignable($2, 0, @1.first_column); + $$ = assignable($2, 0, &@1); /*%%%*/ - $$ = new_masgn(0, new_postarg($$, $4, @1.first_column), @1.first_column); + $$ = new_masgn(0, new_postarg($$, $4, &@1), &@1); /*% $$ = mlhs_add_star(mlhs_new(), $$); $$ = mlhs_add_post($$, $4); @@ -3278,7 +3346,7 @@ f_margs : f_marg_list | tSTAR { /*%%%*/ - $$ = new_masgn(0, (NODE *)-1, @1.first_column); + $$ = new_masgn(0, (NODE *)-1, &@1); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); %*/ @@ -3286,7 +3354,7 @@ f_margs : f_marg_list | tSTAR ',' f_marg_list { /*%%%*/ - $$ = new_masgn(0, new_postarg((NODE *)-1, $3, @1.first_column), @1.first_column); + $$ = new_masgn(0, new_postarg((NODE *)-1, $3, &@1), &@1); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); $$ = mlhs_add_post($$, $3); @@ -3297,19 +3365,19 @@ f_margs : f_marg_list block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg { - $$ = new_args_tail($1, $3, $4, @1.first_column); + $$ = new_args_tail($1, $3, $4, &@1); } | f_block_kwarg opt_f_block_arg { - $$ = new_args_tail($1, Qnone, $2, @1.first_column); + $$ = new_args_tail($1, Qnone, $2, &@1); } | f_kwrest opt_f_block_arg { - $$ = new_args_tail(Qnone, $1, $2, @1.first_column); + $$ = new_args_tail(Qnone, $1, $2, &@1); } | f_block_arg { - $$ = new_args_tail(Qnone, Qnone, $1, @1.first_column); + $$ = new_args_tail(Qnone, Qnone, $1, &@1); } ; @@ -3319,7 +3387,7 @@ opt_block_args_tail : ',' block_args_tail } | /* none */ { - $$ = new_args_tail(Qnone, Qnone, Qnone, @0.first_column); + $$ = new_args_tail(Qnone, Qnone, Qnone, &@0); } ; @@ -3345,7 +3413,7 @@ block_param : f_arg ',' f_block_optarg ',' f_rest_arg opt_block_args_tail } | f_arg ',' { - $$ = new_args($1, Qnone, 1, Qnone, new_args_tail(Qnone, Qnone, Qnone, @1.first_column)); + $$ = new_args($1, Qnone, 1, Qnone, new_args_tail(Qnone, Qnone, Qnone, &@1)); /*%%%*/ /*% dispatch1(excessed_comma, $$); @@ -3494,7 +3562,9 @@ lambda : { /*%%%*/ $$ = NEW_LAMBDA($3, $6); nd_set_line($$, $4); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); + nd_set_lineno($$->nd_body, @1.first_line); nd_set_column($$->nd_body, @1.first_column); /*% $$ = dispatch2(lambda, $3, $6); @@ -3561,13 +3631,13 @@ block_call : command do_block } | block_call call_op2 operation2 opt_paren_args { - $$ = new_qcall($2, $1, $3, $4, @1.first_column); + $$ = new_qcall($2, $1, $3, $4, &@1); } | block_call call_op2 operation2 opt_paren_args brace_block { /*%%%*/ block_dup_check($4, $5); - $5->nd_iter = new_command_qcall($2, $1, $3, $4, @1.first_column); + $5->nd_iter = new_command_qcall($2, $1, $3, $4, &@1); $$ = $5; fixpos($$, $1); /*% @@ -3579,7 +3649,7 @@ block_call : command do_block { /*%%%*/ block_dup_check($4, $5); - $5->nd_iter = new_command_qcall($2, $1, $3, $4, @1.first_column); + $5->nd_iter = new_command_qcall($2, $1, $3, $4, &@1); $$ = $5; fixpos($$, $1); /*% @@ -3606,7 +3676,7 @@ method_call : fcall paren_args } opt_paren_args { - $$ = new_qcall($2, $1, $3, $5, @1.first_column); + $$ = new_qcall($2, $1, $3, $5, &@1); nd_set_line($$, $4); } | primary_value tCOLON2 operation2 @@ -3617,12 +3687,12 @@ method_call : fcall paren_args } paren_args { - $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, $5, @1.first_column); + $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, $5, &@1); nd_set_line($$, $4); } | primary_value tCOLON2 operation3 { - $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, Qnull, @1.first_column); + $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, Qnull, &@1); } | primary_value call_op { @@ -3632,7 +3702,7 @@ method_call : fcall paren_args } paren_args { - $$ = new_qcall($2, $1, ID2VAL(idCall), $4, @1.first_column); + $$ = new_qcall($2, $1, ID2VAL(idCall), $4, &@1); nd_set_line($$, $3); } | primary_value tCOLON2 @@ -3643,13 +3713,14 @@ method_call : fcall paren_args } paren_args { - $$ = new_qcall(ID2VAL(idCOLON2), $1, ID2VAL(idCall), $4, @1.first_column); + $$ = new_qcall(ID2VAL(idCOLON2), $1, ID2VAL(idCall), $4, &@1); nd_set_line($$, $3); } | keyword_super paren_args { /*%%%*/ $$ = NEW_SUPER($2); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(super, $2); @@ -3659,6 +3730,7 @@ method_call : fcall paren_args { /*%%%*/ $$ = NEW_ZSUPER(); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch0(zsuper); @@ -3668,9 +3740,9 @@ method_call : fcall paren_args { /*%%%*/ if ($1 && nd_type($1) == NODE_SELF) - $$ = new_fcall(tAREF, $3, @1.first_column); + $$ = new_fcall(tAREF, $3, &@1); else - $$ = new_call($1, tAREF, $3, @1.first_column); + $$ = new_call($1, tAREF, $3, &@1); fixpos($$, $1); /*% $$ = dispatch2(aref, $1, escape_Qundef($3)); @@ -3710,7 +3782,7 @@ brace_body : {$$ = dyna_push();} {$$ = cmdarg_stack >> 1; CMDARG_SET(0);} opt_block_param compstmt { - $$ = new_brace_body($3, $4, @1.first_column); + $$ = new_brace_body($3, $4, &@1); dyna_pop($1); CMDARG_SET($2); } @@ -3720,7 +3792,7 @@ do_body : {$$ = dyna_push();} {$$ = cmdarg_stack; CMDARG_SET(0);} opt_block_param bodystmt { - $$ = new_do_body($3, $4, @1.first_column); + $$ = new_do_body($3, $4, &@1); dyna_pop($1); CMDARG_SET($2); } @@ -3732,6 +3804,7 @@ case_body : keyword_when args then { /*%%%*/ $$ = NEW_WHEN($2, $4, $5); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch3(when, $2, $4, escape_Qundef($5)); @@ -3749,10 +3822,10 @@ opt_rescue : keyword_rescue exc_list exc_var then { /*%%%*/ if ($3) { - $3 = node_assign($3, new_errinfo(@1.first_column), @1.first_column); - $5 = block_append($3, $5, @1.first_column); + $3 = node_assign($3, new_errinfo(&@1), &@1); + $5 = block_append($3, $5, &@1); } - $$ = new_resbody($2, $5, $6, @1.first_column); + $$ = new_resbody($2, $5, $6, &@1); fixpos($$, $2?$2:$5); /*% $$ = dispatch4(rescue, @@ -3768,7 +3841,7 @@ opt_rescue : keyword_rescue exc_list exc_var then exc_list : arg_value { /*%%%*/ - $$ = new_list($1, @1.first_column); + $$ = new_list($1, &@1); /*% $$ = rb_ary_new3(1, get_value($1)); %*/ @@ -3806,7 +3879,7 @@ literal : numeric | symbol { /*%%%*/ - $$ = new_lit(ID2SYM($1), @1.first_column); + $$ = new_lit(ID2SYM($1), &@1); /*% $$ = dispatch1(symbol_literal, $1); %*/ @@ -3819,10 +3892,10 @@ strings : string /*%%%*/ NODE *node = $1; if (!node) { - node = new_str(STR_NEW0(), @1.first_column); + node = new_str(STR_NEW0(), &@1); } else { - node = evstr2dstr(node, @1.first_column); + node = evstr2dstr(node, &@1); } $$ = node; /*% @@ -3834,6 +3907,7 @@ strings : string string : tCHAR { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -3842,7 +3916,7 @@ string : tCHAR | string string1 { /*%%%*/ - $$ = literal_concat($1, $2, @1.first_column); + $$ = literal_concat($1, $2, &@1); /*% $$ = dispatch2(string_concat, $1, $2); %*/ @@ -3857,20 +3931,20 @@ string1 : tSTRING_BEG string_contents tSTRING_END xstring : tXSTRING_BEG xstring_contents tSTRING_END { - $$ = new_xstring(heredoc_dedent($2), @1.first_column); + $$ = new_xstring(heredoc_dedent($2), &@1); } ; regexp : tREGEXP_BEG regexp_contents tREGEXP_END { - $$ = new_regexp($2, $3, @1.first_column); + $$ = new_regexp($2, $3, &@1); } ; words : tWORDS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = new_zarray(@1.first_column); + $$ = new_zarray(&@1); /*% $$ = dispatch0(words_new); $$ = dispatch1(array, $$); @@ -3897,7 +3971,7 @@ word_list : /* none */ | word_list word ' ' { /*%%%*/ - $$ = list_append($1, evstr2dstr($2, @1.first_column), @1.first_column); + $$ = list_append($1, evstr2dstr($2, &@1), &@1); /*% $$ = dispatch2(words_add, $1, $2); %*/ @@ -3915,7 +3989,7 @@ word : string_content | word string_content { /*%%%*/ - $$ = literal_concat($1, $2, @1.first_column); + $$ = literal_concat($1, $2, &@1); /*% $$ = dispatch2(word_add, $1, $2); %*/ @@ -3925,7 +3999,7 @@ word : string_content symbols : tSYMBOLS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = new_zarray(@1.first_column); + $$ = new_zarray(&@1); /*% $$ = dispatch0(symbols_new); $$ = dispatch1(array, $$); @@ -3952,7 +4026,7 @@ symbol_list : /* none */ | symbol_list word ' ' { /*%%%*/ - $2 = evstr2dstr($2, @1.first_column); + $2 = evstr2dstr($2, &@1); if (nd_type($2) == NODE_DSTR) { nd_set_type($2, NODE_DSYM); } @@ -3960,7 +4034,7 @@ symbol_list : /* none */ nd_set_type($2, NODE_LIT); add_mark_object($2->nd_lit = rb_str_intern($2->nd_lit)); } - $$ = list_append($1, $2, @1.first_column); + $$ = list_append($1, $2, &@1); /*% $$ = dispatch2(symbols_add, $1, $2); %*/ @@ -3970,7 +4044,7 @@ symbol_list : /* none */ qwords : tQWORDS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = new_zarray(@1.first_column); + $$ = new_zarray(&@1); /*% $$ = dispatch0(qwords_new); $$ = dispatch1(array, $$); @@ -3989,7 +4063,7 @@ qwords : tQWORDS_BEG ' ' tSTRING_END qsymbols : tQSYMBOLS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = new_zarray(@1.first_column); + $$ = new_zarray(&@1); /*% $$ = dispatch0(qsymbols_new); $$ = dispatch1(array, $$); @@ -4016,7 +4090,8 @@ qword_list : /* none */ | qword_list tSTRING_CONTENT ' ' { /*%%%*/ - $$ = list_append($1, $2, @1.first_column); + $$ = list_append($1, $2, &@1); + nd_set_lineno($2, @1.first_line); nd_set_column($2, @1.first_column); /*% $$ = dispatch2(qwords_add, $1, $2); @@ -4039,7 +4114,8 @@ qsym_list : /* none */ lit = $2->nd_lit; nd_set_type($2, NODE_LIT); add_mark_object($2->nd_lit = ID2SYM(rb_intern_str(lit))); - $$ = list_append($1, $2, @1.first_column); + $$ = list_append($1, $2, &@1); + nd_set_lineno($2, @1.first_line); nd_set_column($2, @1.first_column); /*% $$ = dispatch2(qsymbols_add, $1, $2); @@ -4058,7 +4134,7 @@ string_contents : /* none */ | string_contents string_content { /*%%%*/ - $$ = literal_concat($1, $2, @1.first_column); + $$ = literal_concat($1, $2, &@1); /*% $$ = dispatch2(string_add, $1, $2); %*/ @@ -4076,7 +4152,7 @@ xstring_contents: /* none */ | xstring_contents string_content { /*%%%*/ - $$ = literal_concat($1, $2, @1.first_column); + $$ = literal_concat($1, $2, &@1); /*% $$ = dispatch2(xstring_add, $1, $2); %*/ @@ -4109,10 +4185,10 @@ regexp_contents: /* none */ case NODE_DSTR: break; default: - head = list_append(new_dstr(Qnil, @1.first_column), head, @1.first_column); + head = list_append(new_dstr(Qnil, &@1), head, &@1); break; } - $$ = list_append(head, tail, @1.first_column); + $$ = list_append(head, tail, &@1); } /*% VALUE s1 = 1, s2 = 0, n1 = $1, n2 = $2; @@ -4135,6 +4211,7 @@ regexp_contents: /* none */ string_content : tSTRING_CONTENT { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -4150,6 +4227,7 @@ string_content : tSTRING_CONTENT lex_strterm = $2; /*%%%*/ $$ = NEW_EVSTR($3); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(string_dvar, $3); @@ -4189,7 +4267,7 @@ string_content : tSTRING_CONTENT heredoc_line_indent = -1; /*%%%*/ if ($7) $7->flags &= ~NODE_FL_NEWLINE; - $$ = new_evstr($7, @1.first_column); + $$ = new_evstr($7, &@1); /*% $$ = dispatch1(string_embexpr, $7); %*/ @@ -4199,7 +4277,7 @@ string_content : tSTRING_CONTENT string_dvar : tGVAR { /*%%%*/ - $$ = new_gvar($1, @1.first_column); + $$ = new_gvar($1, &@1); /*% $$ = dispatch1(var_ref, $1); %*/ @@ -4207,7 +4285,7 @@ string_dvar : tGVAR | tIVAR { /*%%%*/ - $$ = new_ivar($1, @1.first_column); + $$ = new_ivar($1, &@1); /*% $$ = dispatch1(var_ref, $1); %*/ @@ -4216,6 +4294,7 @@ string_dvar : tGVAR { /*%%%*/ $$ = NEW_CVAR($1); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = dispatch1(var_ref, $1); @@ -4245,7 +4324,7 @@ dsym : tSYMBEG xstring_contents tSTRING_END { SET_LEX_STATE(EXPR_END|EXPR_ENDARG); /*%%%*/ - $$ = dsym_node($2, @1.first_column); + $$ = dsym_node($2, &@1); /*% $$ = dispatch1(dyna_symbol, $2); %*/ @@ -4267,6 +4346,7 @@ numeric : simple_numeric simple_numeric : tINTEGER { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -4274,6 +4354,7 @@ simple_numeric : tINTEGER | tFLOAT { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -4281,6 +4362,7 @@ simple_numeric : tINTEGER | tRATIONAL { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -4288,6 +4370,7 @@ simple_numeric : tINTEGER | tIMAGINARY { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -4313,7 +4396,7 @@ keyword_variable: keyword_nil {$$ = KWD2EID(nil, $1);} var_ref : user_variable { /*%%%*/ - if (!($$ = gettable($1, @1.first_column))) $$ = new_begin(0, @1.first_column); + if (!($$ = gettable($1, &@1))) $$ = new_begin(0, &@1); /*% if (id_is_var(get_id($1))) { $$ = dispatch1(var_ref, $1); @@ -4326,7 +4409,7 @@ var_ref : user_variable | keyword_variable { /*%%%*/ - if (!($$ = gettable($1, @1.first_column))) $$ = new_begin(0, @1.first_column); + if (!($$ = gettable($1, &@1))) $$ = new_begin(0, &@1); /*% $$ = dispatch1(var_ref, $1); %*/ @@ -4335,17 +4418,18 @@ var_ref : user_variable var_lhs : user_variable { - $$ = assignable(var_field($1), 0, @1.first_column); + $$ = assignable(var_field($1), 0, &@1); } | keyword_variable { - $$ = assignable(var_field($1), 0, @1.first_column); + $$ = assignable(var_field($1), 0, &@1); } ; backref : tNTH_REF { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -4353,6 +4437,7 @@ backref : tNTH_REF | tBACK_REF { /*%%%*/ + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% %*/ @@ -4404,19 +4489,19 @@ f_arglist : '(' f_args rparen args_tail : f_kwarg ',' f_kwrest opt_f_block_arg { - $$ = new_args_tail($1, $3, $4, @1.first_column); + $$ = new_args_tail($1, $3, $4, &@1); } | f_kwarg opt_f_block_arg { - $$ = new_args_tail($1, Qnone, $2, @1.first_column); + $$ = new_args_tail($1, Qnone, $2, &@1); } | f_kwrest opt_f_block_arg { - $$ = new_args_tail(Qnone, $1, $2, @1.first_column); + $$ = new_args_tail(Qnone, $1, $2, &@1); } | f_block_arg { - $$ = new_args_tail(Qnone, Qnone, $1, @1.first_column); + $$ = new_args_tail(Qnone, Qnone, $1, &@1); } ; @@ -4426,7 +4511,7 @@ opt_args_tail : ',' args_tail } | /* none */ { - $$ = new_args_tail(Qnone, Qnone, Qnone, @0.first_column); + $$ = new_args_tail(Qnone, Qnone, Qnone, &@0); } ; @@ -4488,7 +4573,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail } | /* none */ { - $$ = new_args_tail(Qnone, Qnone, Qnone, @0.first_column); + $$ = new_args_tail(Qnone, Qnone, Qnone, &@0); $$ = new_args(Qnone, Qnone, Qnone, Qnone, $$); } ; @@ -4567,10 +4652,10 @@ f_arg_item : f_arg_asgn arg_var(tid); /*%%%*/ if (dyna_in_block()) { - $2->nd_value = new_dvar(tid, @1.first_column); + $2->nd_value = new_dvar(tid, &@1); } else { - $2->nd_value = new_lvar(tid, @1.first_column); + $2->nd_value = new_lvar(tid, &@1); } $$ = NEW_ARGS_AUX(tid, 1); $$->nd_next = $2; @@ -4592,7 +4677,7 @@ f_arg : f_arg_item /*%%%*/ $$ = $1; $$->nd_plen++; - $$->nd_next = block_append($$->nd_next, $3->nd_next, @1.first_column); + $$->nd_next = block_append($$->nd_next, $3->nd_next, &@1); rb_discard_node($3); /*% $$ = rb_ary_push($1, get_value($3)); @@ -4613,9 +4698,9 @@ f_label : tLABEL f_kw : f_label arg_value { current_arg = 0; - $$ = assignable($1, $2, @1.first_column); + $$ = assignable($1, $2, &@1); /*%%%*/ - $$ = new_kw_arg($$, @1.first_column); + $$ = new_kw_arg($$, &@1); /*% $$ = rb_assoc_new(get_value($$), get_value($2)); %*/ @@ -4623,9 +4708,9 @@ f_kw : f_label arg_value | f_label { current_arg = 0; - $$ = assignable($1, (NODE *)-1, @1.first_column); + $$ = assignable($1, (NODE *)-1, &@1); /*%%%*/ - $$ = new_kw_arg($$, @1.first_column); + $$ = new_kw_arg($$, &@1); /*% $$ = rb_assoc_new(get_value($$), 0); %*/ @@ -4634,18 +4719,18 @@ f_kw : f_label arg_value f_block_kw : f_label primary_value { - $$ = assignable($1, $2, @1.first_column); + $$ = assignable($1, $2, &@1); /*%%%*/ - $$ = new_kw_arg($$, @1.first_column); + $$ = new_kw_arg($$, &@1); /*% $$ = rb_assoc_new(get_value($$), get_value($2)); %*/ } | f_label { - $$ = assignable($1, (NODE *)-1, @1.first_column); + $$ = assignable($1, (NODE *)-1, &@1); /*%%%*/ - $$ = new_kw_arg($$, @1.first_column); + $$ = new_kw_arg($$, &@1); /*% $$ = rb_assoc_new(get_value($$), 0); %*/ @@ -4716,9 +4801,10 @@ f_kwrest : kwrest_mark tIDENTIFIER f_opt : f_arg_asgn '=' arg_value { current_arg = 0; - $$ = assignable($1, $3, @1.first_column); + $$ = assignable($1, $3, &@1); /*%%%*/ $$ = NEW_OPT_ARG(0, $$); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), get_value($3)); @@ -4729,9 +4815,10 @@ f_opt : f_arg_asgn '=' arg_value f_block_opt : f_arg_asgn '=' primary_value { current_arg = 0; - $$ = assignable($1, $3, @1.first_column); + $$ = assignable($1, $3, &@1); /*%%%*/ $$ = NEW_OPT_ARG(0, $$); + nd_set_lineno($$, @1.first_line); nd_set_column($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), get_value($3)); @@ -4939,7 +5026,7 @@ assoc : arg_value tASSOC arg_value nd_set_type($1, NODE_LIT); add_mark_object($1->nd_lit = rb_fstring($1->nd_lit)); } - $$ = list_append(new_list($1, @1.first_column), $3, @1.first_column); + $$ = list_append(new_list($1, &@1), $3, &@1); /*% $$ = dispatch2(assoc_new, $1, $3); %*/ @@ -4947,7 +5034,7 @@ assoc : arg_value tASSOC arg_value | tLABEL arg_value { /*%%%*/ - $$ = list_append(new_list(new_lit(ID2SYM($1), @1.first_column), @1.first_column), $2, @1.first_column); + $$ = list_append(new_list(new_lit(ID2SYM($1), &@1), &@1), $2, &@1); /*% $$ = dispatch2(assoc_new, $1, $2); %*/ @@ -4955,7 +5042,7 @@ assoc : arg_value tASSOC arg_value | tSTRING_BEG string_contents tLABEL_END arg_value { /*%%%*/ - $$ = list_append(new_list(dsym_node($2, @1.first_column), @1.first_column), $4, @1.first_column); + $$ = list_append(new_list(dsym_node($2, &@1), &@1), $4, &@1); /*% $$ = dispatch2(assoc_new, dispatch1(dyna_symbol, $2), $4); %*/ @@ -4967,7 +5054,7 @@ assoc : arg_value tASSOC arg_value !($2->nd_head && $2->nd_head->nd_alen)) $$ = 0; else - $$ = list_append(new_list(0, @1.first_column), $2, @1.first_column); + $$ = list_append(new_list(0, &@1), $2, &@1); /*% $$ = dispatch1(assoc_splat, $2); %*/ @@ -5521,6 +5608,7 @@ yycompile0(VALUE arg) rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov); prelude = NEW_PRELUDE(ruby_eval_tree_begin, body, opt); add_mark_object(opt); + nd_set_lineno(prelude, nd_lineno(body)); nd_set_column(prelude, nd_column(body)); tree->nd_body = prelude; } @@ -8813,6 +8901,7 @@ yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *parser) else if (t != 0) dispatch_scan_event(t); + yylloc->first_line = ruby_sourceline; yylloc->first_column = (int)(parser->tokp - lex_pbeg); yylloc->last_column = (int)(lex_p - lex_pbeg); @@ -8830,7 +8919,8 @@ node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE rb_node_init(n, type, a0, a1, a2); nd_set_line(n, ruby_sourceline); - /* mark not cared column to -1 */ + /* mark not cared lineno to 0 and column to -1 */ + nd_set_lineno(n, 0); nd_set_column(n, -1); return n; } @@ -8880,7 +8970,7 @@ parser_warn(struct parser_params *parser, NODE *node, const char *mesg) #define parser_warn(node, mesg) parser_warn(parser, (node), (mesg)) static NODE* -block_append_gen(struct parser_params *parser, NODE *head, NODE *tail, int column) +block_append_gen(struct parser_params *parser, NODE *head, NODE *tail, YYLTYPE *location) { NODE *end, *h = head, *nd; @@ -8898,7 +8988,8 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail, int colum return tail; default: h = end = NEW_BLOCK(head); - nd_set_column(end, column); + nd_set_lineno(end, location->first_line); + nd_set_column(end, location->first_column); end->nd_end = end; fixpos(end, head); head = end; @@ -8926,7 +9017,8 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail, int colum if (nd_type(tail) != NODE_BLOCK) { tail = NEW_BLOCK(tail); - nd_set_column(tail, column); + nd_set_lineno(tail, location->first_line); + nd_set_column(tail, location->first_column); tail->nd_end = tail; } end->nd_next = tail; @@ -8936,11 +9028,11 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail, int colum /* append item to the list */ static NODE* -list_append_gen(struct parser_params *parser, NODE *list, NODE *item, int column) +list_append_gen(struct parser_params *parser, NODE *list, NODE *item, YYLTYPE *location) { NODE *last; - if (list == 0) return new_list(item, column); + if (list == 0) return new_list(item, location); if (list->nd_next) { last = list->nd_next->nd_end; } @@ -8949,7 +9041,7 @@ list_append_gen(struct parser_params *parser, NODE *list, NODE *item, int column } list->nd_alen += 1; - last->nd_next = new_list(item, column); + last->nd_next = new_list(item, location); list->nd_next->nd_end = last->nd_next; return list; } @@ -8997,7 +9089,7 @@ literal_concat0(struct parser_params *parser, VALUE head, VALUE tail) /* concat two string literals */ static NODE * -literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, int column) +literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, YYLTYPE *location) { enum node_type htype; NODE *headlast; @@ -9008,8 +9100,8 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, int col htype = nd_type(head); if (htype == NODE_EVSTR) { - NODE *node = new_dstr(STR_NEW0(), column); - head = list_append(node, head, column); + NODE *node = new_dstr(STR_NEW0(), location); + head = list_append(node, head, location); htype = NODE_DSTR; } if (heredoc_indent > 0) { @@ -9017,7 +9109,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, int col case NODE_STR: nd_set_type(head, NODE_DSTR); case NODE_DSTR: - return list_append(head, tail, column); + return list_append(head, tail, location); default: break; } @@ -9042,7 +9134,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, int col rb_discard_node(tail); } else { - list_append(head, tail, column); + list_append(head, tail, location); } break; @@ -9071,7 +9163,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, int col } else { nd_set_type(tail, NODE_ARRAY); - tail->nd_head = new_str(tail->nd_lit, column); + tail->nd_head = new_str(tail->nd_lit, location); list_concat(head, tail); } break; @@ -9081,23 +9173,23 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, int col nd_set_type(head, NODE_DSTR); head->nd_alen = 1; } - list_append(head, tail, column); + list_append(head, tail, location); break; } return head; } static NODE * -evstr2dstr_gen(struct parser_params *parser, NODE *node, int column) +evstr2dstr_gen(struct parser_params *parser, NODE *node, YYLTYPE *location) { if (nd_type(node) == NODE_EVSTR) { - node = list_append(new_dstr(STR_NEW0(), column), node, column); + node = list_append(new_dstr(STR_NEW0(), location), node, location); } return node; } static NODE * -new_evstr_gen(struct parser_params *parser, NODE *node, int column) +new_evstr_gen(struct parser_params *parser, NODE *node, YYLTYPE *location) { NODE *head = node; NODE *evstr; @@ -9109,43 +9201,47 @@ new_evstr_gen(struct parser_params *parser, NODE *node, int column) } } evstr = NEW_EVSTR(head); - nd_set_column(evstr, column); + nd_set_lineno(evstr, location->first_line); + nd_set_column(evstr, location->first_column); return evstr; } static NODE * -call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1, int column) +call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1, YYLTYPE *location) { NODE *expr; value_expr(recv); value_expr(arg1); - expr = NEW_OPCALL(recv, id, new_list(arg1, column)); + expr = NEW_OPCALL(recv, id, new_list(arg1, location)); fixpos(expr, recv); - nd_set_column(expr, column); + nd_set_lineno(expr, location->first_line); + nd_set_column(expr, location->first_column); return expr; } static NODE * -call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, int column) +call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, YYLTYPE *location) { NODE *opcall; value_expr(recv); opcall = NEW_OPCALL(recv, id, 0); - nd_set_column(opcall, column); + nd_set_lineno(opcall, location->first_line); + nd_set_column(opcall, location->first_column); return opcall; } static NODE * -new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, int column) +new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, YYLTYPE *location) { NODE *qcall = NEW_QCALL(atype, recv, mid, args); - nd_set_column(qcall, column); + nd_set_lineno(qcall, location->first_line); + nd_set_column(qcall, location->first_column); return qcall; } #define nd_once_body(node) (nd_type(node) == NODE_SCOPE ? (node)->nd_body : node) static NODE* -match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) +match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, YYLTYPE *location) { NODE *n; @@ -9156,7 +9252,8 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) case NODE_DREGX: { NODE *match = NEW_MATCH2(node1, node2); - nd_set_column(match, column); + nd_set_lineno(match, location->first_line); + nd_set_column(match, location->first_column); return match; } @@ -9164,8 +9261,9 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) if (RB_TYPE_P(n->nd_lit, T_REGEXP)) { const VALUE lit = n->nd_lit; NODE *match = NEW_MATCH2(node1, node2); - match->nd_args = reg_named_capture_assign(lit, column); - nd_set_column(match, column); + match->nd_args = reg_named_capture_assign(lit, location); + nd_set_lineno(match, location->first_line); + nd_set_column(match, location->first_column); return match; } } @@ -9177,19 +9275,21 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) switch (nd_type(n)) { case NODE_DREGX: match3 = NEW_MATCH3(node2, node1); - nd_set_column(match3, column); + nd_set_lineno(match3, location->first_line); + nd_set_column(match3, location->first_column); return match3; case NODE_LIT: if (RB_TYPE_P(n->nd_lit, T_REGEXP)) { match3 = NEW_MATCH3(node2, node1); - nd_set_column(match3, column); + nd_set_lineno(match3, location->first_line); + nd_set_column(match3, location->first_column); return match3; } } } - return new_call(node1, tMATCH, new_list(node2, column), column); + return new_call(node1, tMATCH, new_list(node2, location), location); } # if WARN_PAST_SCOPE @@ -9206,34 +9306,38 @@ past_dvar_p(struct parser_params *parser, ID id) # endif static NODE* -gettable_gen(struct parser_params *parser, ID id, int column) +gettable_gen(struct parser_params *parser, ID id, YYLTYPE *location) { ID *vidp = NULL; NODE *node; switch (id) { case keyword_self: node = NEW_SELF(); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); return node; case keyword_nil: node = NEW_NIL(); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); return node; case keyword_true: node = NEW_TRUE(); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); return node; case keyword_false: node = NEW_FALSE(); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); return node; case keyword__FILE__: - node = new_str(rb_str_dup(ruby_sourcefile_string), column); + node = new_str(rb_str_dup(ruby_sourcefile_string), location); return node; case keyword__LINE__: - return new_lit(INT2FIX(tokline), column); + return new_lit(INT2FIX(tokline), location); case keyword__ENCODING__: - return new_lit(rb_enc_from_encoding(current_enc), column); + return new_lit(rb_enc_from_encoding(current_enc), location); } switch (id_type(id)) { case ID_LOCAL: @@ -9242,7 +9346,7 @@ gettable_gen(struct parser_params *parser, ID id, int column) rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id)); } if (vidp) *vidp |= LVAR_USED; - node = new_dvar(id, column); + node = new_dvar(id, location); return node; } if (local_id_ref(id, vidp)) { @@ -9250,7 +9354,7 @@ gettable_gen(struct parser_params *parser, ID id, int column) rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id)); } if (vidp) *vidp |= LVAR_USED; - node = new_lvar(id, column); + node = new_lvar(id, location); return node; } # if WARN_PAST_SCOPE @@ -9260,21 +9364,24 @@ gettable_gen(struct parser_params *parser, ID id, int column) # endif /* method call without arguments */ node = NEW_VCALL(id); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); return node; case ID_GLOBAL: - node = new_gvar(id, column); + node = new_gvar(id, location); return node; case ID_INSTANCE: - node = new_ivar(id, column); + node = new_ivar(id, location); return node; case ID_CONST: node = NEW_CONST(id); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); return node; case ID_CLASS: node = NEW_CVAR(id); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); return node; } compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id)); @@ -9295,21 +9402,22 @@ kwd_append(NODE *kwlist, NODE *kw) } static NODE * -new_defined_gen(struct parser_params *parser, NODE *expr, int column) +new_defined_gen(struct parser_params *parser, NODE *expr, YYLTYPE *location) { NODE *defined = NEW_DEFINED(remove_begin_all(expr)); - nd_set_column(defined, column); + nd_set_lineno(defined, location->first_line); + nd_set_column(defined, location->first_column); return defined; } static NODE * -new_regexp_gen(struct parser_params *parser, NODE *node, int options, int column) +new_regexp_gen(struct parser_params *parser, NODE *node, int options, YYLTYPE *location) { NODE *list, *prev; VALUE lit; if (!node) { - return new_lit(reg_compile(STR_NEW0(), options), column); + return new_lit(reg_compile(STR_NEW0(), options), location); } switch (nd_type(node)) { case NODE_STR: @@ -9321,8 +9429,9 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, int column break; default: add_mark_object(lit = STR_NEW0()); - node = NEW_NODE(NODE_DSTR, lit, 1, new_list(node, column)); - nd_set_column(node, column); + node = NEW_NODE(NODE_DSTR, lit, 1, new_list(node, location)); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); case NODE_DSTR: nd_set_type(node, NODE_DREGX); node->nd_cflag = options & RE_OPTION_MASK; @@ -9357,7 +9466,8 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, int column } if (options & RE_OPTION_ONCE) { node = NEW_NODE(NODE_SCOPE, 0, node, 0); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); } break; } @@ -9365,195 +9475,218 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, int column } static NODE * -new_lit_gen(struct parser_params *parser, VALUE sym, int column) +new_lit_gen(struct parser_params *parser, VALUE sym, YYLTYPE *location) { NODE *lit = NEW_LIT(sym); add_mark_object(sym); - nd_set_column(lit, column); + nd_set_lineno(lit, location->first_line); + nd_set_column(lit, location->first_column); return lit; } static NODE * -new_list_gen(struct parser_params *parser, NODE *item, int column) +new_list_gen(struct parser_params *parser, NODE *item, YYLTYPE *location) { NODE *list = NEW_LIST(item); - nd_set_column(list, column); + nd_set_lineno(list, location->first_line); + nd_set_column(list, location->first_column); return list; } static NODE * -new_str_gen(struct parser_params *parser, VALUE str, int column) +new_str_gen(struct parser_params *parser, VALUE str, YYLTYPE *location) { NODE *nd_str = NEW_STR(str); add_mark_object(str); - nd_set_column(nd_str, column); + nd_set_lineno(nd_str, location->first_line); + nd_set_column(nd_str, location->first_column); return nd_str; } static NODE * -new_dvar_gen(struct parser_params *parser, ID id, int column) +new_dvar_gen(struct parser_params *parser, ID id, YYLTYPE *location) { NODE *dvar = NEW_DVAR(id); - nd_set_column(dvar, column); + nd_set_lineno(dvar, location->first_line); + nd_set_column(dvar, location->first_column); return dvar; } static NODE * -new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, int column) +new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, YYLTYPE *location) { NODE *resbody = NEW_RESBODY(exc_list, stmt, rescue); - nd_set_column(resbody, column); + nd_set_lineno(resbody, location->first_line); + nd_set_column(resbody, location->first_column); return resbody; } static NODE * -new_errinfo_gen(struct parser_params *parser, int column) +new_errinfo_gen(struct parser_params *parser, YYLTYPE *location) { NODE *errinfo = NEW_ERRINFO(); - nd_set_column(errinfo, column); + nd_set_lineno(errinfo, location->first_line); + nd_set_column(errinfo, location->first_column); return errinfo; } static NODE * -new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, int column) +new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, YYLTYPE *location) { NODE *call = NEW_CALL(recv, mid, args); - nd_set_column(call, column); + nd_set_lineno(call, location->first_line); + nd_set_column(call, location->first_column); return call; } static NODE * -new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, int column) +new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, YYLTYPE *location) { NODE *fcall = NEW_FCALL(mid, args); - nd_set_column(fcall, column); + nd_set_lineno(fcall, location->first_line); + nd_set_column(fcall, location->first_column); return fcall; } static NODE * -new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, int column) +new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, YYLTYPE *location) { NODE *nd_for = NEW_FOR(var, iter, body); - nd_set_column(nd_for, column); + nd_set_lineno(nd_for, location->first_line); + nd_set_column(nd_for, location->first_column); return nd_for; } static NODE * -new_gvar_gen(struct parser_params *parser, ID id, int column) +new_gvar_gen(struct parser_params *parser, ID id, YYLTYPE *location) { NODE *gvar = NEW_GVAR(id); - nd_set_column(gvar, column); + nd_set_lineno(gvar, location->first_line); + nd_set_column(gvar, location->first_column); return gvar; } static NODE * -new_lvar_gen(struct parser_params *parser, ID id, int column) +new_lvar_gen(struct parser_params *parser, ID id, YYLTYPE *location) { NODE *lvar = NEW_LVAR(id); - nd_set_column(lvar, column); + nd_set_lineno(lvar, location->first_line); + nd_set_column(lvar, location->first_column); return lvar; } static NODE * -new_dstr_gen(struct parser_params *parser, VALUE str, int column) +new_dstr_gen(struct parser_params *parser, VALUE str, YYLTYPE *location) { NODE *dstr = NEW_DSTR(str); add_mark_object(str); - nd_set_column(dstr, column); + nd_set_lineno(dstr, location->first_line); + nd_set_column(dstr, location->first_column); return dstr; } static NODE * -new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, int column) +new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, YYLTYPE *location) { NODE *rescue = NEW_RESCUE(b, res, e); - nd_set_column(rescue, column); + nd_set_lineno(rescue, location->first_line); + nd_set_column(rescue, location->first_column); return rescue; } static NODE * -new_undef_gen(struct parser_params *parser, NODE *i, int column) +new_undef_gen(struct parser_params *parser, NODE *i, YYLTYPE *location) { NODE *undef = NEW_UNDEF(i); - nd_set_column(undef, column); + nd_set_lineno(undef, location->first_line); + nd_set_column(undef, location->first_column); return undef; } static NODE * -new_zarray_gen(struct parser_params *parser, int column) +new_zarray_gen(struct parser_params *parser, YYLTYPE *location) { NODE *zarray = NEW_ZARRAY(); - nd_set_column(zarray, column); + nd_set_lineno(zarray, location->first_line); + nd_set_column(zarray, location->first_column); return zarray; } static NODE * -new_ivar_gen(struct parser_params *parser, ID id, int column) +new_ivar_gen(struct parser_params *parser, ID id, YYLTYPE *location) { NODE *ivar = NEW_IVAR(id); - nd_set_column(ivar, column); + nd_set_lineno(ivar, location->first_line); + nd_set_column(ivar, location->first_column); return ivar; } static NODE * -new_postarg_gen(struct parser_params *parser, NODE *i, NODE *v, int column) +new_postarg_gen(struct parser_params *parser, NODE *i, NODE *v, YYLTYPE *location) { NODE *postarg = NEW_POSTARG(i, v); - nd_set_column(postarg, column); + nd_set_lineno(postarg, location->first_line); + nd_set_column(postarg, location->first_column); return postarg; } static NODE * -new_cdecl_gen(struct parser_params *parser, ID v, NODE *val, NODE *path, int column) +new_cdecl_gen(struct parser_params *parser, ID v, NODE *val, NODE *path, YYLTYPE *location) { NODE *nd_cdecl = NEW_CDECL(v, val, path); - nd_set_column(nd_cdecl, column); + nd_set_lineno(nd_cdecl, location->first_line); + nd_set_column(nd_cdecl, location->first_column); return nd_cdecl; } static NODE * -new_scope_gen(struct parser_params *parser, NODE *a, NODE *b, int column) +new_scope_gen(struct parser_params *parser, NODE *a, NODE *b, YYLTYPE *location) { NODE *scope = NEW_SCOPE(a, b); - nd_set_column(scope, column); + nd_set_lineno(scope, location->first_line); + nd_set_column(scope, location->first_column); return scope; } static NODE * -new_begin_gen(struct parser_params *parser, NODE *b, int column) +new_begin_gen(struct parser_params *parser, NODE *b, YYLTYPE *location) { NODE *begin = NEW_BEGIN(b); - nd_set_column(begin, column); + nd_set_lineno(begin, location->first_line); + nd_set_column(begin, location->first_column); return begin; } static NODE * -new_masgn_gen(struct parser_params *parser, NODE *l, NODE *r, int column) +new_masgn_gen(struct parser_params *parser, NODE *l, NODE *r, YYLTYPE *location) { NODE *masgn = NEW_MASGN(l, r); - nd_set_column(masgn, column); + nd_set_lineno(masgn, location->first_line); + nd_set_column(masgn, location->first_column); return masgn; } static NODE * -new_kw_arg_gen(struct parser_params *parser, NODE *k, int column) +new_kw_arg_gen(struct parser_params *parser, NODE *k, YYLTYPE *location) { NODE *kw_arg; if (!k) return 0; kw_arg = NEW_KW_ARG(0, (k)); - nd_set_column(kw_arg, column); + nd_set_lineno(kw_arg, location->first_line); + nd_set_column(kw_arg, location->first_column); return kw_arg; } static NODE * -new_xstring_gen(struct parser_params *parser, NODE *node, int column) +new_xstring_gen(struct parser_params *parser, NODE *node, YYLTYPE *location) { if (!node) { VALUE lit = STR_NEW0(); NODE *xstr = NEW_XSTR(lit); add_mark_object(lit); - nd_set_column(xstr, column); + nd_set_lineno(xstr, location->first_line); + nd_set_column(xstr, location->first_column); return xstr; } switch (nd_type(node)) { @@ -9564,19 +9697,22 @@ new_xstring_gen(struct parser_params *parser, NODE *node, int column) nd_set_type(node, NODE_DXSTR); break; default: - node = NEW_NODE(NODE_DXSTR, Qnil, 1, new_list(node, column)); - nd_set_column(node, column); + node = NEW_NODE(NODE_DXSTR, Qnil, 1, new_list(node, location)); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); break; } return node; } static NODE * -new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, int column) +new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, YYLTYPE *location) { NODE *iter = NEW_ITER(param, stmt); - nd_set_column(iter->nd_body, column); - nd_set_column(iter, column); + nd_set_lineno(iter->nd_body, location->first_line); + nd_set_column(iter->nd_body, location->first_column); + nd_set_lineno(iter, location->first_line); + nd_set_column(iter, location->first_column); return iter; } @@ -9745,9 +9881,12 @@ rb_parser_fatal(struct parser_params *parser, const char *fmt, ...) #ifndef RIPPER static NODE* -assignable_result0(NODE *node, int column) +assignable_result0(NODE *node, YYLTYPE *location) { - if (node) nd_set_column(node, column); + if (node) { + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); + } return node; } #endif /* !RIPPER */ @@ -9757,7 +9896,7 @@ static VALUE assignable_gen(struct parser_params *parser, VALUE lhs) #else static NODE* -assignable_gen(struct parser_params *parser, ID id, NODE *val, int column) +assignable_gen(struct parser_params *parser, ID id, NODE *val, YYLTYPE *location) #endif { #ifdef RIPPER @@ -9765,7 +9904,7 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val, int column) # define assignable_result(x) (lhs) # define parser_yyerror(parser, x) (lhs = assign_error_gen(parser, lhs)) #else -# define assignable_result(x) assignable_result0(x, column) +# define assignable_result(x) assignable_result0(x, location) #endif if (!id) return assignable_result(0); switch (id) { @@ -9821,7 +9960,7 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val, int column) return assignable_result(NEW_IASGN(id, val)); case ID_CONST: if (!in_def && !in_single) - return assignable_result(new_cdecl(id, val, 0, column)); + return assignable_result(new_cdecl(id, val, 0, location)); yyerror0("dynamic constant assignment"); break; case ID_CLASS: @@ -9893,10 +10032,11 @@ new_bv_gen(struct parser_params *parser, ID name) #ifndef RIPPER static NODE * -aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, int column) +aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, YYLTYPE *location) { NODE *attrasgn = NEW_ATTRASGN(recv, tASET, idx); - nd_set_column(attrasgn, column); + nd_set_lineno(attrasgn, location->first_line); + nd_set_column(attrasgn, location->first_column); return attrasgn; } @@ -9909,12 +10049,13 @@ block_dup_check_gen(struct parser_params *parser, NODE *node1, NODE *node2) } static NODE * -attrset_gen(struct parser_params *parser, NODE *recv, ID atype, ID id, int column) +attrset_gen(struct parser_params *parser, NODE *recv, ID atype, ID id, YYLTYPE *location) { NODE *attrasgn; if (!CALL_Q_P(atype)) id = rb_id_attrset(id); attrasgn = NEW_ATTRASGN(recv, id, 0); - nd_set_column(attrasgn, column); + nd_set_lineno(attrasgn, location->first_line); + nd_set_column(attrasgn, location->first_column); return attrasgn; } @@ -9932,7 +10073,7 @@ rb_backref_error_gen(struct parser_params *parser, NODE *node) } static NODE * -arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) +arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, YYLTYPE *location) { NODE *argscat; @@ -9940,13 +10081,13 @@ arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, int colum switch (nd_type(node1)) { case NODE_BLOCK_PASS: if (node1->nd_head) - node1->nd_head = arg_concat(node1->nd_head, node2, column); + node1->nd_head = arg_concat(node1->nd_head, node2, location); else - node1->nd_head = new_list(node2, column); + node1->nd_head = new_list(node2, location); return node1; case NODE_ARGSPUSH: if (nd_type(node2) != NODE_ARRAY) break; - node1->nd_body = list_concat(new_list(node1->nd_body, column), node2); + node1->nd_body = list_concat(new_list(node1->nd_body, location), node2); nd_set_type(node1, NODE_ARGSCAT); return node1; case NODE_ARGSCAT: @@ -9956,29 +10097,31 @@ arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, int colum return node1; } argscat = NEW_ARGSCAT(node1, node2); - nd_set_column(argscat, column); + nd_set_lineno(argscat, location->first_line); + nd_set_column(argscat, location->first_column); return argscat; } static NODE * -arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) +arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, YYLTYPE *location) { NODE *argspush; - if (!node1) return new_list(node2, column); + if (!node1) return new_list(node2, location); switch (nd_type(node1)) { case NODE_ARRAY: - return list_append(node1, node2, column); + return list_append(node1, node2, location); case NODE_BLOCK_PASS: - node1->nd_head = arg_append(node1->nd_head, node2, column); + node1->nd_head = arg_append(node1->nd_head, node2, location); return node1; case NODE_ARGSPUSH: - node1->nd_body = list_append(new_list(node1->nd_body, column), node2, column); + node1->nd_body = list_append(new_list(node1->nd_body, location), node2, location); nd_set_type(node1, NODE_ARGSCAT); return node1; } argspush = NEW_ARGSPUSH(node1, node2); - nd_set_column(argspush, column); + nd_set_lineno(argspush, location->first_line); + nd_set_column(argspush, location->first_column); return argspush; } @@ -10018,7 +10161,7 @@ mark_lvar_used(struct parser_params *parser, NODE *rhs) } static NODE * -node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, int column) +node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, YYLTYPE *location) { if (!lhs) return 0; @@ -10036,7 +10179,7 @@ node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, int column) case NODE_ATTRASGN: case NODE_CALL: - lhs->nd_args = arg_append(lhs->nd_args, rhs, column); + lhs->nd_args = arg_append(lhs->nd_args, rhs, location); break; default: @@ -10352,10 +10495,10 @@ warning_unless_e_option(struct parser_params *parser, NODE *node, const char *st if (!e_option_supplied(parser)) parser_warning(node, str); } -static NODE *cond0(struct parser_params*,NODE*,int,int); +static NODE *cond0(struct parser_params*,NODE*,int,YYLTYPE*); static NODE* -range_op(struct parser_params *parser, NODE *node, int column) +range_op(struct parser_params *parser, NODE *node, YYLTYPE *location) { enum node_type type; @@ -10365,9 +10508,9 @@ range_op(struct parser_params *parser, NODE *node, int column) value_expr(node); if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) { warn_unless_e_option(parser, node, "integer literal in conditional range"); - return new_call(node, tEQ, new_list(new_gvar(rb_intern("$."), column), column), column); + return new_call(node, tEQ, new_list(new_gvar(rb_intern("$."), location), location), location); } - return cond0(parser, node, FALSE, column); + return cond0(parser, node, FALSE, location); } static int @@ -10392,7 +10535,7 @@ literal_node(NODE *node) } static NODE* -cond0(struct parser_params *parser, NODE *node, int method_op, int column) +cond0(struct parser_params *parser, NODE *node, int method_op, YYLTYPE *location) { if (node == 0) return 0; if (!(node = nd_once_body(node))) return 0; @@ -10411,21 +10554,22 @@ cond0(struct parser_params *parser, NODE *node, int method_op, int column) if (!method_op) warning_unless_e_option(parser, node, "regex literal in condition"); - match = NEW_MATCH2(node, new_gvar(idLASTLINE, column)); - nd_set_column(match, column); + match = NEW_MATCH2(node, new_gvar(idLASTLINE, location)); + nd_set_lineno(match, location->first_line); + nd_set_column(match, location->first_column); return match; } case NODE_AND: case NODE_OR: - node->nd_1st = cond0(parser, node->nd_1st, FALSE, column); - node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, column); + node->nd_1st = cond0(parser, node->nd_1st, FALSE, location); + node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, location); break; case NODE_DOT2: case NODE_DOT3: - node->nd_beg = range_op(parser, node->nd_beg, column); - node->nd_end = range_op(parser, node->nd_end, column); + node->nd_beg = range_op(parser, node->nd_beg, location); + node->nd_end = range_op(parser, node->nd_end, location); if (nd_type(node) == NODE_DOT2) nd_set_type(node,NODE_FLIP2); else if (nd_type(node) == NODE_DOT3) nd_set_type(node, NODE_FLIP3); if (!method_op && !e_option_supplied(parser)) { @@ -10458,38 +10602,40 @@ cond0(struct parser_params *parser, NODE *node, int method_op, int column) } static NODE* -cond_gen(struct parser_params *parser, NODE *node, int method_op, int column) +cond_gen(struct parser_params *parser, NODE *node, int method_op, YYLTYPE *location) { if (node == 0) return 0; - return cond0(parser, node, method_op, column); + return cond0(parser, node, method_op, location); } static NODE* -new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, int column) +new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, YYLTYPE *location) { NODE *node_if; if (!cc) return right; - cc = cond0(parser, cc, FALSE, column); + cc = cond0(parser, cc, FALSE, location); node_if = NEW_IF(cc, left, right); - nd_set_column(node_if, column); + nd_set_lineno(node_if, location->first_line); + nd_set_column(node_if, location->first_column); return newline_node(node_if); } static NODE* -new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, int column) +new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, YYLTYPE *location) { NODE *node_unless; if (!cc) return right; - cc = cond0(parser, cc, FALSE, column); + cc = cond0(parser, cc, FALSE, location); node_unless = NEW_UNLESS(cc, left, right); - nd_set_column(node_unless, column); + nd_set_lineno(node_unless, location->first_line); + nd_set_column(node_unless, location->first_column); return newline_node(node_unless); } static NODE* -logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right, int column) +logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right, YYLTYPE *location) { NODE *op; value_expr(left); @@ -10499,11 +10645,13 @@ logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *r node = second; } node->nd_2nd = NEW_NODE(type, second, right, 0); - nd_set_column(node->nd_2nd, column); + nd_set_lineno(node->nd_2nd, location->first_line); + nd_set_column(node->nd_2nd, location->first_column); return left; } op = NEW_NODE(type, left, right, 0); - nd_set_column(op, column); + nd_set_lineno(op, location->first_line); + nd_set_column(op, location->first_column); return op; } @@ -10533,13 +10681,14 @@ ret_args_gen(struct parser_params *parser, NODE *node) } static NODE * -new_yield_gen(struct parser_params *parser, NODE *node, int column) +new_yield_gen(struct parser_params *parser, NODE *node, YYLTYPE *location) { NODE *yield; if (node) no_blockarg(parser, node); yield = NEW_YIELD(node); - nd_set_column(yield, column); + nd_set_lineno(yield, location->first_line); + nd_set_column(yield, location->first_column); return yield; } @@ -10612,7 +10761,7 @@ new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE } static NODE* -new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, int column) +new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, YYLTYPE *location) { int saved_line = ruby_sourceline; struct rb_args_info *args; @@ -10621,7 +10770,8 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, int column args = ZALLOC(struct rb_args_info); add_mark_object((VALUE)rb_imemo_alloc_new((VALUE)args, 0, 0, 0)); node = NEW_NODE(NODE_ARGS, 0, 0, args); - nd_set_column(node, column); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); if (parser->error_p) return node; args->block_arg = b; @@ -10667,14 +10817,14 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, int column if (kr) arg_var(kr); if (b) arg_var(b); - args->kw_rest_arg = new_dvar(kr, column); + args->kw_rest_arg = new_dvar(kr, location); args->kw_rest_arg->nd_cflag = kw_bits; } else if (kr) { if (b) vtable_pop(lvtbl->args, 1); /* reorder */ arg_var(kr); if (b) arg_var(b); - args->kw_rest_arg = new_dvar(kr, column); + args->kw_rest_arg = new_dvar(kr, location); } ruby_sourceline = saved_line; @@ -10682,12 +10832,12 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, int column } static NODE* -dsym_node_gen(struct parser_params *parser, NODE *node, int column) +dsym_node_gen(struct parser_params *parser, NODE *node, YYLTYPE *location) { VALUE lit; if (!node) { - return new_lit(ID2SYM(idNULL), column); + return new_lit(ID2SYM(idNULL), location); } switch (nd_type(node)) { @@ -10700,8 +10850,9 @@ dsym_node_gen(struct parser_params *parser, NODE *node, int column) nd_set_type(node, NODE_LIT); break; default: - node = NEW_NODE(NODE_DSYM, Qnil, 1, new_list(node, column)); - nd_set_column(node, column); + node = NEW_NODE(NODE_DSYM, Qnil, 1, new_list(node, location)); + nd_set_lineno(node, location->first_line); + nd_set_column(node, location->first_column); break; } return node; @@ -10723,7 +10874,7 @@ append_literal_keys(st_data_t k, st_data_t v, st_data_t h) } static NODE * -remove_duplicate_keys(struct parser_params *parser, NODE *hash, int column) +remove_duplicate_keys(struct parser_params *parser, NODE *hash, YYLTYPE *location) { st_table *literal_keys = st_init_numtable_with_size(hash->nd_alen / 2); NODE *result = 0; @@ -10739,7 +10890,7 @@ remove_duplicate_keys(struct parser_params *parser, NODE *hash, int column) "key %+"PRIsVALUE" is duplicated and overwritten on line %d", head->nd_lit, nd_line(head)); head = ((NODE *)data)->nd_next; - head->nd_head = block_append(head->nd_head, value->nd_head, column); + head->nd_head = block_append(head->nd_head, value->nd_head, location); } else { st_insert(literal_keys, (st_data_t)key, (st_data_t)hash); @@ -10756,19 +10907,20 @@ remove_duplicate_keys(struct parser_params *parser, NODE *hash, int column) } static NODE * -new_hash_gen(struct parser_params *parser, NODE *hash, int column) +new_hash_gen(struct parser_params *parser, NODE *hash, YYLTYPE *location) { NODE *nd_hash; - if (hash) hash = remove_duplicate_keys(parser, hash, column); + if (hash) hash = remove_duplicate_keys(parser, hash, location); nd_hash = NEW_HASH(hash); - nd_set_column(nd_hash, column); + nd_set_lineno(nd_hash, location->first_line); + nd_set_column(nd_hash, location->first_column); return nd_hash; } #endif /* !RIPPER */ #ifndef RIPPER static NODE * -new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int column) +new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, YYLTYPE *location) { NODE *asgn; @@ -10776,8 +10928,9 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int ID vid = lhs->nd_vid; if (op == tOROP) { lhs->nd_value = rhs; - asgn = NEW_OP_ASGN_OR(gettable(vid, column), lhs); - nd_set_column(asgn, column); + asgn = NEW_OP_ASGN_OR(gettable(vid, location), lhs); + nd_set_lineno(asgn, location->first_line); + nd_set_column(asgn, location->first_column); if (is_notop_id(vid)) { switch (id_type(vid)) { case ID_GLOBAL: @@ -10789,23 +10942,24 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int } else if (op == tANDOP) { lhs->nd_value = rhs; - asgn = NEW_OP_ASGN_AND(gettable(vid, column), lhs); - nd_set_column(asgn, column); + asgn = NEW_OP_ASGN_AND(gettable(vid, location), lhs); + nd_set_lineno(asgn, location->first_line); + nd_set_column(asgn, location->first_column); } else { asgn = lhs; - asgn->nd_value = new_call(gettable(vid, column), op, new_list(rhs, column), column); + asgn->nd_value = new_call(gettable(vid, location), op, new_list(rhs, location), location); } } else { - asgn = new_begin(0, column); + asgn = new_begin(0, location); } return asgn; } static NODE * new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, - ID atype, ID attr, ID op, NODE *rhs, int column) + ID atype, ID attr, ID op, NODE *rhs, YYLTYPE *location) { NODE *asgn; @@ -10816,13 +10970,14 @@ new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, op = 1; } asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs); - nd_set_column(asgn, column); + nd_set_lineno(asgn, location->first_line); + nd_set_column(asgn, location->first_column); fixpos(asgn, lhs); return asgn; } static NODE * -new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int column) +new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, YYLTYPE *location) { NODE *asgn; @@ -10836,28 +10991,30 @@ new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rh asgn = NEW_OP_CDECL(lhs, op, rhs); } else { - asgn = new_begin(0, column); + asgn = new_begin(0, location); } fixpos(asgn, lhs); - nd_set_column(asgn, column); + nd_set_lineno(asgn, location->first_line); + nd_set_column(asgn, location->first_column); return asgn; } static NODE * -const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, int column) +const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, YYLTYPE *location) { NODE *colon2 = NEW_COLON2(head, mid); - nd_set_column(colon2, column); + nd_set_lineno(colon2, location->first_line); + nd_set_column(colon2, location->first_column); return colon2; } static NODE * -const_decl_gen(struct parser_params *parser, NODE *path, int column) +const_decl_gen(struct parser_params *parser, NODE *path, YYLTYPE *location) { if (in_def || in_single) { yyerror0("dynamic constant assignment"); } - return new_cdecl(0, 0, (path), column); + return new_cdecl(0, 0, (path), location); } #else static VALUE @@ -11208,7 +11365,7 @@ typedef struct { struct parser_params* parser; rb_encoding *enc; NODE *succ_block; - int column; + YYLTYPE *location; } reg_named_capture_assign_t; static int @@ -11229,23 +11386,23 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end, return ST_CONTINUE; } var = intern_cstr(s, len, enc); - node = node_assign(assignable(var, 0, arg->column), new_lit(ID2SYM(var), arg->column), arg->column); + node = node_assign(assignable(var, 0, arg->location), new_lit(ID2SYM(var), arg->location), arg->location); succ = arg->succ_block; - if (!succ) succ = new_begin(0, arg->column); - succ = block_append(succ, node, arg->column); + if (!succ) succ = new_begin(0, arg->location); + succ = block_append(succ, node, arg->location); arg->succ_block = succ; return ST_CONTINUE; } static NODE * -reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, int column) +reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, YYLTYPE *location) { reg_named_capture_assign_t arg; arg.parser = parser; arg.enc = rb_enc_get(regexp); arg.succ_block = 0; - arg.column = column; + arg.location = location; onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg); if (!arg.succ_block) return 0; @@ -11313,23 +11470,25 @@ rb_parser_set_options(VALUE vparser, int print, int loop, int chomp, int split) static NODE * parser_append_options(struct parser_params *parser, NODE *node) { + struct YYLTYPE default_location = {1, 0, 1, 0}; + if (parser->do_print) { node = block_append(node, new_fcall(rb_intern("print"), - NEW_ARRAY(new_gvar(idLASTLINE, 0)), 0), - 0); + NEW_ARRAY(new_gvar(idLASTLINE, &default_location)), &default_location), + &default_location); } if (parser->do_loop) { if (parser->do_split) { node = block_append(NEW_GASGN(rb_intern("$F"), - new_call(new_gvar(idLASTLINE, 0), - rb_intern("split"), 0, 0)), - node, 0); + new_call(new_gvar(idLASTLINE, &default_location), + rb_intern("split"), 0, &default_location)), + node, &default_location); } if (parser->do_chomp) { - node = block_append(new_call(new_gvar(idLASTLINE, 0), - rb_intern("chomp!"), 0, 0), node, 0); + node = block_append(new_call(new_gvar(idLASTLINE, &default_location), + rb_intern("chomp!"), 0, &default_location), node, &default_location); } node = NEW_WHILE(NEW_VCALL(idGets), node, 1);