summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y704
1 files changed, 352 insertions, 352 deletions
diff --git a/parse.y b/parse.y
index 3879668ac2..c57ef0de60 100644
--- a/parse.y
+++ b/parse.y
@@ -17,7 +17,7 @@
#define YYDEBUG 1
#define YYERROR_VERBOSE 1
#define YYSTACK_USE_ALLOCA 0
-#define YYLTYPE rb_code_range_t
+#define YYLTYPE rb_code_location_t
#define YYLTYPE_IS_DECLARED 1
#include "ruby/ruby.h"
@@ -44,27 +44,27 @@
#define YYCALLOC(nelem, size) rb_parser_calloc(parser, (nelem), (size))
#define YYFREE(ptr) rb_parser_free(parser, (ptr))
#define YYFPRINTF rb_parser_printf
-#define YY_LOCATION_PRINT(File, Loc) \
+#define YY_LOCATION_PRINT(File, loc) \
rb_parser_printf(parser, "%d.%d-%d.%d", \
- (Loc).first_loc.lineno, (Loc).first_loc.column,\
- (Loc).last_loc.lineno, (Loc).last_loc.column)
+ (loc).beg_pos.lineno, (loc).beg_pos.column,\
+ (loc).end_pos.lineno, (loc).end_pos.column)
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) \
{ \
- (Current).first_loc = YYRHSLOC(Rhs, 1).first_loc; \
- (Current).last_loc = YYRHSLOC(Rhs, N).last_loc; \
+ (Current).beg_pos = YYRHSLOC(Rhs, 1).beg_pos; \
+ (Current).end_pos = YYRHSLOC(Rhs, N).end_pos; \
} \
else \
RUBY_SET_YYLLOC_OF_NONE(Current); \
while (0)
#define RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(Current) \
- rb_parser_set_code_range_from_strterm_heredoc(parser, &lex_strterm->u.heredoc, &(Current))
+ rb_parser_set_location_from_strterm_heredoc(parser, &lex_strterm->u.heredoc, &(Current))
#define RUBY_SET_YYLLOC_OF_NONE(Current) \
- rb_parser_set_code_range_of_none(parser, &(Current))
+ rb_parser_set_location_of_none(parser, &(Current))
#define RUBY_SET_YYLLOC(Current) \
- rb_parser_set_code_range(parser, &(Current))
+ rb_parser_set_location(parser, &(Current))
enum lex_state_bits {
EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
@@ -116,7 +116,7 @@ enum lex_state_e {
typedef VALUE stack_type;
-static const rb_code_range_t NULL_LOC = { {0, -1}, {0, -1} };
+static const rb_code_location_t NULL_LOC = { {0, -1}, {0, -1} };
# define SHOW_BITSTACK(stack, name) (yydebug ? rb_parser_show_bitstack(parser, stack, name, __LINE__) : (void)0)
# define BITSTACK_PUSH(stack, n) (((stack) = ((stack)<<1)|((n)&1)), SHOW_BITSTACK(stack, #stack"(push)"))
@@ -282,7 +282,7 @@ struct parser_params {
static int parser_yyerror(struct parser_params*, const YYLTYPE *yylloc, const char*);
#define yyerror0(msg) parser_yyerror(parser, NULL, (msg))
-#define yyerror1(cr, msg) parser_yyerror(parser, (cr), (msg))
+#define yyerror1(loc, msg) parser_yyerror(parser, (loc), (msg))
#define yyerror(yylloc, parser, msg) parser_yyerror(parser, yylloc, msg)
#define token_flush(p) ((p)->lex.ptok = (p)->lex.pcur)
@@ -337,7 +337,7 @@ static int parser_yyerror(struct parser_params*, const YYLTYPE *yylloc, const ch
#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,cr) NEW_NODE(NODE_CALL_Q(q),r,m,a,cr)
+#define NEW_QCALL(q,r,m,a,loc) NEW_NODE(NODE_CALL_Q(q),r,m,a,loc)
#define lambda_beginning_p() (lpar_beg && lpar_beg == paren_nest)
@@ -366,10 +366,10 @@ add_mark_object_gen(struct parser_params *parser, VALUE obj)
}
#define add_mark_object(obj) add_mark_object_gen(parser, (obj))
-static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_range_t*);
-#define rb_node_newnode(type, a1, a2, a3, cr) node_newnode(parser, (type), (a1), (a2), (a3), (cr))
+static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_location_t*);
+#define rb_node_newnode(type, a1, a2, a3, loc) node_newnode(parser, (type), (a1), (a2), (a3), (loc))
-static NODE *nd_set_crange(NODE *nd, const YYLTYPE *cr);
+static NODE *nd_set_loc(NODE *nd, const YYLTYPE *loc);
#ifndef RIPPER
static inline void
@@ -386,17 +386,17 @@ set_line_body(NODE *body, int line)
#define yyparse ruby_yyparse
static NODE *cond_gen(struct parser_params*,NODE*,int,const YYLTYPE*);
-#define cond(node,cr) cond_gen(parser, (node), FALSE, cr)
-#define method_cond(node,cr) cond_gen(parser, (node), TRUE, cr)
-#define new_nil(cr) NEW_NIL(cr)
+#define cond(node,loc) cond_gen(parser, (node), FALSE, loc)
+#define method_cond(node,loc) cond_gen(parser, (node), TRUE, loc)
+#define new_nil(loc) NEW_NIL(loc)
static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
-#define new_if(cc,left,right,cr) new_if_gen(parser, (cc), (left), (right), (cr))
+#define new_if(cc,left,right,loc) new_if_gen(parser, (cc), (left), (right), (loc))
static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*);
-#define new_unless(cc,left,right,cr) new_unless_gen(parser, (cc), (left), (right), (cr))
+#define new_unless(cc,left,right,loc) new_unless_gen(parser, (cc), (left), (right), (loc))
static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*);
-#define logop(id,node1,node2,op_cr,cr) \
+#define logop(id,node1,node2,op_loc,loc) \
logop_gen(parser, ((id)==idAND||(id)==idANDOP)?NODE_AND:NODE_OR, \
- (node1), (node2), (op_cr), (cr))
+ (node1), (node2), (op_loc), (loc))
static NODE *newline_node(NODE*);
static void fixpos(NODE*,NODE*);
@@ -421,36 +421,36 @@ static NODE *list_append_gen(struct parser_params*,NODE*,NODE*);
#define list_append(l,i) list_append_gen(parser,(l),(i))
static NODE *list_concat(NODE*,NODE*);
static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-#define arg_append(h,t,cr) arg_append_gen(parser,(h),(t),(cr))
+#define arg_append(h,t,loc) arg_append_gen(parser,(h),(t),(loc))
static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-#define arg_concat(h,t,cr) arg_concat_gen(parser,(h),(t),(cr))
+#define arg_concat(h,t,loc) arg_concat_gen(parser,(h),(t),(loc))
static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-#define literal_concat(h,t,cr) literal_concat_gen(parser,(h),(t),(cr))
+#define literal_concat(h,t,loc) literal_concat_gen(parser,(h),(t),(loc))
static int literal_concat0(struct parser_params *, VALUE, VALUE);
static NODE *new_evstr_gen(struct parser_params*,NODE*,const YYLTYPE*);
-#define new_evstr(n, cr) new_evstr_gen(parser,(n),(cr))
+#define new_evstr(n, loc) new_evstr_gen(parser,(n),(loc))
static NODE *evstr2dstr_gen(struct parser_params*,NODE*);
#define evstr2dstr(n) evstr2dstr_gen(parser,(n))
static NODE *splat_array(NODE*);
static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*,const YYLTYPE*,const YYLTYPE*);
-#define call_bin_op(recv,id,arg1,op_cr,cr) call_bin_op_gen(parser, (recv),(id),(arg1),(op_cr),(cr))
+#define call_bin_op(recv,id,arg1,op_loc,loc) call_bin_op_gen(parser, (recv),(id),(arg1),(op_loc),(loc))
static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID,const YYLTYPE*,const YYLTYPE*);
-#define call_uni_op(recv,id,op_cr,cr) call_uni_op_gen(parser, (recv),(id),(op_cr),(cr))
-static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_cr, const YYLTYPE *cr);
-#define new_qcall(q,r,m,a,op_cr,cr) new_qcall_gen(parser,q,r,m,a,op_cr,cr)
-#define new_command_qcall(q,r,m,a,op_cr,cr) new_qcall_gen(parser,q,r,m,a,op_cr,cr)
+#define call_uni_op(recv,id,op_loc,loc) call_uni_op_gen(parser, (recv),(id),(op_loc),(loc))
+static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_loc, const YYLTYPE *loc);
+#define new_qcall(q,r,m,a,op_loc,loc) new_qcall_gen(parser,q,r,m,a,op_loc,loc)
+#define new_command_qcall(q,r,m,a,op_loc,loc) new_qcall_gen(parser,q,r,m,a,op_loc,loc)
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, const YYLTYPE *cr) {b->nd_iter = m; b->nd_crange = *cr; return b;}
-#define method_add_block(m,b,cr) method_add_block_gen(parser, m, b, cr)
+static NODE *method_add_block_gen(struct parser_params*parser, NODE *m, NODE *b, const YYLTYPE *loc) {b->nd_iter = m; b->nd_loc = *loc; return b;}
+#define method_add_block(m,b,loc) method_add_block_gen(parser, m, b, loc)
static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*,const YYLTYPE*);
-#define new_args(f,o,r,p,t,cr) new_args_gen(parser, (f),(o),(r),(p),(t),(cr))
+#define new_args(f,o,r,p,t,loc) new_args_gen(parser, (f),(o),(r),(p),(t),(loc))
static NODE *new_args_tail_gen(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
-#define new_args_tail(k,kr,b,cr) new_args_tail_gen(parser, (k),(kr),(b),(cr))
-static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *cr);
-#define new_kw_arg(k,cr) new_kw_arg_gen(parser, k, cr)
+#define new_args_tail(k,kr,b,loc) new_args_tail_gen(parser, (k),(kr),(b),(loc))
+static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *loc);
+#define new_kw_arg(k,loc) new_kw_arg_gen(parser, k, loc)
static VALUE negate_lit_gen(struct parser_params*, VALUE);
#define negate_lit(lit) negate_lit_gen(parser, lit)
@@ -458,65 +458,65 @@ 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*,const YYLTYPE*);
-#define new_yield(node,cr) new_yield_gen(parser, (node), (cr))
+#define new_yield(node,loc) new_yield_gen(parser, (node), (loc))
static NODE *dsym_node_gen(struct parser_params*,NODE*,const YYLTYPE*);
-#define dsym_node(node,cr) dsym_node_gen(parser, (node), (cr))
+#define dsym_node(node,loc) dsym_node_gen(parser, (node), (loc))
static NODE *gettable_gen(struct parser_params*,ID,const YYLTYPE*);
-#define gettable(id,cr) gettable_gen(parser,(id),(cr))
+#define gettable(id,loc) gettable_gen(parser,(id),(loc))
static NODE *assignable_gen(struct parser_params*,ID,NODE*,const YYLTYPE*);
-#define assignable(id,node,cr) assignable_gen(parser, (id), (node), (cr))
+#define assignable(id,node,loc) assignable_gen(parser, (id), (node), (loc))
static NODE *aryset_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*);
-#define aryset(node1,node2,cr) aryset_gen(parser, (node1), (node2), (cr))
+#define aryset(node1,node2,loc) aryset_gen(parser, (node1), (node2), (loc))
static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID,const YYLTYPE*);
-#define attrset(node,q,id,cr) attrset_gen(parser, (node), (q), (id), (cr))
+#define attrset(node,q,id,loc) attrset_gen(parser, (node), (q), (id), (loc))
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*,const YYLTYPE*);
-#define node_assign(node1, node2, cr) node_assign_gen(parser, (node1), (node2), (cr))
+#define node_assign(node1, node2, loc) node_assign_gen(parser, (node1), (node2), (loc))
-static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr);
-#define new_op_assign(lhs, op, rhs, cr) new_op_assign_gen(parser, (lhs), (op), (rhs), (cr))
-static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *cr);
-#define new_attr_op_assign(lhs, type, attr, op, rhs, cr) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (cr))
-static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr);
-#define new_const_op_assign(lhs, op, rhs, cr) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (cr))
+static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc);
+#define new_op_assign(lhs, op, rhs, loc) new_op_assign_gen(parser, (lhs), (op), (rhs), (loc))
+static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc);
+#define new_attr_op_assign(lhs, type, attr, op, rhs, loc) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (loc))
+static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc);
+#define new_const_op_assign(lhs, op, rhs, loc) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (loc))
-static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *cr);
-#define const_path_field(w, n, cr) const_path_field_gen(parser, w, n, cr)
-#define top_const_field(n,cr) NEW_COLON3(n,cr)
-static NODE *const_decl_gen(struct parser_params *parser, NODE* path, const YYLTYPE *cr);
-#define const_decl(path, cr) const_decl_gen(parser, path, cr)
+static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *loc);
+#define const_path_field(w, n, loc) const_path_field_gen(parser, w, n, loc)
+#define top_const_field(n,loc) NEW_COLON3(n,loc)
+static NODE *const_decl_gen(struct parser_params *parser, NODE* path, const YYLTYPE *loc);
+#define const_decl(path, loc) const_decl_gen(parser, path, loc)
#define var_field(n) (n)
-#define backref_assign_error(n, a, cr) (rb_backref_error(n), NEW_BEGIN(0, cr))
+#define backref_assign_error(n, a, loc) (rb_backref_error(n), NEW_BEGIN(0, loc))
static NODE *opt_arg_append(NODE*, NODE*);
static NODE *kwd_append(NODE*, NODE*);
-static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *cr);
-#define new_hash(hash, cr) new_hash_gen(parser, (hash), cr)
+static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *loc);
+#define new_hash(hash, loc) new_hash_gen(parser, (hash), loc)
-static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *cr);
-#define new_defined(expr, cr) new_defined_gen(parser, expr, cr)
+static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *loc);
+#define new_defined(expr, loc) new_defined_gen(parser, expr, loc)
static NODE *new_regexp_gen(struct parser_params *, NODE *, int, const YYLTYPE *);
-#define new_regexp(node, opt, cr) new_regexp_gen(parser, node, opt, cr)
+#define new_regexp(node, opt, loc) new_regexp_gen(parser, node, opt, loc)
-#define make_array(ary, cr) ((ary) ? (nd_set_crange(ary, cr), ary) : NEW_ZARRAY(cr))
+#define make_array(ary, loc) ((ary) ? (nd_set_loc(ary, loc), ary) : NEW_ZARRAY(loc))
-static NODE *new_xstring_gen(struct parser_params *, NODE *, const YYLTYPE *cr);
-#define new_xstring(node, cr) new_xstring_gen(parser, node, cr)
+static NODE *new_xstring_gen(struct parser_params *, NODE *, const YYLTYPE *loc);
+#define new_xstring(node, loc) new_xstring_gen(parser, node, loc)
#define new_string1(str) (str)
-static NODE *new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *cr);
-#define new_brace_body(param, stmt, cr) new_body_gen(parser, param, stmt, cr)
-#define new_do_body(param, stmt, cr) new_body_gen(parser, param, stmt, cr)
+static NODE *new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *loc);
+#define new_brace_body(param, stmt, loc) new_body_gen(parser, param, stmt, loc)
+#define new_do_body(param, stmt, loc) new_body_gen(parser, param, stmt, loc)
static NODE *match_op_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*);
-#define match_op(node1,node2,op_cr,cr) match_op_gen(parser, (node1), (node2), (op_cr), (cr))
+#define match_op(node1,node2,op_loc,loc) match_op_gen(parser, (node1), (node2), (op_loc), (loc))
static ID *local_tbl_gen(struct parser_params*);
#define local_tbl() local_tbl_gen(parser)
@@ -527,8 +527,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, const YYLTYPE *cr);
-#define reg_named_capture_assign(regexp,cr) reg_named_capture_assign_gen(parser,(regexp),cr)
+static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *loc);
+#define reg_named_capture_assign(regexp,loc) reg_named_capture_assign_gen(parser,(regexp),loc)
static NODE *parser_heredoc_dedent(struct parser_params*,NODE*);
# define heredoc_dedent(str) parser_heredoc_dedent(parser, (str))
@@ -562,48 +562,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,cr) assignable_gen(parser, (lhs))
+#define assignable(lhs,node,loc) 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,cr) (node)
-#define call_bin_op(recv,id,arg1,op_cr,cr) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1))
-#define match_op(node1,node2,op_cr,cr) call_bin_op((node1), idEqTilde, (node2), op_cr, cr)
-#define call_uni_op(recv,id,op_cr,cr) dispatch2(unary, STATIC_ID2SYM(id), (recv))
-#define logop(id,node1,node2,op_cr,cr) call_bin_op((node1), (id), (node2), op_cr, cr)
-#define node_assign(node1, node2, cr) dispatch2(assign, (node1), (node2))
+#define method_cond(node,loc) (node)
+#define call_bin_op(recv,id,arg1,op_loc,loc) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1))
+#define match_op(node1,node2,op_loc,loc) call_bin_op((node1), idEqTilde, (node2), op_loc, loc)
+#define call_uni_op(recv,id,op_loc,loc) dispatch2(unary, STATIC_ID2SYM(id), (recv))
+#define logop(id,node1,node2,op_loc,loc) call_bin_op((node1), (id), (node2), op_loc, loc)
+#define node_assign(node1, node2, loc) 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,op_cr,cr) new_qcall_gen(parser, (r), (q), (m), (a))
-#define new_command_qcall(q,r,m,a,op_cr,cr) dispatch4(command_call, (r), (q), (m), (a))
+#define new_qcall(q,r,m,a,op_loc,loc) new_qcall_gen(parser, (r), (q), (m), (a))
+#define new_command_qcall(q,r,m,a,op_loc,loc) dispatch4(command_call, (r), (q), (m), (a))
#define new_command(m,a) dispatch2(command, (m), (a));
-#define new_nil(cr) Qnil
+#define new_nil(loc) Qnil
static VALUE new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs);
-#define new_op_assign(lhs, op, rhs, cr) new_op_assign_gen(parser, (lhs), (op), (rhs))
+#define new_op_assign(lhs, op, rhs, loc) new_op_assign_gen(parser, (lhs), (op), (rhs))
static VALUE new_attr_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE type, VALUE attr, VALUE op, VALUE rhs);
-#define new_attr_op_assign(lhs, type, attr, op, rhs, cr) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
-#define new_const_op_assign(lhs, op, rhs, cr) new_op_assign(lhs, op, rhs, cr)
+#define new_attr_op_assign(lhs, type, attr, op, rhs, loc) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
+#define new_const_op_assign(lhs, op, rhs, loc) new_op_assign(lhs, op, rhs, loc)
static VALUE new_regexp_gen(struct parser_params *, VALUE, VALUE);
-#define new_regexp(node, opt, cr) new_regexp_gen(parser, node, opt)
+#define new_regexp(node, opt, loc) new_regexp_gen(parser, node, opt)
static VALUE new_xstring_gen(struct parser_params *, VALUE);
-#define new_xstring(str, cr) new_xstring_gen(parser, str)
+#define new_xstring(str, loc) new_xstring_gen(parser, str)
#define new_string1(str) dispatch1(string_literal, str)
-#define new_brace_body(param, stmt, cr) dispatch2(brace_block, escape_Qundef(param), stmt)
-#define new_do_body(param, stmt, cr) dispatch2(do_block, escape_Qundef(param), stmt)
+#define new_brace_body(param, stmt, loc) dispatch2(brace_block, escape_Qundef(param), stmt)
+#define new_do_body(param, stmt, loc) dispatch2(do_block, escape_Qundef(param), stmt)
-#define const_path_field(w, n, cr) dispatch2(const_path_field, (w), (n))
-#define top_const_field(n,cr) dispatch1(top_const_field, (n))
+#define const_path_field(w, n, loc) dispatch2(const_path_field, (w), (n))
+#define top_const_field(n,loc) dispatch1(top_const_field, (n))
static VALUE const_decl_gen(struct parser_params *parser, VALUE path);
-#define const_decl(path, cr) const_decl_gen(parser, path)
+#define const_decl(path, loc) 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, cr) assign_error(a)
+#define backref_assign_error(n, a, loc) assign_error(a)
#define block_dup_check(n1,n2) ((void)(n1), (void)(n2))
#define fixpos(n1,n2) ((void)(n1), (void)(n2))
@@ -624,9 +624,9 @@ enum lex_state_e rb_parser_trace_lex_state(struct parser_params *, enum lex_stat
VALUE rb_parser_lex_state_name(enum lex_state_e state);
void rb_parser_show_bitstack(struct parser_params *, stack_type, const char *, int);
PRINTF_ARGS(void rb_parser_fatal(struct parser_params *parser, const char *fmt, ...), 2, 3);
-void rb_parser_set_code_range_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc);
-void rb_parser_set_code_range_of_none(struct parser_params *parser, YYLTYPE *yylloc);
-void rb_parser_set_code_range(struct parser_params *parser, YYLTYPE *yylloc);
+void rb_parser_set_location_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc);
+void rb_parser_set_location_of_none(struct parser_params *parser, YYLTYPE *yylloc);
+void rb_parser_set_location(struct parser_params *parser, YYLTYPE *yylloc);
RUBY_SYMBOL_EXPORT_END
static ID formal_argument_gen(struct parser_params*, ID);
@@ -801,7 +801,7 @@ static void ripper_error_gen(struct parser_params *parser);
#define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
#define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
-#define method_add_block(m,b,cr) dispatch2(method_add_block, (m), (b))
+#define method_add_block(m,b,loc) dispatch2(method_add_block, (m), (b))
#define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
@@ -812,7 +812,7 @@ new_args_gen(struct parser_params *parser, VALUE f, VALUE o, VALUE r, VALUE p, V
VALUE k = t->u1.value, kr = t->u2.value, b = t->u3.value;
return params_new(f, o, r, p, k, kr, escape_Qundef(b));
}
-#define new_args(f,o,r,p,t,cr) new_args_gen(parser, (f),(o),(r),(p),(t))
+#define new_args(f,o,r,p,t,loc) new_args_gen(parser, (f),(o),(r),(p),(t))
static inline VALUE
new_args_tail_gen(struct parser_params *parser, VALUE k, VALUE kr, VALUE b)
@@ -823,9 +823,9 @@ new_args_tail_gen(struct parser_params *parser, VALUE k, VALUE kr, VALUE b)
add_mark_object(b);
return (VALUE)t;
}
-#define new_args_tail(k,kr,b,cr) new_args_tail_gen(parser, (k),(kr),(b))
+#define new_args_tail(k,kr,b,loc) new_args_tail_gen(parser, (k),(kr),(b))
-#define new_defined(expr,cr) dispatch1(defined, (expr))
+#define new_defined(expr,loc) dispatch1(defined, (expr))
static VALUE parser_heredoc_dedent(struct parser_params*,VALUE);
# define heredoc_dedent(str) parser_heredoc_dedent(parser, (str))
@@ -1380,8 +1380,8 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
/*%%%*/
NODE *resq;
- YYLTYPE cr = code_range_gen(&@2, &@3);
- resq = NEW_RESBODY(0, remove_begin($3), 0, &cr);
+ YYLTYPE loc = code_loc_gen(&@2, &@3);
+ resq = NEW_RESBODY(0, remove_begin($3), 0, &loc);
$$ = NEW_RESCUE(remove_begin($1), resq, 0, &@$);
/*%
$$ = dispatch2(rescue_mod, $1, $3);
@@ -1466,10 +1466,10 @@ command_asgn : lhs '=' command_rhs
| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
{
/*%%%*/
- YYLTYPE cr = code_range_gen(&@1, &@3);
+ YYLTYPE loc = code_loc_gen(&@1, &@3);
/*%
%*/
- $$ = const_path_field($1, $3, &cr);
+ $$ = const_path_field($1, $3, &loc);
$$ = new_const_op_assign($$, $4, $5, &@$);
}
| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
@@ -1495,9 +1495,9 @@ command_rhs : command_call %prec tOP_ASGN
| command_call modifier_rescue stmt
{
/*%%%*/
- YYLTYPE cr = code_range_gen(&@2, &@3);
+ YYLTYPE loc = code_loc_gen(&@2, &@3);
value_expr($1);
- $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &cr), 0, &@$);
+ $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &loc), 0, &@$);
/*%
$$ = dispatch2(rescue_mod, $1, $3);
%*/
@@ -1552,8 +1552,8 @@ cmd_brace_block : tLBRACE_ARG brace_body '}'
{
$$ = $2;
/*%%%*/
- $$->nd_body->nd_crange = code_range_gen(&@1, &@3);
- nd_set_line($$, @1.last_loc.lineno);
+ $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
+ nd_set_line($$, @1.end_pos.lineno);
/*% %*/
}
;
@@ -2101,10 +2101,10 @@ arg : lhs '=' arg_rhs
| primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
{
/*%%%*/
- YYLTYPE cr = code_range_gen(&@1, &@3);
+ YYLTYPE loc = code_loc_gen(&@1, &@3);
/*%
%*/
- $$ = const_path_field($1, $3, &cr);
+ $$ = const_path_field($1, $3, &loc);
$$ = new_const_op_assign($$, $4, $5, &@$);
}
| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
@@ -2318,9 +2318,9 @@ arg_rhs : arg %prec tOP_ASGN
| arg modifier_rescue arg
{
/*%%%*/
- YYLTYPE cr = code_range_gen(&@2, &@3);
+ YYLTYPE loc = code_loc_gen(&@2, &@3);
value_expr($1);
- $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &cr), 0, &@$);
+ $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &loc), 0, &@$);
/*%
$$ = dispatch2(rescue_mod, $1, $3);
%*/
@@ -2563,10 +2563,10 @@ primary : literal
$$ = NEW_NIL(&@$);
}
else {
- set_line_body($3, @1.last_loc.lineno);
+ set_line_body($3, @1.end_pos.lineno);
$$ = NEW_BEGIN($3, &@$);
}
- nd_set_line($$, @1.last_loc.lineno);
+ nd_set_line($$, @1.end_pos.lineno);
/*%
$$ = dispatch1(begin, $3);
%*/
@@ -2822,8 +2822,8 @@ primary : literal
| k_class cpath superclass
{
if (in_def) {
- YYLTYPE cr = code_range_gen(&@1, &@2);
- yyerror1(&cr, "class definition in method body");
+ YYLTYPE loc = code_loc_gen(&@1, &@2);
+ yyerror1(&loc, "class definition in method body");
}
$<num>1 = in_class;
in_class = 1;
@@ -2834,9 +2834,9 @@ primary : literal
{
/*%%%*/
$$ = NEW_CLASS($2, $5, $3, &@$);
- nd_set_line($$->nd_body, @6.last_loc.lineno);
- set_line_body($5, @3.last_loc.lineno);
- nd_set_line($$, @3.last_loc.lineno);
+ nd_set_line($$->nd_body, @6.end_pos.lineno);
+ set_line_body($5, @3.end_pos.lineno);
+ nd_set_line($$, @3.end_pos.lineno);
/*%
$$ = dispatch3(class, $2, $3, $5);
%*/
@@ -2856,7 +2856,7 @@ primary : literal
{
/*%%%*/
$$ = NEW_SCLASS($3, $6, &@$);
- nd_set_line($$->nd_body, @7.last_loc.lineno);
+ nd_set_line($$->nd_body, @7.end_pos.lineno);
set_line_body($6, nd_line($3));
fixpos($$, $3);
/*%
@@ -2869,8 +2869,8 @@ primary : literal
| k_module cpath
{
if (in_def) {
- YYLTYPE cr = code_range_gen(&@1, &@2);
- yyerror1(&cr, "module definition in method body");
+ YYLTYPE loc = code_loc_gen(&@1, &@2);
+ yyerror1(&loc, "module definition in method body");
}
$<num>1 = in_class;
in_class = 1;
@@ -2881,9 +2881,9 @@ primary : literal
{
/*%%%*/
$$ = NEW_MODULE($2, $4, &@$);
- nd_set_line($$->nd_body, @5.last_loc.lineno);
- set_line_body($4, @2.last_loc.lineno);
- nd_set_line($$, @2.last_loc.lineno);
+ nd_set_line($$->nd_body, @5.end_pos.lineno);
+ set_line_body($4, @2.end_pos.lineno);
+ nd_set_line($$, @2.end_pos.lineno);
/*%
$$ = dispatch2(module, $2, $4);
%*/
@@ -2908,8 +2908,8 @@ primary : literal
NODE *body = remove_begin($6);
reduce_nodes(&body);
$$ = NEW_DEFN($2, $5, body, &@$);
- nd_set_line($$->nd_defn, @7.last_loc.lineno);
- set_line_body(body, @1.first_loc.lineno);
+ nd_set_line($$->nd_defn, @7.end_pos.lineno);
+ set_line_body(body, @1.beg_pos.lineno);
/*%
$$ = dispatch3(def, $2, $5, $6);
%*/
@@ -2934,8 +2934,8 @@ primary : literal
NODE *body = remove_begin($8);
reduce_nodes(&body);
$$ = NEW_DEFS($2, $5, $7, body, &@$);
- nd_set_line($$->nd_defn, @9.last_loc.lineno);
- set_line_body(body, @1.first_loc.lineno);
+ nd_set_line($$->nd_defn, @9.end_pos.lineno);
+ set_line_body(body, @1.beg_pos.lineno);
/*%
$$ = dispatch5(defs, $2, $<val>3, $5, $7, $8);
%*/
@@ -3425,8 +3425,8 @@ lambda : {
CMDARG_LEXPOP();
/*%%%*/
$$ = NEW_LAMBDA($3, $5, &@$);
- nd_set_line($$->nd_body, @5.last_loc.lineno);
- nd_set_line($$, @3.last_loc.lineno);
+ nd_set_line($$->nd_body, @5.end_pos.lineno);
+ nd_set_line($$, @3.end_pos.lineno);
/*%
$$ = dispatch2(lambda, $3, $5);
%*/
@@ -3463,8 +3463,8 @@ do_block : keyword_do_block do_body keyword_end
{
$$ = $2;
/*%%%*/
- $$->nd_body->nd_crange = code_range_gen(&@1, &@3);
- nd_set_line($$, @1.last_loc.lineno);
+ $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
+ nd_set_line($$, @1.end_pos.lineno);
/*% %*/
}
;
@@ -3519,7 +3519,7 @@ method_call : fcall paren_args
/*%%%*/
$$ = $1;
$$->nd_args = $2;
- nd_set_last_loc($1, @2.last_loc);
+ nd_set_last_loc($1, @2.end_pos);
/*%
$$ = method_arg(dispatch1(fcall, $1), $2);
%*/
@@ -3527,12 +3527,12 @@ method_call : fcall paren_args
| primary_value call_op operation2 opt_paren_args
{
$$ = new_qcall($2, $1, $3, $4, &@3, &@$);
- nd_set_line($$, @3.last_loc.lineno);
+ nd_set_line($$, @3.end_pos.lineno);
}
| primary_value tCOLON2 operation2 paren_args
{
$$ = new_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@3, &@$);
- nd_set_line($$, @3.last_loc.lineno);
+ nd_set_line($$, @3.end_pos.lineno);
}
| primary_value tCOLON2 operation3
{
@@ -3541,12 +3541,12 @@ method_call : fcall paren_args
| primary_value call_op paren_args
{
$$ = new_qcall($2, $1, ID2VAL(idCall), $3, &@2, &@$);
- nd_set_line($$, @2.last_loc.lineno);
+ nd_set_line($$, @2.end_pos.lineno);
}
| primary_value tCOLON2 paren_args
{
$$ = new_qcall(ID2VAL(idCOLON2), $1, ID2VAL(idCall), $3, &@2, &@$);
- nd_set_line($$, @2.last_loc.lineno);
+ nd_set_line($$, @2.end_pos.lineno);
}
| keyword_super paren_args
{
@@ -3582,16 +3582,16 @@ brace_block : '{' brace_body '}'
{
$$ = $2;
/*%%%*/
- $$->nd_body->nd_crange = code_range_gen(&@1, &@3);
- nd_set_line($$, @1.last_loc.lineno);
+ $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
+ nd_set_line($$, @1.end_pos.lineno);
/*% %*/
}
| keyword_do do_body keyword_end
{
$$ = $2;
/*%%%*/
- $$->nd_body->nd_crange = code_range_gen(&@1, &@3);
- nd_set_line($$, @1.last_loc.lineno);
+ $$->nd_body->nd_loc = code_loc_gen(&@1, &@3);
+ nd_set_line($$, @1.end_pos.lineno);
/*% %*/
}
;
@@ -3724,7 +3724,7 @@ strings : string
string : tCHAR
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
@@ -3743,7 +3743,7 @@ string1 : tSTRING_BEG string_contents tSTRING_END
{
$$ = new_string1(heredoc_dedent($2));
/*%%%*/
- if ($$) nd_set_crange($$, &@$);
+ if ($$) nd_set_loc($$, &@$);
/*%
%*/
}
@@ -3874,7 +3874,7 @@ qword_list : /* none */
| qword_list tSTRING_CONTENT ' '
{
/*%%%*/
- nd_set_crange($2, &@2);
+ nd_set_loc($2, &@2);
$$ = list_append($1, $2);
/*%
$$ = dispatch2(qwords_add, $1, $2);
@@ -3897,7 +3897,7 @@ qsym_list : /* none */
lit = $2->nd_lit;
nd_set_type($2, NODE_LIT);
add_mark_object($2->nd_lit = ID2SYM(rb_intern_str(lit)));
- nd_set_crange($2, &@2);
+ nd_set_loc($2, &@2);
$$ = list_append($1, $2);
/*%
$$ = dispatch2(qsymbols_add, $1, $2);
@@ -3993,7 +3993,7 @@ regexp_contents: /* none */
string_content : tSTRING_CONTENT
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
@@ -4009,7 +4009,7 @@ string_content : tSTRING_CONTENT
lex_strterm = $<strterm>2;
/*%%%*/
$$ = NEW_EVSTR($3, &@$);
- nd_set_line($$, @3.last_loc.lineno);
+ nd_set_line($$, @3.end_pos.lineno);
/*%
$$ = dispatch1(string_dvar, $3);
%*/
@@ -4126,28 +4126,28 @@ numeric : simple_numeric
simple_numeric : tINTEGER
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
| tFLOAT
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
| tRATIONAL
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
| tIMAGINARY
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
@@ -4205,14 +4205,14 @@ var_lhs : user_variable
backref : tNTH_REF
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
| tBACK_REF
{
/*%%%*/
- nd_set_crange($$, &@$);
+ nd_set_loc($$, &@$);
/*%
%*/
}
@@ -4424,18 +4424,18 @@ f_arg_item : f_arg_asgn
{
ID tid = internal_id();
/*%%%*/
- YYLTYPE cr;
- cr.first_loc = @2.first_loc;
- cr.last_loc = @2.first_loc;
+ YYLTYPE loc;
+ loc.beg_pos = @2.beg_pos;
+ loc.end_pos = @2.beg_pos;
/*%
%*/
arg_var(tid);
/*%%%*/
if (dyna_in_block()) {
- $2->nd_value = NEW_DVAR(tid, &cr);
+ $2->nd_value = NEW_DVAR(tid, &loc);
}
else {
- $2->nd_value = NEW_LVAR(tid, &cr);
+ $2->nd_value = NEW_LVAR(tid, &loc);
}
$$ = NEW_ARGS_AUX(tid, 1, &NULL_LOC);
$$->nd_next = $2;
@@ -4806,8 +4806,8 @@ assoc : arg_value tASSOC arg_value
| tSTRING_BEG string_contents tLABEL_END arg_value
{
/*%%%*/
- YYLTYPE cr = code_range_gen(&@1, &@3);
- $$ = list_append(NEW_LIST(dsym_node($2, &cr), &cr), $4);
+ YYLTYPE loc = code_loc_gen(&@1, &@3);
+ $$ = list_append(NEW_LIST(dsym_node($2, &loc), &loc), $4);
/*%
$$ = dispatch2(assoc_new, dispatch1(dyna_symbol, $2), $4);
%*/
@@ -5115,10 +5115,10 @@ parser_yyerror(struct parser_params *parser, const YYLTYPE *yylloc, const char *
RUBY_SET_YYLLOC(current);
yylloc = &current;
}
- else if ((ruby_sourceline != yylloc->first_loc.lineno &&
- ruby_sourceline != yylloc->last_loc.lineno) ||
- (yylloc->first_loc.lineno == yylloc->last_loc.lineno &&
- yylloc->first_loc.column == yylloc->last_loc.column)) {
+ else if ((ruby_sourceline != yylloc->beg_pos.lineno &&
+ ruby_sourceline != yylloc->end_pos.lineno) ||
+ (yylloc->beg_pos.lineno == yylloc->end_pos.lineno &&
+ yylloc->beg_pos.column == yylloc->end_pos.column)) {
compile_error(PARSER_ARG "%s", msg);
return 0;
}
@@ -5128,8 +5128,8 @@ parser_yyerror(struct parser_params *parser, const YYLTYPE *yylloc, const char *
if (--pend > lex_pbeg && pend[-1] == '\r') --pend;
}
- pt = (ruby_sourceline == yylloc->last_loc.lineno) ?
- lex_pbeg + yylloc->last_loc.column : lex_pend;
+ pt = (ruby_sourceline == yylloc->end_pos.lineno) ?
+ lex_pbeg + yylloc->end_pos.column : lex_pend;
p = pe = pt < pend ? pt : pend;
lim = p - lex_pbeg > max_line_margin ? p - max_line_margin : lex_pbeg;
while ((lim < p) && (*(p-1) != '\n')) p--;
@@ -5149,12 +5149,12 @@ parser_yyerror(struct parser_params *parser, const YYLTYPE *yylloc, const char *
}
}
pb = lex_pbeg;
- if (ruby_sourceline == yylloc->first_loc.lineno) {
- pb += yylloc->first_loc.column;
+ if (ruby_sourceline == yylloc->beg_pos.lineno) {
+ pb += yylloc->beg_pos.column;
if (pb > pt) pb = pt;
}
if (pb < p) pb = p;
- if (len <= 4 && yylloc->first_loc.lineno == yylloc->last_loc.lineno) {
+ if (len <= 4 && yylloc->beg_pos.lineno == yylloc->end_pos.lineno) {
compile_error(PARSER_ARG "%s", msg);
}
else if (!parser->error_buffer && rb_stderr_tty_p()) {
@@ -8717,21 +8717,21 @@ yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *parser)
#define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
static NODE*
-node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2, const rb_code_range_t *cr)
+node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2, const rb_code_location_t *loc)
{
NODE *n = rb_ast_newnode(parser->ast);
rb_node_init(n, type, a0, a1, a2);
- nd_set_crange(n, cr);
+ nd_set_loc(n, loc);
return n;
}
static NODE *
-nd_set_crange(NODE *nd, const YYLTYPE *cr)
+nd_set_loc(NODE *nd, const YYLTYPE *loc)
{
- nd->nd_crange = *cr;
- nd_set_line(nd, cr->first_loc.lineno);
+ nd->nd_loc = *loc;
+ nd_set_line(nd, loc->beg_pos.lineno);
return nd;
}
@@ -8798,7 +8798,7 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail)
parser_warning(h, "unused literal ignored");
return tail;
default:
- h = end = NEW_BLOCK(head, &head->nd_crange);
+ h = end = NEW_BLOCK(head, &head->nd_loc);
end->nd_end = end;
head = end;
break;
@@ -8824,7 +8824,7 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail)
}
if (nd_type(tail) != NODE_BLOCK) {
- tail = NEW_BLOCK(tail, &tail->nd_crange);
+ tail = NEW_BLOCK(tail, &tail->nd_loc);
tail->nd_end = tail;
}
end->nd_next = tail;
@@ -8839,7 +8839,7 @@ list_append_gen(struct parser_params *parser, NODE *list, NODE *item)
{
NODE *last;
- if (list == 0) return NEW_LIST(item, &item->nd_crange);
+ if (list == 0) return NEW_LIST(item, &item->nd_loc);
if (list->nd_next) {
last = list->nd_next->nd_end;
}
@@ -8848,7 +8848,7 @@ list_append_gen(struct parser_params *parser, NODE *list, NODE *item)
}
list->nd_alen += 1;
- last->nd_next = NEW_LIST(item, &item->nd_crange);
+ last->nd_next = NEW_LIST(item, &item->nd_loc);
list->nd_next->nd_end = last->nd_next;
nd_set_last_loc(list, nd_last_loc(item));
@@ -8901,7 +8901,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, const YYLTYPE *cr)
+literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const YYLTYPE *loc)
{
enum node_type htype;
NODE *headlast;
@@ -8912,7 +8912,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const Y
htype = nd_type(head);
if (htype == NODE_EVSTR) {
- NODE *node = NEW_DSTR(add_mark_object(STR_NEW0()), cr);
+ NODE *node = NEW_DSTR(add_mark_object(STR_NEW0()), loc);
head = list_append(node, head);
htype = NODE_DSTR;
}
@@ -8975,7 +8975,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const Y
}
else {
nd_set_type(tail, NODE_ARRAY);
- tail->nd_head = NEW_STR(tail->nd_lit, cr);
+ tail->nd_head = NEW_STR(tail->nd_lit, loc);
list_concat(head, tail);
}
break;
@@ -8995,13 +8995,13 @@ static NODE *
evstr2dstr_gen(struct parser_params *parser, NODE *node)
{
if (nd_type(node) == NODE_EVSTR) {
- node = list_append(NEW_DSTR(add_mark_object(STR_NEW0()), &node->nd_crange), node);
+ node = list_append(NEW_DSTR(add_mark_object(STR_NEW0()), &node->nd_loc), node);
}
return node;
}
static NODE *
-new_evstr_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr)
+new_evstr_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc)
{
NODE *head = node;
@@ -9011,45 +9011,45 @@ new_evstr_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr)
return node;
}
}
- return NEW_EVSTR(head, cr);
+ return NEW_EVSTR(head, loc);
}
static NODE *
call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1,
- const YYLTYPE *op_cr, const YYLTYPE *cr)
+ const YYLTYPE *op_loc, const YYLTYPE *loc)
{
NODE *expr;
value_expr(recv);
value_expr(arg1);
- expr = NEW_OPCALL(recv, id, NEW_LIST(arg1, &arg1->nd_crange), cr);
- nd_set_line(expr, op_cr->first_loc.lineno);
+ expr = NEW_OPCALL(recv, id, NEW_LIST(arg1, &arg1->nd_loc), loc);
+ nd_set_line(expr, op_loc->beg_pos.lineno);
return expr;
}
static NODE *
-call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, const YYLTYPE *op_cr, const YYLTYPE *cr)
+call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, const YYLTYPE *op_loc, const YYLTYPE *loc)
{
NODE *opcall;
value_expr(recv);
- opcall = NEW_OPCALL(recv, id, 0, cr);
- nd_set_line(opcall, op_cr->first_loc.lineno);
+ opcall = NEW_OPCALL(recv, id, 0, loc);
+ nd_set_line(opcall, op_loc->beg_pos.lineno);
return opcall;
}
static NODE *
-new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_cr, const YYLTYPE *cr)
+new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_loc, const YYLTYPE *loc)
{
- NODE *qcall = NEW_QCALL(atype, recv, mid, args, cr);
- nd_set_line(qcall, op_cr->first_loc.lineno);
+ NODE *qcall = NEW_QCALL(atype, recv, mid, args, loc);
+ nd_set_line(qcall, op_loc->beg_pos.lineno);
return qcall;
}
#define nd_once_body(node) (nd_type(node) == NODE_ONCE ? (node)->nd_body : node)
static NODE*
-match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *op_cr, const YYLTYPE *cr)
+match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *op_loc, const YYLTYPE *loc)
{
NODE *n;
- int line = op_cr->first_loc.lineno;
+ int line = op_loc->beg_pos.lineno;
value_expr(node1);
value_expr(node2);
@@ -9057,7 +9057,7 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTY
switch (nd_type(n)) {
case NODE_DREGX:
{
- NODE *match = NEW_MATCH2(node1, node2, cr);
+ NODE *match = NEW_MATCH2(node1, node2, loc);
nd_set_line(match, line);
return match;
}
@@ -9065,8 +9065,8 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTY
case NODE_LIT:
if (RB_TYPE_P(n->nd_lit, T_REGEXP)) {
const VALUE lit = n->nd_lit;
- NODE *match = NEW_MATCH2(node1, node2, cr);
- match->nd_args = reg_named_capture_assign(lit, cr);
+ NODE *match = NEW_MATCH2(node1, node2, loc);
+ match->nd_args = reg_named_capture_assign(lit, loc);
nd_set_line(match, line);
return match;
}
@@ -9081,12 +9081,12 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTY
if (!RB_TYPE_P(n->nd_lit, T_REGEXP)) break;
/* fallthru */
case NODE_DREGX:
- match3 = NEW_MATCH3(node2, node1, cr);
+ match3 = NEW_MATCH3(node2, node1, loc);
return match3;
}
}
- n = NEW_CALL(node1, tMATCH, NEW_LIST(node2, &node2->nd_crange), cr);
+ n = NEW_CALL(node1, tMATCH, NEW_LIST(node2, &node2->nd_loc), loc);
nd_set_line(n, line);
return n;
}
@@ -9112,28 +9112,28 @@ past_dvar_p(struct parser_params *parser, ID id)
} while (0)
static NODE*
-gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr)
+gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *loc)
{
ID *vidp = NULL;
NODE *node;
switch (id) {
case keyword_self:
- return NEW_SELF(cr);
+ return NEW_SELF(loc);
case keyword_nil:
- return NEW_NIL(cr);
+ return NEW_NIL(loc);
case keyword_true:
- return NEW_TRUE(cr);
+ return NEW_TRUE(loc);
case keyword_false:
- return NEW_FALSE(cr);
+ return NEW_FALSE(loc);
case keyword__FILE__:
WARN_LOCATION("__FILE__");
- node = NEW_STR(add_mark_object(rb_str_dup(ruby_sourcefile_string)), cr);
+ node = NEW_STR(add_mark_object(rb_str_dup(ruby_sourcefile_string)), loc);
return node;
case keyword__LINE__:
WARN_LOCATION("__LINE__");
- return NEW_LIT(INT2FIX(tokline), cr);
+ return NEW_LIT(INT2FIX(tokline), loc);
case keyword__ENCODING__:
- return NEW_LIT(add_mark_object(rb_enc_from_encoding(current_enc)), cr);
+ return NEW_LIT(add_mark_object(rb_enc_from_encoding(current_enc)), loc);
}
switch (id_type(id)) {
case ID_LOCAL:
@@ -9142,7 +9142,7 @@ gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr)
rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id));
}
if (vidp) *vidp |= LVAR_USED;
- node = NEW_DVAR(id, cr);
+ node = NEW_DVAR(id, loc);
return node;
}
if (local_id_ref(id, vidp)) {
@@ -9150,7 +9150,7 @@ gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr)
rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id));
}
if (vidp) *vidp |= LVAR_USED;
- node = NEW_LVAR(id, cr);
+ node = NEW_LVAR(id, loc);
return node;
}
# if WARN_PAST_SCOPE
@@ -9159,15 +9159,15 @@ gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr)
}
# endif
/* method call without arguments */
- return NEW_VCALL(id, cr);
+ return NEW_VCALL(id, loc);
case ID_GLOBAL:
- return NEW_GVAR(id, cr);
+ return NEW_GVAR(id, loc);
case ID_INSTANCE:
- return NEW_IVAR(id, cr);
+ return NEW_IVAR(id, loc);
case ID_CONST:
- return NEW_CONST(id, cr);
+ return NEW_CONST(id, loc);
case ID_CLASS:
- return NEW_CVAR(id, cr);
+ return NEW_CVAR(id, loc);
}
compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id));
return 0;
@@ -9177,11 +9177,11 @@ static NODE *
opt_arg_append(NODE *opt_list, NODE *opt)
{
NODE *opts = opt_list;
- opts->nd_crange.last_loc = opt->nd_crange.last_loc;
+ opts->nd_loc.end_pos = opt->nd_loc.end_pos;
while (opts->nd_next) {
opts = opts->nd_next;
- opts->nd_crange.last_loc = opt->nd_crange.last_loc;
+ opts->nd_loc.end_pos = opt->nd_loc.end_pos;
}
opts->nd_next = opt;
@@ -9193,10 +9193,10 @@ kwd_append(NODE *kwlist, NODE *kw)
{
if (kwlist) {
NODE *kws = kwlist;
- kws->nd_crange.last_loc = kw->nd_crange.last_loc;
+ kws->nd_loc.end_pos = kw->nd_loc.end_pos;
while (kws->nd_next) {
kws = kws->nd_next;
- kws->nd_crange.last_loc = kw->nd_crange.last_loc;
+ kws->nd_loc.end_pos = kw->nd_loc.end_pos;
}
kws->nd_next = kw;
}
@@ -9204,35 +9204,35 @@ kwd_append(NODE *kwlist, NODE *kw)
}
static NODE *
-new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *cr)
+new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *loc)
{
- return NEW_DEFINED(remove_begin_all(expr), cr);
+ return NEW_DEFINED(remove_begin_all(expr), loc);
}
static NODE *
-new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLTYPE *cr)
+new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLTYPE *loc)
{
NODE *list, *prev;
VALUE lit;
if (!node) {
- return NEW_LIT(add_mark_object(reg_compile(STR_NEW0(), options)), cr);
+ return NEW_LIT(add_mark_object(reg_compile(STR_NEW0(), options)), loc);
}
switch (nd_type(node)) {
case NODE_STR:
{
VALUE src = node->nd_lit;
nd_set_type(node, NODE_LIT);
- nd_set_crange(node, cr);
+ nd_set_loc(node, loc);
add_mark_object(node->nd_lit = reg_compile(src, options));
}
break;
default:
add_mark_object(lit = STR_NEW0());
- node = NEW_NODE(NODE_DSTR, lit, 1, NEW_LIST(node, cr), cr);
+ node = NEW_NODE(NODE_DSTR, lit, 1, NEW_LIST(node, loc), loc);
case NODE_DSTR:
nd_set_type(node, NODE_DREGX);
- nd_set_crange(node, cr);
+ nd_set_loc(node, loc);
node->nd_cflag = options & RE_OPTION_MASK;
if (!NIL_P(node->nd_lit)) reg_fragment_check(node->nd_lit, options);
for (list = (prev = node)->nd_next; list; list = list->nd_next) {
@@ -9264,7 +9264,7 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLT
add_mark_object(node->nd_lit = reg_compile(src, options));
}
if (options & RE_OPTION_ONCE) {
- node = NEW_NODE(NODE_ONCE, 0, node, 0, cr);
+ node = NEW_NODE(NODE_ONCE, 0, node, 0, loc);
}
break;
}
@@ -9272,41 +9272,41 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLT
}
static NODE *
-new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *cr)
+new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *loc)
{
if (!k) return 0;
- return NEW_KW_ARG(0, (k), cr);
+ return NEW_KW_ARG(0, (k), loc);
}
static NODE *
-new_xstring_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr)
+new_xstring_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc)
{
if (!node) {
VALUE lit = STR_NEW0();
- NODE *xstr = NEW_XSTR(lit, cr);
+ NODE *xstr = NEW_XSTR(lit, loc);
add_mark_object(lit);
return xstr;
}
switch (nd_type(node)) {
case NODE_STR:
nd_set_type(node, NODE_XSTR);
- nd_set_crange(node, cr);
+ nd_set_loc(node, loc);
break;
case NODE_DSTR:
nd_set_type(node, NODE_DXSTR);
- nd_set_crange(node, cr);
+ nd_set_loc(node, loc);
break;
default:
- node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node, cr), cr);
+ node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node, loc), loc);
break;
}
return node;
}
static NODE *
-new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *cr)
+new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *loc)
{
- return NEW_ITER(param, stmt, cr);
+ return NEW_ITER(param, stmt, loc);
}
#else /* !RIPPER */
static int
@@ -9471,33 +9471,33 @@ rb_parser_fatal(struct parser_params *parser, const char *fmt, ...)
}
void
-rb_parser_set_code_range_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc)
+rb_parser_set_location_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc)
{
const char *eos = RSTRING_PTR(here->term);
int term_len = (int)eos[0];
- yylloc->first_loc.lineno = (int)here->sourceline;
- yylloc->first_loc.column = (int)(here->u3.lastidx - term_len);
- yylloc->last_loc.lineno = (int)here->sourceline;
- yylloc->last_loc.column = (int)(here->u3.lastidx);
+ yylloc->beg_pos.lineno = (int)here->sourceline;
+ yylloc->beg_pos.column = (int)(here->u3.lastidx - term_len);
+ yylloc->end_pos.lineno = (int)here->sourceline;
+ yylloc->end_pos.column = (int)(here->u3.lastidx);
}
void
-rb_parser_set_code_range_of_none(struct parser_params *parser, YYLTYPE *yylloc)
+rb_parser_set_location_of_none(struct parser_params *parser, YYLTYPE *yylloc)
{
- yylloc->first_loc.lineno = ruby_sourceline;
- yylloc->first_loc.column = (int)(parser->tokp - lex_pbeg);
- yylloc->last_loc.lineno = ruby_sourceline;
- yylloc->last_loc.column = (int)(parser->tokp - lex_pbeg);
+ yylloc->beg_pos.lineno = ruby_sourceline;
+ yylloc->beg_pos.column = (int)(parser->tokp - lex_pbeg);
+ yylloc->end_pos.lineno = ruby_sourceline;
+ yylloc->end_pos.column = (int)(parser->tokp - lex_pbeg);
}
void
-rb_parser_set_code_range(struct parser_params *parser, YYLTYPE *yylloc)
+rb_parser_set_location(struct parser_params *parser, YYLTYPE *yylloc)
{
- yylloc->first_loc.lineno = ruby_sourceline;
- yylloc->first_loc.column = (int)(parser->tokp - lex_pbeg);
- yylloc->last_loc.lineno = ruby_sourceline;
- yylloc->last_loc.column = (int)(lex_p - lex_pbeg);
+ yylloc->beg_pos.lineno = ruby_sourceline;
+ yylloc->beg_pos.column = (int)(parser->tokp - lex_pbeg);
+ yylloc->end_pos.lineno = ruby_sourceline;
+ yylloc->end_pos.column = (int)(lex_p - lex_pbeg);
}
#endif /* !RIPPER */
@@ -9506,77 +9506,77 @@ static VALUE
assignable_gen(struct parser_params *parser, VALUE lhs)
#else
static NODE*
-assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *cr)
+assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *loc)
#endif
{
#ifdef RIPPER
ID id = get_id(lhs);
# define assignable_result(x) (lhs)
# define assignable_error() (lhs)
-# define parser_yyerror(parser, cr, x) (lhs = assign_error_gen(parser, lhs))
+# define parser_yyerror(parser, loc, x) (lhs = assign_error_gen(parser, lhs))
#else
# define assignable_result(x) (x)
-# define assignable_error() NEW_BEGIN(0, cr)
+# define assignable_error() NEW_BEGIN(0, loc)
#endif
if (!id) return assignable_error();
switch (id) {
case keyword_self:
- yyerror1(cr, "Can't change the value of self");
+ yyerror1(loc, "Can't change the value of self");
goto error;
case keyword_nil:
- yyerror1(cr, "Can't assign to nil");
+ yyerror1(loc, "Can't assign to nil");
goto error;
case keyword_true:
- yyerror1(cr, "Can't assign to true");
+ yyerror1(loc, "Can't assign to true");
goto error;
case keyword_false:
- yyerror1(cr, "Can't assign to false");
+ yyerror1(loc, "Can't assign to false");
goto error;
case keyword__FILE__:
- yyerror1(cr, "Can't assign to __FILE__");
+ yyerror1(loc, "Can't assign to __FILE__");
goto error;
case keyword__LINE__:
- yyerror1(cr, "Can't assign to __LINE__");
+ yyerror1(loc, "Can't assign to __LINE__");
goto error;
case keyword__ENCODING__:
- yyerror1(cr, "Can't assign to __ENCODING__");
+ yyerror1(loc, "Can't assign to __ENCODING__");
goto error;
}
switch (id_type(id)) {
case ID_LOCAL:
if (dyna_in_block()) {
if (dvar_curr(id)) {
- return assignable_result(NEW_DASGN_CURR(id, val, cr));
+ return assignable_result(NEW_DASGN_CURR(id, val, loc));
}
else if (dvar_defined(id)) {
- return assignable_result(NEW_DASGN(id, val, cr));
+ return assignable_result(NEW_DASGN(id, val, loc));
}
else if (local_id(id)) {
- return assignable_result(NEW_LASGN(id, val, cr));
+ return assignable_result(NEW_LASGN(id, val, loc));
}
else {
dyna_var(id);
- return assignable_result(NEW_DASGN_CURR(id, val, cr));
+ return assignable_result(NEW_DASGN_CURR(id, val, loc));
}
}
else {
if (!local_id(id)) {
local_var(id);
}
- return assignable_result(NEW_LASGN(id, val, cr));
+ return assignable_result(NEW_LASGN(id, val, loc));
}
break;
case ID_GLOBAL:
- return assignable_result(NEW_GASGN(id, val, cr));
+ return assignable_result(NEW_GASGN(id, val, loc));
case ID_INSTANCE:
- return assignable_result(NEW_IASGN(id, val, cr));
+ return assignable_result(NEW_IASGN(id, val, loc));
case ID_CONST:
if (!in_def)
- return assignable_result(NEW_CDECL(id, val, 0, cr));
- yyerror1(cr, "dynamic constant assignment");
+ return assignable_result(NEW_CDECL(id, val, 0, loc));
+ yyerror1(loc, "dynamic constant assignment");
break;
case ID_CLASS:
- return assignable_result(NEW_CVASGN(id, val, cr));
+ return assignable_result(NEW_CVASGN(id, val, loc));
default:
compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id));
}
@@ -9644,9 +9644,9 @@ new_bv_gen(struct parser_params *parser, ID name)
#ifndef RIPPER
static NODE *
-aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, const YYLTYPE *cr)
+aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, const YYLTYPE *loc)
{
- return NEW_ATTRASGN(recv, tASET, idx, cr);
+ return NEW_ATTRASGN(recv, tASET, idx, loc);
}
static void
@@ -9658,10 +9658,10 @@ 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, const YYLTYPE *cr)
+attrset_gen(struct parser_params *parser, NODE *recv, ID atype, ID id, const YYLTYPE *loc)
{
if (!CALL_Q_P(atype)) id = rb_id_attrset(id);
- return NEW_ATTRASGN(recv, id, 0, cr);
+ return NEW_ATTRASGN(recv, id, 0, loc);
}
static void
@@ -9678,19 +9678,19 @@ rb_backref_error_gen(struct parser_params *parser, NODE *node)
}
static NODE *
-arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *cr)
+arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *loc)
{
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, cr);
+ node1->nd_head = arg_concat(node1->nd_head, node2, loc);
else
- node1->nd_head = NEW_LIST(node2, cr);
+ node1->nd_head = NEW_LIST(node2, loc);
return node1;
case NODE_ARGSPUSH:
if (nd_type(node2) != NODE_ARRAY) break;
- node1->nd_body = list_concat(NEW_LIST(node1->nd_body, cr), node2);
+ node1->nd_body = list_concat(NEW_LIST(node1->nd_body, loc), node2);
nd_set_type(node1, NODE_ARGSCAT);
return node1;
case NODE_ARGSCAT:
@@ -9699,27 +9699,27 @@ arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYL
node1->nd_body = list_concat(node1->nd_body, node2);
return node1;
}
- return NEW_ARGSCAT(node1, node2, cr);
+ return NEW_ARGSCAT(node1, node2, loc);
}
static NODE *
-arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *cr)
+arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *loc)
{
- if (!node1) return NEW_LIST(node2, &node2->nd_crange);
+ if (!node1) return NEW_LIST(node2, &node2->nd_loc);
switch (nd_type(node1)) {
case NODE_ARRAY:
return list_append(node1, node2);
case NODE_BLOCK_PASS:
- node1->nd_head = arg_append(node1->nd_head, node2, cr);
- node1->nd_crange.last_loc = node1->nd_head->nd_crange.last_loc;
+ node1->nd_head = arg_append(node1->nd_head, node2, loc);
+ node1->nd_loc.end_pos = node1->nd_head->nd_loc.end_pos;
return node1;
case NODE_ARGSPUSH:
- node1->nd_body = list_append(NEW_LIST(node1->nd_body, &node1->nd_body->nd_crange), node2);
- node1->nd_crange.last_loc = node1->nd_body->nd_crange.last_loc;
+ node1->nd_body = list_append(NEW_LIST(node1->nd_body, &node1->nd_body->nd_loc), node2);
+ node1->nd_loc.end_pos = node1->nd_body->nd_loc.end_pos;
nd_set_type(node1, NODE_ARGSCAT);
return node1;
}
- return NEW_ARGSPUSH(node1, node2, cr);
+ return NEW_ARGSPUSH(node1, node2, loc);
}
static NODE *
@@ -9758,7 +9758,7 @@ mark_lvar_used(struct parser_params *parser, NODE *rhs)
}
static NODE *
-node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, const YYLTYPE *cr)
+node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, const YYLTYPE *loc)
{
if (!lhs) return 0;
@@ -9772,12 +9772,12 @@ node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, const YYLTYP
case NODE_CDECL:
case NODE_CVASGN:
lhs->nd_value = rhs;
- nd_set_crange(lhs, cr);
+ nd_set_loc(lhs, loc);
break;
case NODE_ATTRASGN:
- lhs->nd_args = arg_append(lhs->nd_args, rhs, cr);
- nd_set_crange(lhs, cr);
+ lhs->nd_args = arg_append(lhs->nd_args, rhs, loc);
+ nd_set_loc(lhs, loc);
break;
default:
@@ -9803,7 +9803,7 @@ value_expr_gen(struct parser_params *parser, NODE *node)
case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
- if (!cond) yyerror1(&node->nd_crange, "void value expression");
+ if (!cond) yyerror1(&node->nd_loc, "void value expression");
/* or "control never reach"? */
return FALSE;
@@ -10096,7 +10096,7 @@ warning_unless_e_option(struct parser_params *parser, NODE *node, const char *st
static NODE *cond0(struct parser_params*,NODE*,int,const YYLTYPE*);
static NODE*
-range_op(struct parser_params *parser, NODE *node, const YYLTYPE *cr)
+range_op(struct parser_params *parser, NODE *node, const YYLTYPE *loc)
{
enum node_type type;
@@ -10106,9 +10106,9 @@ range_op(struct parser_params *parser, NODE *node, const YYLTYPE *cr)
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("$."), cr), cr), cr);
+ return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(rb_intern("$."), loc), loc), loc);
}
- return cond0(parser, node, FALSE, cr);
+ return cond0(parser, node, FALSE, loc);
}
static int
@@ -10133,7 +10133,7 @@ literal_node(NODE *node)
}
static NODE*
-cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr)
+cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *loc)
{
if (node == 0) return 0;
if (!(node = nd_once_body(node))) return 0;
@@ -10151,19 +10151,19 @@ cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr
if (!method_op)
warning_unless_e_option(parser, node, "regex literal in condition");
- return NEW_MATCH2(node, NEW_GVAR(idLASTLINE, cr), cr);
+ return NEW_MATCH2(node, NEW_GVAR(idLASTLINE, loc), loc);
}
case NODE_AND:
case NODE_OR:
- node->nd_1st = cond0(parser, node->nd_1st, FALSE, cr);
- node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, cr);
+ node->nd_1st = cond0(parser, node->nd_1st, FALSE, loc);
+ node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, loc);
break;
case NODE_DOT2:
case NODE_DOT3:
- node->nd_beg = range_op(parser, node->nd_beg, cr);
- node->nd_end = range_op(parser, node->nd_end, cr);
+ node->nd_beg = range_op(parser, node->nd_beg, loc);
+ node->nd_end = range_op(parser, node->nd_end, loc);
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)) {
@@ -10196,31 +10196,31 @@ cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr
}
static NODE*
-cond_gen(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr)
+cond_gen(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *loc)
{
if (node == 0) return 0;
- return cond0(parser, node, method_op, cr);
+ return cond0(parser, node, method_op, loc);
}
static NODE*
-new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *cr)
+new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc)
{
if (!cc) return right;
- cc = cond0(parser, cc, FALSE, cr);
- return newline_node(NEW_IF(cc, left, right, cr));
+ cc = cond0(parser, cc, FALSE, loc);
+ return newline_node(NEW_IF(cc, left, right, loc));
}
static NODE*
-new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *cr)
+new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc)
{
if (!cc) return right;
- cc = cond0(parser, cc, FALSE, cr);
- return newline_node(NEW_UNLESS(cc, left, right, cr));
+ cc = cond0(parser, cc, FALSE, loc);
+ return newline_node(NEW_UNLESS(cc, left, right, loc));
}
static NODE*
logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right,
- const YYLTYPE *op_cr, const YYLTYPE *cr)
+ const YYLTYPE *op_loc, const YYLTYPE *loc)
{
NODE *op;
value_expr(left);
@@ -10229,13 +10229,13 @@ logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *r
while ((second = node->nd_2nd) != 0 && (enum node_type)nd_type(second) == type) {
node = second;
}
- node->nd_2nd = NEW_NODE(type, second, right, 0, cr);
- nd_set_line(node->nd_2nd, op_cr->first_loc.lineno);
- left->nd_crange.last_loc = cr->last_loc;
+ node->nd_2nd = NEW_NODE(type, second, right, 0, loc);
+ nd_set_line(node->nd_2nd, op_loc->beg_pos.lineno);
+ left->nd_loc.end_pos = loc->end_pos;
return left;
}
- op = NEW_NODE(type, left, right, 0, cr);
- nd_set_line(op, op_cr->first_loc.lineno);
+ op = NEW_NODE(type, left, right, 0, loc);
+ nd_set_line(op, op_loc->beg_pos.lineno);
return op;
}
@@ -10265,11 +10265,11 @@ ret_args_gen(struct parser_params *parser, NODE *node)
}
static NODE *
-new_yield_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr)
+new_yield_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc)
{
if (node) no_blockarg(parser, node);
- return NEW_YIELD(node, cr);
+ return NEW_YIELD(node, loc);
}
static VALUE
@@ -10321,7 +10321,7 @@ arg_blk_pass(NODE *node1, NODE *node2)
static NODE*
-new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE *tail, const YYLTYPE *cr)
+new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE *tail, const YYLTYPE *loc)
{
int saved_line = ruby_sourceline;
struct rb_args_info *args = tail->nd_ainfo;
@@ -10338,13 +10338,13 @@ new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE
args->opt_args = o;
ruby_sourceline = saved_line;
- nd_set_crange(tail, cr);
+ nd_set_loc(tail, loc);
return tail;
}
static NODE*
-new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLTYPE *cr)
+new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLTYPE *loc)
{
int saved_line = ruby_sourceline;
struct rb_args_info *args;
@@ -10398,14 +10398,14 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLT
if (kr) arg_var(kr);
if (b) arg_var(b);
- args->kw_rest_arg = NEW_DVAR(kr, cr);
+ args->kw_rest_arg = NEW_DVAR(kr, loc);
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, cr);
+ args->kw_rest_arg = NEW_DVAR(kr, loc);
}
ruby_sourceline = saved_line;
@@ -10413,27 +10413,27 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLT
}
static NODE*
-dsym_node_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr)
+dsym_node_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc)
{
VALUE lit;
if (!node) {
- return NEW_LIT(ID2SYM(idNULL), cr);
+ return NEW_LIT(ID2SYM(idNULL), loc);
}
switch (nd_type(node)) {
case NODE_DSTR:
nd_set_type(node, NODE_DSYM);
- nd_set_crange(node, cr);
+ nd_set_loc(node, loc);
break;
case NODE_STR:
lit = node->nd_lit;
add_mark_object(node->nd_lit = ID2SYM(rb_intern_str(lit)));
nd_set_type(node, NODE_LIT);
- nd_set_crange(node, cr);
+ nd_set_loc(node, loc);
break;
default:
- node = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(node, cr), cr);
+ node = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(node, loc), loc);
break;
}
return node;
@@ -10488,26 +10488,26 @@ remove_duplicate_keys(struct parser_params *parser, NODE *hash)
}
static NODE *
-new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *cr)
+new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *loc)
{
if (hash) hash = remove_duplicate_keys(parser, hash);
- return NEW_HASH(hash, cr);
+ return NEW_HASH(hash, loc);
}
#endif /* !RIPPER */
#ifndef RIPPER
static NODE *
-new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr)
+new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc)
{
NODE *asgn;
if (lhs) {
ID vid = lhs->nd_vid;
- YYLTYPE lhs_cr = lhs->nd_crange;
+ YYLTYPE lhs_loc = lhs->nd_loc;
if (op == tOROP) {
lhs->nd_value = rhs;
- nd_set_crange(lhs, cr);
- asgn = NEW_OP_ASGN_OR(gettable(vid, &lhs_cr), lhs, cr);
+ nd_set_loc(lhs, loc);
+ asgn = NEW_OP_ASGN_OR(gettable(vid, &lhs_loc), lhs, loc);
if (is_notop_id(vid)) {
switch (id_type(vid)) {
case ID_GLOBAL:
@@ -10519,60 +10519,60 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, con
}
else if (op == tANDOP) {
lhs->nd_value = rhs;
- nd_set_crange(lhs, cr);
- asgn = NEW_OP_ASGN_AND(gettable(vid, &lhs_cr), lhs, cr);
+ nd_set_loc(lhs, loc);
+ asgn = NEW_OP_ASGN_AND(gettable(vid, &lhs_loc), lhs, loc);
}
else {
asgn = lhs;
- asgn->nd_value = NEW_CALL(gettable(vid, &lhs_cr), op, NEW_LIST(rhs, &rhs->nd_crange), cr);
- nd_set_crange(asgn, cr);
+ asgn->nd_value = NEW_CALL(gettable(vid, &lhs_loc), op, NEW_LIST(rhs, &rhs->nd_loc), loc);
+ nd_set_loc(asgn, loc);
}
}
else {
- asgn = NEW_BEGIN(0, cr);
+ asgn = NEW_BEGIN(0, loc);
}
return asgn;
}
static NODE *
new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs,
- ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *cr)
+ ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc)
{
NODE *asgn;
- asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs, cr);
+ asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs, loc);
fixpos(asgn, lhs);
return asgn;
}
static NODE *
-new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr)
+new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc)
{
NODE *asgn;
if (lhs) {
- asgn = NEW_OP_CDECL(lhs, op, rhs, cr);
+ asgn = NEW_OP_CDECL(lhs, op, rhs, loc);
}
else {
- asgn = NEW_BEGIN(0, cr);
+ asgn = NEW_BEGIN(0, loc);
}
fixpos(asgn, lhs);
return asgn;
}
static NODE *
-const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *cr)
+const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *loc)
{
- return NEW_COLON2(head, mid, cr);
+ return NEW_COLON2(head, mid, loc);
}
static NODE *
-const_decl_gen(struct parser_params *parser, NODE *path, const YYLTYPE *cr)
+const_decl_gen(struct parser_params *parser, NODE *path, const YYLTYPE *loc)
{
if (in_def) {
- yyerror1(cr, "dynamic constant assignment");
+ yyerror1(loc, "dynamic constant assignment");
}
- return NEW_CDECL(0, 0, (path), cr);
+ return NEW_CDECL(0, 0, (path), loc);
}
#else
static VALUE
@@ -10923,7 +10923,7 @@ typedef struct {
struct parser_params* parser;
rb_encoding *enc;
NODE *succ_block;
- const YYLTYPE *crange;
+ const YYLTYPE *loc;
} reg_named_capture_assign_t;
static int
@@ -10944,23 +10944,23 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end,
return ST_CONTINUE;
}
var = intern_cstr(s, len, enc);
- node = node_assign(assignable(var, 0, arg->crange), NEW_LIT(ID2SYM(var), arg->crange), arg->crange);
+ node = node_assign(assignable(var, 0, arg->loc), NEW_LIT(ID2SYM(var), arg->loc), arg->loc);
succ = arg->succ_block;
- if (!succ) succ = NEW_BEGIN(0, arg->crange);
+ if (!succ) succ = NEW_BEGIN(0, arg->loc);
succ = block_append(succ, node);
arg->succ_block = succ;
return ST_CONTINUE;
}
static NODE *
-reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *cr)
+reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *loc)
{
reg_named_capture_assign_t arg;
arg.parser = parser;
arg.enc = rb_enc_get(regexp);
arg.succ_block = 0;
- arg.crange = cr;
+ arg.loc = loc;
onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg);
if (!arg.succ_block) return 0;