15 #define PARSER_DEBUG 0
18 #define YYERROR_VERBOSE 1
19 #define YYSTACK_USE_ALLOCA 0
34 #define numberof(array) (int)(sizeof(array) / sizeof((array)[0]))
36 #define YYMALLOC(size) rb_parser_malloc(parser, (size))
37 #define YYREALLOC(ptr, size) rb_parser_realloc(parser, (ptr), (size))
38 #define YYCALLOC(nelem, size) rb_parser_calloc(parser, (nelem), (size))
39 #define YYFREE(ptr) rb_parser_free(parser, (ptr))
40 #define malloc YYMALLOC
41 #define realloc YYREALLOC
42 #define calloc YYCALLOC
48 #define REGISTER_SYMID(id, name) register_symid((id), (name), strlen(name), enc)
52 #define is_notop_id(id) ((id)>tLAST_OP_ID)
53 #define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
54 #define is_global_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL)
55 #define is_instance_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE)
56 #define is_attrset_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET)
57 #define is_const_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST)
58 #define is_class_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS)
59 #define is_junk_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_JUNK)
60 #define id_type(id) (is_notop_id(id) ? (int)((id)&ID_SCOPE_MASK) : -1)
62 #define is_asgn_or_id(id) ((is_notop_id(id)) && \
63 (((id)&ID_SCOPE_MASK) == ID_GLOBAL || \
64 ((id)&ID_SCOPE_MASK) == ID_INSTANCE || \
65 ((id)&ID_SCOPE_MASK) == ID_CLASS))
83 #define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
99 #define IS_lex_state_for(x, ls) ((x) & (ls))
100 #define IS_lex_state(ls) IS_lex_state_for(lex_state, (ls))
108 # define BITSTACK_PUSH(stack, n) ((stack) = ((stack)<<1)|((n)&1))
109 # define BITSTACK_POP(stack) ((stack) = (stack) >> 1)
110 # define BITSTACK_LEXPOP(stack) ((stack) = ((stack) >> 1) | ((stack) & 1))
111 # define BITSTACK_SET_P(stack) ((stack)&1)
113 #define COND_PUSH(n) BITSTACK_PUSH(cond_stack, (n))
114 #define COND_POP() BITSTACK_POP(cond_stack)
115 #define COND_LEXPOP() BITSTACK_LEXPOP(cond_stack)
116 #define COND_P() BITSTACK_SET_P(cond_stack)
118 #define CMDARG_PUSH(n) BITSTACK_PUSH(cmdarg_stack, (n))
119 #define CMDARG_POP() BITSTACK_POP(cmdarg_stack)
120 #define CMDARG_LEXPOP() BITSTACK_LEXPOP(cmdarg_stack)
121 #define CMDARG_P() BITSTACK_SET_P(cmdarg_stack)
138 #define DVARS_INHERIT ((void*)1)
139 #define DVARS_TOPSCOPE NULL
140 #define DVARS_SPECIAL_P(tbl) (!POINTER_P(tbl))
141 #define POINTER_P(val) ((VALUE)(val) & ~(VALUE)3)
184 rb_bug(
"vtable_add: vtable is not allocated (%p)", (
void *)tbl);
201 for (i = 0; i < tbl->
pos; i++) {
287 VALUE parser_ruby_sourcefile_string;
295 VALUE parsing_thread;
300 #define STR_NEW(p,n) rb_enc_str_new((p),(n),current_enc)
301 #define STR_NEW0() rb_enc_str_new(0,0,current_enc)
302 #define STR_NEW2(p) rb_enc_str_new((p),strlen(p),current_enc)
303 #define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),current_enc)
304 #define ENC_SINGLE(cr) ((cr)==ENC_CODERANGE_7BIT)
305 #define TOK_INTERN(mb) rb_intern3(tok(), toklen(), current_enc)
308 #define yyerror(msg) parser_yyerror(parser, (msg))
310 #define lex_strterm (parser->parser_lex_strterm)
311 #define lex_state (parser->parser_lex_state)
312 #define cond_stack (parser->parser_cond_stack)
313 #define cmdarg_stack (parser->parser_cmdarg_stack)
314 #define class_nest (parser->parser_class_nest)
315 #define paren_nest (parser->parser_paren_nest)
316 #define lpar_beg (parser->parser_lpar_beg)
317 #define brace_nest (parser->parser_brace_nest)
318 #define in_single (parser->parser_in_single)
319 #define in_def (parser->parser_in_def)
320 #define compile_for_eval (parser->parser_compile_for_eval)
321 #define cur_mid (parser->parser_cur_mid)
322 #define in_defined (parser->parser_in_defined)
323 #define tokenbuf (parser->parser_tokenbuf)
324 #define tokidx (parser->parser_tokidx)
325 #define toksiz (parser->parser_toksiz)
326 #define tokline (parser->parser_tokline)
327 #define lex_input (parser->parser_lex_input)
328 #define lex_lastline (parser->parser_lex_lastline)
329 #define lex_nextline (parser->parser_lex_nextline)
330 #define lex_pbeg (parser->parser_lex_pbeg)
331 #define lex_p (parser->parser_lex_p)
332 #define lex_pend (parser->parser_lex_pend)
333 #define heredoc_end (parser->parser_heredoc_end)
334 #define command_start (parser->parser_command_start)
335 #define deferred_nodes (parser->parser_deferred_nodes)
336 #define lex_gets_ptr (parser->parser_lex_gets_ptr)
337 #define lex_gets (parser->parser_lex_gets)
338 #define lvtbl (parser->parser_lvtbl)
339 #define ruby__end__seen (parser->parser_ruby__end__seen)
340 #define ruby_sourceline (parser->parser_ruby_sourceline)
341 #define ruby_sourcefile (parser->parser_ruby_sourcefile)
342 #define current_enc (parser->enc)
343 #define yydebug (parser->parser_yydebug)
346 #define ruby_eval_tree (parser->parser_eval_tree)
347 #define ruby_eval_tree_begin (parser->parser_eval_tree_begin)
348 #define ruby_debug_lines (parser->debug_lines)
349 #define ruby_coverage (parser->coverage)
353 static int yylex(
void*,
void*);
355 static int yylex(
void*);
359 #define yyparse ruby_yyparse
362 #define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3))
365 #define cond(node) cond_gen(parser, (node))
367 #define logop(type,node1,node2) logop_gen(parser, (type), (node1), (node2))
375 #define value_expr(node) value_expr_gen(parser, (node) = remove_begin(node))
376 #define void_expr0(node) void_expr_gen(parser, (node))
377 #define void_expr(node) void_expr0((node) = remove_begin(node))
379 #define void_stmts(node) void_stmts_gen(parser, (node))
381 #define reduce_nodes(n) reduce_nodes_gen(parser,(n))
383 #define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2))
386 #define block_append(h,t) block_append_gen(parser,(h),(t))
388 #define list_append(l,i) list_append_gen(parser,(l),(i))
390 #define list_concat(h,t) list_concat_gen(parser,(h),(t))
392 #define arg_append(h,t) arg_append_gen(parser,(h),(t))
394 #define arg_concat(h,t) arg_concat_gen(parser,(h),(t))
396 #define literal_concat(h,t) literal_concat_gen(parser,(h),(t))
399 #define new_evstr(n) new_evstr_gen(parser,(n))
401 #define evstr2dstr(n) evstr2dstr_gen(parser,(n))
405 #define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, (recv),(id),(arg1))
407 #define call_uni_op(recv,id) call_uni_op_gen(parser, (recv),(id))
410 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
412 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
416 #define ret_args(node) ret_args_gen(parser, (node))
419 #define new_yield(node) new_yield_gen(parser, (node))
421 #define dsym_node(node) dsym_node_gen(parser, (node))
424 #define gettable(id) gettable_gen(parser,(id))
426 #define assignable(id,node) assignable_gen(parser, (id), (node))
429 #define aryset(node1,node2) aryset_gen(parser, (node1), (node2))
431 #define attrset(node,id) attrset_gen(parser, (node), (id))
434 #define rb_backref_error(n) rb_backref_error_gen(parser,(n))
436 #define node_assign(node1, node2) node_assign_gen(parser, (node1), (node2))
440 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (attr), (op), (rhs))
442 #define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs))
445 #define match_op(node1,node2) match_op_gen(parser, (node1), (node2))
448 #define local_tbl() local_tbl_gen(parser)
453 #define reg_compile(str,options) reg_compile_gen(parser, (str), (options))
455 #define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options))
457 #define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options))
459 #define reg_named_capture_assign(regexp,match) reg_named_capture_assign_gen(parser,(regexp),(match))
461 #define get_id(id) (id)
462 #define get_value(val) (val)
464 #define value_expr(node) ((void)(node))
465 #define remove_begin(node) (node)
466 #define rb_dvar_defined(id) 0
467 #define rb_local_defined(id) 0
468 static ID ripper_get_id(
VALUE);
469 #define get_id(id) ripper_get_id(id)
471 #define get_value(val) ripper_get_value(val)
473 #define assignable(lhs,node) assignable_gen(parser, (lhs))
475 #define id_is_var(id) id_is_var_gen(parser, (id))
477 #define node_assign(node1, node2) dispatch2(assign, (node1), (node2))
481 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
485 #define new_op_assign(lhs, op, rhs) new_op_assign_gen(parser, (lhs), (op), (rhs))
488 #define formal_argument(id) formal_argument_gen(parser, (id))
490 #define shadowing_lvar(name) shadowing_lvar_gen(parser, (name))
492 #define new_bv(id) new_bv_gen(parser, (id))
495 #define local_push(top) local_push_gen(parser,(top))
497 #define local_pop() local_pop_gen(parser)
499 #define local_var(id) local_var_gen(parser, (id))
501 #define arg_var(id) arg_var_gen(parser, (id))
503 #define local_id(id) local_id_gen(parser, (id))
505 #define internal_id() internal_id_gen(parser)
508 #define dyna_push() dyna_push_gen(parser)
510 #define dyna_pop(node) dyna_pop_gen(parser, (node))
512 #define dyna_in_block() dyna_in_block_gen(parser)
513 #define dyna_var(id) local_var(id)
515 #define dvar_defined(id) dvar_defined_gen(parser, (id), 0)
516 #define dvar_defined_get(id) dvar_defined_gen(parser, (id), 1)
518 #define dvar_curr(id) dvar_curr_gen(parser, (id))
521 #define lvar_defined(id) lvar_defined_gen(parser, (id))
523 #define RE_OPTION_ONCE (1<<16)
524 #define RE_OPTION_ENCODING_SHIFT 8
525 #define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
526 #define RE_OPTION_ENCODING_IDX(o) (((o)>>RE_OPTION_ENCODING_SHIFT)&0xff)
527 #define RE_OPTION_ENCODING_NONE(o) ((o)&RE_OPTION_ARG_ENCODING_NONE)
528 #define RE_OPTION_MASK 0xff
529 #define RE_OPTION_ARG_ENCODING_NONE 32
531 #define NODE_STRTERM NODE_ZARRAY
532 #define NODE_HEREDOC NODE_ARRAY
533 #define SIGN_EXTEND(x,n) (((1<<(n)-1)^((x)&~(~0<<(n))))-(1<<(n)-1))
534 #define nd_func u1.id
535 #if SIZEOF_SHORT == 2
536 #define nd_term(node) ((signed short)(node)->u2.id)
538 #define nd_term(node) SIGN_EXTEND((node)->u2.id, CHAR_BIT*2)
540 #define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2)
541 #define nd_nest u3.cnt
546 #define RIPPER_VERSION "0.1.0"
559 #define dispatch0(n) ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
560 #define dispatch1(n,a) ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), (a))
561 #define dispatch2(n,a,b) ripper_dispatch2(parser, TOKEN_PASTE(ripper_id_, n), (a), (b))
562 #define dispatch3(n,a,b,c) ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
563 #define dispatch4(n,a,b,c,d) ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
564 #define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
565 #define dispatch7(n,a,b,c,d,e,f,g) ripper_dispatch7(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e), (f), (g))
567 #define yyparse ripper_yyparse
569 #define ripper_intern(s) ID2SYM(rb_intern(s))
570 static VALUE ripper_id2sym(
ID);
572 #define ripper_id2sym(id) ((id) < 256 && rb_ispunct(id) ? \
573 ID2SYM(id) : ripper_id2sym(id))
576 #define arg_new() dispatch0(args_new)
577 #define arg_add(l,a) dispatch2(args_add, (l), (a))
578 #define arg_add_star(l,a) dispatch2(args_add_star, (l), (a))
579 #define arg_add_block(l,b) dispatch2(args_add_block, (l), (b))
580 #define arg_add_optblock(l,b) ((b)==Qundef? (l) : dispatch2(args_add_block, (l), (b)))
581 #define bare_assoc(v) dispatch1(bare_assoc_hash, (v))
582 #define arg_add_assocs(l,b) arg_add((l), bare_assoc(b))
584 #define args2mrhs(a) dispatch1(mrhs_new_from_args, (a))
585 #define mrhs_new() dispatch0(mrhs_new)
586 #define mrhs_add(l,a) dispatch2(mrhs_add, (l), (a))
587 #define mrhs_add_star(l,a) dispatch2(mrhs_add_star, (l), (a))
589 #define mlhs_new() dispatch0(mlhs_new)
590 #define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
591 #define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
593 #define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
594 dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
596 #define blockvar_new(p,v) dispatch2(block_var, (p), (v))
597 #define blockvar_add_star(l,a) dispatch2(block_var_add_star, (l), (a))
598 #define blockvar_add_block(l,a) dispatch2(block_var_add_block, (l), (a))
600 #define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
601 #define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
602 #define method_add_block(m,b) dispatch2(method_add_block, (m), (b))
604 #define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
613 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
620 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
628 # define ifndef_ripper(x) (x)
631 # define ifndef_ripper(x)
635 # define rb_warn0(fmt) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt))
636 # define rb_warnI(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
637 # define rb_warnS(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
638 # define rb_warn4S(file,line,fmt,a) rb_compile_warn((file), (line), (fmt), (a))
639 # define rb_warning0(fmt) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt))
640 # define rb_warningS(fmt,a) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt), (a))
642 # define rb_warn0(fmt) ripper_warn0(parser, (fmt))
643 # define rb_warnI(fmt,a) ripper_warnI(parser, (fmt), (a))
644 # define rb_warnS(fmt,a) ripper_warnS(parser, (fmt), (a))
645 # define rb_warn4S(file,line,fmt,a) ripper_warnS(parser, (fmt), (a))
646 # define rb_warning0(fmt) ripper_warning0(parser, (fmt))
647 # define rb_warningS(fmt,a) ripper_warningS(parser, (fmt), (a))
648 static void ripper_warn0(
struct parser_params*,
const char*);
649 static void ripper_warnI(
struct parser_params*,
const char*,
int);
650 static void ripper_warnS(
struct parser_params*,
const char*,
const char*);
651 static void ripper_warning0(
struct parser_params*,
const char*);
652 static void ripper_warningS(
struct parser_params*,
const char*,
const char*);
656 static void ripper_compile_error(
struct parser_params*,
const char *fmt, ...);
657 # define rb_compile_error ripper_compile_error
658 # define compile_error ripper_compile_error
659 # define PARSER_ARG parser,
661 # define rb_compile_error rb_compile_error_with_enc
662 # define compile_error parser->nerr++,rb_compile_error_with_enc
663 # define PARSER_ARG ruby_sourcefile, ruby_sourceline, current_enc,
671 #define YYMAXDEPTH 10000
678 #define token_info_push(token) (RTEST(ruby_verbose) ? token_info_push(parser, (token)) : (void)0)
679 #define token_info_pop(token) (RTEST(ruby_verbose) ? token_info_pop(parser, (token)) : (void)0)
681 #define token_info_push(token)
682 #define token_info_pop(token)
758 %type <val> singleton strings
string string1 xstring regexp
759 %type <val> string_contents xstring_contents regexp_contents string_content
760 %type <val> words
symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
761 %type <val> literal numeric dsym cpath
762 %type <val> top_compstmt top_stmts
top_stmt
764 %type <val> expr_value arg_value primary_value fcall
765 %type <val> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
767 %type <val> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
768 %type <val>
command_args aref_args opt_block_arg block_arg var_ref var_lhs
769 %type <val> command_asgn mrhs superclass block_call block_command
770 %type <val> f_block_optarg f_block_opt
771 %type <val> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
772 %type <val> assoc_list assocs assoc undef_list backref string_dvar for_var
773 %type <val> block_param opt_block_param block_param_def f_opt
774 %type <val> f_kwarg f_kw f_block_kwarg f_block_kw
775 %type <val> bv_decls opt_bv_decl bvar
776 %type <val> lambda f_larglist lambda_body
780 %type <val> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
784 %type <val> program reswords then
do dot_or_colon
870 while (node->nd_next) {
871 node = node->nd_next;
879 parser->result = dispatch1(program, $$);
885 top_compstmt : top_stmts opt_terms
901 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
918 $$ = dispatch2(stmts_add, $1, $3);
944 $$ = dispatch1(BEGIN, $4);
998 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
1007 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
1015 $$ = dispatch2(stmts_add, $1, $3);
1030 yyerror(
"BEGIN is permitted only at toplevel");
1036 '{' top_compstmt
'}'
1045 $$ = dispatch1(BEGIN, $4);
1054 $$ = dispatch2(
alias, $2, $4);
1062 $$ = dispatch2(var_alias, $2, $3);
1070 buf[1] = (char)$3->
nd_nth;
1073 $$ = dispatch2(var_alias, $2, $3);
1079 yyerror(
"can't make alias for the number variables");
1082 $$ = dispatch2(var_alias, $2, $3);
1083 $$ = dispatch1(alias_error, $$);
1091 $$ = dispatch1(undef, $2);
1100 $$ = dispatch2(if_mod, $3, $1);
1109 $$ = dispatch2(unless_mod, $3, $1);
1122 $$ = dispatch2(while_mod, $3, $1);
1135 $$ = dispatch2(until_mod, $3, $1);
1144 $$ = dispatch2(rescue_mod, $1, $3);
1150 rb_warn0(
"END in method; use at_exit");
1156 $$ = dispatch1(
END, $3);
1167 $$ = dispatch2(massign, $1, $3);
1193 $$ = dispatch3(opassign, $$, $5, $6);
1212 $$ = dispatch2(const_path_field, $1, $3);
1213 $$ = dispatch3(opassign, $$, $4, $5);
1227 $$ = dispatch2(assign, dispatch1(var_field, $1), $3);
1228 $$ = dispatch1(assign_error, $$);
1237 $$ = dispatch2(assign, $1, $3);
1240 | mlhs
'=' arg_value
1246 $$ = dispatch2(massign, $1, $3);
1255 $$ = dispatch2(massign, $1, $3);
1267 $$ = dispatch2(assign, $1, $3);
1276 $$ = dispatch2(assign, $1, $3);
1312 $$ = dispatch2(unary, ripper_id2sym(
'!'), $2);
1334 block_command : block_call
1340 $$ = dispatch3(call, $1, $2, $3);
1341 $$ = method_arg($$, $4);
1384 $$ = dispatch2(command, $1, $2);
1396 $$ = dispatch2(command, $1, $2);
1397 $$ = method_add_block($$, $3);
1406 $$ = dispatch4(
command_call, $1, ripper_id2sym(
'.'), $3, $4);
1413 $5->nd_iter =
NEW_CALL($1, $3, $4);
1418 $$ = method_add_block($$, $5);
1439 $$ = method_add_block($$, $5);
1448 $$ = dispatch1(super, $2);
1457 $$ = dispatch1(yield, $2);
1465 $$ = dispatch1(
return, $2);
1473 $$ = dispatch1(
break, $2);
1481 $$ = dispatch1(next, $2);
1492 $$ = dispatch1(mlhs_paren, $2);
1503 $$ = dispatch1(mlhs_paren, $2);
1521 $$ = mlhs_add($1, $2);
1529 $$ = mlhs_add_star($1, $3);
1537 $1 = mlhs_add_star($1, $3);
1538 $$ = mlhs_add($1, $5);
1546 $$ = mlhs_add_star($1,
Qnil);
1554 $1 = mlhs_add_star($1,
Qnil);
1555 $$ = mlhs_add($1, $4);
1563 $$ = mlhs_add_star(mlhs_new(), $2);
1571 $2 = mlhs_add_star(mlhs_new(), $2);
1572 $$ = mlhs_add($2, $4);
1580 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1588 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1589 $$ = mlhs_add($$, $3);
1600 $$ = dispatch1(mlhs_paren, $2);
1610 $$ = mlhs_add(mlhs_new(), $1);
1618 $$ = mlhs_add($1, $2);
1628 $$ = mlhs_add(mlhs_new(), $1);
1636 $$ = mlhs_add($1, $3);
1649 | primary_value
'[' opt_call_args rbracket
1662 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1670 $$ = dispatch2(const_path_field, $1, $3);
1678 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1685 yyerror(
"dynamic constant assignment");
1689 yyerror(
"dynamic constant assignment");
1690 $$ = dispatch2(const_path_field, $1, $3);
1697 yyerror(
"dynamic constant assignment");
1700 $$ = dispatch1(top_const_field, $2);
1709 $$ = dispatch1(var_field, $1);
1710 $$ = dispatch1(assign_error, $$);
1721 $$ = dispatch1(var_field, $$);
1730 $$ = dispatch1(var_field, $$);
1733 | primary_value
'[' opt_call_args rbracket
1746 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1762 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1769 yyerror(
"dynamic constant assignment");
1772 $$ = dispatch2(const_path_field, $1, $3);
1774 $$ = dispatch1(assign_error, $$);
1782 yyerror(
"dynamic constant assignment");
1785 $$ = dispatch1(top_const_field, $2);
1787 $$ = dispatch1(assign_error, $$);
1797 $$ = dispatch1(assign_error, $1);
1805 yyerror(
"class/module name must be CONSTANT");
1807 $$ = dispatch1(class_name_error, $1);
1818 $$ = dispatch1(top_const_ref, $2);
1826 $$ = dispatch1(const_ref, $1);
1834 $$ = dispatch2(const_path_ref, $1, $3);
1867 $$ = dispatch1(symbol_literal, $1);
1881 | undef_list
',' {
lex_state = EXPR_FNAME;} fitem
1943 $$ = dispatch2(assign, $1, $3);
1953 $$ = dispatch2(assign, $1, dispatch2(rescue_mod, $3, $5));
1967 $3 = dispatch2(rescue_mod, $3, $5);
1971 | primary_value
'[' opt_call_args rbracket
tOP_ASGN arg
1994 $$ = dispatch3(opassign, $1, $5, $6);
2018 $$ = dispatch2(const_path_field, $1, $3);
2019 $$ = dispatch3(opassign, $$, $4, $5);
2028 $$ = dispatch1(top_const_field, $2);
2029 $$ = dispatch3(opassign, $$, $3, $4);
2038 $$ = dispatch1(var_field, $1);
2039 $$ = dispatch3(opassign, $$, $2, $3);
2040 $$ = dispatch1(assign_error, $$);
2054 $$ = dispatch2(dot2, $1, $3);
2068 $$ = dispatch2(dot3, $1, $3);
2076 $$ = dispatch3(binary, $1,
ID2SYM(
'+'), $3);
2084 $$ = dispatch3(binary, $1,
ID2SYM(
'-'), $3);
2092 $$ = dispatch3(binary, $1,
ID2SYM(
'*'), $3);
2100 $$ = dispatch3(binary, $1,
ID2SYM(
'/'), $3);
2108 $$ = dispatch3(binary, $1,
ID2SYM(
'%'), $3);
2158 $$ = dispatch3(binary, $1,
ID2SYM(
'|'), $3);
2166 $$ = dispatch3(binary, $1,
ID2SYM(
'^'), $3);
2174 $$ = dispatch3(binary, $1,
ID2SYM(
'&'), $3);
2190 $$ = dispatch3(binary, $1,
ID2SYM(
'>'), $3);
2206 $$ = dispatch3(binary, $1,
ID2SYM(
'<'), $3);
2265 $$ = dispatch2(unary,
ID2SYM(
'!'), $2);
2273 $$ = dispatch2(unary,
ID2SYM(
'~'), $2);
2315 $$ = dispatch1(defined, $4);
2325 $$ = dispatch3(ifop, $1, $3, $6);
2351 | args
',' assocs trailer
2356 $$ = arg_add_assocs($1, $3);
2364 $$ = arg_add_assocs(arg_new(), $1);
2369 paren_args :
'(' opt_call_args rparen
2379 opt_paren_args : none
2383 opt_call_args : none
2389 | args
',' assocs
','
2394 $$ = arg_add_assocs($1, $3);
2402 $$ = arg_add_assocs(arg_new(), $1);
2413 $$ = arg_add(arg_new(), $1);
2416 | args opt_block_arg
2421 $$ = arg_add_optblock($1, $2);
2424 | assocs opt_block_arg
2430 $$ = arg_add_assocs(arg_new(), $1);
2431 $$ = arg_add_optblock($$, $2);
2434 | args
',' assocs opt_block_arg
2440 $$ = arg_add_optblock(arg_add_assocs($1, $3), $4);
2447 $$ = arg_add_block(arg_new(), $1);
2464 block_arg :
tAMPER arg_value
2474 opt_block_arg :
',' block_arg
2489 $$ = arg_add(arg_new(), $1);
2497 $$ = arg_add_star(arg_new(), $2);
2500 | args
',' arg_value
2511 $$ = arg_add($1, $3);
2514 | args
',' tSTAR arg_value
2525 $$ = arg_add_star($1, $4);
2530 mrhs : args
',' arg_value
2541 $$ = mrhs_add(args2mrhs($1), $3);
2544 | args
',' tSTAR arg_value
2556 $$ = mrhs_add_star(args2mrhs($1), $4);
2564 $$ = mrhs_add_star(mrhs_new(), $2);
2584 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2612 $$ = dispatch1(begin, $3);
2620 $$ = dispatch1(paren, 0);
2628 $$ = dispatch1(paren, $2);
2636 $$ = dispatch1(paren, $2);
2644 $$ = dispatch2(const_path_ref, $1, $3);
2652 $$ = dispatch1(top_const_ref, $2);
2689 $$ = dispatch1(yield, dispatch1(paren, $3));
2697 $$ = dispatch1(yield, dispatch1(paren, arg_new()));
2715 $$ = dispatch1(defined, $5);
2740 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2741 $$ = method_add_block($$, $2);
2745 | method_call brace_block
2752 $$ = method_add_block($1, $2);
2759 | k_if expr_value then
2771 | k_unless expr_value then
2791 $$ = dispatch2(
while, $3, $6);
2802 $$ = dispatch2(until, $3, $6);
2805 | k_case expr_value opt_terms
2813 $$ = dispatch2(
case, $2, $4);
2816 | k_case opt_terms case_body k_end
2821 $$ = dispatch2(
case,
Qnil, $3);
2883 tbl[0] = 1; tbl[1] =
id;
2887 $$ = dispatch3(
for, $2, $5, $8);
2890 | k_class cpath superclass
2893 yyerror(
"class definition in method body");
2907 $$ = dispatch3(
class, $2, $3, $5);
2929 $$ = dispatch2(sclass, $3, $7);
2938 yyerror(
"module definition in method body");
2952 $$ = dispatch2(module, $2, $4);
2973 $$ = dispatch3(def, $2, $4, $5);
2979 | k_def singleton dot_or_colon {
lex_state = EXPR_FNAME;} fname
2995 $$ = dispatch5(defs, $2, $3, $5, $7, $8);
3005 $$ = dispatch1(
break, arg_new());
3013 $$ = dispatch1(next, arg_new());
3034 primary_value : primary
3157 $$ = dispatch1(
else, $2);
3171 $$ = dispatch1(mlhs_paren, $$);
3179 $$ = dispatch1(mlhs_paren, $2);
3184 f_marg_list : f_marg
3189 $$ = mlhs_add(mlhs_new(), $1);
3192 | f_marg_list
',' f_marg
3197 $$ = mlhs_add($1, $3);
3202 f_margs : f_marg_list
3210 | f_marg_list
',' tSTAR f_norm_arg
3216 $$ = mlhs_add_star($1, $$);
3219 | f_marg_list
',' tSTAR f_norm_arg
',' f_marg_list
3225 $$ = mlhs_add_star($1, $$);
3228 | f_marg_list
',' tSTAR
3233 $$ = mlhs_add_star($1,
Qnil);
3236 | f_marg_list
',' tSTAR ',' f_marg_list
3241 $$ = mlhs_add_star($1, $5);
3250 $$ = mlhs_add_star(mlhs_new(), $$);
3253 |
tSTAR f_norm_arg
',' f_marg_list
3262 $$ = mlhs_add_star($$, $4);
3270 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3273 |
tSTAR ',' f_marg_list
3278 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3284 block_args_tail : f_block_kwarg
',' f_kwrest opt_f_block_arg
3288 | f_block_kwarg opt_f_block_arg
3292 | f_kwrest opt_f_block_arg
3302 opt_block_args_tail :
',' block_args_tail
3312 block_param : f_arg
',' f_block_optarg
',' f_rest_arg opt_block_args_tail
3316 | f_arg
',' f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3320 | f_arg
',' f_block_optarg opt_block_args_tail
3324 | f_arg
',' f_block_optarg
',' f_arg opt_block_args_tail
3328 | f_arg
',' f_rest_arg opt_block_args_tail
3337 dispatch1(excessed_comma, $$);
3340 | f_arg
',' f_rest_arg
',' f_arg opt_block_args_tail
3344 | f_arg opt_block_args_tail
3348 | f_block_optarg
',' f_rest_arg opt_block_args_tail
3352 | f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3356 | f_block_optarg opt_block_args_tail
3360 | f_block_optarg
',' f_arg opt_block_args_tail
3364 | f_rest_arg opt_block_args_tail
3368 | f_rest_arg
',' f_arg opt_block_args_tail
3378 opt_block_param : none
3385 block_param_def :
'|' opt_bv_decl
'|'
3403 |
'|' block_param opt_bv_decl
'|'
3414 opt_bv_decl : opt_nl
3418 | opt_nl
';' bv_decls opt_nl
3476 $$ = dispatch2(lambda, $3, $5);
3482 f_larglist :
'(' f_args opt_bv_decl
')'
3487 $$ = dispatch1(paren, $2);
3531 block_call : command do_block
3544 $$ = method_add_block($1, $2);
3547 | block_call dot_or_colon operation2 opt_paren_args
3552 $$ = dispatch3(call, $1, $2, $3);
3553 $$ = method_optarg($$, $4);
3556 | block_call dot_or_colon operation2 opt_paren_args brace_block
3560 $5->nd_iter =
NEW_CALL($1, $3, $4);
3565 $$ = method_add_block($$, $5);
3568 | block_call dot_or_colon operation2
command_args do_block
3572 $5->nd_iter =
NEW_CALL($1, $3, $4);
3577 $$ = method_add_block($$, $5);
3582 method_call : fcall paren_args
3588 $$ = method_arg(dispatch1(fcall, $1), $2);
3591 | primary_value
'.' operation2
3603 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3604 $$ = method_optarg($$, $5);
3607 | primary_value
tCOLON2 operation2
3619 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3620 $$ = method_optarg($$, $5);
3623 | primary_value
tCOLON2 operation3
3643 $$ = dispatch3(call, $1, ripper_id2sym(
'.'),
3645 $$ = method_optarg($$, $4);
3662 $$ = method_optarg($$, $4);
3670 $$ = dispatch1(super, $2);
3681 | primary_value
'[' opt_call_args rbracket
3763 $$ = dispatch4(rescue,
3773 exc_list : arg_value
3804 $$ = dispatch1(ensure, $2);
3816 $$ = dispatch1(symbol_literal, $1);
3846 $$ = dispatch2(string_concat, $1, $2);
3856 $$ = dispatch1(string_literal, $2);
3883 $$ = dispatch1(xstring_literal, $2);
3900 VALUE src = node->nd_lit;
3916 for (list = (prev = node)->
nd_next;
list; list = list->nd_next) {
3920 VALUE lit = prev == node ? prev->nd_lit : prev->nd_head->nd_lit;
3926 prev->nd_next = list->nd_next;
3939 if (!node->nd_next) {
3940 VALUE src = node->nd_lit;
3948 $$ = dispatch2(regexp_literal, $2, $3);
3959 $$ = dispatch1(array, $$);
3967 $$ = dispatch1(array, $2);
3980 | word_list word
' '
3985 $$ = dispatch2(words_add, $1, $2);
3990 word : string_content
3995 $$ = dispatch2(word_add, $$, $1);
3998 | word string_content
4003 $$ = dispatch2(word_add, $1, $2);
4014 $$ = dispatch1(array, $$);
4022 $$ = dispatch1(array, $2);
4035 | symbol_list word
' '
4042 $$ = dispatch2(symbols_add, $1, $2);
4053 $$ = dispatch1(array, $$);
4061 $$ = dispatch1(array, $2);
4072 $$ = dispatch1(array, $$);
4080 $$ = dispatch1(array, $2);
4098 $$ = dispatch2(qwords_add, $1, $2);
4120 $$ = dispatch2(qsymbols_add, $1, $2);
4133 | string_contents string_content
4138 $$ = dispatch2(string_add, $1, $2);
4151 | xstring_contents string_content
4156 $$ = dispatch2(xstring_add, $1, $2);
4169 | regexp_contents string_content
4193 $$ = dispatch2(regexp_add, $1, $2);
4212 $$ = dispatch1(string_dvar, $3);
4241 $$ = dispatch1(string_embexpr, $5);
4251 $$ = dispatch1(var_ref, $1);
4259 $$ = dispatch1(var_ref, $1);
4267 $$ = dispatch1(var_ref, $1);
4279 $$ = dispatch1(symbol, $2);
4296 $$ = dispatch1(dyna_symbol, $2);
4337 var_ref : user_variable
4342 if (id_is_var(
get_id($1))) {
4343 $$ = dispatch1(var_ref, $1);
4346 $$ = dispatch1(vcall, $1);
4355 $$ = dispatch1(var_ref, $1);
4360 var_lhs : user_variable
4365 $$ = dispatch1(var_field, $$);
4373 $$ = dispatch1(var_field, $$);
4411 f_arglist :
'(' f_args rparen
4416 $$ = dispatch1(paren, $2);
4429 args_tail : f_kwarg
',' f_kwrest opt_f_block_arg
4433 | f_kwarg opt_f_block_arg
4437 | f_kwrest opt_f_block_arg
4447 opt_args_tail :
',' args_tail
4457 f_args : f_arg
',' f_optarg
',' f_rest_arg opt_args_tail
4461 | f_arg
',' f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4465 | f_arg
',' f_optarg opt_args_tail
4469 | f_arg
',' f_optarg
',' f_arg opt_args_tail
4473 | f_arg
',' f_rest_arg opt_args_tail
4477 | f_arg
',' f_rest_arg
',' f_arg opt_args_tail
4481 | f_arg opt_args_tail
4485 | f_optarg
',' f_rest_arg opt_args_tail
4489 | f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4493 | f_optarg opt_args_tail
4497 | f_optarg
',' f_arg opt_args_tail
4501 | f_rest_arg opt_args_tail
4505 | f_rest_arg
',' f_arg opt_args_tail
4523 yyerror(
"formal argument cannot be a constant");
4526 $$ = dispatch1(param_error, $1);
4532 yyerror(
"formal argument cannot be an instance variable");
4535 $$ = dispatch1(param_error, $1);
4541 yyerror(
"formal argument cannot be a global variable");
4544 $$ = dispatch1(param_error, $1);
4550 yyerror(
"formal argument cannot be a class variable");
4553 $$ = dispatch1(param_error, $1);
4558 f_norm_arg : f_bad_arg
4566 f_arg_item : f_norm_arg
4589 $$ = dispatch1(mlhs_paren, $2);
4601 | f_arg
',' f_arg_item
4626 f_block_kw :
tLABEL primary_value
4638 f_block_kwarg : f_block_kw
4646 | f_block_kwarg
',' f_block_kw
4651 while (kws->nd_next) {
4676 while (kws->nd_next) {
4726 f_block_optarg : f_block_opt
4734 | f_block_optarg
',' f_block_opt
4739 while (opts->nd_next) {
4740 opts = opts->nd_next;
4758 | f_optarg
',' f_opt
4763 while (opts->nd_next) {
4764 opts = opts->nd_next;
4782 yyerror(
"rest argument must be local variable");
4788 $$ = dispatch1(rest_param, $2);
4797 $$ = dispatch1(rest_param,
Qnil);
4810 yyerror(
"block argument must be local variable");
4812 yyerror(
"duplicated block argument name");
4818 $$ = dispatch1(blockarg, $2);
4823 opt_f_block_arg :
',' f_block_arg
4851 yyerror(
"can't define singleton method for ().");
4863 yyerror(
"can't define singleton method for literals");
4871 $$ = dispatch1(paren, $3);
4882 $$ = dispatch1(assoclist_from_args, $1);
4904 assoc : arg_value
tASSOC arg_value
4909 $$ = dispatch2(assoc_new, $1, $3);
4917 $$ = dispatch2(assoc_new, $1, $2);
4925 $$ = dispatch1(assoc_splat, $2);
4971 rbracket : opt_nl
']'
5000 # define yylval (*((YYSTYPE*)(parser->parser_yylval)))
5009 # define nextc() parser_nextc(parser)
5010 # define pushback(c) parser_pushback(parser, (c))
5011 # define newtok() parser_newtok(parser)
5012 # define tokspace(n) parser_tokspace(parser, (n))
5013 # define tokadd(c) parser_tokadd(parser, (c))
5014 # define tok_hex(numlen) parser_tok_hex(parser, (numlen))
5015 # define read_escape(flags,e) parser_read_escape(parser, (flags), (e))
5016 # define tokadd_escape(e) parser_tokadd_escape(parser, (e))
5017 # define regx_options() parser_regx_options(parser)
5018 # define tokadd_string(f,t,p,n,e) parser_tokadd_string(parser,(f),(t),(p),(n),(e))
5019 # define parse_string(n) parser_parse_string(parser,(n))
5020 # define tokaddmbc(c, enc) parser_tokaddmbc(parser, (c), (enc))
5021 # define here_document(n) parser_here_document(parser,(n))
5022 # define heredoc_identifier() parser_heredoc_identifier(parser)
5023 # define heredoc_restore(n) parser_heredoc_restore(parser,(n))
5024 # define whole_match_p(e,l,i) parser_whole_match_p(parser,(e),(l),(i))
5027 # define set_yylval_str(x) (yylval.node = NEW_STR(x))
5028 # define set_yylval_num(x) (yylval.num = (x))
5029 # define set_yylval_id(x) (yylval.id = (x))
5030 # define set_yylval_name(x) (yylval.id = (x))
5031 # define set_yylval_literal(x) (yylval.node = NEW_LIT(x))
5032 # define set_yylval_node(x) (yylval.node = (x))
5033 # define yylval_id() (yylval.id)
5036 ripper_yylval_id(
ID x)
5040 # define set_yylval_str(x) (void)(x)
5041 # define set_yylval_num(x) (void)(x)
5042 # define set_yylval_id(x) (void)(x)
5043 # define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(x))
5044 # define set_yylval_literal(x) (void)(x)
5045 # define set_yylval_node(x) (void)(x)
5046 # define yylval_id() yylval.id
5050 #define ripper_flush(p) (void)(p)
5052 #define ripper_flush(p) ((p)->tokp = (p)->parser_lex_p)
5054 #define yylval_rval (*(RB_TYPE_P(yylval.val, T_NODE) ? &yylval.node->nd_rval : &yylval.val))
5061 return lex_p > parser->tokp;
5074 ripper_dispatch_scan_event(
struct parser_params *parser,
int t)
5076 if (!ripper_has_scan_event(parser))
return;
5077 yylval_rval = ripper_scan_event_val(parser, t);
5081 ripper_dispatch_ignored_scan_event(
struct parser_params *parser,
int t)
5083 if (!ripper_has_scan_event(parser))
return;
5084 (void)ripper_scan_event_val(parser, t);
5088 ripper_dispatch_delayed_token(
struct parser_params *parser,
int t)
5091 const char *saved_tokp = parser->tokp;
5094 parser->tokp =
lex_pbeg + parser->delayed_col;
5096 parser->delayed =
Qnil;
5098 parser->tokp = saved_tokp;
5109 #undef SIGN_EXTEND_CHAR
5111 # define SIGN_EXTEND_CHAR(c) ((signed char)(c))
5114 # define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
5117 #define parser_encoding_name() (current_enc->name)
5118 #define parser_mbclen() mbclen((lex_p-1),lex_pend,current_enc)
5119 #define parser_precise_mbclen() rb_enc_precise_mbclen((lex_p-1),lex_pend,current_enc)
5120 #define is_identchar(p,e,enc) (rb_enc_isalnum(*(p),(enc)) || (*(p)) == '_' || !ISASCII(*(p)))
5121 #define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,current_enc))
5123 #define parser_isascii() ISASCII(*(lex_p-1))
5131 for (p =
lex_pbeg; p < pend; p++) {
5133 column = (((column - 1) / 8) + 1) * 8;
5144 for (p =
lex_pbeg; p < pend; p++) {
5145 if (*p !=
' ' && *p !=
'\t') {
5152 #undef token_info_push
5169 #undef token_info_pop
5176 if (!ptinfo)
return;
5182 if (linenum == ptinfo->
linenum) {
5190 "mismatched indentations at '%s' with '%s' at %d",
5203 const int max_line_margin = 30;
5212 if (*p ==
'\n')
break;
5219 if (*pe ==
'\n')
break;
5226 const char *pre =
"", *post =
"";
5228 if (len > max_line_margin * 2 + 10) {
5229 if (
lex_p - p > max_line_margin) {
5233 if (pe -
lex_p > max_line_margin) {
5240 MEMCPY(buf, p,
char, len);
5244 i = (int)(
lex_p - p);
5245 p2 =
buf; pe = buf + len;
5248 if (*p2 !=
'\t') *p2 =
' ';
5256 dispatch1(parse_error,
STR_NEW2(msg));
5268 CONST_ID(script_lines,
"SCRIPT_LINES__");
5285 if (
RTEST(coverages) &&
RBASIC(coverages)->klass == 0) {
5289 RBASIC(lines)->klass = 0;
5291 RARRAY(lines)->as.heap.len = n;
5386 char *beg, *end, *pend;
5396 while (end < pend) {
5397 if (*end++ ==
'\n')
break;
5407 if (
NIL_P(line))
return line;
5506 #define STR_FUNC_ESCAPE 0x01
5507 #define STR_FUNC_EXPAND 0x02
5508 #define STR_FUNC_REGEXP 0x04
5509 #define STR_FUNC_QWORDS 0x08
5510 #define STR_FUNC_SYMBOL 0x10
5511 #define STR_FUNC_INDENT 0x20
5541 #define lex_goto_eol(parser) ((parser)->parser_lex_p = (parser)->parser_lex_pend)
5542 #define lex_eol_p() (lex_p >= lex_pend)
5543 #define peek(c) peek_n((c), 0)
5544 #define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
5567 if (
NIL_P(parser->delayed)) {
5571 parser->tokp,
lex_pend - parser->tokp);
5573 parser->delayed_col = (int)(parser->tokp -
lex_pbeg);
5577 parser->tokp,
lex_pend - parser->tokp);
5593 c = (
unsigned char)*
lex_p++;
5594 if (c ==
'\r' &&
peek(
'\n')) {
5605 if (c == -1)
return;
5612 #define was_bol() (lex_p == lex_pbeg + 1)
5614 #define tokfix() (tokenbuf[tokidx]='\0')
5615 #define tok() tokenbuf
5616 #define toklen() tokidx
5617 #define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
5664 yyerror(
"invalid hex escape");
5671 #define tokcopy(n) memcpy(tokspace(n), lex_p - (n), (n))
5676 int string_literal,
int symbol_literal,
int regexp_literal)
5696 yyerror(
"invalid Unicode escape");
5699 if (codepoint > 0x10ffff) {
5700 yyerror(
"invalid Unicode codepoint (too large)");
5704 if (regexp_literal) {
5707 else if (codepoint >= 0x80) {
5709 if (string_literal)
tokaddmbc(codepoint, *encp);
5711 else if (string_literal) {
5714 }
while (string_literal && (
peek(
' ') ||
peek(
'\t')));
5717 yyerror(
"unterminated Unicode escape");
5721 if (regexp_literal) {
tokadd(
'}'); }
5727 yyerror(
"invalid Unicode escape");
5731 if (regexp_literal) {
5734 else if (codepoint >= 0x80) {
5736 if (string_literal)
tokaddmbc(codepoint, *encp);
5738 else if (string_literal) {
5746 #define ESCAPE_CONTROL 1
5747 #define ESCAPE_META 2
5756 switch (c =
nextc()) {
5781 case '0':
case '1':
case '2':
case '3':
5782 case '4':
case '5':
case '6':
case '7':
5790 if (numlen == 0)
return 0;
5801 if ((c =
nextc()) !=
'-') {
5805 if ((c =
nextc()) ==
'\\') {
5806 if (
peek(
'u'))
goto eof;
5807 return read_escape(flags|ESCAPE_META, encp) | 0x80;
5809 else if (c == -1 || !
ISASCII(c))
goto eof;
5811 return ((c & 0xff) | 0x80);
5815 if ((c =
nextc()) !=
'-') {
5821 if ((c =
nextc())==
'\\') {
5822 if (
peek(
'u'))
goto eof;
5827 else if (c == -1 || !
ISASCII(c))
goto eof;
5832 yyerror(
"Invalid escape character syntax");
5855 switch (c =
nextc()) {
5859 case '0':
case '1':
case '2':
case '3':
5860 case '4':
case '5':
case '6':
case '7':
5863 if (numlen == 0)
goto eof;
5872 if (numlen == 0)
return -1;
5878 if (flags & ESCAPE_META)
goto eof;
5879 if ((c =
nextc()) !=
'-') {
5888 if (flags & ESCAPE_CONTROL)
goto eof;
5889 if ((c =
nextc()) !=
'-') {
5897 if (flags & ESCAPE_CONTROL)
goto eof;
5901 if ((c =
nextc()) ==
'\\') {
5904 else if (c == -1)
goto eof;
5910 yyerror(
"Invalid escape character syntax");
5977 #define tokadd_mbchar(c) parser_tokadd_mbchar(parser, (c))
5983 case '$':
case '*':
case '+':
case '.':
5984 case '?':
case '^':
case '|':
5985 case ')':
case ']':
case '}':
case '>':
5994 int func,
int term,
int paren,
long *nest,
5998 int has_nonascii = 0;
6001 static const char mixed_msg[] =
"%s mixed within %s source";
6003 #define mixed_error(enc1, enc2) if (!errbuf) { \
6004 size_t len = sizeof(mixed_msg) - 4; \
6005 len += strlen(rb_enc_name(enc1)); \
6006 len += strlen(rb_enc_name(enc2)); \
6007 errbuf = ALLOCA_N(char, len); \
6008 snprintf(errbuf, len, mixed_msg, \
6009 rb_enc_name(enc1), \
6010 rb_enc_name(enc2)); \
6013 #define mixed_escape(beg, enc1, enc2) do { \
6014 const char *pos = lex_p; \
6016 mixed_error((enc1), (enc2)); \
6020 while ((c =
nextc()) != -1) {
6021 if (paren && c == paren) {
6024 else if (c == term) {
6025 if (!nest || !*nest) {
6033 if (c2 ==
'$' || c2 ==
'@' || c2 ==
'{') {
6038 else if (c ==
'\\') {
6039 const char *beg =
lex_p - 1;
6044 if (func & STR_FUNC_EXPAND)
continue;
6053 if ((func & STR_FUNC_EXPAND) == 0) {
6059 func & STR_FUNC_REGEXP);
6060 if (has_nonascii && enc != *encp) {
6066 if (c == -1)
return -1;
6068 if ((func & STR_FUNC_EXPAND) == 0)
tokadd(
'\\');
6071 if (func & STR_FUNC_REGEXP) {
6079 if (has_nonascii && enc != *encp) {
6084 else if (func & STR_FUNC_EXPAND) {
6086 if (func & STR_FUNC_ESCAPE)
tokadd(
'\\');
6089 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6092 else if (c != term && !(paren && c == paren)) {
6109 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6126 #define NEW_STRTERM(func, term, paren) \
6127 rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
6133 if (!
NIL_P(parser->delayed)) {
6134 ptrdiff_t len =
lex_p - parser->tokp;
6139 parser->tokp =
lex_p;
6143 #define flush_string_content(enc) ripper_flush_string_content(parser, (enc))
6145 #define flush_string_content(enc) ((void)(enc))
6152 #define BIT(c, idx) (((c) / 32 - 1 == idx) ? (1U << ((c) % 32)) : 0)
6153 #define SPECIAL_PUNCT(idx) ( \
6154 BIT('~', idx) | BIT('*', idx) | BIT('$', idx) | BIT('?', idx) | \
6155 BIT('!', idx) | BIT('@', idx) | BIT('/', idx) | BIT('\\', idx) | \
6156 BIT(';', idx) | BIT(',', idx) | BIT('.', idx) | BIT('=', idx) | \
6157 BIT(':', idx) | BIT('<', idx) | BIT('>', idx) | BIT('\"', idx) | \
6158 BIT('&', idx) | BIT('`', idx) | BIT('\'', idx) | BIT('+', idx) | \
6166 #undef SPECIAL_PUNCT
6172 if (c <= 0x20 || 0x7e < c)
return 0;
6173 return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
6180 const char *p =
lex_p;
6186 if ((c = *p) ==
'-') {
6195 if ((c = *p) ==
'@') {
6215 int func = (int)quote->nd_func;
6223 if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6227 if (c == term && !quote->nd_nest) {
6228 if (func & STR_FUNC_QWORDS) {
6229 quote->nd_func = -1;
6232 if (!(func & STR_FUNC_REGEXP))
return tSTRING_END;
6241 if ((func & STR_FUNC_EXPAND) && c ==
'#') {
6251 if (func & STR_FUNC_REGEXP) {
6273 int c =
nextc(), term, func = 0;
6291 while ((c =
nextc()) != -1 && c != term) {
6338 line = here->nd_orig;
6342 lex_p = lex_pbeg + here->nd_nth;
6352 const char *eos,
long len,
int indent)
6358 while (*p &&
ISSPACE(*p)) p++;
6361 if (n < 0 || (n > 0 && p[len] !=
'\n' && p[len] !=
'\r'))
return FALSE;
6362 return strncmp(eos, p, len) == 0;
6369 if (!
NIL_P(parser->delayed))
6372 ripper_dispatch_ignored_scan_event(parser,
tHEREDOC_END);
6375 #define dispatch_heredoc_end() ripper_dispatch_heredoc_end(parser)
6377 #define dispatch_heredoc_end() ((void)0)
6383 int c,
func, indent = 0;
6384 const char *eos, *
p, *pend;
6393 if ((c =
nextc()) == -1) {
6397 if (
NIL_P(parser->delayed)) {
6402 ((len =
lex_p - parser->tokp) > 0 &&
6403 (str =
STR_NEW3(parser->tokp, len, enc, func), 1))) {
6421 if (!(func & STR_FUNC_EXPAND)) {
6428 if (--pend == p || pend[-1] !=
'\r') {
6442 if (
nextc() == -1) {
6460 if (parser->
eofp)
goto error;
6470 if ((c =
nextc()) == -1)
goto error;
6487 rb_warning0(
"ambiguous first argument; put parentheses or even spaces");
6492 #define arg_ambiguous() (arg_ambiguous_gen(parser), 1)
6499 yyerror(
"formal argument must be local variable");
6517 if (len > 5 && name[nlen = len - 5] ==
'-') {
6521 if (len > 4 && name[nlen = len - 4] ==
'-') {
6524 if (
rb_memcicmp(name + nlen + 1,
"mac", 3) == 0 &&
6525 !(len == 8 &&
rb_memcicmp(name,
"utf8-mac", len) == 0))
6540 excargs[1] =
rb_sprintf(
"unknown encoding name: %s", name);
6557 for (i = 0; i < n; ++
i) {
6632 if (str[i-1] ==
'*' && str[i-2] ==
'-') {
6638 if (i + 1 >= len)
return 0;
6639 if (str[i+1] !=
'-') {
6642 else if (str[i-1] !=
'-') {
6660 VALUE name = 0, val = 0;
6661 const char *beg, *end, *vbeg, *vend;
6662 #define str_copy(_s, _p, _n) ((_s) \
6663 ? (void)(rb_str_resize((_s), (_n)), \
6664 MEMCPY(RSTRING_PTR(_s), (_p), char, (_n)), (_s)) \
6665 : (void)((_s) = STR_NEW((_p), (_n))))
6667 if (len <= 7)
return FALSE;
6671 len = end - beg - 3;
6682 for (; len > 0 && *str; str++, --len) {
6684 case '\'':
case '"':
case ':':
case ';':
6689 for (beg = str; len > 0; str++, --len) {
6691 case '\'':
case '"':
case ':':
case ';':
6699 for (end = str; len > 0 &&
ISSPACE(*str); str++, --len);
6701 if (*str !=
':')
continue;
6703 do str++;
while (--len > 0 &&
ISSPACE(*str));
6706 for (vbeg = ++str; --len > 0 && *str !=
'"'; str++) {
6719 for (vbeg = str; len > 0 && *str !=
'"' && *str !=
';' && !
ISSPACE(*str); --len, str++);
6722 while (len > 0 && (*str ==
';' ||
ISSPACE(*str))) --len, str++;
6727 for (i = 0; i < n; ++
i) {
6728 if (s[i] ==
'-') s[
i] =
'_';
6735 n = (*p->
length)(parser, vbeg, n);
6741 }
while (++p < magic_comments +
numberof(magic_comments));
6755 const char *beg = str;
6759 if (send - str <= 6)
return;
6761 case 'C':
case 'c': str += 6;
continue;
6762 case 'O':
case 'o': str += 5;
continue;
6763 case 'D':
case 'd': str += 4;
continue;
6764 case 'I':
case 'i': str += 3;
continue;
6765 case 'N':
case 'n': str += 2;
continue;
6766 case 'G':
case 'g': str += 1;
continue;
6780 if (++str >= send)
return;
6783 if (*str !=
'=' && *str !=
':')
return;
6788 while ((*str ==
'-' || *str ==
'_' ||
ISALNUM(*str)) && ++str < send);
6804 (
unsigned char)
lex_p[0] == 0xbb &&
6805 (
unsigned char)
lex_p[1] == 0xbf) {
6819 #define IS_ARG() IS_lex_state(EXPR_ARG_ANY)
6820 #define IS_END() IS_lex_state(EXPR_END_ANY)
6821 #define IS_BEG() IS_lex_state(EXPR_BEG_ANY)
6822 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
6823 #define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG | EXPR_ENDFN) && !cmd_state) || IS_ARG())
6824 #define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1))
6825 #define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT)
6828 #define ambiguous_operator(op, syn) ( \
6829 rb_warning0("`"op"' after local variable is interpreted as binary operator"), \
6830 rb_warning0("even though it seems like "syn""))
6832 #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn))
6834 #define warn_balanced(op, syn) ((void) \
6835 (!IS_lex_state_for(last_state, EXPR_CLASS|EXPR_DOT|EXPR_FNAME|EXPR_ENDFN|EXPR_ENDARG) && \
6836 space_seen && !ISSPACE(c) && \
6837 (ambiguous_operator(op, syn), 0)))
6849 int fallthru =
FALSE;
6875 switch (c =
nextc()) {
6883 case ' ':
case '\t':
case '\f':
case '\r':
6887 while ((c =
nextc())) {
6889 case ' ':
case '\t':
case '\f':
case '\r':
6898 ripper_dispatch_scan_event(parser,
tSP);
6911 ripper_dispatch_scan_event(parser,
tCOMMENT);
6916 if (
IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT)) {
6925 while ((c =
nextc())) {
6927 case ' ':
case '\t':
case '\f':
case '\r':
6932 if ((c =
nextc()) !=
'.') {
6945 parser->tokp =
lex_p;
6948 goto normal_newline;
6957 if ((c =
nextc()) ==
'*') {
6958 if ((c =
nextc()) ==
'=') {
6965 rb_warning0(
"`**' interpreted as argument prefix");
6984 rb_warning0(
"`*' interpreted as argument prefix");
7032 ripper_dispatch_scan_event(parser,
tEMBDOC);
7041 if (c !=
'=')
continue;
7042 if (strncmp(
lex_p,
"end", 3) == 0 &&
7056 if ((c =
nextc()) ==
'=') {
7057 if ((c =
nextc()) ==
'=') {
7066 else if (c ==
'>') {
7078 (!
IS_ARG() || space_seen)) {
7080 if (token)
return token;
7091 if ((c =
nextc()) ==
'>') {
7098 if ((c =
nextc()) ==
'=') {
7112 if ((c =
nextc()) ==
'=') {
7116 if ((c =
nextc()) ==
'=') {
7184 rb_warnI(
"invalid character syntax; use ?\\%c", c2);
7201 else if (c ==
'\\') {
7230 if ((c =
nextc()) ==
'&') {
7232 if ((c =
nextc()) ==
'=') {
7240 else if (c ==
'=') {
7247 rb_warning0(
"`&' interpreted as argument prefix");
7261 if ((c =
nextc()) ==
'|') {
7263 if ((c =
nextc()) ==
'=') {
7343 if ((c =
nextc()) ==
'.') {
7344 if ((c =
nextc()) ==
'.') {
7352 yyerror(
"no .<digit> floating literal anymore; put 0 before dot");
7358 case '0':
case '1':
case '2':
case '3':
case '4':
7359 case '5':
case '6':
case '7':
case '8':
case '9':
7361 int is_float, seen_point, seen_e, nondigit;
7363 is_float = seen_point = seen_e = nondigit = 0;
7366 if (c ==
'-' || c ==
'+') {
7371 #define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
7374 if (c ==
'x' || c ==
'X') {
7380 if (nondigit)
break;
7387 }
while ((c =
nextc()) != -1);
7394 else if (nondigit)
goto trailing_uc;
7398 if (c ==
'b' || c ==
'B') {
7401 if (c ==
'0' || c ==
'1') {
7404 if (nondigit)
break;
7408 if (c !=
'0' && c !=
'1')
break;
7411 }
while ((c =
nextc()) != -1);
7418 else if (nondigit)
goto trailing_uc;
7422 if (c ==
'd' || c ==
'D') {
7428 if (nondigit)
break;
7435 }
while ((c =
nextc()) != -1);
7442 else if (nondigit)
goto trailing_uc;
7450 if (c ==
'o' || c ==
'O') {
7453 if (c == -1 || c ==
'_' || !
ISDIGIT(c)) {
7457 if (c >=
'0' && c <=
'7') {
7462 if (nondigit)
break;
7466 if (c < '0' || c >
'9')
break;
7467 if (c >
'7')
goto invalid_octal;
7470 }
while ((c =
nextc()) != -1);
7474 if (nondigit)
goto trailing_uc;
7483 if (c >
'7' && c <=
'9') {
7485 yyerror(
"Invalid octal digit");
7487 else if (c ==
'.' || c ==
'e' || c ==
'E') {
7499 case '0':
case '1':
case '2':
case '3':
case '4':
7500 case '5':
case '6':
case '7':
case '8':
case '9':
7506 if (nondigit)
goto trailing_uc;
7507 if (seen_point || seen_e) {
7512 if (c0 == -1 || !
ISDIGIT(c0)) {
7540 if (c !=
'-' && c !=
'+')
continue;
7546 if (nondigit)
goto decode_num;
7561 snprintf(tmp,
sizeof(tmp),
"trailing `%c' in number", nondigit);
7567 if (
errno == ERANGE) {
7644 if ((c =
nextc()) ==
'=') {
7664 if ((c =
nextc()) !=
'@') {
7691 if ((c =
nextc()) ==
']') {
7692 if ((c =
nextc()) ==
'=') {
7704 else if (
IS_ARG() && space_seen) {
7739 ripper_dispatch_scan_event(parser,
tSP);
7760 yyerror(
"unknown type of %string");
7764 if (c == -1 || term == -1) {
7769 if (term ==
'(') term =
')';
7770 else if (term ==
'[') term =
']';
7771 else if (term ==
'{') term =
'}';
7772 else if (term ==
'<') term =
'>';
7822 yyerror(
"unknown type of %string");
7826 if ((c =
nextc()) ==
'=') {
7903 case '1':
case '2':
case '3':
7904 case '4':
case '5':
case '6':
7905 case '7':
case '8':
case '9':
7910 }
while (c != -1 &&
ISDIGIT(c));
7956 ripper_dispatch_scan_event(parser,
k__END__);
7984 if ((c ==
'!' || c ==
'?') && !
peek(
'=')) {
8004 if (
tok()[1] ==
'@')
8050 if (state == EXPR_FNAME) {
8064 if (
CMDARG_P() && state != EXPR_CMDARG)
8066 if (state & (EXPR_BEG | EXPR_ENDARG))
8070 if (state & (EXPR_BEG | EXPR_VALUE))
8073 if (kw->
id[0] != kw->
id[1])
8110 yylex(
void *lval,
void *p)
8124 if (!
NIL_P(parser->delayed)) {
8125 ripper_dispatch_delayed_token(parser, t);
8129 ripper_dispatch_scan_event(parser, t);
8171 if (orig == (
NODE*)1)
return;
8180 #define parser_warning(node, mesg) parser_warning(parser, (node), (mesg))
8187 #define parser_warn(node, mesg) parser_warn(parser, (node), (mesg))
8194 if (tail == 0)
return head;
8196 if (h == 0)
return tail;
8235 tail->nd_end =
tail;
8237 end->nd_next =
tail;
8238 h->nd_end = tail->nd_end;
8248 if (list == 0)
return NEW_LIST(item);
8249 if (list->nd_next) {
8250 last = list->nd_next->nd_end;
8258 list->nd_next->nd_end = last->nd_next;
8268 if (head->nd_next) {
8269 last = head->nd_next->nd_end;
8275 head->nd_alen += tail->nd_alen;
8276 last->nd_next =
tail;
8277 if (tail->nd_next) {
8278 head->nd_next->nd_end = tail->nd_next->nd_end;
8281 head->nd_next->nd_end =
tail;
8290 if (
NIL_P(tail))
return 1;
8311 if (!head)
return tail;
8312 if (!tail)
return head;
8322 if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8325 lit = headlast->nd_lit;
8348 tail->nd_lit = head->nd_lit;
8352 else if (
NIL_P(tail->nd_lit)) {
8354 head->nd_alen += tail->nd_alen - 1;
8355 head->nd_next->nd_end->nd_next = tail->nd_next;
8356 head->nd_next->nd_end = tail->nd_next->nd_end;
8359 else if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8361 lit = headlast->nd_lit;
8364 tail->nd_lit =
Qnil;
8369 tail->nd_head =
NEW_STR(tail->nd_lit);
8519 static const char names[][12] = {
8520 "EXPR_BEG",
"EXPR_END",
"EXPR_ENDARG",
"EXPR_ENDFN",
"EXPR_ARG",
8521 "EXPR_CMDARG",
"EXPR_MID",
"EXPR_FNAME",
"EXPR_DOT",
"EXPR_CLASS",
8526 return names[
ffs(state)];
8541 # define assignable_result(x) get_value(lhs)
8542 # define parser_yyerror(parser, x) dispatch1(assign_error, lhs)
8544 # define assignable_result(x) (x)
8549 yyerror(
"Can't change the value of self");
8552 yyerror(
"Can't assign to nil");
8555 yyerror(
"Can't assign to true");
8558 yyerror(
"Can't assign to false");
8561 yyerror(
"Can't assign to __FILE__");
8564 yyerror(
"Can't assign to __LINE__");
8567 yyerror(
"Can't assign to __ENCODING__");
8601 yyerror(
"dynamic constant assignment");
8610 #undef assignable_result
8611 #undef parser_yyerror
8618 if (name == idUScore)
return 1;
8625 #define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
8633 yyerror(
"duplicated argument name");
8645 yyerror(
"duplicated argument name");
8703 int scope = (int)(
id & ID_SCOPE_MASK);
8712 id_type_names[scope],
ID2SYM(
id));
8716 id &= ~ID_SCOPE_MASK;
8745 if (!node2)
return node1;
8749 node1->nd_head =
arg_concat(node1->nd_head, node2);
8761 node1->nd_body =
list_concat(node1->nd_body, node2);
8770 if (!node1)
return NEW_LIST(node2);
8775 node1->nd_head =
arg_append(node1->nd_head, node2);
8808 lhs->nd_value = rhs;
8813 lhs->nd_args =
arg_append(lhs->nd_args, rhs);
8844 if (!cond)
yyerror(
"void value expression");
8849 while (node->nd_next) {
8850 node = node->nd_next;
8852 node = node->nd_head;
8856 node = node->nd_body;
8860 if (!node->nd_body) {
8861 node = node->nd_else;
8864 else if (!node->nd_else) {
8865 node = node->nd_body;
8869 node = node->nd_else;
8875 node = node->nd_2nd;
8889 const char *useless = 0;
8896 switch (node->nd_mid) {
8927 useless =
"a variable";
8930 useless =
"a constant";
8937 useless =
"a literal";
8962 useless =
"defined?";
8970 rb_warnS(
"possibly useless use of %s in void context", useless);
8983 if (!node->nd_next)
return;
8985 node = node->nd_next;
8992 NODE **n = &node, *n1 = node;
8994 *n = n1 = n1->nd_body;
9008 #define subnodes(n1, n2) \
9009 ((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
9010 (!node->n2) ? (body = &node->n1, 1) : \
9011 (reduce_nodes(&node->n1), body = &node->n2, 1))
9021 *body = node = node->nd_stts;
9025 *body = node = node->nd_body;
9029 body = &node->nd_end->nd_head;
9035 body = &node->nd_body;
9044 if (node->nd_else) {
9045 body = &node->nd_resq;
9063 if (!node)
return 1;
9066 if (!(node = node->nd_head))
break;
9070 }
while ((node = node->nd_next) != 0);
9089 yyerror(
"multiple assignment in conditional");
9103 if (!node->nd_value)
return 1;
9106 parser_warn(node->nd_value,
"found = in conditional, should be ==");
9128 for (node = *rootnode; node; node = next) {
9132 next = node->nd_next;
9133 head = node->nd_head;
9136 switch (type =
nd_type(head)) {
9139 val =
rb_range_new(head->nd_beg->nd_lit, head->nd_end->nd_lit,
9159 if (node == 0)
return 0;
9167 return cond0(parser, node);
9173 if (!node)
return 1;
9194 if (node == 0)
return 0;
9201 rb_warn0(
"string literal in condition");
9211 node->nd_1st =
cond0(parser, node->nd_1st);
9212 node->nd_2nd =
cond0(parser, node->nd_2nd);
9217 node->nd_beg =
range_op(parser, node->nd_beg);
9218 node->nd_end =
range_op(parser, node->nd_end);
9251 if (node == 0)
return 0;
9252 return cond0(parser, node);
9260 NODE *node = left, *second;
9261 while ((second = node->nd_2nd) != 0 && (
enum node_type)
nd_type(second) == type) {
9264 node->nd_2nd =
NEW_NODE(type, second, right, 0);
9267 return NEW_NODE(type, left, right, 0);
9284 if (node->nd_next == 0) {
9285 node = node->nd_head;
9306 switch (
TYPE(node->nd_lit)) {
9335 node2->nd_head = node1;
9349 args->
pre_init = m ? m->nd_next : 0;
9422 ID vid = lhs->nd_vid;
9424 lhs->nd_value = rhs;
9431 lhs->nd_value = rhs;
9485 return dispatch3(opassign, lhs, op, rhs);
9491 VALUE recv = dispatch3(field, lhs, type, attr);
9492 return dispatch3(opassign, recv, op, rhs);
9502 if (!local->
used)
return;
9506 if (cnt != local->
vars->
pos) {
9507 rb_bug(
"local->used->pos != local->vars->pos");
9509 for (i = 0; i <
cnt; ++
i) {
9510 if (!v[i] || (u[i] &
LVAR_USED))
continue;
9525 local->
used = !(inherit_dvars &&
9556 for (i = 0; i <
cnt; i++) {
9557 buf[
i] = src->
tbl[
i];
9570 if (cnt <= 0)
return 0;
9608 if (used) used = used->
prev;
9624 static const struct vtable *
9640 if ((tmp =
lvtbl->used) != 0) {
9656 while (
lvtbl->args != lvargs) {
9694 if (used) used = used->
prev;
9747 "regexp encoding option '%c' differs from source encoding '%s'",
9776 int back_num,
int *back_refs,
OnigRegex regex,
void *arg0)
9781 long len = name_end -
name;
9782 const char *s = (
const char *)name;
9799 rb_warningS(
"named capture conflicts a local variable - %s",
9882 if (!node)
return node;
9886 node = node->nd_body;
9890 node = node->nd_body;
9897 prelude->nd_body = node;
9898 scope->nd_body = prelude;
9901 scope->nd_body = node;
9914 if (!node)
return node;
9918 node = node->nd_body;
9922 node = node->nd_body;
9938 prelude->nd_body = node;
9939 scope->nd_body = prelude;
9942 scope->nd_body = node;
9948 static const struct {
9973 #define op_tbl_count numberof(op_tbl)
9975 #ifndef ENABLE_SELECTOR_NAMESPACE
9976 #define ENABLE_SELECTOR_NAMESPACE 0
9983 #if ENABLE_SELECTOR_NAMESPACE
9995 #if ENABLE_SELECTOR_NAMESPACE
10002 ivar2_cmp(
struct ivar2_key *key1,
struct ivar2_key *key2)
10004 if (key1->id == key2->id && key1->klass == key2->klass) {
10011 ivar2_hash(
struct ivar2_key *
key)
10013 return (key->id << 8) ^ (key->klass >> 2);
10027 #if ENABLE_SELECTOR_NAMESPACE
10035 (void)lex_state_name(-1);
10064 if (m >= e)
return 0;
10068 else if (*m ==
'-') {
10082 return m == e ? mb + 1 : 0;
10097 #define IDSET_ATTRSET_FOR_SYNTAX ((1U<<ID_LOCAL)|(1U<<ID_CONST))
10098 #define IDSET_ATTRSET_FOR_INTERN (~(~0U<<(1<<ID_SCOPE_SHIFT)) & ~(1U<<ID_ATTRSET))
10103 const char *m =
name;
10104 const char *e = m + len;
10107 if (!m || len <= 0)
return -1;
10127 case '<': ++m;
break;
10128 case '=':
if (*++m ==
'>') ++m;
break;
10135 case '>':
case '=': ++m;
break;
10141 case '~': ++m;
break;
10142 case '=':
if (*++m ==
'=') ++m;
break;
10143 default:
return -1;
10148 if (*++m ==
'*') ++m;
10151 case '+':
case '-':
10152 if (*++m ==
'@') ++m;
10155 case '|':
case '^':
case '&':
case '/':
case '%':
case '~':
case '`':
10160 if (*++m !=
']')
return -1;
10161 if (*++m ==
'=') ++m;
10165 if (len == 1)
return ID_JUNK;
10167 case '=':
case '~': ++m;
break;
10168 default:
return -1;
10180 case '!':
case '?':
10184 if (m + 1 < e || *m !=
'=')
break;
10187 if (!(allowed_atttset & (1
U << type)))
return -1;
10194 return m == e ? type : -1;
10257 fake_str.as.heap.len =
len;
10258 fake_str.as.heap.ptr = (
char *)name;
10259 fake_str.as.heap.aux.capa =
len;
10260 str = (
VALUE)&fake_str;
10274 const char *
name, *m, *e;
10296 if (len < 2)
goto junk;
10305 if (len < 3)
goto junk;
10310 if (len < 2)
goto junk;
10326 if (*
op_tbl[i].name == *m &&
10327 strcmp(
op_tbl[i].name, m) == 0) {
10335 if (name[last] ==
'=') {
10337 if (last > 1 && name[last-1] ==
'=')
10347 else if (
id == 0) {
10419 name[0] = (char)
id;
10428 if (
op_tbl[i].token ==
id) {
10442 if (
RBASIC(str)->klass == 0)
10448 ID id_stem = (
id & ~ID_SCOPE_MASK);
10465 if (
RBASIC(str)->klass == 0)
10478 if (!str)
return 0;
10572 VALUE name = *namep;
10601 fake_str.as.heap.aux.capa = fake_str.as.heap.len;
10622 fake_str.as.heap.len =
len;
10623 fake_str.as.heap.ptr = (
char *)ptr;
10624 fake_str.as.heap.aux.capa =
len;
10633 fake_str.as.heap.len = len - 1;
10731 parser->parser_ruby_sourcefile_string =
Qnil;
10732 parser->delayed =
Qnil;
10734 parser->result =
Qnil;
10735 parser->parsing_thread =
Qnil;
10736 parser->toplevel_p =
TRUE;
10745 #define parser_mark ripper_parser_mark
10746 #define parser_free ripper_parser_free
10764 rb_gc_mark(p->parser_ruby_sourcefile_string);
10786 prev = local->
prev;
10800 size_t size =
sizeof(*p);
10802 if (!ptr)
return 0;
10805 size +=
sizeof(*local);
10830 #undef rb_reserved_word
10919 #define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
10920 #define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0)
10921 #define ADD2HEAP(n, c, p) ((parser->heap = (n))->u1.node = (p), \
10922 (n)->u3.cnt = (c), (p))
10927 size_t cnt =
HEAPCNT(1, size);
10937 size_t cnt =
HEAPCNT(nelem, size);
10939 void *ptr =
xcalloc(nelem, size);
10948 size_t cnt =
HEAPCNT(1, size);
10950 if (ptr && (n = parser->
heap) !=
NULL) {
10952 if (n->
u1.
node == ptr) {
10969 while ((n = *prev) !=
NULL) {
10970 if (n->
u1.
node == ptr) {
10983 #ifdef RIPPER_DEBUG
10984 extern int rb_is_pointer_to_heap(
VALUE);
10990 if (x ==
Qfalse)
return x;
10991 if (x ==
Qtrue)
return x;
10992 if (x ==
Qnil)
return x;
10997 if (!rb_is_pointer_to_heap(x))
11010 return ((
NODE *)x)->nd_rval;
11019 #define validate(x) ((x) = get_value(x))
11031 return rb_funcall(parser->value, mid, 1, a);
11039 return rb_funcall(parser->value, mid, 2, a, b);
11048 return rb_funcall(parser->value, mid, 3, a, b, c);
11058 return rb_funcall(parser->value, mid, 4, a, b, c, d);
11069 return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
11082 return rb_funcall(parser->value, mid, 7, a, b, c, d, e, f, g);
11085 static const struct kw_assoc {
11088 } keyword_to_name[] = {
11141 keyword_id_to_str(
ID id)
11143 const struct kw_assoc *a;
11145 for (a = keyword_to_name; a->id; a++) {
11152 #undef ripper_id2sym
11154 ripper_id2sym(
ID id)
11164 if ((name = keyword_id_to_str(
id))) {
11177 rb_bug(
"cannot convert ID to string: %ld", (
unsigned long)
id);
11185 ripper_get_id(
VALUE v)
11195 ripper_get_value(
VALUE v)
11202 return nd->nd_rval;
11206 ripper_compile_error(
struct parser_params *parser,
const char *fmt, ...)
11211 va_start(args, fmt);
11218 ripper_warn0(
struct parser_params *parser,
const char *fmt)
11224 ripper_warnI(
struct parser_params *parser,
const char *fmt,
int a)
11231 ripper_warnS(
struct parser_params *parser,
const char *fmt,
const char *str)
11238 ripper_warning0(
struct parser_params *parser,
const char *fmt)
11244 ripper_warningS(
struct parser_params *parser,
const char *fmt,
const char *str)
11257 ripper_s_allocate(
VALUE klass)
11269 #define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
11285 VALUE src, fname, lineno;
11288 rb_scan_args(argc, argv,
"12", &src, &fname, &lineno);
11298 if (
NIL_P(fname)) {
11306 parser->parser_ruby_sourcefile_string = fname;
11313 struct ripper_args {
11320 ripper_parse0(
VALUE parser_v)
11326 ripper_yyparse((
void*)parser);
11327 return parser->result;
11331 ripper_ensure(
VALUE parser_v)
11336 parser->parsing_thread =
Qnil;
11347 ripper_parse(
VALUE self)
11352 if (!ripper_initialized_p(parser)) {
11355 if (!
NIL_P(parser->parsing_thread)) {
11362 rb_ensure(ripper_parse0,
self, ripper_ensure,
self);
11364 return parser->result;
11375 ripper_column(
VALUE self)
11381 if (!ripper_initialized_p(parser)) {
11384 if (
NIL_P(parser->parsing_thread))
return Qnil;
11396 ripper_filename(
VALUE self)
11401 if (!ripper_initialized_p(parser)) {
11404 return parser->parser_ruby_sourcefile_string;
11415 ripper_lineno(
VALUE self)
11420 if (!ripper_initialized_p(parser)) {
11423 if (
NIL_P(parser->parsing_thread))
return Qnil;
11427 #ifdef RIPPER_DEBUG
11463 InitVM_ripper(
void)
11479 #ifdef RIPPER_DEBUG
static const struct @60 op_tbl[]
#define rb_enc_islower(c, enc)
char * parser_ruby_sourcefile
#define RB_TYPE_P(obj, type)
#define NEW_ARGSCAT(a, b)
VALUE rb_const_get_at(VALUE, ID)
int rb_enc_symname_p(const char *, rb_encoding *)
VALUE rb_ary_new3(long,...)
struct local_vars * parser_lvtbl
static ID ripper_token2eventid(int tok)
const struct kwtable * rb_reserved_word(const char *, unsigned int)
int rb_is_attrset_name(VALUE name)
static NODE * remove_begin(NODE *)
static NODE * reg_named_capture_assign_gen(struct parser_params *parser, VALUE regexp, NODE *match)
static struct parser_params * parser_new(void)
int onig_foreach_name(regex_t *reg, int(*func)(const UChar *, const UChar *, int, int *, regex_t *, void *), void *arg)
st_table * st_init_table_with_size(const struct st_hash_type *, st_index_t)
#define NEW_IASGN(v, val)
VALUE rb_get_coverages(void)
static NODE * newline_node(NODE *)
void rb_bug(const char *fmt,...)
#define NEW_DASGN_CURR(v, val)
static const struct kwtable * reserved_word(const char *, unsigned int)
void rb_mark_tbl(struct st_table *)
static int comment_at_top(struct parser_params *parser)
size_t strlen(const char *)
static size_t parser_memsize(const void *ptr)
VALUE parser_lex_nextline
static NODE * logop_gen(struct parser_params *, enum node_type, NODE *, NODE *)
static NODE * new_yield_gen(struct parser_params *, NODE *)
#define scan_oct(s, l, e)
const char * rb_obj_classname(VALUE)
int parser_ruby__end__seen
static NODE * gettable_gen(struct parser_params *, ID)
#define logop(type, node1, node2)
static NODE * match_op_gen(struct parser_params *, NODE *, NODE *)
#define NEW_CALL(r, m, a)
int st_lookup(st_table *, st_data_t, st_data_t *)
void st_add_direct(st_table *, st_data_t, st_data_t)
void rb_enc_copy(VALUE dst, VALUE src)
VALUE rb_str_buf_append(VALUE, VALUE)
static ID shadowing_lvar_gen(struct parser_params *, ID)
static int parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp, int string_literal, int symbol_literal, int regexp_literal)
int parser_compile_for_eval
int parser_token_info_enabled
#define token_info_pop(token)
#define NEW_OP_CDECL(v, op, val)
#define IS_lex_state_for(x, ls)
#define rb_node_newnode(type, a1, a2, a3)
static void parser_heredoc_restore(struct parser_params *parser, NODE *here)
#define rb_usascii_str_new2
void rb_define_global_const(const char *, VALUE)
void rb_gc_force_recycle(VALUE)
static NODE * new_args_gen(struct parser_params *, NODE *, NODE *, ID, NODE *, NODE *)
static int dvar_defined_gen(struct parser_params *, ID, int)
static ID internal_id_gen(struct parser_params *)
static struct symbols global_symbols
rb_encoding * rb_filesystem_encoding(void)
static int literal_concat0(struct parser_params *, VALUE, VALUE)
VALUE rb_cstr_to_inum(const char *, int, int)
#define reg_named_capture_assign(regexp, match)
stack_type parser_cmdarg_stack
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
static void rb_backref_error_gen(struct parser_params *, NODE *)
#define assignable(id, node)
static NODE * block_append_gen(struct parser_params *, NODE *, NODE *)
#define IDSET_ATTRSET_FOR_SYNTAX
static VALUE debug_lines(const char *f)
#define rb_enc_isalnum(c, enc)
static int parser_here_document(struct parser_params *, NODE *)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
long(* rb_magic_comment_length_t)(struct parser_params *parser, const char *name, long len)
#define rb_enc_prev_char(s, p, e, enc)
static int reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg0)
static void warn_unused_var(struct parser_params *parser, struct local_vars *local)
#define NEW_MATCH2(n1, n2)
VALUE op_sym[tLAST_OP_ID]
VALUE rb_reg_compile(VALUE str, int options, const char *sourcefile, int sourceline)
static NODE * arg_blk_pass(NODE *, NODE *)
VALUE rb_enc_str_new(const char *, long, rb_encoding *)
VALUE rb_sym_all_symbols(void)
void * rb_parser_realloc(struct parser_params *, void *, size_t)
#define set_yylval_str(x)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
static void ripper_init_eventids1_table(VALUE self)
void rb_raise(VALUE exc, const char *fmt,...)
static NODE * assignable_gen(struct parser_params *, ID, NODE *)
void rb_compile_warn(const char *file, int line, const char *fmt,...)
static NODE * range_op(struct parser_params *parser, NODE *node)
rb_encoding * rb_enc_compatible(VALUE, VALUE)
static NODE * new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID attr, ID op, NODE *rhs)
primary_value operation2 command_args prec tLOWEST
static void parser_pushback(struct parser_params *parser, int c)
struct token_info token_info
static void block_dup_check_gen(struct parser_params *, NODE *, NODE *)
static int parser_yyerror(struct parser_params *, const char *)
#define parser_encoding_name()
void(* rb_magic_comment_setter_t)(struct parser_params *parser, const char *name, const char *val)
#define is_asgn_or_id(id)
static VALUE reg_compile_gen(struct parser_params *, VALUE, int)
#define NEW_CVASGN(v, val)
VALUE rb_make_exception(int, VALUE *)
static int parser_whole_match_p(struct parser_params *parser, const char *eos, long len, int indent)
#define NEW_OP_ASGN_OR(i, val)
static void parser_initialize(struct parser_params *parser)
NODE * rb_parser_compile_file(volatile VALUE, const char *, VALUE, int)
#define ENCODING_IS_ASCII8BIT(obj)
static VALUE parse(int argc, VALUE *argv, VALUE self)
static void local_pop_gen(struct parser_params *)
#define STR_NEW3(p, n, e, func)
static NODE * yycompile(struct parser_params *parser, const char *f, int line)
static ID * vtable_tblcpy(ID *buf, const struct vtable *src)
#define whole_match_p(e, l, i)
static long parser_encode_length(struct parser_params *parser, const char *name, long len)
#define is_identchar(p, e, enc)
static NODE * call_bin_op_gen(struct parser_params *, NODE *, ID, NODE *)
#define rb_enc_isdigit(c, enc)
#define parser_warn(node, mesg)
static enum node_type nodetype(NODE *node)
ID rb_intern_str(VALUE str)
#define ENC_CODERANGE_BROKEN
static VALUE lex_getline(struct parser_params *parser)
VALUE rb_str_append(VALUE, VALUE)
#define RUBY_DTRACE_PARSE_BEGIN(arg0, arg1)
#define NEW_CLASS(n, b, s)
void * rb_parser_malloc(struct parser_params *, size_t)
#define reg_fragment_setenc(str, options)
#define node_assign(node1, node2)
static int local_var_gen(struct parser_params *, ID)
#define dvar_defined_get(id)
#define NEW_PRELUDE(p, b)
VALUE rb_enc_from_encoding(rb_encoding *enc)
#define ENCODING_GET(obj)
#define dispatch_heredoc_end()
static int dvar_curr_gen(struct parser_params *, ID)
NODE * parser_deferred_nodes
static int simple_re_meta(int c)
void rb_name_error(ID id, const char *fmt,...)
static int e_option_supplied(struct parser_params *parser)
#define nd_set_type(n, t)
static int assign_in_cond(struct parser_params *parser, NODE *node)
#define MEMZERO(p, type, n)
void rb_exc_raise(VALUE mesg)
#define NEW_UNLESS(c, t, e)
static NODE * node_assign_gen(struct parser_params *, NODE *, NODE *)
VALUE rb_usascii_str_new(const char *, long)
static rb_encoding * must_be_ascii_compatible(VALUE s)
#define parser_is_identchar()
#define block_dup_check(n1, n2)
#define RUBY_DTRACE_PARSE_END(arg0, arg1)
static void local_push_gen(struct parser_params *, int)
static void new_bv_gen(struct parser_params *, ID)
static ID register_symid(ID, const char *, long, rb_encoding *)
static int parser_tokadd_string(struct parser_params *, int, int, int, long *, rb_encoding **)
#define NEW_OP_ASGN_AND(i, val)
static int parser_regx_options(struct parser_params *)
#define reg_fragment_check(str, options)
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
enum lex_state_e parser_lex_state
#define IS_LABEL_POSSIBLE()
VALUE parser_lex_lastline
#define lex_goto_eol(parser)
void * rb_parser_calloc(struct parser_params *, size_t, size_t)
VALUE rb_parser_new(void)
static ID * local_tbl_gen(struct parser_params *)
static int parser_yylex(struct parser_params *parser)
int rb_ascii8bit_encindex(void)
static VALUE parser_str_new(const char *p, long n, rb_encoding *enc, int func, rb_encoding *enc0)
VALUE rb_parser_set_yydebug(VALUE, VALUE)
#define scan_hex(s, l, e)
void rb_parser_free(struct parser_params *, void *)
static NODE * aryset_gen(struct parser_params *, NODE *, NODE *)
int rb_char_to_option_kcode(int c, int *option, int *kcode)
static char * parser_tokspace(struct parser_params *parser, int n)
VALUE rb_enc_associate(VALUE, rb_encoding *)
#define TypedData_Get_Struct(obj, type, data_type, sval)
void rb_compile_error_append(const char *fmt,...)
static void parser_free(void *ptr)
int rb_enc_find_index(const char *name)
#define StringValuePtr(v)
static NODE * dsym_node_gen(struct parser_params *, NODE *)
#define block_append(h, t)
static int symbols_i(VALUE sym, ID value, VALUE ary)
const rb_data_type_t * parent
#define NEW_RESCUE(b, res, e)
static int parser_tokadd_escape(struct parser_params *parser, rb_encoding **encp)
static void vtable_free(struct vtable *tbl)
VALUE rb_parser_get_yydebug(VALUE)
static void void_expr_gen(struct parser_params *, NODE *)
struct parser_params * parser
#define NEW_NODE(t, a0, a1, a2)
#define NEW_ENSURE(b, en)
RUBY_EXTERN VALUE rb_mKernel
char * ruby_strdup(const char *)
static struct vtable * vtable_alloc(struct vtable *prev)
void rb_set_errinfo(VALUE)
static int is_global_name_punct(const char c)
#define attrset(node, id)
static char * parser_newtok(struct parser_params *parser)
void rb_define_const(VALUE, const char *, VALUE)
#define mixed_escape(beg, enc1, enc2)
#define NEW_WHEN(c, t, e)
top_stmt escape_Qundef($1)
#define aryset(node1, node2)
#define IS_AFTER_OPERATOR()
VALUE rb_define_class(const char *, VALUE)
Defines a top-level class.
#define assignable_result(x)
static void parser_set_token_info(struct parser_params *parser, const char *name, const char *val)
#define parser_warning(node, mesg)
static void parser_tokadd(struct parser_params *parser, int c)
ID rb_intern3(const char *, long, rb_encoding *)
int rb_symname_p(const char *)
static void parser_mark(void *ptr)
rb_atomic_t cnt[RUBY_NSIG]
#define MBCLEN_CHARFOUND_P(ret)
static void dyna_pop_gen(struct parser_params *, const struct vtable *)
#define set_yylval_literal(x)
#define new_args_tail(k, kr, b)
#define nd_set_line(n, l)
static void ripper_init_eventids1(void)
#define parser_precise_mbclen()
char ary[RSTRING_EMBED_LEN_MAX+1]
static NODE * parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int line)
#define list_concat(h, t)
#define NEW_ARGS_AUX(r, b)
#define TypedData_Wrap_Struct(klass, data_type, sval)
static VALUE coverage(const char *f, int n)
#define rb_warningS(fmt, a)
static VALUE lex_get_str(struct parser_params *parser, VALUE s)
static int rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_atttset)
#define RUBY_FUNC_EXPORTED
#define literal_concat(h, t)
VALUE rb_suppress_tracing(VALUE(*func)(VALUE), VALUE arg)
static int parser_nextc(struct parser_params *parser)
const char * parser_lex_pend
#define ALLOCA_N(type, n)
#define ENC_CODERANGE_UNKNOWN
static ID intern_str(VALUE str)
token_info * parser_token_info
#define tokaddmbc(c, enc)
static void magic_comment_encoding(struct parser_params *parser, const char *name, const char *val)
#define set_yylval_name(x)
VALUE rb_str_buf_cat(VALUE, const char *, long)
static int parser_peek_variable_name(struct parser_params *parser)
static void fixpos(NODE *, NODE *)
static NODE * splat_array(NODE *)
#define NEW_LASGN(v, val)
static VALUE yycompile0(VALUE arg)
VALUE rb_obj_as_string(VALUE)
int rb_is_global_name(VALUE name)
#define NEW_OPT_ARG(i, v)
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
#define heredoc_identifier()
static int value_expr_gen(struct parser_params *, NODE *)
static void dispose_string(VALUE str)
VALUE rb_str_resize(VALUE, long)
VALUE rb_parser_encoding(VALUE)
int st_foreach(st_table *, int(*)(ANYARGS), st_data_t)
#define RUBY_DTRACE_PARSE_END_ENABLED()
rb_encoding * rb_enc_get(VALUE)
static NODE * call_uni_op_gen(struct parser_params *, NODE *, ID)
#define new_const_op_assign(lhs, op, rhs)
static int reg_fragment_check_gen(struct parser_params *, VALUE, int)
SSL_METHOD *(* func)(void)
VALUE rb_thread_current(void)
mlhs_head tSTAR mlhs_node
NODE * rb_compile_string(const char *, VALUE, int)
VALUE rb_range_new(VALUE, VALUE, int)
VALUE rb_sprintf(const char *format,...)
NODE * rb_parser_compile_cstr(volatile VALUE, const char *, const char *, int, int)
#define rb_enc_mbcput(c, buf, enc)
static void vtable_add(struct vtable *tbl, ID id)
keyword_super command_args
static void set_file_encoding(struct parser_params *parser, const char *str, const char *send)
#define NEW_DASGN(v, val)
#define NEW_POSTARG(i, v)
static int arg_var_gen(struct parser_params *, ID)
#define CONST_ID(var, str)
#define str_copy(_s, _p, _n)
static const struct magic_comment magic_comments[]
static int parser_parse_string(struct parser_params *, NODE *)
VALUE rb_parser_end_seen_p(VALUE)
#define tokadd_string(f, t, p, n, e)
rb_encoding * rb_utf8_encoding(void)
int rb_scan_args(int, const VALUE *, const char *,...)
VALUE rb_ary_push(VALUE, VALUE)
static NODE * new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs)
unsigned char buf[MIME_BUF_SIZE]
#define RE_OPTION_ENCODING_IDX(o)
static void Init_id(void)
#define new_args(f, o, r, p, t)
NODE * rb_parser_append_print(VALUE, NODE *)
void rb_gc_mark_symbols(void)
static void arg_ambiguous_gen(struct parser_params *parser)
static void parser_prepare(struct parser_params *parser)
#define reg_compile(str, options)
#define token_info_push(token)
static const struct vtable * dyna_push_gen(struct parser_params *)
int rb_is_local_name(VALUE name)
static int options(unsigned char *cp)
#define NEW_UNTIL(c, b, n)
ID rb_intern2(const char *, long)
#define NEW_MATCH3(r, n2)
VALUE rb_enc_associate_index(VALUE, int)
VALUE rb_str_buf_new(long)
stack_type parser_cond_stack
static void reduce_nodes_gen(struct parser_params *, NODE **)
#define set_yylval_num(x)
static void ripper_init_eventids2(void)
int rb_const_defined_at(VALUE, ID)
static void dyna_pop_1(struct parser_params *parser)
static int parser_read_escape(struct parser_params *parser, int flags, rb_encoding **encp)
static int parser_heredoc_identifier(struct parser_params *parser)
const char * rb_id2name(ID)
int rb_is_instance_id(ID)
ID rb_check_id(volatile VALUE *)
Returns ID for the given name if it is interned already, or 0.
#define new_attr_op_assign(lhs, type, attr, op, rhs)
static NODE * ret_args_gen(struct parser_params *, NODE *)
VALUE rb_attr_get(VALUE, ID)
#define rb_enc_ispunct(c, enc)
#define NEW_RESBODY(a, ex, n)
static void reg_fragment_setenc_gen(struct parser_params *, VALUE, int)
#define rb_warn4S(file, line, fmt, a)
VALUE rb_reg_check_preprocess(VALUE)
expr ripper_intern("and")
static int is_static_content(NODE *node)
static void void_stmts_gen(struct parser_params *, NODE *)
RUBY_EXTERN VALUE rb_cString
#define RUBY_DTRACE_PARSE_BEGIN_ENABLED()
mlhs_head tSTAR mlhs_post
static NODE * negate_lit(NODE *)
VALUE rb_vsprintf(const char *, va_list)
static int local_id_gen(struct parser_params *, ID)
#define MEMCPY(p1, p2, type, n)
#define new_op_assign(lhs, op, rhs)
mlhs_node keyword_variable
block_command cmd_brace_block
RUBY_EXTERN VALUE rb_eRuntimeError
static NODE * new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs)
static int lvar_defined_gen(struct parser_params *, ID)
#define NEW_GASGN(v, val)
static void warning_unless_e_option(struct parser_params *parser, NODE *node, const char *str)
#define NEW_ARGSPUSH(a, b)
#define heredoc_restore(n)
static void parser_tokaddmbc(struct parser_params *parser, int c, rb_encoding *enc)
RUBY_EXTERN VALUE rb_eTypeError
static NODE * literal_concat_gen(struct parser_params *, NODE *, NODE *)
VALUE rb_ensure(VALUE(*)(ANYARGS), VALUE, VALUE(*)(ANYARGS), VALUE)
VALUE rb_str_cat(VALUE, const char *, long)
#define ENC_CODERANGE_7BIT
#define NEW_WHILE(c, b, n)
#define NEW_DEFS(r, i, a, d)
static int is_private_local_id(ID name)
static void fixup_nodes(NODE **)
static void no_blockarg(struct parser_params *parser, NODE *node)
static NODE * cond_gen(struct parser_params *, NODE *)
RUBY_EXTERN VALUE rb_eEncodingError
#define warn_balanced(op, syn)
#define match_op(node1, node2)
static NODE * arg_concat_gen(struct parser_params *, NODE *, NODE *)
rb_encoding * rb_enc_from_index(int idx)
#define call_uni_op(recv, id)
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
#define rb_enc_isspace(c, enc)
NODE * parser_lex_strterm
#define RE_OPTION_ENCODING_NONE(o)
NODE * rb_parser_compile_string(volatile VALUE, const char *, VALUE, int)
top_stmts dispatch0(stmts_new)
void rb_gc_mark_locations(VALUE *, VALUE *)
#define NEW_ATTRASGN(r, m, a)
static int token_info_get_column(struct parser_params *parser, const char *token)
static const struct st_hash_type symhash
#define formal_argument(id)
static NODE * list_append_gen(struct parser_params *, NODE *, NODE *)
static int token_info_has_nonspaces(struct parser_params *parser, const char *token)
st_index_t rb_str_hash(VALUE)
#define NEW_OP_ASGN2(r, i, o, val)
static const rb_data_type_t parser_data_type
void rb_compile_warning(const char *file, int line, const char *fmt,...)
RUBY_EXTERN VALUE rb_cObject
static NODE * node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE)
#define SPECIAL_PUNCT(idx)
static VALUE lex_io_gets(struct parser_params *parser, VALUE io)
static NODE * arg_append_gen(struct parser_params *, NODE *, NODE *)
VALUE rb_ary_unshift(VALUE, VALUE)
int rb_enc_symname2_p(const char *, long, rb_encoding *)
struct rb_encoding_entry * list
int rb_is_const_name(VALUE name)
#define STRNCASECMP(s1, s2, n)
VALUE rb_make_backtrace(void)
NODE * rb_compile_file(const char *, VALUE, int)
#define RE_OPTION_ENCODING(e)
rb_encoding * rb_usascii_encoding(void)
#define rb_backref_error(n)
int rb_is_method_name(VALUE name)
void rb_gc_mark_parser(void)
#define shadowing_lvar(name)
NODE * rb_parser_while_loop(VALUE, NODE *, int, int)
#define ADD2HEAP(n, c, p)
static const char * magic_comment_marker(const char *str, long len)
NODE * rb_compile_cstr(const char *, const char *, int, int)
#define NEW_OP_ASGN1(p, id, a)
static NODE * list_concat_gen(struct parser_params *, NODE *, NODE *)
static unsigned int hash(const char *str, unsigned int len)
static int parser_magic_comment(struct parser_params *parser, const char *str, long len)
#define is_instance_id(id)
#define call_bin_op(recv, id, arg1)
#define read_escape(flags, e)
static const char id_type_names[][9]
VALUE rb_str_new(const char *, long)
const char * parser_lex_pbeg
int rb_parse_in_main(void)
VALUE rb_assoc_new(VALUE, VALUE)
static void parser_set_encode(struct parser_params *parser, const char *name)
#define NEW_CDECL(v, val, path)
static int dyna_in_block_gen(struct parser_params *)
static int literal_node(NODE *node)
const char * parser_lex_p
static int parser_tok_hex(struct parser_params *parser, size_t *numlen)
#define rb_enc_asciicompat(enc)
static NODE * attrset_gen(struct parser_params *, NODE *, ID)
int parser_ruby_sourceline
rb_encoding * rb_ascii8bit_encoding(void)
#define rb_enc_isupper(c, enc)
static int nodeline(NODE *node)
static NODE * evstr2dstr_gen(struct parser_params *, NODE *)
#define list_append(l, i)
#define rb_enc_isascii(c, enc)
int rb_str_hash_cmp(VALUE, VALUE)
static NODE * cond0(struct parser_params *, NODE *)
static int vtable_size(const struct vtable *tbl)
RUBY_EXTERN VALUE rb_cArray
static NODE * new_evstr_gen(struct parser_params *, NODE *)
RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e-0x20+31)/32]
int rb_parse_in_eval(void)
#define RSTRING_GETMEM(str, ptrvar, lenvar)
static NODE * new_args_tail_gen(struct parser_params *, NODE *, ID, ID)
#define is_attrset_id(id)
#define IDSET_ATTRSET_FOR_INTERN
expr expr keyword_or expr
#define NEW_DEFN(i, a, d, p)
st_table * st_init_numtable_with_size(st_index_t)
#define ENCODING_SET(obj, i)
int rb_memcicmp(const void *, const void *, long)
static int is_special_global_name(const char *m, const char *e, rb_encoding *enc)
VALUE(* parser_lex_gets)(struct parser_params *, VALUE)
#define IS_LABEL_SUFFIX(n)
#define rb_enc_isalpha(c, enc)
static int rb_str_symname_type(VALUE name, unsigned int allowed_atttset)
VALUE rb_check_string_type(VALUE)
#define REALLOC_N(var, type, n)
#define NEW_STRTERM(func, term, paren)
#define set_yylval_node(x)
int rb_enc_str_coderange(VALUE)
NODE * parser_eval_tree_begin
static int match(VALUE str, VALUE pat, VALUE hash, int(*cb)(VALUE, VALUE))
void rb_define_method(VALUE, const char *, VALUE(*)(ANYARGS), int)
#define flush_string_content(enc)
static void warn_unless_e_option(struct parser_params *parser, NODE *node, const char *str)
int rb_is_instance_name(VALUE name)
#define ruby_eval_tree_begin
int rb_is_class_name(VALUE name)
static ID formal_argument_gen(struct parser_params *, ID)
#define RTYPEDDATA_TYPE(v)
unsigned long ruby_scan_oct(const char *, size_t, size_t *)
int rb_is_junk_name(VALUE name)
static void ripper_init_eventids2_table(VALUE self)
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc)
static int vtable_included(const struct vtable *tbl, ID id)
static int sym_check_asciionly(VALUE str)
#define mixed_error(enc1, enc2)
RUBY_EXTERN VALUE rb_eArgError
#define NEW_BLOCK_PASS(b)
static ID register_symid_str(ID, VALUE)
static int parser_tokadd_mbchar(struct parser_params *parser, int c)
int rb_enc_codelen(int code, rb_encoding *enc)