diff options
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 1545 |
1 files changed, 1022 insertions, 523 deletions
@@ -266,7 +266,8 @@ struct parser_params { #define TOK_INTERN() intern_cstr(tok(), toklen(), current_enc) static int parser_yyerror(struct parser_params*, const char*); -#define yyerror(msg) parser_yyerror(parser, (msg)) +#define yyerror0(msg) parser_yyerror(parser, (msg)) +#define yyerror(yylloc, parser, msg) yyerror0(msg) #define token_flush(p) ((p)->lex.ptok = (p)->lex.pcur) #define lex_strterm (parser->lex.strterm) @@ -315,13 +316,15 @@ static int parser_yyerror(struct parser_params*, const char*); #endif #define tokp lex.ptok +#define token_column ((int)(parser->tokp - lex_pbeg)) + #define CALL_Q_P(q) ((q) == TOKEN2VAL(tANDDOT)) #define NODE_CALL_Q(q) (CALL_Q_P(q) ? NODE_QCALL : NODE_CALL) #define NEW_QCALL(q,r,m,a) NEW_NODE(NODE_CALL_Q(q),r,m,a) #define lambda_beginning_p() (lpar_beg && lpar_beg == paren_nest) -static enum yytokentype yylex(YYSTYPE*, struct parser_params*); +static enum yytokentype yylex(YYSTYPE*, YYLTYPE*, struct parser_params*); static inline void parser_set_line(NODE *n, int l) @@ -346,18 +349,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); -#define cond(node) cond_gen(parser, (node), FALSE) -#define method_cond(node) cond_gen(parser, (node), TRUE) +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) #define new_nil() NEW_NIL() -static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*); -#define new_if(cc,left,right) new_if_gen(parser, (cc), (left), (right)) -static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*); -#define new_unless(cc,left,right) new_unless_gen(parser, (cc), (left), (right)) -static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*); -#define logop(id,node1,node2) \ +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) \ logop_gen(parser, ((id)==idAND||(id)==idANDOP)?NODE_AND:NODE_OR, \ - (node1), (node2)) + (node1), (node2), (column)) static NODE *newline_node(NODE*); static void fixpos(NODE*,NODE*); @@ -376,30 +379,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*); -#define block_append(h,t) block_append_gen(parser,(h),(t)) -static NODE *list_append_gen(struct parser_params*,NODE*,NODE*); -#define list_append(l,i) list_append_gen(parser,(l),(i)) +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 *list_concat(NODE*,NODE*); -static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*); -#define arg_append(h,t) arg_append_gen(parser,(h),(t)) -static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*); -#define arg_concat(h,t) arg_concat_gen(parser,(h),(t)) -static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*); -#define literal_concat(h,t) literal_concat_gen(parser,(h),(t)) +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 int literal_concat0(struct parser_params *, VALUE, VALUE); -static NODE *new_evstr_gen(struct parser_params*,NODE*); -#define new_evstr(n) new_evstr_gen(parser,(n)) -static NODE *evstr2dstr_gen(struct parser_params*,NODE*); -#define evstr2dstr(n) evstr2dstr_gen(parser,(n)) +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 *splat_array(NODE*); -static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*); -#define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, (recv),(id),(arg1)) -static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID); -#define call_uni_op(recv,id) call_uni_op_gen(parser, (recv),(id)) -#define new_qcall(q,r,m,a) NEW_QCALL(q,r,m,a) -#define new_command_qcall(q,r,m,a) NEW_QCALL(q,r,m,a) +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 *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;} @@ -407,68 +411,135 @@ 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); -#define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b)) -#define new_kw_arg(k) ((k) ? NEW_KW_ARG(0, (k)) : 0) +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 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*); -#define new_yield(node) new_yield_gen(parser, (node)) -static NODE *dsym_node_gen(struct parser_params*,NODE*); -#define dsym_node(node) dsym_node_gen(parser, (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 *gettable_gen(struct parser_params*,ID); -#define gettable(id) gettable_gen(parser,(id)) -static NODE *assignable_gen(struct parser_params*,ID,NODE*); -#define assignable(id,node) assignable_gen(parser, (id), (node)) +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 *aryset_gen(struct parser_params*,NODE*,NODE*); -#define aryset(node1,node2) aryset_gen(parser, (node1), (node2)) -static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID); -#define attrset(node,q,id) attrset_gen(parser, (node), (q), (id)) +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 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*); -#define node_assign(node1, node2) node_assign_gen(parser, (node1), (node2)) +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 *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs); -static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs); -#define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs)) -static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs); -#define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs)) +static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int 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)) -#define const_path_field(w, n) NEW_COLON2(w, n) +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) #define top_const_field(n) NEW_COLON3(n) -static NODE *const_decl_gen(struct parser_params *parser, NODE* path); -#define const_decl(path) const_decl_gen(parser, path) +static NODE *const_decl_gen(struct parser_params *parser, NODE* path, int column); +#define const_decl(path, column) const_decl_gen(parser, path, column) #define var_field(n) (n) -#define backref_assign_error(n, a) (rb_backref_error(n), NEW_BEGIN(0)) +#define backref_assign_error(n, a, column) (rb_backref_error(n), new_begin(0, column)) static NODE *kwd_append(NODE*, NODE*); -static NODE *new_hash_gen(struct parser_params *parser, NODE *hash); -#define new_hash(hash) new_hash_gen(parser, (hash)) +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_defined_gen(struct parser_params *parser, NODE *expr, int column); +#define new_defined(expr, column) new_defined_gen(parser, expr, column) + +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_lit_gen(struct parser_params *parser, VALUE sym, int column); +#define new_lit(sym, column) new_lit_gen(parser, sym, column) + +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_str_gen(struct parser_params *parser, VALUE str, int column); +#define new_str(s,column) new_str_gen(parser, s, column) + +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_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_errinfo_gen(struct parser_params *parser, int column); +#define new_errinfo(column) new_errinfo_gen(parser, column) + +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_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_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_gvar_gen(struct parser_params *parser, ID id, int column); +#define new_gvar(id, column) new_gvar_gen(parser, id, column) -#define new_defined(expr) NEW_DEFINED(remove_begin_all(expr)) +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_regexp_gen(struct parser_params *, NODE *, int); -#define new_regexp(node, opt) new_regexp_gen(parser, node, opt) +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_xstring_gen(struct parser_params *, NODE *); -#define new_xstring(node) new_xstring_gen(parser, node) +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_undef_gen(struct parser_params *parser, NODE *i, int column); +#define new_undef(i, column) new_undef_gen(parser, i, column) + +static NODE *new_zarray_gen(struct parser_params *parser, int column); +#define new_zarray(column) new_zarray_gen(parser, column) + +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_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_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_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_begin_gen(struct parser_params *parser, NODE *b, int column); +#define new_begin(b,column) new_begin_gen(parser,b,column) + +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_xstring_gen(struct parser_params *, NODE *, int column); +#define new_xstring(node, column) new_xstring_gen(parser, node, column) #define new_string1(str) (str) -#define new_brace_body(param, stmt) NEW_ITER(param, stmt) -#define new_do_body(param, stmt) NEW_ITER(param, stmt) +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 *match_op_gen(struct parser_params*,NODE*,NODE*); -#define match_op(node1,node2) match_op_gen(parser, (node1), (node2)) +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 ID *local_tbl_gen(struct parser_params*); #define local_tbl() local_tbl_gen(parser) @@ -479,8 +550,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); -#define reg_named_capture_assign(regexp) reg_named_capture_assign_gen(parser,(regexp)) +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 *parser_heredoc_dedent(struct parser_params*,NODE*); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) @@ -511,48 +582,48 @@ 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) assignable_gen(parser, (lhs)) +#define assignable(lhs,node,column) 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) (node) -#define call_bin_op(recv,id,arg1) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1)) -#define match_op(node1,node2) call_bin_op((node1), idEqTilde, (node2)) -#define call_uni_op(recv,id) dispatch2(unary, STATIC_ID2SYM(id), (recv)) -#define logop(id,node1,node2) call_bin_op((node1), (id), (node2)) -#define node_assign(node1, node2) dispatch2(assign, (node1), (node2)) +#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)) static VALUE new_qcall_gen(struct parser_params *parser, VALUE q, VALUE r, VALUE m, VALUE a); -#define new_qcall(q,r,m,a) new_qcall_gen(parser, (r), (q), (m), (a)) -#define new_command_qcall(q,r,m,a) dispatch4(command_call, (r), (q), (m), (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_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); +static VALUE new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs, int column); 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) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs)) -#define new_const_op_assign(lhs, op, rhs) new_op_assign(lhs, op, 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) static VALUE new_regexp_gen(struct parser_params *, VALUE, VALUE); -#define new_regexp(node, opt) new_regexp_gen(parser, node, opt) +#define new_regexp(node, opt, column) new_regexp_gen(parser, node, opt) static VALUE new_xstring_gen(struct parser_params *, VALUE); -#define new_xstring(str) new_xstring_gen(parser, str) +#define new_xstring(str, column) new_xstring_gen(parser, str) #define new_string1(str) dispatch1(string_literal, str) -#define new_brace_body(param, stmt) dispatch2(brace_block, escape_Qundef(param), stmt) -#define new_do_body(param, stmt) dispatch2(do_block, escape_Qundef(param), stmt) +#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 const_path_field(w, n) dispatch2(const_path_field, (w), (n)) +#define const_path_field(w, n, column) 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) const_decl_gen(parser, path) +#define const_decl(path, column) 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) assign_error(a) +#define backref_assign_error(n, a, column) assign_error(a) #define block_dup_check(n1,n2) ((void)(n1), (void)(n2)) #define fixpos(n1,n2) ((void)(n1), (void)(n2)) @@ -563,7 +634,7 @@ static VALUE parser_reg_compile(struct parser_params*, VALUE, int, VALUE *); #endif /* !RIPPER */ -#define new_op_assign(lhs, op, rhs) new_op_assign_gen(parser, (lhs), (op), (rhs)) +#define new_op_assign(lhs, op, rhs, column) new_op_assign_gen(parser, (lhs), (op), (rhs), (column)) RUBY_SYMBOL_EXPORT_BEGIN VALUE rb_parser_reg_compile(struct parser_params* parser, VALUE str, int options); @@ -723,9 +794,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) new_args_tail_gen(parser, (k),(kr),(b)) +#define new_args_tail(k,kr,b,column) new_args_tail_gen(parser, (k),(kr),(b)) -#define new_defined(expr) dispatch1(defined, (expr)) +#define new_defined(expr,column) dispatch1(defined, (expr)) static VALUE parser_heredoc_dedent(struct parser_params*,VALUE); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) @@ -1012,7 +1083,7 @@ program : { void_expr(node->nd_head); } } - ruby_eval_tree = NEW_SCOPE(0, block_append(ruby_eval_tree, $2)); + ruby_eval_tree = new_scope(0, block_append(ruby_eval_tree, $2, @1.first_column), @1.first_column); /*% $$ = $2; parser->result = dispatch1(program, $$); @@ -1034,7 +1105,7 @@ top_compstmt : top_stmts opt_terms top_stmts : none { /*%%%*/ - $$ = NEW_BEGIN(0); + $$ = new_begin(0, @1.first_column); /*% $$ = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); @@ -1051,7 +1122,7 @@ top_stmts : none | top_stmts terms top_stmt { /*%%%*/ - $$ = block_append($1, newline_node($3)); + $$ = block_append($1, newline_node($3), @1.first_column); /*% $$ = dispatch2(stmts_add, $1, $3); %*/ @@ -1074,10 +1145,10 @@ top_stmt : stmt { /*%%%*/ ruby_eval_tree_begin = block_append(ruby_eval_tree_begin, - $4); + $4, @1.first_column); /* NEW_PREEXE($4)); */ /* local_pop(); */ - $$ = NEW_BEGIN(0); + $$ = new_begin(0, @1.first_column); /*% $$ = dispatch1(BEGIN, $4); %*/ @@ -1092,18 +1163,21 @@ bodystmt : compstmt /*%%%*/ $$ = $1; if ($2) { - $$ = NEW_RESCUE($1, $2, $3); + $$ = new_rescue($1, $2, $3, @1.first_column); } else if ($3) { rb_warn0("else without rescue is useless"); - $$ = block_append($$, $3); + $$ = block_append($$, $3, @1.first_column); } if ($4) { if ($$) { $$ = NEW_ENSURE($$, $4); + nd_set_column($$, @1.first_column); } else { - $$ = block_append($4, NEW_NIL()); + NODE *nil = NEW_NIL(); + nd_set_column(nil, @1.first_column); + $$ = block_append($4, nil, @1.first_column); } } fixpos($$, $1); @@ -1130,7 +1204,7 @@ compstmt : stmts opt_terms stmts : none { /*%%%*/ - $$ = NEW_BEGIN(0); + $$ = new_begin(0, @1.first_column); /*% $$ = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); @@ -1147,7 +1221,7 @@ stmts : none | stmts terms stmt_or_begin { /*%%%*/ - $$ = block_append($1, newline_node($3)); + $$ = block_append($1, newline_node($3), @1.first_column); /*% $$ = dispatch2(stmts_add, $1, $3); %*/ @@ -1164,7 +1238,7 @@ stmt_or_begin : stmt } | keyword_BEGIN { - yyerror("BEGIN is permitted only at toplevel"); + yyerror0("BEGIN is permitted only at toplevel"); /*%%%*/ /* local_push(0); */ /*% @@ -1174,10 +1248,10 @@ stmt_or_begin : stmt { /*%%%*/ ruby_eval_tree_begin = block_append(ruby_eval_tree_begin, - $4); + $4, @1.first_column); /* NEW_PREEXE($4)); */ /* local_pop(); */ - $$ = NEW_BEGIN(0); + $$ = new_begin(0, @1.first_column); /*% $$ = dispatch1(BEGIN, $4); %*/ @@ -1188,6 +1262,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ $$ = NEW_ALIAS($2, $4); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(alias, $2, $4); %*/ @@ -1196,6 +1271,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ $$ = NEW_VALIAS($2, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(var_alias, $2, $3); %*/ @@ -1207,6 +1283,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_column($$, @1.first_column); /*% $$ = dispatch2(var_alias, $2, $3); %*/ @@ -1214,8 +1291,8 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | keyword_alias tGVAR tNTH_REF { /*%%%*/ - yyerror("can't make alias for the number variables"); - $$ = NEW_BEGIN(0); + yyerror0("can't make alias for the number variables"); + $$ = new_begin(0, @1.first_column); /*% $$ = dispatch2(var_alias, $2, $3); $$ = dispatch1(alias_error, $$); @@ -1233,7 +1310,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); + $$ = new_if($3, remove_begin($1), 0, @1.first_column); fixpos($$, $3); /*% $$ = dispatch2(if_mod, $3, $1); @@ -1242,7 +1319,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); + $$ = new_unless($3, remove_begin($1), 0, @1.first_column); fixpos($$, $3); /*% $$ = dispatch2(unless_mod, $3, $1); @@ -1252,11 +1329,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->nd_body, 0); + $$ = NEW_WHILE(cond($3, @1.first_column), $1->nd_body, 0); } else { - $$ = NEW_WHILE(cond($3), $1, 1); + $$ = NEW_WHILE(cond($3, @1.first_column), $1, 1); } + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(while_mod, $3, $1); %*/ @@ -1265,11 +1343,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->nd_body, 0); + $$ = NEW_UNTIL(cond($3, @1.first_column), $1->nd_body, 0); } else { - $$ = NEW_UNTIL(cond($3), $1, 1); + $$ = NEW_UNTIL(cond($3, @1.first_column), $1, 1); } + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(until_mod, $3, $1); %*/ @@ -1277,8 +1356,9 @@ 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); - $$ = NEW_RESCUE(remove_begin($1), resq, 0); + NODE *resq = new_resbody(0, remove_begin($3), 0, @1.first_column); + $$ = new_rescue(remove_begin($1), resq, 0, @1.first_column); + nd_set_column(resq, @1.first_column); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -1289,8 +1369,13 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem rb_warn0("END in method; use at_exit"); } /*%%%*/ - $$ = NEW_POSTEXE(NEW_NODE( - NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */)); + { + NODE *scope = NEW_NODE( + NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */); + $$ = NEW_POSTEXE(scope); + nd_set_column(scope, @1.first_column); + nd_set_column($$, @1.first_column); + } /*% $$ = dispatch1(END, $3); %*/ @@ -1309,7 +1394,7 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem | lhs '=' mrhs { value_expr($3); - $$ = node_assign($1, $3); + $$ = node_assign($1, $3, @1.first_column); } | mlhs '=' mrhs_arg { @@ -1326,12 +1411,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); + $$ = node_assign($1, $3, @1.first_column); } | var_lhs tOP_ASGN command_rhs { value_expr($3); - $$ = new_op_assign($1, $2, $3); + $$ = new_op_assign($1, $2, $3, @1.first_column); } | primary_value '[' opt_call_args rbracket tOP_ASGN command_rhs { @@ -1339,8 +1424,8 @@ command_asgn : lhs '=' command_rhs NODE *args; value_expr($6); - if (!$3) $3 = NEW_ZARRAY(); - args = arg_concat($3, $6); + if (!$3) $3 = new_zarray(@1.first_column); + args = arg_concat($3, $6, @1.first_column); if ($5 == tOROP) { $5 = 0; } @@ -1349,6 +1434,7 @@ command_asgn : lhs '=' command_rhs } $$ = NEW_OP_ASGN1($1, $5, args); fixpos($$, $1); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); $$ = dispatch3(opassign, $$, $5, $6); @@ -1357,27 +1443,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); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); } | primary_value call_op tCONSTANT tOP_ASGN command_rhs { value_expr($5); - $$ = new_attr_op_assign($1, $2, $3, $4, $5); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); } | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs { - $$ = const_path_field($1, $3); - $$ = new_const_op_assign($$, $4, $5); + $$ = const_path_field($1, $3, @1.first_column); + $$ = new_const_op_assign($$, $4, $5, @1.first_column); } | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs { value_expr($5); - $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5); + $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, @1.first_column); } | backref tOP_ASGN command_rhs { $1 = var_field($1); - $$ = backref_assign_error($1, node_assign($1, $3)); + $$ = backref_assign_error($1, node_assign($1, $3, @1.first_column), @1.first_column); } ; @@ -1393,7 +1479,7 @@ command_rhs : command_call %prec tOP_ASGN { /*%%%*/ value_expr($1); - $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0), 0); + $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, @1.first_column), 0, @1.first_column); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -1404,19 +1490,19 @@ command_rhs : command_call %prec tOP_ASGN expr : command_call | expr keyword_and expr { - $$ = logop(idAND, $1, $3); + $$ = logop(idAND, $1, $3, @1.first_column); } | expr keyword_or expr { - $$ = logop(idOR, $1, $3); + $$ = logop(idOR, $1, $3, @1.first_column); } | keyword_not opt_nl expr { - $$ = call_uni_op(method_cond($3), METHOD_NOT); + $$ = call_uni_op(method_cond($3, @1.first_column), METHOD_NOT, @1.first_column); } | '!' command_call { - $$ = call_uni_op(method_cond($2), '!'); + $$ = call_uni_op(method_cond($2, @1.first_column), '!', @1.first_column); } | arg ; @@ -1440,7 +1526,7 @@ command_call : command block_command : block_call | block_call call_op2 operation2 command_args { - $$ = new_qcall($2, $1, $3, $4); + $$ = new_qcall($2, $1, $3, $4, @1.first_column); } ; @@ -1463,7 +1549,7 @@ cmd_brace_block : tLBRACE_ARG fcall : operation { /*%%%*/ - $$ = NEW_FCALL($1, 0); + $$ = new_fcall($1, 0, @1.first_column); nd_set_line($$, tokline); /*% %*/ @@ -1488,25 +1574,25 @@ command : fcall command_args %prec tLOWEST } | primary_value call_op operation2 command_args %prec tLOWEST { - $$ = new_command_qcall($2, $1, $3, $4); + $$ = new_command_qcall($2, $1, $3, $4, @1.first_column); fixpos($$, $1); } | primary_value call_op operation2 command_args cmd_brace_block { block_dup_check($4,$5); - $$ = new_command_qcall($2, $1, $3, $4); + $$ = new_command_qcall($2, $1, $3, $4, @1.first_column); $$ = method_add_block($$, $5); fixpos($$, $1); } | primary_value tCOLON2 operation2 command_args %prec tLOWEST { - $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4); + $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, @1.first_column); fixpos($$, $1); } | primary_value tCOLON2 operation2 command_args cmd_brace_block { block_dup_check($4,$5); - $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4); + $$ = new_command_qcall(ID2VAL(idCOLON2), $1, $3, $4, @1.first_column); $$ = method_add_block($$, $5); fixpos($$, $1); } @@ -1515,6 +1601,7 @@ command : fcall command_args %prec tLOWEST /*%%%*/ $$ = NEW_SUPER($2); fixpos($$, $2); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(super, $2); %*/ @@ -1522,7 +1609,7 @@ command : fcall command_args %prec tLOWEST | keyword_yield command_args { /*%%%*/ - $$ = new_yield($2); + $$ = new_yield($2, @1.first_column); fixpos($$, $2); /*% $$ = dispatch1(yield, $2); @@ -1532,6 +1619,7 @@ command : fcall command_args %prec tLOWEST { /*%%%*/ $$ = NEW_RETURN(ret_args($2)); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(return, $2); %*/ @@ -1540,6 +1628,7 @@ command : fcall command_args %prec tLOWEST { /*%%%*/ $$ = NEW_BREAK(ret_args($2)); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(break, $2); %*/ @@ -1548,6 +1637,7 @@ command : fcall command_args %prec tLOWEST { /*%%%*/ $$ = NEW_NEXT(ret_args($2)); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(next, $2); %*/ @@ -1569,7 +1659,7 @@ mlhs_inner : mlhs_basic | tLPAREN mlhs_inner rparen { /*%%%*/ - $$ = NEW_MASGN(NEW_LIST($2), 0); + $$ = new_masgn(new_list($2, @1.first_column), 0, @1.first_column); /*% $$ = dispatch1(mlhs_paren, $2); %*/ @@ -1579,7 +1669,7 @@ mlhs_inner : mlhs_basic mlhs_basic : mlhs_head { /*%%%*/ - $$ = NEW_MASGN($1, 0); + $$ = new_masgn($1, 0, @1.first_column); /*% $$ = $1; %*/ @@ -1587,7 +1677,7 @@ mlhs_basic : mlhs_head | mlhs_head mlhs_item { /*%%%*/ - $$ = NEW_MASGN(list_append($1,$2), 0); + $$ = new_masgn(list_append($1,$2,@1.first_column), 0, @1.first_column); /*% $$ = mlhs_add($1, $2); %*/ @@ -1595,7 +1685,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR mlhs_node { /*%%%*/ - $$ = NEW_MASGN($1, $3); + $$ = new_masgn($1, $3, @1.first_column); /*% $$ = mlhs_add_star($1, $3); %*/ @@ -1603,7 +1693,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR mlhs_node ',' mlhs_post { /*%%%*/ - $$ = NEW_MASGN($1, NEW_POSTARG($3,$5)); + $$ = new_masgn($1, new_postarg($3,$5,@1.first_column), @1.first_column); /*% $1 = mlhs_add_star($1, $3); $$ = mlhs_add_post($1, $5); @@ -1612,7 +1702,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR { /*%%%*/ - $$ = NEW_MASGN($1, -1); + $$ = new_masgn($1, (NODE *)-1, @1.first_column); /*% $$ = mlhs_add_star($1, Qnil); %*/ @@ -1620,7 +1710,7 @@ mlhs_basic : mlhs_head | mlhs_head tSTAR ',' mlhs_post { /*%%%*/ - $$ = NEW_MASGN($1, NEW_POSTARG(-1, $4)); + $$ = new_masgn($1, new_postarg((NODE *)-1, $4, @1.first_column), @1.first_column); /*% $1 = mlhs_add_star($1, Qnil); $$ = mlhs_add_post($1, $4); @@ -1629,7 +1719,7 @@ mlhs_basic : mlhs_head | tSTAR mlhs_node { /*%%%*/ - $$ = NEW_MASGN(0, $2); + $$ = new_masgn(0, $2, @1.first_column); /*% $$ = mlhs_add_star(mlhs_new(), $2); %*/ @@ -1637,7 +1727,7 @@ mlhs_basic : mlhs_head | tSTAR mlhs_node ',' mlhs_post { /*%%%*/ - $$ = NEW_MASGN(0, NEW_POSTARG($2,$4)); + $$ = new_masgn(0, new_postarg($2,$4,@1.first_column), @1.first_column); /*% $2 = mlhs_add_star(mlhs_new(), $2); $$ = mlhs_add_post($2, $4); @@ -1646,7 +1736,7 @@ mlhs_basic : mlhs_head | tSTAR { /*%%%*/ - $$ = NEW_MASGN(0, -1); + $$ = new_masgn(0, (NODE *)-1, @1.first_column); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); %*/ @@ -1654,7 +1744,7 @@ mlhs_basic : mlhs_head | tSTAR ',' mlhs_post { /*%%%*/ - $$ = NEW_MASGN(0, NEW_POSTARG(-1, $3)); + $$ = new_masgn(0, new_postarg((NODE *)-1, $3, @1.first_column), @1.first_column); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); $$ = mlhs_add_post($$, $3); @@ -1676,7 +1766,7 @@ mlhs_item : mlhs_node mlhs_head : mlhs_item ',' { /*%%%*/ - $$ = NEW_LIST($1); + $$ = new_list($1, @1.first_column); /*% $$ = mlhs_add(mlhs_new(), $1); %*/ @@ -1684,7 +1774,7 @@ mlhs_head : mlhs_item ',' | mlhs_head mlhs_item ',' { /*%%%*/ - $$ = list_append($1, $2); + $$ = list_append($1, $2, @1.first_column); /*% $$ = mlhs_add($1, $2); %*/ @@ -1694,7 +1784,7 @@ mlhs_head : mlhs_item ',' mlhs_post : mlhs_item { /*%%%*/ - $$ = NEW_LIST($1); + $$ = new_list($1, @1.first_column); /*% $$ = mlhs_add(mlhs_new(), $1); %*/ @@ -1702,7 +1792,7 @@ mlhs_post : mlhs_item | mlhs_post ',' mlhs_item { /*%%%*/ - $$ = list_append($1, $3); + $$ = list_append($1, $3, @1.first_column); /*% $$ = mlhs_add($1, $3); %*/ @@ -1711,16 +1801,16 @@ mlhs_post : mlhs_item mlhs_node : user_variable { - $$ = assignable(var_field($1), 0); + $$ = assignable(var_field($1), 0, @1.first_column); } | keyword_variable { - $$ = assignable(var_field($1), 0); + $$ = assignable(var_field($1), 0, @1.first_column); } | primary_value '[' opt_call_args rbracket { /*%%%*/ - $$ = aryset($1, $3); + $$ = aryset($1, $3, @1.first_column); /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); %*/ @@ -1728,7 +1818,7 @@ mlhs_node : user_variable | primary_value call_op tIDENTIFIER { /*%%%*/ - $$ = attrset($1, $2, $3); + $$ = attrset($1, $2, $3, @1.first_column); /*% $$ = dispatch3(field, $1, $2, $3); %*/ @@ -1736,7 +1826,7 @@ mlhs_node : user_variable | primary_value tCOLON2 tIDENTIFIER { /*%%%*/ - $$ = attrset($1, idCOLON2, $3); + $$ = attrset($1, idCOLON2, $3, @1.first_column); /*% $$ = dispatch2(const_path_field, $1, $3); %*/ @@ -1744,46 +1834,46 @@ mlhs_node : user_variable | primary_value call_op tCONSTANT { /*%%%*/ - $$ = attrset($1, $2, $3); + $$ = attrset($1, $2, $3, @1.first_column); /*% $$ = dispatch3(field, $1, $2, $3); %*/ } | primary_value tCOLON2 tCONSTANT { - $$ = const_decl(const_path_field($1, $3)); + $$ = const_decl(const_path_field($1, $3, @1.first_column), @1.first_column); } | tCOLON3 tCONSTANT { - $$ = const_decl(top_const_field($2)); + $$ = const_decl(top_const_field($2), @1.first_column); } | backref { $1 = var_field($1); - $$ = backref_assign_error($1, $1); + $$ = backref_assign_error($1, $1, @1.first_column); } ; lhs : user_variable { - $$ = assignable(var_field($1), 0); + $$ = assignable(var_field($1), 0, @1.first_column); /*%%%*/ - if (!$$) $$ = NEW_BEGIN(0); + if (!$$) $$ = new_begin(0, @1.first_column); /*% %*/ } | keyword_variable { - $$ = assignable(var_field($1), 0); + $$ = assignable(var_field($1), 0, @1.first_column); /*%%%*/ - if (!$$) $$ = NEW_BEGIN(0); + if (!$$) $$ = new_begin(0, @1.first_column); /*% %*/ } | primary_value '[' opt_call_args rbracket { /*%%%*/ - $$ = aryset($1, $3); + $$ = aryset($1, $3, @1.first_column); /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); %*/ @@ -1791,7 +1881,7 @@ lhs : user_variable | primary_value call_op tIDENTIFIER { /*%%%*/ - $$ = attrset($1, $2, $3); + $$ = attrset($1, $2, $3, @1.first_column); /*% $$ = dispatch3(field, $1, $2, $3); %*/ @@ -1799,7 +1889,7 @@ lhs : user_variable | primary_value tCOLON2 tIDENTIFIER { /*%%%*/ - $$ = attrset($1, idCOLON2, $3); + $$ = attrset($1, idCOLON2, $3, @1.first_column); /*% $$ = dispatch3(field, $1, ID2VAL(idCOLON2), $3); %*/ @@ -1807,30 +1897,30 @@ lhs : user_variable | primary_value call_op tCONSTANT { /*%%%*/ - $$ = attrset($1, $2, $3); + $$ = attrset($1, $2, $3, @1.first_column); /*% $$ = dispatch3(field, $1, $2, $3); %*/ } | primary_value tCOLON2 tCONSTANT { - $$ = const_decl(const_path_field($1, $3)); + $$ = const_decl(const_path_field($1, $3, @1.first_column), @1.first_column); } | tCOLON3 tCONSTANT { - $$ = const_decl(top_const_field($2)); + $$ = const_decl(top_const_field($2), @1.first_column); } | backref { $1 = var_field($1); - $$ = backref_assign_error($1, $1); + $$ = backref_assign_error($1, $1, @1.first_column); } ; cname : tIDENTIFIER { /*%%%*/ - yyerror("class/module name must be CONSTANT"); + yyerror0("class/module name must be CONSTANT"); /*% $$ = dispatch1(class_name_error, $1); ripper_error(); @@ -1851,6 +1941,7 @@ cpath : tCOLON3 cname { /*%%%*/ $$ = NEW_COLON2(0, $$); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(const_ref, $1); %*/ @@ -1859,6 +1950,7 @@ cpath : tCOLON3 cname { /*%%%*/ $$ = NEW_COLON2($1, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(const_path_ref, $1, $3); %*/ @@ -1887,7 +1979,7 @@ fsym : fname fitem : fsym { /*%%%*/ - $$ = NEW_LIT(ID2SYM($1)); + $$ = new_lit(ID2SYM($1), @1.first_column); /*% $$ = dispatch1(symbol_literal, $1); %*/ @@ -1898,7 +1990,7 @@ fitem : fsym undef_list : fitem { /*%%%*/ - $$ = NEW_UNDEF($1); + $$ = new_undef($1, @1.first_column); /*% $$ = rb_ary_new3(1, get_value($1)); %*/ @@ -1906,7 +1998,8 @@ undef_list : fitem | undef_list ',' {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ - $$ = block_append($1, NEW_UNDEF($4)); + NODE *undef = new_undef($4, @1.first_column); + $$ = block_append($1, undef, @1.first_column); /*% rb_ary_push($1, get_value($4)); %*/ @@ -1961,11 +2054,11 @@ reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__ arg : lhs '=' arg_rhs { - $$ = node_assign($1, $3); + $$ = node_assign($1, $3, @1.first_column); } | var_lhs tOP_ASGN arg_rhs { - $$ = new_op_assign($1, $2, $3); + $$ = new_op_assign($1, $2, $3, @1.first_column); } | primary_value '[' opt_call_args rbracket tOP_ASGN arg_rhs { @@ -1973,12 +2066,13 @@ arg : lhs '=' arg_rhs NODE *args; value_expr($6); - if (!$3) $3 = NEW_ZARRAY(); + if (!$3) $3 = new_zarray(@1.first_column); if (nd_type($3) == NODE_BLOCK_PASS) { args = NEW_ARGSCAT($3, $6); + nd_set_column(args, @1.first_column); } else { - args = arg_concat($3, $6); + args = arg_concat($3, $6, @1.first_column); } if ($5 == tOROP) { $5 = 0; @@ -1988,6 +2082,7 @@ arg : lhs '=' arg_rhs } $$ = NEW_OP_ASGN1($1, $5, args); fixpos($$, $1); + nd_set_column($$, @1.first_column); /*% $1 = dispatch2(aref_field, $1, escape_Qundef($3)); $$ = dispatch3(opassign, $1, $5, $6); @@ -1996,32 +2091,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); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); } | primary_value call_op tCONSTANT tOP_ASGN arg_rhs { value_expr($5); - $$ = new_attr_op_assign($1, $2, $3, $4, $5); + $$ = new_attr_op_assign($1, $2, $3, $4, $5, @1.first_column); } | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg_rhs { value_expr($5); - $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5); + $$ = new_attr_op_assign($1, ID2VAL(idCOLON2), $3, $4, $5, @1.first_column); } | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs { - $$ = const_path_field($1, $3); - $$ = new_const_op_assign($$, $4, $5); + $$ = const_path_field($1, $3, @1.first_column); + $$ = new_const_op_assign($$, $4, $5, @1.first_column); } | tCOLON3 tCONSTANT tOP_ASGN arg_rhs { $$ = top_const_field($2); - $$ = new_const_op_assign($$, $3, $4); + $$ = new_const_op_assign($$, $3, $4, @1.first_column); } | backref tOP_ASGN arg_rhs { $1 = var_field($1); - $$ = backref_assign_error($1, new_op_assign($1, $2, $3)); + $$ = backref_assign_error($1, new_op_assign($1, $2, $3, @1.first_column), @1.first_column); } | arg tDOT2 arg { @@ -2029,6 +2124,7 @@ arg : lhs '=' arg_rhs value_expr($1); value_expr($3); $$ = NEW_DOT2($1, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(dot2, $1, $3); %*/ @@ -2039,121 +2135,118 @@ arg : lhs '=' arg_rhs value_expr($1); value_expr($3); $$ = NEW_DOT3($1, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(dot3, $1, $3); %*/ } | arg '+' arg { - $$ = call_bin_op($1, '+', $3); + $$ = call_bin_op($1, '+', $3, @1.first_column); } | arg '-' arg { - $$ = call_bin_op($1, '-', $3); + $$ = call_bin_op($1, '-', $3, @1.first_column); } | arg '*' arg { - $$ = call_bin_op($1, '*', $3); + $$ = call_bin_op($1, '*', $3, @1.first_column); } | arg '/' arg { - $$ = call_bin_op($1, '/', $3); + $$ = call_bin_op($1, '/', $3, @1.first_column); } | arg '%' arg { - $$ = call_bin_op($1, '%', $3); + $$ = call_bin_op($1, '%', $3, @1.first_column); } | arg tPOW arg { - $$ = call_bin_op($1, idPow, $3); + $$ = call_bin_op($1, idPow, $3, @1.first_column); } | tUMINUS_NUM simple_numeric tPOW arg { - $$ = call_uni_op(call_bin_op($2, idPow, $4), idUMinus); + $$ = call_uni_op(call_bin_op($2, idPow, $4, @1.first_column), idUMinus, @1.first_column); } | tUPLUS arg { - $$ = call_uni_op($2, idUPlus); + $$ = call_uni_op($2, idUPlus, @1.first_column); } | tUMINUS arg { - $$ = call_uni_op($2, idUMinus); + $$ = call_uni_op($2, idUMinus, @1.first_column); } | arg '|' arg { - $$ = call_bin_op($1, '|', $3); + $$ = call_bin_op($1, '|', $3, @1.first_column); } | arg '^' arg { - $$ = call_bin_op($1, '^', $3); + $$ = call_bin_op($1, '^', $3, @1.first_column); } | arg '&' arg { - $$ = call_bin_op($1, '&', $3); + $$ = call_bin_op($1, '&', $3, @1.first_column); } | arg tCMP arg { - $$ = call_bin_op($1, idCmp, $3); + $$ = call_bin_op($1, idCmp, $3, @1.first_column); } | rel_expr %prec tCMP | arg tEQ arg { - $$ = call_bin_op($1, idEq, $3); + $$ = call_bin_op($1, idEq, $3, @1.first_column); } | arg tEQQ arg { - $$ = call_bin_op($1, idEqq, $3); + $$ = call_bin_op($1, idEqq, $3, @1.first_column); } | arg tNEQ arg { - $$ = call_bin_op($1, idNeq, $3); + $$ = call_bin_op($1, idNeq, $3, @1.first_column); } | arg tMATCH arg { - $$ = match_op($1, $3); + $$ = match_op($1, $3, @1.first_column); } | arg tNMATCH arg { - $$ = call_bin_op($1, idNeqTilde, $3); + $$ = call_bin_op($1, idNeqTilde, $3, @1.first_column); } | '!' arg { - $$ = call_uni_op(method_cond($2), '!'); + $$ = call_uni_op(method_cond($2, @1.first_column), '!', @1.first_column); } | '~' arg { - $$ = call_uni_op($2, '~'); + $$ = call_uni_op($2, '~', @1.first_column); } | arg tLSHFT arg { - $$ = call_bin_op($1, idLTLT, $3); + $$ = call_bin_op($1, idLTLT, $3, @1.first_column); } | arg tRSHFT arg { - $$ = call_bin_op($1, idGTGT, $3); + $$ = call_bin_op($1, idGTGT, $3, @1.first_column); } | arg tANDOP arg { - $$ = logop(idANDOP, $1, $3); + $$ = logop(idANDOP, $1, $3, @1.first_column); } | arg tOROP arg { - $$ = logop(idOROP, $1, $3); + $$ = logop(idOROP, $1, $3, @1.first_column); } | keyword_defined opt_nl {in_defined = 1;} arg { in_defined = 0; - /*%%%*/ - $$ = new_defined($4); - /*% - $$ = dispatch1(defined, $4); - %*/ + $$ = new_defined($4, @1.first_column); } | arg '?' arg opt_nl ':' arg { /*%%%*/ value_expr($1); - $$ = new_if($1, $3, $6); + $$ = new_if($1, $3, $6, @1.first_column); fixpos($$, $1); /*% $$ = dispatch3(ifop, $1, $3, $6); @@ -2173,12 +2266,12 @@ relop : '>' {$$ = '>';} rel_expr : arg relop arg %prec '>' { - $$ = call_bin_op($1, $2, $3); + $$ = call_bin_op($1, $2, $3, @1.first_column); } | rel_expr relop arg %prec '>' { rb_warning1("comparison '%s' after comparison", WARN_ID($2)); - $$ = call_bin_op($1, $2, $3); + $$ = call_bin_op($1, $2, $3, @1.first_column); } ; @@ -2202,7 +2295,7 @@ aref_args : none | args ',' assocs trailer { /*%%%*/ - $$ = $3 ? arg_append($1, new_hash($3)) : $1; + $$ = $3 ? arg_append($1, new_hash($3, @1.first_column), @1.first_column) : $1; /*% $$ = arg_add_assocs($1, $3); %*/ @@ -2210,7 +2303,7 @@ aref_args : none | assocs trailer { /*%%%*/ - $$ = $1 ? NEW_LIST(new_hash($1)) : 0; + $$ = $1 ? new_list(new_hash($1, @1.first_column), @1.first_column) : 0; /*% $$ = arg_add_assocs(arg_new(), $1); %*/ @@ -2229,7 +2322,7 @@ arg_rhs : arg %prec tOP_ASGN { /*%%%*/ value_expr($1); - $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0), 0); + $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, @1.first_column), 0, @1.first_column); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -2259,7 +2352,7 @@ opt_call_args : none | args ',' assocs ',' { /*%%%*/ - $$ = $3 ? arg_append($1, new_hash($3)) : $1; + $$ = $3 ? arg_append($1, new_hash($3, @1.first_column), @1.first_column) : $1; /*% $$ = arg_add_assocs($1, $3); %*/ @@ -2267,7 +2360,7 @@ opt_call_args : none | assocs ',' { /*%%%*/ - $$ = $1 ? NEW_LIST(new_hash($1)) : 0; + $$ = $1 ? new_list(new_hash($1, @1.first_column), @1.first_column) : 0; /*% $$ = arg_add_assocs(arg_new(), $1); %*/ @@ -2278,7 +2371,7 @@ call_args : command { /*%%%*/ value_expr($1); - $$ = NEW_LIST($1); + $$ = new_list($1, @1.first_column); /*% $$ = arg_add(arg_new(), $1); %*/ @@ -2294,7 +2387,7 @@ call_args : command | assocs opt_block_arg { /*%%%*/ - $$ = $1 ? NEW_LIST(new_hash($1)) : 0; + $$ = $1 ? new_list(new_hash($1, @1.first_column), @1.first_column) : 0; $$ = arg_blk_pass($$, $2); /*% $$ = arg_add_assocs(arg_new(), $1); @@ -2304,7 +2397,7 @@ call_args : command | args ',' assocs opt_block_arg { /*%%%*/ - $$ = $3 ? arg_append($1, new_hash($3)) : $1; + $$ = $3 ? arg_append($1, new_hash($3, @1.first_column), @1.first_column) : $1; $$ = arg_blk_pass($$, $4); /*% $$ = arg_add_optblock(arg_add_assocs($1, $3), $4); @@ -2335,6 +2428,7 @@ block_arg : tAMPER arg_value { /*%%%*/ $$ = NEW_BLOCK_PASS($2); + nd_set_column($$, @1.first_column); /*% $$ = $2; %*/ @@ -2354,7 +2448,7 @@ opt_block_arg : ',' block_arg args : arg_value { /*%%%*/ - $$ = NEW_LIST($1); + $$ = new_list($1, @1.first_column); /*% $$ = arg_add(arg_new(), $1); %*/ @@ -2363,6 +2457,7 @@ args : arg_value { /*%%%*/ $$ = NEW_SPLAT($2); + nd_set_column($$, @1.first_column); /*% $$ = arg_add_star(arg_new(), $2); %*/ @@ -2372,10 +2467,10 @@ args : arg_value /*%%%*/ NODE *n1; if ((n1 = splat_array($1)) != 0) { - $$ = list_append(n1, $3); + $$ = list_append(n1, $3, @1.first_column); } else { - $$ = arg_append($1, $3); + $$ = arg_append($1, $3, @1.first_column); } /*% $$ = arg_add($1, $3); @@ -2389,7 +2484,7 @@ args : arg_value $$ = list_concat(n1, $4); } else { - $$ = arg_concat($1, $4); + $$ = arg_concat($1, $4, @1.first_column); } /*% $$ = arg_add_star($1, $4); @@ -2406,10 +2501,10 @@ mrhs : args ',' arg_value /*%%%*/ NODE *n1; if ((n1 = splat_array($1)) != 0) { - $$ = list_append(n1, $3); + $$ = list_append(n1, $3, @1.first_column); } else { - $$ = arg_append($1, $3); + $$ = arg_append($1, $3, @1.first_column); } /*% $$ = mrhs_add(args2mrhs($1), $3); @@ -2424,7 +2519,7 @@ mrhs : args ',' arg_value $$ = list_concat(n1, $4); } else { - $$ = arg_concat($1, $4); + $$ = arg_concat($1, $4, @1.first_column); } /*% $$ = mrhs_add_star(args2mrhs($1), $4); @@ -2434,6 +2529,7 @@ mrhs : args ',' arg_value { /*%%%*/ $$ = NEW_SPLAT($2); + nd_set_column($$, @1.first_column); /*% $$ = mrhs_add_star(mrhs_new(), $2); %*/ @@ -2453,7 +2549,7 @@ primary : literal | tFID { /*%%%*/ - $$ = NEW_FCALL($1, 0); + $$ = new_fcall($1, 0, @1.first_column); /*% $$ = method_arg(dispatch1(fcall, $1), arg_new()); %*/ @@ -2474,10 +2570,11 @@ primary : literal /*%%%*/ if ($3 == NULL) { $$ = NEW_NIL(); + nd_set_column($$, @1.first_column); } else { set_line_body($3, $<num>2); - $$ = NEW_BEGIN($3); + $$ = new_begin($3, @1.first_column); } nd_set_line($$, $<num>2); /*% @@ -2487,7 +2584,7 @@ primary : literal | tLPAREN_ARG {SET_LEX_STATE(EXPR_ENDARG);} rparen { /*%%%*/ - $$ = NEW_BEGIN(0); + $$ = new_begin(0, @1.first_column); /*% $$ = dispatch1(paren, 0); %*/ @@ -2518,6 +2615,7 @@ primary : literal { /*%%%*/ $$ = NEW_COLON2($1, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(const_path_ref, $1, $3); %*/ @@ -2526,6 +2624,7 @@ primary : literal { /*%%%*/ $$ = NEW_COLON3($2); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(top_const_ref, $2); %*/ @@ -2534,7 +2633,7 @@ primary : literal { /*%%%*/ if ($2 == 0) { - $$ = NEW_ZARRAY(); /* zero length array*/ + $$ = new_zarray(@1.first_column); /* zero length array*/ } else { $$ = $2; @@ -2546,7 +2645,7 @@ primary : literal | tLBRACE assoc_list '}' { /*%%%*/ - $$ = new_hash($2); + $$ = new_hash($2, @1.first_column); $$->nd_alen = TRUE; /*% $$ = dispatch1(hash, escape_Qundef($2)); @@ -2556,6 +2655,7 @@ primary : literal { /*%%%*/ $$ = NEW_RETURN(0); + nd_set_column($$, @1.first_column); /*% $$ = dispatch0(return0); %*/ @@ -2563,7 +2663,7 @@ primary : literal | keyword_yield '(' call_args rparen { /*%%%*/ - $$ = new_yield($3); + $$ = new_yield($3, @1.first_column); /*% $$ = dispatch1(yield, dispatch1(paren, $3)); %*/ @@ -2572,6 +2672,7 @@ primary : literal { /*%%%*/ $$ = NEW_YIELD(0); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(yield, dispatch1(paren, arg_new())); %*/ @@ -2580,6 +2681,7 @@ primary : literal { /*%%%*/ $$ = NEW_YIELD(0); + nd_set_column($$, @1.first_column); /*% $$ = dispatch0(yield0); %*/ @@ -2587,19 +2689,15 @@ primary : literal | keyword_defined opt_nl '(' {in_defined = 1;} expr rparen { in_defined = 0; - /*%%%*/ - $$ = new_defined($5); - /*% - $$ = dispatch1(defined, $5); - %*/ + $$ = new_defined($5, @1.first_column); } | keyword_not '(' expr rparen { - $$ = call_uni_op(method_cond($3), METHOD_NOT); + $$ = call_uni_op(method_cond($3, @1.first_column), METHOD_NOT, @1.first_column); } | keyword_not '(' rparen { - $$ = call_uni_op(method_cond(new_nil()), METHOD_NOT); + $$ = call_uni_op(method_cond(new_nil(), @1.first_column), METHOD_NOT, @1.first_column); } | fcall brace_block { @@ -2632,7 +2730,7 @@ primary : literal k_end { /*%%%*/ - $$ = new_if($2, $4, $5); + $$ = new_if($2, $4, $5, @1.first_column); fixpos($$, $2); /*% $$ = dispatch3(if, $2, $4, escape_Qundef($5)); @@ -2644,7 +2742,7 @@ primary : literal k_end { /*%%%*/ - $$ = new_unless($2, $4, $5); + $$ = new_unless($2, $4, $5, @1.first_column); fixpos($$, $2); /*% $$ = dispatch3(unless, $2, $4, escape_Qundef($5)); @@ -2655,8 +2753,9 @@ primary : literal k_end { /*%%%*/ - $$ = NEW_WHILE(cond($3), $6, 1); + $$ = NEW_WHILE(cond($3, @1.first_column), $6, 1); fixpos($$, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(while, $3, $6); %*/ @@ -2666,8 +2765,9 @@ primary : literal k_end { /*%%%*/ - $$ = NEW_UNTIL(cond($3), $6, 1); + $$ = NEW_UNTIL(cond($3, @1.first_column), $6, 1); fixpos($$, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(until, $3, $6); %*/ @@ -2679,6 +2779,7 @@ primary : literal /*%%%*/ $$ = NEW_CASE($2, $4); fixpos($$, $2); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(case, $2, $4); %*/ @@ -2688,6 +2789,7 @@ primary : literal /*%%%*/ $$ = NEW_CASE(0, $3); nd_set_line($3, $<num>1); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(case, Qnil, $3); %*/ @@ -2716,25 +2818,29 @@ primary : literal switch (nd_type($2)) { case NODE_MASGN: - m->nd_next = node_assign($2, NEW_FOR(NEW_DVAR(id), 0, 0)); - args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0)); + 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)); break; case NODE_LASGN: case NODE_DASGN: case NODE_DASGN_CURR: - $2->nd_value = NEW_DVAR(id); + $2->nd_value = new_dvar(id, @1.first_column); m->nd_plen = 1; m->nd_next = $2; - args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0)); + args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0, @1.first_column)); break; default: - m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id)); - args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0)); - break; + { + 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)); + break; + } } scope = NEW_NODE(NODE_SCOPE, tbl, $8, args); + nd_set_column(scope, @1.first_column); tbl[0] = 1; tbl[1] = id; - $$ = NEW_FOR(0, $5, scope); + $$ = new_for(0, $5, scope, @1.first_column); fixpos($$, $2); /*% $$ = dispatch3(for, $2, $5, $8); @@ -2743,7 +2849,7 @@ primary : literal | k_class cpath superclass { if (in_def || in_single) - yyerror("class definition in method body"); + yyerror0("class definition in method body"); local_push(0); /*%%%*/ $<num>$ = ruby_sourceline; @@ -2755,8 +2861,10 @@ primary : literal { /*%%%*/ $$ = NEW_CLASS($2, $5, $3); + nd_set_column($$->nd_body, @1.first_column); set_line_body($5, $<num>4); nd_set_line($$, $<num>4); + nd_set_column($$, @1.first_column); /*% $$ = dispatch3(class, $2, $3, $5); %*/ @@ -2775,8 +2883,10 @@ primary : literal { /*%%%*/ $$ = NEW_SCLASS($3, $6); + nd_set_column($$->nd_body, @1.first_column); set_line_body($6, nd_line($3)); fixpos($$, $3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(sclass, $3, $6); %*/ @@ -2787,7 +2897,7 @@ primary : literal | k_module cpath { if (in_def || in_single) - yyerror("module definition in method body"); + yyerror0("module definition in method body"); local_push(0); /*%%%*/ $<num>$ = ruby_sourceline; @@ -2799,8 +2909,10 @@ primary : literal { /*%%%*/ $$ = NEW_MODULE($2, $4); + nd_set_column($$->nd_body, @1.first_column); set_line_body($4, $<num>3); nd_set_line($$, $<num>3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch2(module, $2, $4); %*/ @@ -2824,8 +2936,10 @@ primary : literal NODE *body = remove_begin($6); reduce_nodes(&body); $$ = NEW_DEFN($2, $5, body, METHOD_VISI_PRIVATE); + nd_set_column($$->nd_defn, @1.first_column); set_line_body(body, $<num>1); nd_set_line($$, $<num>1); + nd_set_column($$, @1.first_column); /*% $$ = dispatch3(def, $2, $5, $6); %*/ @@ -2850,8 +2964,10 @@ primary : literal NODE *body = remove_begin($8); reduce_nodes(&body); $$ = NEW_DEFS($2, $5, $7, body); + nd_set_column($$->nd_defn, @1.first_column); set_line_body(body, $<num>1); nd_set_line($$, $<num>1); + nd_set_column($$, @1.first_column); /*% $$ = dispatch5(defs, $2, $<val>3, $5, $7, $8); %*/ @@ -2863,6 +2979,7 @@ primary : literal { /*%%%*/ $$ = NEW_BREAK(0); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(break, arg_new()); %*/ @@ -2871,6 +2988,7 @@ primary : literal { /*%%%*/ $$ = NEW_NEXT(0); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(next, arg_new()); %*/ @@ -2879,6 +2997,7 @@ primary : literal { /*%%%*/ $$ = NEW_REDO(); + nd_set_column($$, @1.first_column); /*% $$ = dispatch0(redo); %*/ @@ -2887,6 +3006,7 @@ primary : literal { /*%%%*/ $$ = NEW_RETRY(); + nd_set_column($$, @1.first_column); /*% $$ = dispatch0(retry); %*/ @@ -3006,7 +3126,7 @@ if_tail : opt_else if_tail { /*%%%*/ - $$ = new_if($2, $4, $5); + $$ = new_if($2, $4, $5, @1.first_column); fixpos($$, $2); /*% $$ = dispatch3(elsif, $2, $4, escape_Qundef($5)); @@ -3031,7 +3151,7 @@ for_var : lhs f_marg : f_norm_arg { - $$ = assignable($1, 0); + $$ = assignable($1, 0, @1.first_column); /*%%%*/ /*% %*/ @@ -3049,7 +3169,7 @@ f_marg : f_norm_arg f_marg_list : f_marg { /*%%%*/ - $$ = NEW_LIST($1); + $$ = new_list($1, @1.first_column); /*% $$ = mlhs_add(mlhs_new(), $1); %*/ @@ -3057,7 +3177,7 @@ f_marg_list : f_marg | f_marg_list ',' f_marg { /*%%%*/ - $$ = list_append($1, $3); + $$ = list_append($1, $3, @1.first_column); /*% $$ = mlhs_add($1, $3); %*/ @@ -3067,25 +3187,25 @@ f_marg_list : f_marg f_margs : f_marg_list { /*%%%*/ - $$ = NEW_MASGN($1, 0); + $$ = new_masgn($1, 0, @1.first_column); /*% $$ = $1; %*/ } | f_marg_list ',' tSTAR f_norm_arg { - $$ = assignable($4, 0); + $$ = assignable($4, 0, @1.first_column); /*%%%*/ - $$ = NEW_MASGN($1, $$); + $$ = new_masgn($1, $$, @1.first_column); /*% $$ = mlhs_add_star($1, $$); %*/ } | f_marg_list ',' tSTAR f_norm_arg ',' f_marg_list { - $$ = assignable($4, 0); + $$ = assignable($4, 0, @1.first_column); /*%%%*/ - $$ = NEW_MASGN($1, NEW_POSTARG($$, $6)); + $$ = new_masgn($1, new_postarg($$, $6, @1.first_column), @1.first_column); /*% $$ = mlhs_add_star($1, $$); $$ = mlhs_add_post($$, $6); @@ -3094,7 +3214,7 @@ f_margs : f_marg_list | f_marg_list ',' tSTAR { /*%%%*/ - $$ = NEW_MASGN($1, -1); + $$ = new_masgn($1, (NODE *)-1, @1.first_column); /*% $$ = mlhs_add_star($1, Qnil); %*/ @@ -3102,7 +3222,7 @@ f_margs : f_marg_list | f_marg_list ',' tSTAR ',' f_marg_list { /*%%%*/ - $$ = NEW_MASGN($1, NEW_POSTARG(-1, $5)); + $$ = new_masgn($1, new_postarg((NODE *)-1, $5, @1.first_column), @1.first_column); /*% $$ = mlhs_add_star($1, Qnil); $$ = mlhs_add_post($$, $5); @@ -3110,18 +3230,18 @@ f_margs : f_marg_list } | tSTAR f_norm_arg { - $$ = assignable($2, 0); + $$ = assignable($2, 0, @1.first_column); /*%%%*/ - $$ = NEW_MASGN(0, $$); + $$ = new_masgn(0, $$, @1.first_column); /*% $$ = mlhs_add_star(mlhs_new(), $$); %*/ } | tSTAR f_norm_arg ',' f_marg_list { - $$ = assignable($2, 0); + $$ = assignable($2, 0, @1.first_column); /*%%%*/ - $$ = NEW_MASGN(0, NEW_POSTARG($$, $4)); + $$ = new_masgn(0, new_postarg($$, $4, @1.first_column), @1.first_column); /*% $$ = mlhs_add_star(mlhs_new(), $$); $$ = mlhs_add_post($$, $4); @@ -3130,7 +3250,7 @@ f_margs : f_marg_list | tSTAR { /*%%%*/ - $$ = NEW_MASGN(0, -1); + $$ = new_masgn(0, (NODE *)-1, @1.first_column); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); %*/ @@ -3138,7 +3258,7 @@ f_margs : f_marg_list | tSTAR ',' f_marg_list { /*%%%*/ - $$ = NEW_MASGN(0, NEW_POSTARG(-1, $3)); + $$ = new_masgn(0, new_postarg((NODE *)-1, $3, @1.first_column), @1.first_column); /*% $$ = mlhs_add_star(mlhs_new(), Qnil); $$ = mlhs_add_post($$, $3); @@ -3149,19 +3269,19 @@ f_margs : f_marg_list block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg { - $$ = new_args_tail($1, $3, $4); + $$ = new_args_tail($1, $3, $4, @1.first_column); } | f_block_kwarg opt_f_block_arg { - $$ = new_args_tail($1, Qnone, $2); + $$ = new_args_tail($1, Qnone, $2, @1.first_column); } | f_kwrest opt_f_block_arg { - $$ = new_args_tail(Qnone, $1, $2); + $$ = new_args_tail(Qnone, $1, $2, @1.first_column); } | f_block_arg { - $$ = new_args_tail(Qnone, Qnone, $1); + $$ = new_args_tail(Qnone, Qnone, $1, @1.first_column); } ; @@ -3171,7 +3291,7 @@ opt_block_args_tail : ',' block_args_tail } | /* none */ { - $$ = new_args_tail(Qnone, Qnone, Qnone); + $$ = new_args_tail(Qnone, Qnone, Qnone, @0.first_column); } ; @@ -3197,7 +3317,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)); + $$ = new_args($1, Qnone, 1, Qnone, new_args_tail(Qnone, Qnone, Qnone, @1.first_column)); /*%%%*/ /*% dispatch1(excessed_comma, $$); @@ -3346,6 +3466,8 @@ lambda : { /*%%%*/ $$ = NEW_LAMBDA($3, $6); nd_set_line($$, $<num>4); + nd_set_column($$, @1.first_column); + nd_set_column($$->nd_body, @1.first_column); /*% $$ = dispatch2(lambda, $3, $6); %*/ @@ -3411,13 +3533,13 @@ block_call : command do_block } | block_call call_op2 operation2 opt_paren_args { - $$ = new_qcall($2, $1, $3, $4); + $$ = new_qcall($2, $1, $3, $4, @1.first_column); } | 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); + $5->nd_iter = new_command_qcall($2, $1, $3, $4, @1.first_column); $$ = $5; fixpos($$, $1); /*% @@ -3429,7 +3551,7 @@ block_call : command do_block { /*%%%*/ block_dup_check($4, $5); - $5->nd_iter = new_command_qcall($2, $1, $3, $4); + $5->nd_iter = new_command_qcall($2, $1, $3, $4, @1.first_column); $$ = $5; fixpos($$, $1); /*% @@ -3456,7 +3578,7 @@ method_call : fcall paren_args } opt_paren_args { - $$ = new_qcall($2, $1, $3, $5); + $$ = new_qcall($2, $1, $3, $5, @1.first_column); nd_set_line($$, $<num>4); } | primary_value tCOLON2 operation2 @@ -3467,12 +3589,12 @@ method_call : fcall paren_args } paren_args { - $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, $5); + $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, $5, @1.first_column); nd_set_line($$, $<num>4); } | primary_value tCOLON2 operation3 { - $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, Qnull); + $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, Qnull, @1.first_column); } | primary_value call_op { @@ -3482,7 +3604,7 @@ method_call : fcall paren_args } paren_args { - $$ = new_qcall($2, $1, ID2VAL(idCall), $4); + $$ = new_qcall($2, $1, ID2VAL(idCall), $4, @1.first_column); nd_set_line($$, $<num>3); } | primary_value tCOLON2 @@ -3493,13 +3615,14 @@ method_call : fcall paren_args } paren_args { - $$ = new_qcall(ID2VAL(idCOLON2), $1, ID2VAL(idCall), $4); + $$ = new_qcall(ID2VAL(idCOLON2), $1, ID2VAL(idCall), $4, @1.first_column); nd_set_line($$, $<num>3); } | keyword_super paren_args { /*%%%*/ $$ = NEW_SUPER($2); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(super, $2); %*/ @@ -3508,6 +3631,7 @@ method_call : fcall paren_args { /*%%%*/ $$ = NEW_ZSUPER(); + nd_set_column($$, @1.first_column); /*% $$ = dispatch0(zsuper); %*/ @@ -3516,9 +3640,9 @@ method_call : fcall paren_args { /*%%%*/ if ($1 && nd_type($1) == NODE_SELF) - $$ = NEW_FCALL(tAREF, $3); + $$ = new_fcall(tAREF, $3, @1.first_column); else - $$ = NEW_CALL($1, tAREF, $3); + $$ = new_call($1, tAREF, $3, @1.first_column); fixpos($$, $1); /*% $$ = dispatch2(aref, $1, escape_Qundef($3)); @@ -3558,7 +3682,7 @@ brace_body : {$<vars>$ = dyna_push();} {$<val>$ = cmdarg_stack >> 1; CMDARG_SET(0);} opt_block_param compstmt { - $$ = new_brace_body($3, $4); + $$ = new_brace_body($3, $4, @1.first_column); dyna_pop($<vars>1); CMDARG_SET($<val>2); } @@ -3568,7 +3692,7 @@ do_body : {$<vars>$ = dyna_push();} {$<val>$ = cmdarg_stack; CMDARG_SET(0);} opt_block_param bodystmt { - $$ = new_do_body($3, $4); + $$ = new_do_body($3, $4, @1.first_column); dyna_pop($<vars>1); CMDARG_SET($<val>2); } @@ -3580,6 +3704,7 @@ case_body : keyword_when args then { /*%%%*/ $$ = NEW_WHEN($2, $4, $5); + nd_set_column($$, @1.first_column); /*% $$ = dispatch3(when, $2, $4, escape_Qundef($5)); %*/ @@ -3596,10 +3721,10 @@ opt_rescue : keyword_rescue exc_list exc_var then { /*%%%*/ if ($3) { - $3 = node_assign($3, NEW_ERRINFO()); - $5 = block_append($3, $5); + $3 = node_assign($3, new_errinfo(@1.first_column), @1.first_column); + $5 = block_append($3, $5, @1.first_column); } - $$ = NEW_RESBODY($2, $5, $6); + $$ = new_resbody($2, $5, $6, @1.first_column); fixpos($$, $2?$2:$5); /*% $$ = dispatch4(rescue, @@ -3615,7 +3740,7 @@ opt_rescue : keyword_rescue exc_list exc_var then exc_list : arg_value { /*%%%*/ - $$ = NEW_LIST($1); + $$ = new_list($1, @1.first_column); /*% $$ = rb_ary_new3(1, get_value($1)); %*/ @@ -3653,7 +3778,7 @@ literal : numeric | symbol { /*%%%*/ - $$ = NEW_LIT(ID2SYM($1)); + $$ = new_lit(ID2SYM($1), @1.first_column); /*% $$ = dispatch1(symbol_literal, $1); %*/ @@ -3666,10 +3791,10 @@ strings : string /*%%%*/ NODE *node = $1; if (!node) { - node = NEW_STR(STR_NEW0()); + node = new_str(STR_NEW0(), @1.first_column); } else { - node = evstr2dstr(node); + node = evstr2dstr(node, @1.first_column); } $$ = node; /*% @@ -3679,11 +3804,17 @@ strings : string ; string : tCHAR + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } | string1 | string string1 { /*%%%*/ - $$ = literal_concat($1, $2); + $$ = literal_concat($1, $2, @1.first_column); /*% $$ = dispatch2(string_concat, $1, $2); %*/ @@ -3698,20 +3829,20 @@ string1 : tSTRING_BEG string_contents tSTRING_END xstring : tXSTRING_BEG xstring_contents tSTRING_END { - $$ = new_xstring(heredoc_dedent($2)); + $$ = new_xstring(heredoc_dedent($2), @1.first_column); } ; regexp : tREGEXP_BEG regexp_contents tREGEXP_END { - $$ = new_regexp($2, $3); + $$ = new_regexp($2, $3, @1.first_column); } ; words : tWORDS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = NEW_ZARRAY(); + $$ = new_zarray(@1.first_column); /*% $$ = dispatch0(words_new); $$ = dispatch1(array, $$); @@ -3738,7 +3869,7 @@ word_list : /* none */ | word_list word ' ' { /*%%%*/ - $$ = list_append($1, evstr2dstr($2)); + $$ = list_append($1, evstr2dstr($2, @1.first_column), @1.first_column); /*% $$ = dispatch2(words_add, $1, $2); %*/ @@ -3756,7 +3887,7 @@ word : string_content | word string_content { /*%%%*/ - $$ = literal_concat($1, $2); + $$ = literal_concat($1, $2, @1.first_column); /*% $$ = dispatch2(word_add, $1, $2); %*/ @@ -3766,7 +3897,7 @@ word : string_content symbols : tSYMBOLS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = NEW_ZARRAY(); + $$ = new_zarray(@1.first_column); /*% $$ = dispatch0(symbols_new); $$ = dispatch1(array, $$); @@ -3793,7 +3924,7 @@ symbol_list : /* none */ | symbol_list word ' ' { /*%%%*/ - $2 = evstr2dstr($2); + $2 = evstr2dstr($2, @1.first_column); if (nd_type($2) == NODE_DSTR) { nd_set_type($2, NODE_DSYM); } @@ -3801,7 +3932,7 @@ symbol_list : /* none */ nd_set_type($2, NODE_LIT); $2->nd_lit = rb_str_intern($2->nd_lit); } - $$ = list_append($1, $2); + $$ = list_append($1, $2, @1.first_column); /*% $$ = dispatch2(symbols_add, $1, $2); %*/ @@ -3811,7 +3942,7 @@ symbol_list : /* none */ qwords : tQWORDS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = NEW_ZARRAY(); + $$ = new_zarray(@1.first_column); /*% $$ = dispatch0(qwords_new); $$ = dispatch1(array, $$); @@ -3830,7 +3961,7 @@ qwords : tQWORDS_BEG ' ' tSTRING_END qsymbols : tQSYMBOLS_BEG ' ' tSTRING_END { /*%%%*/ - $$ = NEW_ZARRAY(); + $$ = new_zarray(@1.first_column); /*% $$ = dispatch0(qsymbols_new); $$ = dispatch1(array, $$); @@ -3857,7 +3988,8 @@ qword_list : /* none */ | qword_list tSTRING_CONTENT ' ' { /*%%%*/ - $$ = list_append($1, $2); + $$ = list_append($1, $2, @1.first_column); + nd_set_column($2, @1.first_column); /*% $$ = dispatch2(qwords_add, $1, $2); %*/ @@ -3879,7 +4011,8 @@ qsym_list : /* none */ lit = $2->nd_lit; $2->nd_lit = ID2SYM(rb_intern_str(lit)); nd_set_type($2, NODE_LIT); - $$ = list_append($1, $2); + $$ = list_append($1, $2, @1.first_column); + nd_set_column($2, @1.first_column); /*% $$ = dispatch2(qsymbols_add, $1, $2); %*/ @@ -3897,7 +4030,7 @@ string_contents : /* none */ | string_contents string_content { /*%%%*/ - $$ = literal_concat($1, $2); + $$ = literal_concat($1, $2, @1.first_column); /*% $$ = dispatch2(string_add, $1, $2); %*/ @@ -3915,7 +4048,7 @@ xstring_contents: /* none */ | xstring_contents string_content { /*%%%*/ - $$ = literal_concat($1, $2); + $$ = literal_concat($1, $2, @1.first_column); /*% $$ = dispatch2(xstring_add, $1, $2); %*/ @@ -3948,10 +4081,10 @@ regexp_contents: /* none */ case NODE_DSTR: break; default: - head = list_append(NEW_DSTR(Qnil), head); + head = list_append(new_dstr(Qnil, @1.first_column), head, @1.first_column); break; } - $$ = list_append(head, tail); + $$ = list_append(head, tail, @1.first_column); } /*% VALUE s1 = 1, s2 = 0, n1 = $1, n2 = $2; @@ -3972,6 +4105,12 @@ regexp_contents: /* none */ ; string_content : tSTRING_CONTENT + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } | tSTRING_DVAR { $<node>$ = lex_strterm; @@ -3983,6 +4122,7 @@ string_content : tSTRING_CONTENT lex_strterm = $<node>2; /*%%%*/ $$ = NEW_EVSTR($3); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(string_dvar, $3); %*/ @@ -4021,7 +4161,7 @@ string_content : tSTRING_CONTENT heredoc_line_indent = -1; /*%%%*/ if ($7) $7->flags &= ~NODE_FL_NEWLINE; - $$ = new_evstr($7); + $$ = new_evstr($7, @1.first_column); /*% $$ = dispatch1(string_embexpr, $7); %*/ @@ -4031,7 +4171,7 @@ string_content : tSTRING_CONTENT string_dvar : tGVAR { /*%%%*/ - $$ = NEW_GVAR($1); + $$ = new_gvar($1, @1.first_column); /*% $$ = dispatch1(var_ref, $1); %*/ @@ -4039,7 +4179,7 @@ string_dvar : tGVAR | tIVAR { /*%%%*/ - $$ = NEW_IVAR($1); + $$ = new_ivar($1, @1.first_column); /*% $$ = dispatch1(var_ref, $1); %*/ @@ -4048,6 +4188,7 @@ string_dvar : tGVAR { /*%%%*/ $$ = NEW_CVAR($1); + nd_set_column($$, @1.first_column); /*% $$ = dispatch1(var_ref, $1); %*/ @@ -4076,7 +4217,7 @@ dsym : tSYMBEG xstring_contents tSTRING_END { SET_LEX_STATE(EXPR_END|EXPR_ENDARG); /*%%%*/ - $$ = dsym_node($2); + $$ = dsym_node($2, @1.first_column); /*% $$ = dispatch1(dyna_symbol, $2); %*/ @@ -4096,9 +4237,33 @@ numeric : simple_numeric ; simple_numeric : tINTEGER + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } | tFLOAT + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } | tRATIONAL + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } | tIMAGINARY + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } ; user_variable : tIDENTIFIER @@ -4120,7 +4285,7 @@ keyword_variable: keyword_nil {$$ = KWD2EID(nil, $1);} var_ref : user_variable { /*%%%*/ - if (!($$ = gettable($1))) $$ = NEW_BEGIN(0); + if (!($$ = gettable($1, @1.first_column))) $$ = new_begin(0, @1.first_column); /*% if (id_is_var(get_id($1))) { $$ = dispatch1(var_ref, $1); @@ -4133,7 +4298,7 @@ var_ref : user_variable | keyword_variable { /*%%%*/ - if (!($$ = gettable($1))) $$ = NEW_BEGIN(0); + if (!($$ = gettable($1, @1.first_column))) $$ = new_begin(0, @1.first_column); /*% $$ = dispatch1(var_ref, $1); %*/ @@ -4142,16 +4307,28 @@ var_ref : user_variable var_lhs : user_variable { - $$ = assignable(var_field($1), 0); + $$ = assignable(var_field($1), 0, @1.first_column); } | keyword_variable { - $$ = assignable(var_field($1), 0); + $$ = assignable(var_field($1), 0, @1.first_column); } ; backref : tNTH_REF + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } | tBACK_REF + { + /*%%%*/ + nd_set_column($$, @1.first_column); + /*% + %*/ + } ; superclass : '<' @@ -4199,19 +4376,19 @@ f_arglist : '(' f_args rparen args_tail : f_kwarg ',' f_kwrest opt_f_block_arg { - $$ = new_args_tail($1, $3, $4); + $$ = new_args_tail($1, $3, $4, @1.first_column); } | f_kwarg opt_f_block_arg { - $$ = new_args_tail($1, Qnone, $2); + $$ = new_args_tail($1, Qnone, $2, @1.first_column); } | f_kwrest opt_f_block_arg { - $$ = new_args_tail(Qnone, $1, $2); + $$ = new_args_tail(Qnone, $1, $2, @1.first_column); } | f_block_arg { - $$ = new_args_tail(Qnone, Qnone, $1); + $$ = new_args_tail(Qnone, Qnone, $1, @1.first_column); } ; @@ -4221,7 +4398,7 @@ opt_args_tail : ',' args_tail } | /* none */ { - $$ = new_args_tail(Qnone, Qnone, Qnone); + $$ = new_args_tail(Qnone, Qnone, Qnone, @0.first_column); } ; @@ -4283,7 +4460,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail } | /* none */ { - $$ = new_args_tail(Qnone, Qnone, Qnone); + $$ = new_args_tail(Qnone, Qnone, Qnone, @0.first_column); $$ = new_args(Qnone, Qnone, Qnone, Qnone, $$); } ; @@ -4291,7 +4468,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail f_bad_arg : tCONSTANT { /*%%%*/ - yyerror("formal argument cannot be a constant"); + yyerror0("formal argument cannot be a constant"); $$ = 0; /*% $$ = dispatch1(param_error, $1); @@ -4301,7 +4478,7 @@ f_bad_arg : tCONSTANT | tIVAR { /*%%%*/ - yyerror("formal argument cannot be an instance variable"); + yyerror0("formal argument cannot be an instance variable"); $$ = 0; /*% $$ = dispatch1(param_error, $1); @@ -4311,7 +4488,7 @@ f_bad_arg : tCONSTANT | tGVAR { /*%%%*/ - yyerror("formal argument cannot be a global variable"); + yyerror0("formal argument cannot be a global variable"); $$ = 0; /*% $$ = dispatch1(param_error, $1); @@ -4321,7 +4498,7 @@ f_bad_arg : tCONSTANT | tCVAR { /*%%%*/ - yyerror("formal argument cannot be a class variable"); + yyerror0("formal argument cannot be a class variable"); $$ = 0; /*% $$ = dispatch1(param_error, $1); @@ -4362,10 +4539,10 @@ f_arg_item : f_arg_asgn arg_var(tid); /*%%%*/ if (dyna_in_block()) { - $2->nd_value = NEW_DVAR(tid); + $2->nd_value = new_dvar(tid, @1.first_column); } else { - $2->nd_value = NEW_LVAR(tid); + $2->nd_value = new_lvar(tid, @1.first_column); } $$ = NEW_ARGS_AUX(tid, 1); $$->nd_next = $2; @@ -4387,7 +4564,7 @@ f_arg : f_arg_item /*%%%*/ $$ = $1; $$->nd_plen++; - $$->nd_next = block_append($$->nd_next, $3->nd_next); + $$->nd_next = block_append($$->nd_next, $3->nd_next, @1.first_column); rb_gc_force_recycle((VALUE)$3); /*% $$ = rb_ary_push($1, get_value($3)); @@ -4408,9 +4585,9 @@ f_label : tLABEL f_kw : f_label arg_value { current_arg = 0; - $$ = assignable($1, $2); + $$ = assignable($1, $2, @1.first_column); /*%%%*/ - $$ = new_kw_arg($$); + $$ = new_kw_arg($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), get_value($2)); %*/ @@ -4418,9 +4595,9 @@ f_kw : f_label arg_value | f_label { current_arg = 0; - $$ = assignable($1, (NODE *)-1); + $$ = assignable($1, (NODE *)-1, @1.first_column); /*%%%*/ - $$ = new_kw_arg($$); + $$ = new_kw_arg($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), 0); %*/ @@ -4429,18 +4606,18 @@ f_kw : f_label arg_value f_block_kw : f_label primary_value { - $$ = assignable($1, $2); + $$ = assignable($1, $2, @1.first_column); /*%%%*/ - $$ = new_kw_arg($$); + $$ = new_kw_arg($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), get_value($2)); %*/ } | f_label { - $$ = assignable($1, (NODE *)-1); + $$ = assignable($1, (NODE *)-1, @1.first_column); /*%%%*/ - $$ = new_kw_arg($$); + $$ = new_kw_arg($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), 0); %*/ @@ -4511,9 +4688,10 @@ f_kwrest : kwrest_mark tIDENTIFIER f_opt : f_arg_asgn '=' arg_value { current_arg = 0; - $$ = assignable($1, $3); + $$ = assignable($1, $3, @1.first_column); /*%%%*/ $$ = NEW_OPT_ARG(0, $$); + nd_set_column($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), get_value($3)); %*/ @@ -4523,9 +4701,10 @@ f_opt : f_arg_asgn '=' arg_value f_block_opt : f_arg_asgn '=' primary_value { current_arg = 0; - $$ = assignable($1, $3); + $$ = assignable($1, $3, @1.first_column); /*%%%*/ $$ = NEW_OPT_ARG(0, $$); + nd_set_column($$, @1.first_column); /*% $$ = rb_assoc_new(get_value($$), get_value($3)); %*/ @@ -4588,7 +4767,7 @@ f_rest_arg : restarg_mark tIDENTIFIER { /*%%%*/ if (!is_local_id($2)) - yyerror("rest argument must be local variable"); + yyerror0("rest argument must be local variable"); /*% %*/ arg_var(shadowing_lvar(get_id($2))); /*%%%*/ @@ -4616,9 +4795,9 @@ f_block_arg : blkarg_mark tIDENTIFIER { /*%%%*/ if (!is_local_id($2)) - yyerror("block argument must be local variable"); + yyerror0("block argument must be local variable"); else if (!dyna_in_block() && local_id($2)) - yyerror("duplicated block argument name"); + yyerror0("duplicated block argument name"); /*% %*/ arg_var(shadowing_lvar(get_id($2))); /*%%%*/ @@ -4657,7 +4836,7 @@ singleton : var_ref { /*%%%*/ if ($3 == 0) { - yyerror("can't define singleton method for ()."); + yyerror0("can't define singleton method for ()."); } else { switch (nd_type($3)) { @@ -4669,7 +4848,7 @@ singleton : var_ref case NODE_LIT: case NODE_ARRAY: case NODE_ZARRAY: - yyerror("can't define singleton method for literals"); + yyerror0("can't define singleton method for literals"); break; default: value_expr($3); @@ -4732,7 +4911,7 @@ assoc : arg_value tASSOC arg_value nd_set_type($1, NODE_LIT); $1->nd_lit = rb_fstring($1->nd_lit); } - $$ = list_append(NEW_LIST($1), $3); + $$ = list_append(new_list($1, @1.first_column), $3, @1.first_column); /*% $$ = dispatch2(assoc_new, $1, $3); %*/ @@ -4740,7 +4919,7 @@ assoc : arg_value tASSOC arg_value | tLABEL arg_value { /*%%%*/ - $$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2); + $$ = list_append(new_list(new_lit(ID2SYM($1), @1.first_column), @1.first_column), $2, @1.first_column); /*% $$ = dispatch2(assoc_new, $1, $2); %*/ @@ -4748,7 +4927,7 @@ assoc : arg_value tASSOC arg_value | tSTRING_BEG string_contents tLABEL_END arg_value { /*%%%*/ - $$ = list_append(NEW_LIST(dsym_node($2)), $4); + $$ = list_append(new_list(dsym_node($2, @1.first_column), @1.first_column), $4, @1.first_column); /*% $$ = dispatch2(assoc_new, dispatch1(dyna_symbol, $2), $4); %*/ @@ -4760,7 +4939,7 @@ assoc : arg_value tASSOC arg_value !($2->nd_head && $2->nd_head->nd_alen)) $$ = 0; else - $$ = list_append(NEW_LIST(0), $2); + $$ = list_append(new_list(0, @1.first_column), $2, @1.first_column); /*% $$ = dispatch1(assoc_splat, $2); %*/ @@ -5306,9 +5485,12 @@ yycompile0(VALUE arg) } else { VALUE opt = parser->compile_option; + NODE *prelude; if (!opt) opt = rb_obj_hide(rb_ident_hash_new()); rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov); - tree->nd_body = NEW_PRELUDE(ruby_eval_tree_begin, tree->nd_body, opt); + prelude = NEW_PRELUDE(ruby_eval_tree_begin, tree->nd_body, opt); + nd_set_column(prelude, nd_column(tree->nd_body)); + tree->nd_body = prelude; } return (VALUE)tree; } @@ -5650,7 +5832,7 @@ parser_tok_hex(struct parser_params *parser, size_t *numlen) c = scan_hex(lex_p, 2, numlen); if (!*numlen) { parser->tokp = lex_p; - yyerror("invalid hex escape"); + yyerror0("invalid hex escape"); return 0; } lex_p += *numlen; @@ -5668,15 +5850,15 @@ parser_tokadd_codepoint(struct parser_params *parser, rb_encoding **encp, literal_flush(lex_p); lex_p += numlen; if (wide ? (numlen == 0 || numlen > 6) : (numlen < 4)) { - yyerror("invalid Unicode escape"); + yyerror0("invalid Unicode escape"); return wide && numlen > 0; } if (codepoint > 0x10ffff) { - yyerror("invalid Unicode codepoint (too large)"); + yyerror0("invalid Unicode codepoint (too large)"); return wide; } if ((codepoint & 0xfffff800) == 0xd800) { - yyerror("invalid Unicode codepoint"); + yyerror0("invalid Unicode codepoint"); return wide; } if (regexp_literal) { @@ -5689,7 +5871,7 @@ parser_tokadd_codepoint(struct parser_params *parser, rb_encoding **encp, size_t len = sizeof(mixed_utf8) - 2 + strlen(rb_enc_name(*encp)); char *mesg = alloca(len); snprintf(mesg, len, mixed_utf8, rb_enc_name(*encp)); - yyerror(mesg); + yyerror0(mesg); return wide; } *encp = utf8; @@ -5735,7 +5917,7 @@ parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp, if (c != close_brace) { unterminated: literal_flush(lex_p); - yyerror("unterminated Unicode escape"); + yyerror0("unterminated Unicode escape"); return 0; } @@ -5835,7 +6017,7 @@ parser_read_escape(struct parser_params *parser, int flags, eof: case -1: - yyerror("Invalid escape character syntax"); + yyerror0("Invalid escape character syntax"); pushback(c); return '\0'; @@ -5914,7 +6096,7 @@ parser_tokadd_escape(struct parser_params *parser, rb_encoding **encp) eof: case -1: - yyerror("Invalid escape character syntax"); + yyerror0("Invalid escape character syntax"); return -1; default: @@ -6037,7 +6219,7 @@ parser_tokadd_string(struct parser_params *parser, snprintf(errbuf, len, mixed_msg, \ rb_enc_name(enc1), \ rb_enc_name(enc2)); \ - yyerror(errbuf); \ + yyerror0(errbuf); \ } #define mixed_escape(beg, enc1, enc2) do { \ const char *pos = lex_p; \ @@ -6318,7 +6500,7 @@ parser_parse_string(struct parser_params *parser, NODE *quote) &enc) == -1) { if (parser->eofp) { #ifndef RIPPER -# define unterminated_literal(mesg) yyerror(mesg) +# define unterminated_literal(mesg) yyerror0(mesg) #else # define unterminated_literal(mesg) compile_error(PARSER_ARG mesg) #endif @@ -6579,7 +6761,7 @@ parser_number_literal_suffix(struct parser_params *parser, int mask) if (c == '.') { c = peekc_n(1); if (ISDIGIT(c)) { - yyerror("unexpected fraction part after numeric literal"); + yyerror0("unexpected fraction part after numeric literal"); lex_p += 2; while (parser_is_identchar()) nextc(); } @@ -6796,19 +6978,19 @@ formal_argument_gen(struct parser_params *parser, ID lhs) break; #ifndef RIPPER case ID_CONST: - yyerror("formal argument cannot be a constant"); + yyerror0("formal argument cannot be a constant"); return 0; case ID_INSTANCE: - yyerror("formal argument cannot be an instance variable"); + yyerror0("formal argument cannot be an instance variable"); return 0; case ID_GLOBAL: - yyerror("formal argument cannot be a global variable"); + yyerror0("formal argument cannot be a global variable"); return 0; case ID_CLASS: - yyerror("formal argument cannot be a class variable"); + yyerror0("formal argument cannot be a class variable"); return 0; default: - yyerror("formal argument must be local variable"); + yyerror0("formal argument must be local variable"); return 0; #else default: @@ -7219,7 +7401,7 @@ parse_numeric(struct parser_params *parser, int c) c = nextc(); } if (c == '0') { -#define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0) +#define no_digits() do {yyerror0("numeric literal without digits"); return 0;} while (0) int start = toklen(); c = nextc(); if (c == 'x' || c == 'X') { @@ -7333,7 +7515,7 @@ parse_numeric(struct parser_params *parser, int c) } if (c > '7' && c <= '9') { invalid_octal: - yyerror("Invalid octal digit"); + yyerror0("Invalid octal digit"); } else if (c == '.' || c == 'e' || c == 'E') { tokadd('0'); @@ -7415,7 +7597,7 @@ parse_numeric(struct parser_params *parser, int c) trailing_uc: literal_flush(lex_p - 1); snprintf(tmp, sizeof(tmp), "trailing `%c' in number", nondigit); - yyerror(tmp); + yyerror0(tmp); } tokfix(); if (is_float) { @@ -7552,7 +7734,7 @@ parse_percent(struct parser_params *parser, const int space_seen, const enum lex else { term = nextc(); if (rb_enc_isalnum(term, current_enc) || !parser_isascii()) { - yyerror("unknown type of %string"); + yyerror0("unknown type of %string"); return 0; } } @@ -7614,7 +7796,7 @@ parse_percent(struct parser_params *parser, const int space_seen, const enum lex return tSYMBEG; default: - yyerror("unknown type of %string"); + yyerror0("unknown type of %string"); return 0; } } @@ -8345,7 +8527,7 @@ parser_yylex(struct parser_params *parser) } pushback(c); if (c != -1 && ISDIGIT(c)) { - yyerror("no .<digit> floating literal anymore; put 0 before dot"); + yyerror0("no .<digit> floating literal anymore; put 0 before dot"); } SET_LEX_STATE(EXPR_DOT); return '.'; @@ -8567,7 +8749,7 @@ parser_yylex(struct parser_params *parser) } static enum yytokentype -yylex(YYSTYPE *lval, struct parser_params *parser) +yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *parser) { enum yytokentype t; @@ -8579,6 +8761,9 @@ yylex(YYSTYPE *lval, struct parser_params *parser) else if (t != 0) dispatch_scan_event(t); + yylloc->first_column = (int)(parser->tokp - lex_pbeg); + yylloc->last_column = (int)(lex_p - lex_pbeg); + return t; } @@ -8590,6 +8775,8 @@ node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE { NODE *n = (rb_node_newnode)(type, a0, a1, a2); nd_set_line(n, ruby_sourceline); + /* mark not cared column to -1 */ + nd_set_column(n, -1); return n; } @@ -8639,7 +8826,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) +block_append_gen(struct parser_params *parser, NODE *head, NODE *tail, int column) { NODE *end, *h = head, *nd; @@ -8657,6 +8844,7 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail) return tail; default: h = end = NEW_BLOCK(head); + nd_set_column(end, column); end->nd_end = end; fixpos(end, head); head = end; @@ -8684,6 +8872,7 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail) if (nd_type(tail) != NODE_BLOCK) { tail = NEW_BLOCK(tail); + nd_set_column(tail, column); tail->nd_end = tail; } end->nd_next = tail; @@ -8693,11 +8882,11 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail) /* append item to the list */ static NODE* -list_append_gen(struct parser_params *parser, NODE *list, NODE *item) +list_append_gen(struct parser_params *parser, NODE *list, NODE *item, int column) { NODE *last; - if (list == 0) return NEW_LIST(item); + if (list == 0) return new_list(item, column); if (list->nd_next) { last = list->nd_next->nd_end; } @@ -8706,7 +8895,7 @@ list_append_gen(struct parser_params *parser, NODE *list, NODE *item) } list->nd_alen += 1; - last->nd_next = NEW_LIST(item); + last->nd_next = new_list(item, column); list->nd_next->nd_end = last->nd_next; return list; } @@ -8754,7 +8943,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) +literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, int column) { enum node_type htype; NODE *headlast; @@ -8765,8 +8954,8 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) htype = nd_type(head); if (htype == NODE_EVSTR) { - NODE *node = NEW_DSTR(STR_NEW0()); - head = list_append(node, head); + NODE *node = new_dstr(STR_NEW0(), column); + head = list_append(node, head, column); htype = NODE_DSTR; } if (heredoc_indent > 0) { @@ -8774,7 +8963,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) case NODE_STR: nd_set_type(head, NODE_DSTR); case NODE_DSTR: - return list_append(head, tail); + return list_append(head, tail, column); default: break; } @@ -8799,7 +8988,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) rb_gc_force_recycle((VALUE)tail); } else { - list_append(head, tail); + list_append(head, tail, column); } break; @@ -8828,7 +9017,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) } else { nd_set_type(tail, NODE_ARRAY); - tail->nd_head = NEW_STR(tail->nd_lit); + tail->nd_head = new_str(tail->nd_lit, column); list_concat(head, tail); } break; @@ -8838,25 +9027,26 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail) nd_set_type(head, NODE_DSTR); head->nd_alen = 1; } - list_append(head, tail); + list_append(head, tail, column); break; } return head; } static NODE * -evstr2dstr_gen(struct parser_params *parser, NODE *node) +evstr2dstr_gen(struct parser_params *parser, NODE *node, int column) { if (nd_type(node) == NODE_EVSTR) { - node = list_append(NEW_DSTR(STR_NEW0()), node); + node = list_append(new_dstr(STR_NEW0(), column), node, column); } return node; } static NODE * -new_evstr_gen(struct parser_params *parser, NODE *node) +new_evstr_gen(struct parser_params *parser, NODE *node, int column) { NODE *head = node; + NODE *evstr; if (node) { switch (nd_type(node)) { @@ -8864,29 +9054,43 @@ new_evstr_gen(struct parser_params *parser, NODE *node) return node; } } - return NEW_EVSTR(head); + evstr = NEW_EVSTR(head); + nd_set_column(evstr, column); + return evstr; } static NODE * -call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1) +call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1, int column) { NODE *expr; value_expr(recv); value_expr(arg1); - expr = NEW_OPCALL(recv, id, NEW_LIST(arg1)); + expr = NEW_OPCALL(recv, id, new_list(arg1, column)); fixpos(expr, recv); + nd_set_column(expr, column); return expr; } static NODE * -call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id) +call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, int column) { + NODE *opcall; value_expr(recv); - return NEW_OPCALL(recv, id, 0); + opcall = NEW_OPCALL(recv, id, 0); + nd_set_column(opcall, column); + return opcall; +} + +static NODE * +new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, int column) +{ + NODE *qcall = NEW_QCALL(atype, recv, mid, args); + nd_set_column(qcall, column); + return qcall; } static NODE* -match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2) +match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) { value_expr(node1); value_expr(node2); @@ -8894,32 +9098,43 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2) switch (nd_type(node1)) { case NODE_DREGX: case NODE_DREGX_ONCE: - return NEW_MATCH2(node1, node2); + { + NODE *match = NEW_MATCH2(node1, node2); + nd_set_column(match, column); + return match; + } case NODE_LIT: if (RB_TYPE_P(node1->nd_lit, T_REGEXP)) { const VALUE lit = node1->nd_lit; NODE *match = NEW_MATCH2(node1, node2); - match->nd_args = reg_named_capture_assign(lit); + match->nd_args = reg_named_capture_assign(lit, column); + nd_set_column(match, column); return match; } } } if (node2) { + NODE *match3; + switch (nd_type(node2)) { case NODE_DREGX: case NODE_DREGX_ONCE: - return NEW_MATCH3(node2, node1); + match3 = NEW_MATCH3(node2, node1); + nd_set_column(match3, column); + return match3; case NODE_LIT: if (RB_TYPE_P(node2->nd_lit, T_REGEXP)) { - return NEW_MATCH3(node2, node1); + match3 = NEW_MATCH3(node2, node1); + nd_set_column(match3, column); + return match3; } } } - return NEW_CALL(node1, tMATCH, NEW_LIST(node2)); + return new_call(node1, tMATCH, new_list(node2, column), column); } # if WARN_PAST_SCOPE @@ -8936,24 +9151,34 @@ past_dvar_p(struct parser_params *parser, ID id) # endif static NODE* -gettable_gen(struct parser_params *parser, ID id) +gettable_gen(struct parser_params *parser, ID id, int column) { ID *vidp = NULL; + NODE *node; switch (id) { case keyword_self: - return NEW_SELF(); + node = NEW_SELF(); + nd_set_column(node, column); + return node; case keyword_nil: - return NEW_NIL(); + node = NEW_NIL(); + nd_set_column(node, column); + return node; case keyword_true: - return NEW_TRUE(); + node = NEW_TRUE(); + nd_set_column(node, column); + return node; case keyword_false: - return NEW_FALSE(); + node = NEW_FALSE(); + nd_set_column(node, column); + return node; case keyword__FILE__: - return NEW_STR(rb_str_dup(ruby_sourcefile_string)); + node = new_str(rb_str_dup(ruby_sourcefile_string), column); + return node; case keyword__LINE__: - return NEW_LIT(INT2FIX(tokline)); + return new_lit(INT2FIX(tokline), column); case keyword__ENCODING__: - return NEW_LIT(rb_enc_from_encoding(current_enc)); + return new_lit(rb_enc_from_encoding(current_enc), column); } switch (id_type(id)) { case ID_LOCAL: @@ -8962,14 +9187,16 @@ gettable_gen(struct parser_params *parser, ID id) rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id)); } if (vidp) *vidp |= LVAR_USED; - return NEW_DVAR(id); + node = new_dvar(id, column); + return node; } if (local_id_ref(id, vidp)) { if (id == current_arg) { rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id)); } if (vidp) *vidp |= LVAR_USED; - return NEW_LVAR(id); + node = new_lvar(id, column); + return node; } # if WARN_PAST_SCOPE if (!in_defined && RTEST(ruby_verbose) && past_dvar_p(parser, id)) { @@ -8977,15 +9204,23 @@ gettable_gen(struct parser_params *parser, ID id) } # endif /* method call without arguments */ - return NEW_VCALL(id); + node = NEW_VCALL(id); + nd_set_column(node, column); + return node; case ID_GLOBAL: - return NEW_GVAR(id); + node = new_gvar(id, column); + return node; case ID_INSTANCE: - return NEW_IVAR(id); + node = new_ivar(id, column); + return node; case ID_CONST: - return NEW_CONST(id); + node = NEW_CONST(id); + nd_set_column(node, column); + return node; case ID_CLASS: - return NEW_CVAR(id); + node = NEW_CVAR(id); + nd_set_column(node, column); + return node; } compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id)); return 0; @@ -9005,12 +9240,20 @@ kwd_append(NODE *kwlist, NODE *kw) } static NODE * -new_regexp_gen(struct parser_params *parser, NODE *node, int options) +new_defined_gen(struct parser_params *parser, NODE *expr, int column) +{ + NODE *defined = NEW_DEFINED(remove_begin_all(expr)); + nd_set_column(defined, column); + return defined; +} + +static NODE * +new_regexp_gen(struct parser_params *parser, NODE *node, int options, int column) { NODE *list, *prev; if (!node) { - return NEW_LIT(reg_compile(STR_NEW0(), options)); + return new_lit(reg_compile(STR_NEW0(), options), column); } switch (nd_type(node)) { case NODE_STR: @@ -9021,7 +9264,8 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options) } break; default: - node = NEW_NODE(NODE_DSTR, STR_NEW0(), 1, NEW_LIST(node)); + node = NEW_NODE(NODE_DSTR, STR_NEW0(), 1, new_list(node, column)); + nd_set_column(node, column); case NODE_DSTR: if (options & RE_OPTION_ONCE) { nd_set_type(node, NODE_DREGX_ONCE); @@ -9065,10 +9309,191 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options) } static NODE * -new_xstring_gen(struct parser_params *parser, NODE *node) +new_lit_gen(struct parser_params *parser, VALUE sym, int column) +{ + NODE *lit = NEW_LIT(sym); + nd_set_column(lit, column); + return lit; +} + +static NODE * +new_list_gen(struct parser_params *parser, NODE *item, int column) +{ + NODE *list = NEW_LIST(item); + nd_set_column(list, column); + return list; +} + +static NODE * +new_str_gen(struct parser_params *parser, VALUE str, int column) +{ + NODE *nd_str = NEW_STR(str); + nd_set_column(nd_str, column); + return nd_str; +} + +static NODE * +new_dvar_gen(struct parser_params *parser, ID id, int column) +{ + NODE *dvar = NEW_DVAR(id); + nd_set_column(dvar, column); + return dvar; +} + +static NODE * +new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, int column) +{ + NODE *resbody = NEW_RESBODY(exc_list, stmt, rescue); + nd_set_column(resbody, column); + return resbody; +} + +static NODE * +new_errinfo_gen(struct parser_params *parser, int column) +{ + NODE *errinfo = NEW_ERRINFO(); + nd_set_column(errinfo, column); + return errinfo; +} + +static NODE * +new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, int column) +{ + NODE *call = NEW_CALL(recv, mid, args); + nd_set_column(call, column); + return call; +} + +static NODE * +new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, int column) +{ + NODE *fcall = NEW_FCALL(mid, args); + nd_set_column(fcall, column); + return fcall; +} + +static NODE * +new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, int column) +{ + NODE *nd_for = NEW_FOR(var, iter, body); + nd_set_column(nd_for, column); + return nd_for; +} + +static NODE * +new_gvar_gen(struct parser_params *parser, ID id, int column) +{ + NODE *gvar = NEW_GVAR(id); + nd_set_column(gvar, column); + return gvar; +} + +static NODE * +new_lvar_gen(struct parser_params *parser, ID id, int column) +{ + NODE *lvar = NEW_LVAR(id); + nd_set_column(lvar, column); + return lvar; +} + +static NODE * +new_dstr_gen(struct parser_params *parser, VALUE str, int column) +{ + NODE *dstr = NEW_DSTR(str); + nd_set_column(dstr, column); + return dstr; +} + +static NODE * +new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, int column) +{ + NODE *rescue = NEW_RESCUE(b, res, e); + nd_set_column(rescue, column); + return rescue; +} + +static NODE * +new_undef_gen(struct parser_params *parser, NODE *i, int column) +{ + NODE *undef = NEW_UNDEF(i); + nd_set_column(undef, column); + return undef; +} + +static NODE * +new_zarray_gen(struct parser_params *parser, int column) +{ + NODE *zarray = NEW_ZARRAY(); + nd_set_column(zarray, column); + return zarray; +} + +static NODE * +new_ivar_gen(struct parser_params *parser, ID id, int column) +{ + NODE *ivar = NEW_IVAR(id); + nd_set_column(ivar, column); + return ivar; +} + +static NODE * +new_postarg_gen(struct parser_params *parser, NODE *i, NODE *v, int column) +{ + NODE *postarg = NEW_POSTARG(i, v); + nd_set_column(postarg, column); + return postarg; +} + +static NODE * +new_cdecl_gen(struct parser_params *parser, ID v, NODE *val, NODE *path, int column) +{ + NODE *cdecl = NEW_CDECL(v, val, path); + nd_set_column(cdecl, column); + return cdecl; +} + +static NODE * +new_scope_gen(struct parser_params *parser, NODE *a, NODE *b, int column) +{ + NODE *scope = NEW_SCOPE(a, b); + nd_set_column(scope, column); + return scope; +} + +static NODE * +new_begin_gen(struct parser_params *parser, NODE *b, int column) +{ + NODE *begin = NEW_BEGIN(b); + nd_set_column(begin, column); + return begin; +} + +static NODE * +new_masgn_gen(struct parser_params *parser, NODE *l, NODE *r, int column) +{ + NODE *masgn = NEW_MASGN(l, r); + nd_set_column(masgn, column); + return masgn; +} + + +static NODE * +new_kw_arg_gen(struct parser_params *parser, NODE *k, int column) +{ + NODE *kw_arg; + if (!k) return 0; + kw_arg = NEW_KW_ARG(0, (k)); + nd_set_column(kw_arg, column); + return kw_arg; +} + +static NODE * +new_xstring_gen(struct parser_params *parser, NODE *node, int column) { if (!node) { - return NEW_XSTR(STR_NEW0()); + NODE *xstr = NEW_XSTR(STR_NEW0()); + nd_set_column(xstr, column); + return xstr; } switch (nd_type(node)) { case NODE_STR: @@ -9078,11 +9503,22 @@ new_xstring_gen(struct parser_params *parser, NODE *node) nd_set_type(node, NODE_DXSTR); break; default: - node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node)); + node = NEW_NODE(NODE_DXSTR, Qnil, 1, new_list(node, column)); + nd_set_column(node, column); break; } return node; } + +static NODE * +new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, int column) +{ + NODE *iter = NEW_ITER(param, stmt); + nd_set_column(iter->nd_body, column); + nd_set_column(iter, column); + return iter; + +} #else /* !RIPPER */ static int id_is_var_gen(struct parser_params *parser, ID id) @@ -9246,12 +9682,21 @@ rb_parser_fatal(struct parser_params *parser, const char *fmt, ...) } #endif /* !RIPPER */ +#ifndef RIPPER +static NODE* +assignable_result0(NODE *node, int column) +{ + if (node) nd_set_column(node, column); + return node; +} +#endif /* !RIPPER */ + #ifdef RIPPER static VALUE assignable_gen(struct parser_params *parser, VALUE lhs) #else static NODE* -assignable_gen(struct parser_params *parser, ID id, NODE *val) +assignable_gen(struct parser_params *parser, ID id, NODE *val, int column) #endif { #ifdef RIPPER @@ -9259,30 +9704,30 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val) # define assignable_result(x) (lhs) # define parser_yyerror(parser, x) (lhs = assign_error_gen(parser, lhs)) #else -# define assignable_result(x) (x) +# define assignable_result(x) assignable_result0(x, column) #endif if (!id) return assignable_result(0); switch (id) { case keyword_self: - yyerror("Can't change the value of self"); + yyerror0("Can't change the value of self"); goto error; case keyword_nil: - yyerror("Can't assign to nil"); + yyerror0("Can't assign to nil"); goto error; case keyword_true: - yyerror("Can't assign to true"); + yyerror0("Can't assign to true"); goto error; case keyword_false: - yyerror("Can't assign to false"); + yyerror0("Can't assign to false"); goto error; case keyword__FILE__: - yyerror("Can't assign to __FILE__"); + yyerror0("Can't assign to __FILE__"); goto error; case keyword__LINE__: - yyerror("Can't assign to __LINE__"); + yyerror0("Can't assign to __LINE__"); goto error; case keyword__ENCODING__: - yyerror("Can't assign to __ENCODING__"); + yyerror0("Can't assign to __ENCODING__"); goto error; } switch (id_type(id)) { @@ -9315,8 +9760,8 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val) return assignable_result(NEW_IASGN(id, val)); case ID_CONST: if (!in_def && !in_single) - return assignable_result(NEW_CDECL(id, val, 0)); - yyerror("dynamic constant assignment"); + return assignable_result(new_cdecl(id, val, 0, column)); + yyerror0("dynamic constant assignment"); break; case ID_CLASS: return assignable_result(NEW_CVASGN(id, val)); @@ -9346,7 +9791,7 @@ shadowing_lvar_0(struct parser_params *parser, ID name) if (is_private_local_id(name)) return 1; if (dyna_in_block()) { if (dvar_curr(name)) { - yyerror("duplicated argument name"); + yyerror0("duplicated argument name"); } else if (dvar_defined(name) || local_id(name)) { rb_warning1("shadowing outer local variable - %"PRIsWARN, rb_id2str(name)); @@ -9359,7 +9804,7 @@ shadowing_lvar_0(struct parser_params *parser, ID name) } else { if (local_id(name)) { - yyerror("duplicated argument name"); + yyerror0("duplicated argument name"); } } return 1; @@ -9387,9 +9832,11 @@ new_bv_gen(struct parser_params *parser, ID name) #ifndef RIPPER static NODE * -aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx) +aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, int column) { - return NEW_ATTRASGN(recv, tASET, idx); + NODE *attrasgn = NEW_ATTRASGN(recv, tASET, idx); + nd_set_column(attrasgn, column); + return attrasgn; } static void @@ -9401,10 +9848,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) +attrset_gen(struct parser_params *parser, NODE *recv, ID atype, ID id, int column) { + NODE *attrasgn; if (!CALL_Q_P(atype)) id = rb_id_attrset(id); - return NEW_ATTRASGN(recv, id, 0); + attrasgn = NEW_ATTRASGN(recv, id, 0); + nd_set_column(attrasgn, column); + return attrasgn; } static void @@ -9421,19 +9871,21 @@ rb_backref_error_gen(struct parser_params *parser, NODE *node) } static NODE * -arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2) +arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) { + NODE *argscat; + if (!node2) return node1; switch (nd_type(node1)) { case NODE_BLOCK_PASS: if (node1->nd_head) - node1->nd_head = arg_concat(node1->nd_head, node2); + node1->nd_head = arg_concat(node1->nd_head, node2, column); else - node1->nd_head = NEW_LIST(node2); + node1->nd_head = new_list(node2, column); return node1; case NODE_ARGSPUSH: if (nd_type(node2) != NODE_ARRAY) break; - node1->nd_body = list_concat(NEW_LIST(node1->nd_body), node2); + node1->nd_body = list_concat(new_list(node1->nd_body, column), node2); nd_set_type(node1, NODE_ARGSCAT); return node1; case NODE_ARGSCAT: @@ -9442,25 +9894,31 @@ arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2) node1->nd_body = list_concat(node1->nd_body, node2); return node1; } - return NEW_ARGSCAT(node1, node2); + argscat = NEW_ARGSCAT(node1, node2); + nd_set_column(argscat, column); + return argscat; } static NODE * -arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2) +arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, int column) { - if (!node1) return NEW_LIST(node2); + NODE *argspush; + + if (!node1) return new_list(node2, column); switch (nd_type(node1)) { case NODE_ARRAY: - return list_append(node1, node2); + return list_append(node1, node2, column); case NODE_BLOCK_PASS: - node1->nd_head = arg_append(node1->nd_head, node2); + node1->nd_head = arg_append(node1->nd_head, node2, column); return node1; case NODE_ARGSPUSH: - node1->nd_body = list_append(NEW_LIST(node1->nd_body), node2); + node1->nd_body = list_append(new_list(node1->nd_body, column), node2, column); nd_set_type(node1, NODE_ARGSCAT); return node1; } - return NEW_ARGSPUSH(node1, node2); + argspush = NEW_ARGSPUSH(node1, node2); + nd_set_column(argspush, column); + return argspush; } static NODE * @@ -9472,7 +9930,7 @@ splat_array(NODE* node) } static NODE * -node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs) +node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, int column) { if (!lhs) return 0; @@ -9491,7 +9949,7 @@ node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs) case NODE_ATTRASGN: case NODE_CALL: - lhs->nd_args = arg_append(lhs->nd_args, rhs); + lhs->nd_args = arg_append(lhs->nd_args, rhs, column); break; default: @@ -9517,7 +9975,7 @@ value_expr_gen(struct parser_params *parser, NODE *node) case NODE_NEXT: case NODE_REDO: case NODE_RETRY: - if (!cond) yyerror("void value expression"); + if (!cond) yyerror0("void value expression"); /* or "control never reach"? */ return FALSE; @@ -9801,10 +10259,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); +static NODE *cond0(struct parser_params*,NODE*,int,int); static NODE* -range_op(struct parser_params *parser, NODE *node) +range_op(struct parser_params *parser, NODE *node, int column) { enum node_type type; @@ -9814,9 +10272,9 @@ range_op(struct parser_params *parser, NODE *node) 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("$.")))); + return new_call(node, tEQ, new_list(new_gvar(rb_intern("$."), column), column), column); } - return cond0(parser, node, FALSE); + return cond0(parser, node, FALSE, column); } static int @@ -9841,7 +10299,7 @@ literal_node(NODE *node) } static NODE* -cond0(struct parser_params *parser, NODE *node, int method_op) +cond0(struct parser_params *parser, NODE *node, int method_op, int column) { if (node == 0) return 0; assign_in_cond(parser, node); @@ -9855,20 +10313,26 @@ cond0(struct parser_params *parser, NODE *node, int method_op) case NODE_DREGX: case NODE_DREGX_ONCE: - if (!method_op) - warning_unless_e_option(parser, node, "regex literal in condition"); - return NEW_MATCH2(node, NEW_GVAR(idLASTLINE)); + { + NODE *match; + 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); + return match; + } case NODE_AND: case NODE_OR: - node->nd_1st = cond0(parser, node->nd_1st, FALSE); - node->nd_2nd = cond0(parser, node->nd_2nd, FALSE); + node->nd_1st = cond0(parser, node->nd_1st, FALSE, column); + node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, column); break; case NODE_DOT2: case NODE_DOT3: - node->nd_beg = range_op(parser, node->nd_beg); - node->nd_end = range_op(parser, node->nd_end); + node->nd_beg = range_op(parser, node->nd_beg, column); + node->nd_end = range_op(parser, node->nd_end, column); 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)) { @@ -9901,31 +10365,40 @@ cond0(struct parser_params *parser, NODE *node, int method_op) } static NODE* -cond_gen(struct parser_params *parser, NODE *node, int method_op) +cond_gen(struct parser_params *parser, NODE *node, int method_op, int column) { if (node == 0) return 0; - return cond0(parser, node, method_op); + return cond0(parser, node, method_op, column); } static NODE* -new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right) +new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, int column) { + NODE *node_if; + if (!cc) return right; - cc = cond0(parser, cc, FALSE); - return newline_node(NEW_IF(cc, left, right)); + cc = cond0(parser, cc, FALSE, column); + node_if = NEW_IF(cc, left, right); + nd_set_column(node_if, column); + return newline_node(node_if); } static NODE* -new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right) +new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, int column) { + NODE *node_unless; + if (!cc) return right; - cc = cond0(parser, cc, FALSE); - return newline_node(NEW_UNLESS(cc, left, right)); + cc = cond0(parser, cc, FALSE, column); + node_unless = NEW_UNLESS(cc, left, right); + nd_set_column(node_unless, column); + return newline_node(node_unless); } static NODE* -logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right) +logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right, int column) { + NODE *op; value_expr(left); if (left && (enum node_type)nd_type(left) == type) { NODE *node = left, *second; @@ -9933,9 +10406,12 @@ 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); return left; } - return NEW_NODE(type, left, right, 0); + op = NEW_NODE(type, left, right, 0); + nd_set_column(op, column); + return op; } static void @@ -9964,11 +10440,14 @@ ret_args_gen(struct parser_params *parser, NODE *node) } static NODE * -new_yield_gen(struct parser_params *parser, NODE *node) +new_yield_gen(struct parser_params *parser, NODE *node, int column) { + NODE *yield; if (node) no_blockarg(parser, node); - return NEW_YIELD(node); + yield = NEW_YIELD(node); + nd_set_column(yield, column); + return yield; } static VALUE @@ -10040,7 +10519,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) +new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, int column) { int saved_line = ruby_sourceline; struct rb_args_info *args; @@ -10048,6 +10527,7 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b) args = ZALLOC(struct rb_args_info); node = NEW_NODE(NODE_ARGS, 0, 0, args); + nd_set_column(node, column); if (parser->error_p) return node; args->block_arg = b; @@ -10093,14 +10573,14 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b) if (kr) arg_var(kr); if (b) arg_var(b); - args->kw_rest_arg = NEW_DVAR(kr); + args->kw_rest_arg = new_dvar(kr, column); 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); + args->kw_rest_arg = new_dvar(kr, column); } ruby_sourceline = saved_line; @@ -10108,12 +10588,12 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b) } static NODE* -dsym_node_gen(struct parser_params *parser, NODE *node) +dsym_node_gen(struct parser_params *parser, NODE *node, int column) { VALUE lit; if (!node) { - return NEW_LIT(ID2SYM(idNULL)); + return new_lit(ID2SYM(idNULL), column); } switch (nd_type(node)) { @@ -10126,7 +10606,8 @@ dsym_node_gen(struct parser_params *parser, NODE *node) nd_set_type(node, NODE_LIT); break; default: - node = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(node)); + node = NEW_NODE(NODE_DSYM, Qnil, 1, new_list(node, column)); + nd_set_column(node, column); break; } return node; @@ -10148,7 +10629,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) +remove_duplicate_keys(struct parser_params *parser, NODE *hash, int column) { st_table *literal_keys = st_init_numtable_with_size(hash->nd_alen / 2); NODE *result = 0; @@ -10164,7 +10645,7 @@ remove_duplicate_keys(struct parser_params *parser, NODE *hash) "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); + head->nd_head = block_append(head->nd_head, value->nd_head, column); } else { st_insert(literal_keys, (st_data_t)key, (st_data_t)hash); @@ -10181,16 +10662,19 @@ remove_duplicate_keys(struct parser_params *parser, NODE *hash) } static NODE * -new_hash_gen(struct parser_params *parser, NODE *hash) +new_hash_gen(struct parser_params *parser, NODE *hash, int column) { - if (hash) hash = remove_duplicate_keys(parser, hash); - return NEW_HASH(hash); + NODE *nd_hash; + if (hash) hash = remove_duplicate_keys(parser, hash, column); + nd_hash = NEW_HASH(hash); + nd_set_column(nd_hash, column); + return nd_hash; } #endif /* !RIPPER */ #ifndef RIPPER static NODE * -new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs) +new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int column) { NODE *asgn; @@ -10198,7 +10682,8 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs) ID vid = lhs->nd_vid; if (op == tOROP) { lhs->nd_value = rhs; - asgn = NEW_OP_ASGN_OR(gettable(vid), lhs); + asgn = NEW_OP_ASGN_OR(gettable(vid, column), lhs); + nd_set_column(asgn, column); if (is_notop_id(vid)) { switch (id_type(vid)) { case ID_GLOBAL: @@ -10210,22 +10695,23 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs) } else if (op == tANDOP) { lhs->nd_value = rhs; - asgn = NEW_OP_ASGN_AND(gettable(vid), lhs); + asgn = NEW_OP_ASGN_AND(gettable(vid, column), lhs); + nd_set_column(asgn, column); } else { asgn = lhs; - asgn->nd_value = NEW_CALL(gettable(vid), op, NEW_LIST(rhs)); + asgn->nd_value = new_call(gettable(vid, column), op, new_list(rhs, column), column); } } else { - asgn = NEW_BEGIN(0); + asgn = new_begin(0, column); } return asgn; } static NODE * new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, - ID atype, ID attr, ID op, NODE *rhs) + ID atype, ID attr, ID op, NODE *rhs, int column) { NODE *asgn; @@ -10236,12 +10722,13 @@ 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); fixpos(asgn, lhs); return asgn; } static NODE * -new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs) +new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, int column) { NODE *asgn; @@ -10255,23 +10742,32 @@ 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); + asgn = new_begin(0, column); } fixpos(asgn, lhs); + nd_set_column(asgn, column); return asgn; } static NODE * -const_decl_gen(struct parser_params *parser, NODE *path) +const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, int column) +{ + NODE *colon2 = NEW_COLON2(head, mid); + nd_set_column(colon2, column); + return colon2; +} + +static NODE * +const_decl_gen(struct parser_params *parser, NODE *path, int column) { if (in_def || in_single) { - yyerror("dynamic constant assignment"); + yyerror0("dynamic constant assignment"); } - return NEW_CDECL(0, 0, (path)); + return new_cdecl(0, 0, (path), column); } #else static VALUE -new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs) +new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs, int column) { return dispatch3(opassign, lhs, op, rhs); } @@ -10615,6 +11111,7 @@ typedef struct { struct parser_params* parser; rb_encoding *enc; NODE *succ_block; + int column; } reg_named_capture_assign_t; static int @@ -10635,22 +11132,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), NEW_LIT(ID2SYM(var))); + node = node_assign(assignable(var, 0, arg->column), new_lit(ID2SYM(var), arg->column), arg->column); succ = arg->succ_block; - if (!succ) succ = NEW_BEGIN(0); - succ = block_append(succ, node); + if (!succ) succ = new_begin(0, arg->column); + succ = block_append(succ, node, arg->column); arg->succ_block = succ; return ST_CONTINUE; } static NODE * -reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp) +reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, int column) { reg_named_capture_assign_t arg; arg.parser = parser; arg.enc = rb_enc_get(regexp); arg.succ_block = 0; + arg.column = column; onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg); if (!arg.succ_block) return 0; @@ -10723,8 +11221,9 @@ rb_parser_append_print(VALUE vparser, NODE *node) } node = block_append(node, - NEW_FCALL(rb_intern("print"), - NEW_ARRAY(NEW_GVAR(idLASTLINE)))); + new_fcall(rb_intern("print"), + NEW_ARRAY(new_gvar(idLASTLINE, 0)), 0), + 0); if (prelude) { prelude->nd_body = node; scope->nd_body = prelude; @@ -10755,13 +11254,13 @@ rb_parser_while_loop(VALUE vparser, NODE *node, int chomp, int split) } if (split) { node = block_append(NEW_GASGN(rb_intern("$F"), - NEW_CALL(NEW_GVAR(idLASTLINE), - rb_intern("split"), 0)), - node); + new_call(new_gvar(idLASTLINE, 0), + rb_intern("split"), 0, 0)), + node, 0); } if (chomp) { - node = block_append(NEW_CALL(NEW_GVAR(idLASTLINE), - rb_intern("chomp!"), 0), node); + node = block_append(new_call(new_gvar(idLASTLINE, 0), + rb_intern("chomp!"), 0, 0), node, 0); } node = NEW_OPT_N(node); |