15 #define PARSER_DEBUG 0
18 #define YYERROR_VERBOSE 1
19 #define YYSTACK_USE_ALLOCA 0
34 #define YYMALLOC(size) rb_parser_malloc(parser, (size))
35 #define YYREALLOC(ptr, size) rb_parser_realloc(parser, (ptr), (size))
36 #define YYCALLOC(nelem, size) rb_parser_calloc(parser, (nelem), (size))
37 #define YYFREE(ptr) rb_parser_free(parser, (ptr))
38 #define malloc YYMALLOC
39 #define realloc YYREALLOC
40 #define calloc YYCALLOC
46 #define REGISTER_SYMID(id, name) register_symid((id), (name), strlen(name), enc)
50 #define is_notop_id(id) ((id)>tLAST_OP_ID)
51 #define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
52 #define is_global_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL)
53 #define is_instance_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE)
54 #define is_attrset_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET)
55 #define is_const_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST)
56 #define is_class_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS)
57 #define is_junk_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_JUNK)
58 #define id_type(id) (is_notop_id(id) ? (int)((id)&ID_SCOPE_MASK) : -1)
60 #define is_asgn_or_id(id) ((is_notop_id(id)) && \
61 (((id)&ID_SCOPE_MASK) == ID_GLOBAL || \
62 ((id)&ID_SCOPE_MASK) == ID_INSTANCE || \
63 ((id)&ID_SCOPE_MASK) == ID_CLASS))
82 #define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
95 EXPR_BEG_ANY = (EXPR_BEG | EXPR_VALUE | EXPR_MID | EXPR_CLASS | EXPR_LABELARG),
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++) {
303 #define STR_NEW(p,n) rb_enc_str_new((p),(n),current_enc)
304 #define STR_NEW0() rb_enc_str_new(0,0,current_enc)
305 #define STR_NEW2(p) rb_enc_str_new((p),strlen(p),current_enc)
306 #define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),current_enc)
307 #define ENC_SINGLE(cr) ((cr)==ENC_CODERANGE_7BIT)
308 #define TOK_INTERN(mb) rb_intern3(tok(), toklen(), current_enc)
311 #define yyerror(msg) parser_yyerror(parser, (msg))
313 #define lex_strterm (parser->parser_lex_strterm)
314 #define lex_state (parser->parser_lex_state)
315 #define cond_stack (parser->parser_cond_stack)
316 #define cmdarg_stack (parser->parser_cmdarg_stack)
317 #define class_nest (parser->parser_class_nest)
318 #define paren_nest (parser->parser_paren_nest)
319 #define lpar_beg (parser->parser_lpar_beg)
320 #define brace_nest (parser->parser_brace_nest)
321 #define in_single (parser->parser_in_single)
322 #define in_def (parser->parser_in_def)
323 #define compile_for_eval (parser->parser_compile_for_eval)
324 #define cur_mid (parser->parser_cur_mid)
325 #define in_defined (parser->parser_in_defined)
326 #define tokenbuf (parser->parser_tokenbuf)
327 #define tokidx (parser->parser_tokidx)
328 #define toksiz (parser->parser_toksiz)
329 #define tokline (parser->parser_tokline)
330 #define lex_input (parser->parser_lex_input)
331 #define lex_lastline (parser->parser_lex_lastline)
332 #define lex_nextline (parser->parser_lex_nextline)
333 #define lex_pbeg (parser->parser_lex_pbeg)
334 #define lex_p (parser->parser_lex_p)
335 #define lex_pend (parser->parser_lex_pend)
336 #define heredoc_end (parser->parser_heredoc_end)
337 #define command_start (parser->parser_command_start)
338 #define deferred_nodes (parser->parser_deferred_nodes)
339 #define lex_gets_ptr (parser->parser_lex_gets_ptr)
340 #define lex_gets (parser->parser_lex_gets)
341 #define lvtbl (parser->parser_lvtbl)
342 #define ruby__end__seen (parser->parser_ruby__end__seen)
343 #define ruby_sourceline (parser->parser_ruby_sourceline)
344 #define ruby_sourcefile (parser->parser_ruby_sourcefile)
345 #define ruby_sourcefile_string (parser->parser_ruby_sourcefile_string)
346 #define current_enc (parser->enc)
347 #define yydebug (parser->parser_yydebug)
350 #define ruby_eval_tree (parser->parser_eval_tree)
351 #define ruby_eval_tree_begin (parser->parser_eval_tree_begin)
352 #define ruby_debug_lines (parser->debug_lines)
353 #define ruby_coverage (parser->coverage)
357 static int yylex(
void*,
void*);
359 static int yylex(
void*);
363 #define yyparse ruby_yyparse
366 #define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3))
369 #define cond(node) cond_gen(parser, (node))
371 #define logop(type,node1,node2) logop_gen(parser, (type), (node1), (node2))
380 #define value_expr(node) value_expr_gen(parser, (node) = remove_begin(node))
381 #define void_expr0(node) void_expr_gen(parser, (node))
382 #define void_expr(node) void_expr0((node) = remove_begin(node))
384 #define void_stmts(node) void_stmts_gen(parser, (node))
386 #define reduce_nodes(n) reduce_nodes_gen(parser,(n))
388 #define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2))
391 #define block_append(h,t) block_append_gen(parser,(h),(t))
393 #define list_append(l,i) list_append_gen(parser,(l),(i))
395 #define list_concat(h,t) list_concat_gen(parser,(h),(t))
397 #define arg_append(h,t) arg_append_gen(parser,(h),(t))
399 #define arg_concat(h,t) arg_concat_gen(parser,(h),(t))
401 #define literal_concat(h,t) literal_concat_gen(parser,(h),(t))
404 #define new_evstr(n) new_evstr_gen(parser,(n))
406 #define evstr2dstr(n) evstr2dstr_gen(parser,(n))
410 #define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, (recv),(id),(arg1))
412 #define call_uni_op(recv,id) call_uni_op_gen(parser, (recv),(id))
415 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
417 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
421 #define ret_args(node) ret_args_gen(parser, (node))
424 #define new_yield(node) new_yield_gen(parser, (node))
426 #define dsym_node(node) dsym_node_gen(parser, (node))
429 #define gettable(id) gettable_gen(parser,(id))
431 #define assignable(id,node) assignable_gen(parser, (id), (node))
434 #define aryset(node1,node2) aryset_gen(parser, (node1), (node2))
436 #define attrset(node,id) attrset_gen(parser, (node), (id))
439 #define rb_backref_error(n) rb_backref_error_gen(parser,(n))
441 #define node_assign(node1, node2) node_assign_gen(parser, (node1), (node2))
445 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (attr), (op), (rhs))
447 #define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs))
449 #define new_defined(expr) NEW_DEFINED(remove_begin_all(expr))
452 #define match_op(node1,node2) match_op_gen(parser, (node1), (node2))
455 #define local_tbl() local_tbl_gen(parser)
460 #define reg_compile(str,options) reg_compile_gen(parser, (str), (options))
462 #define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options))
464 #define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options))
466 #define reg_named_capture_assign(regexp,match) reg_named_capture_assign_gen(parser,(regexp),(match))
468 #define get_id(id) (id)
469 #define get_value(val) (val)
471 #define value_expr(node) ((void)(node))
472 #define remove_begin(node) (node)
473 #define rb_dvar_defined(id) 0
474 #define rb_local_defined(id) 0
475 static ID ripper_get_id(
VALUE);
476 #define get_id(id) ripper_get_id(id)
478 #define get_value(val) ripper_get_value(val)
480 #define assignable(lhs,node) assignable_gen(parser, (lhs))
482 #define id_is_var(id) id_is_var_gen(parser, (id))
484 #define node_assign(node1, node2) dispatch2(assign, (node1), (node2))
488 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
492 #define new_op_assign(lhs, op, rhs) new_op_assign_gen(parser, (lhs), (op), (rhs))
495 #define formal_argument(id) formal_argument_gen(parser, (id))
497 #define shadowing_lvar(name) shadowing_lvar_gen(parser, (name))
499 #define new_bv(id) new_bv_gen(parser, (id))
502 #define local_push(top) local_push_gen(parser,(top))
504 #define local_pop() local_pop_gen(parser)
506 #define local_var(id) local_var_gen(parser, (id))
508 #define arg_var(id) arg_var_gen(parser, (id))
510 #define local_id(id) local_id_gen(parser, (id))
512 #define internal_id() internal_id_gen(parser)
515 #define dyna_push() dyna_push_gen(parser)
517 #define dyna_pop(node) dyna_pop_gen(parser, (node))
519 #define dyna_in_block() dyna_in_block_gen(parser)
520 #define dyna_var(id) local_var(id)
522 #define dvar_defined(id) dvar_defined_gen(parser, (id), 0)
523 #define dvar_defined_get(id) dvar_defined_gen(parser, (id), 1)
525 #define dvar_curr(id) dvar_curr_gen(parser, (id))
528 #define lvar_defined(id) lvar_defined_gen(parser, (id))
530 #define RE_OPTION_ONCE (1<<16)
531 #define RE_OPTION_ENCODING_SHIFT 8
532 #define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
533 #define RE_OPTION_ENCODING_IDX(o) (((o)>>RE_OPTION_ENCODING_SHIFT)&0xff)
534 #define RE_OPTION_ENCODING_NONE(o) ((o)&RE_OPTION_ARG_ENCODING_NONE)
535 #define RE_OPTION_MASK 0xff
536 #define RE_OPTION_ARG_ENCODING_NONE 32
538 #define NODE_STRTERM NODE_ZARRAY
539 #define NODE_HEREDOC NODE_ARRAY
540 #define SIGN_EXTEND(x,n) (((1<<(n)-1)^((x)&~(~0<<(n))))-(1<<(n)-1))
541 #define nd_func u1.id
542 #if SIZEOF_SHORT == 2
543 #define nd_term(node) ((signed short)(node)->u2.id)
545 #define nd_term(node) SIGN_EXTEND((node)->u2.id, CHAR_BIT*2)
547 #define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2)
548 #define nd_nest u3.cnt
553 #define RIPPER_VERSION "0.1.0"
566 #define dispatch0(n) ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
567 #define dispatch1(n,a) ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), (a))
568 #define dispatch2(n,a,b) ripper_dispatch2(parser, TOKEN_PASTE(ripper_id_, n), (a), (b))
569 #define dispatch3(n,a,b,c) ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
570 #define dispatch4(n,a,b,c,d) ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
571 #define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
572 #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))
574 #define yyparse ripper_yyparse
576 #define ripper_intern(s) ID2SYM(rb_intern(s))
577 static VALUE ripper_id2sym(
ID);
579 #define ripper_id2sym(id) ((id) < 256 && rb_ispunct(id) ? \
580 ID2SYM(id) : ripper_id2sym(id))
583 #define arg_new() dispatch0(args_new)
584 #define arg_add(l,a) dispatch2(args_add, (l), (a))
585 #define arg_add_star(l,a) dispatch2(args_add_star, (l), (a))
586 #define arg_add_block(l,b) dispatch2(args_add_block, (l), (b))
587 #define arg_add_optblock(l,b) ((b)==Qundef? (l) : dispatch2(args_add_block, (l), (b)))
588 #define bare_assoc(v) dispatch1(bare_assoc_hash, (v))
589 #define arg_add_assocs(l,b) arg_add((l), bare_assoc(b))
591 #define args2mrhs(a) dispatch1(mrhs_new_from_args, (a))
592 #define mrhs_new() dispatch0(mrhs_new)
593 #define mrhs_add(l,a) dispatch2(mrhs_add, (l), (a))
594 #define mrhs_add_star(l,a) dispatch2(mrhs_add_star, (l), (a))
596 #define mlhs_new() dispatch0(mlhs_new)
597 #define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
598 #define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
600 #define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
601 dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
603 #define blockvar_new(p,v) dispatch2(block_var, (p), (v))
604 #define blockvar_add_star(l,a) dispatch2(block_var_add_star, (l), (a))
605 #define blockvar_add_block(l,a) dispatch2(block_var_add_block, (l), (a))
607 #define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
608 #define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
609 #define method_add_block(m,b) dispatch2(method_add_block, (m), (b))
611 #define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
620 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
627 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
629 #define new_defined(expr) dispatch1(defined, (expr))
637 # define ifndef_ripper(x) (x)
640 # define ifndef_ripper(x)
644 # define rb_warn0(fmt) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt))
645 # define rb_warnI(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
646 # define rb_warnS(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
647 # define rb_warn4S(file,line,fmt,a) rb_compile_warn((file), (line), (fmt), (a))
648 # define rb_warning0(fmt) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt))
649 # define rb_warningS(fmt,a) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt), (a))
651 # define rb_warn0(fmt) ripper_warn0(parser, (fmt))
652 # define rb_warnI(fmt,a) ripper_warnI(parser, (fmt), (a))
653 # define rb_warnS(fmt,a) ripper_warnS(parser, (fmt), (a))
654 # define rb_warn4S(file,line,fmt,a) ripper_warnS(parser, (fmt), (a))
655 # define rb_warning0(fmt) ripper_warning0(parser, (fmt))
656 # define rb_warningS(fmt,a) ripper_warningS(parser, (fmt), (a))
661 static void ripper_warningS(
struct parser_params*,
const char*,
const char*);
666 # define rb_compile_error ripper_compile_error
667 # define compile_error ripper_compile_error
668 # define PARSER_ARG parser,
670 # define rb_compile_error rb_compile_error_with_enc
671 # define compile_error parser->nerr++,rb_compile_error_with_enc
672 # define PARSER_ARG ruby_sourcefile, ruby_sourceline, current_enc,
680 #define YYMAXDEPTH 10000
687 #define token_info_push(token) (RTEST(ruby_verbose) ? token_info_push(parser, (token)) : (void)0)
688 #define token_info_pop(token) (RTEST(ruby_verbose) ? token_info_pop(parser, (token)) : (void)0)
690 #define token_info_push(token)
691 #define token_info_pop(token)
704 const struct vtable *vars;
767 %type <val> singleton strings
string string1 xstring regexp
768 %type <val> string_contents xstring_contents regexp_contents string_content
769 %type <val> words
symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
770 %type <val> literal numeric simple_numeric dsym cpath
771 %type <val> top_compstmt top_stmts
top_stmt
773 %type <val> expr_value arg_value primary_value fcall
774 %type <val> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
776 %type <val> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
777 %type <val>
command_args aref_args opt_block_arg block_arg var_ref var_lhs
778 %type <val> command_asgn mrhs mrhs_arg superclass block_call block_command
779 %type <val> f_block_optarg f_block_opt
780 %type <val> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
781 %type <val> assoc_list assocs
assoc undef_list backref string_dvar for_var
782 %type <val> block_param opt_block_param block_param_def f_opt
783 %type <val> f_kwarg f_kw f_block_kwarg f_block_kw
784 %type <val> bv_decls opt_bv_decl bvar
785 %type <val> lambda f_larglist lambda_body
789 %type <val> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
790 %type <val> f_kwrest f_label
793 %type <val> program reswords then
do dot_or_colon
879 while (node->nd_next) {
880 node = node->nd_next;
888 parser->result = dispatch1(program, $$);
894 top_compstmt : top_stmts opt_terms
919 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
927 $$ = dispatch2(stmts_add, $1, $3);
953 $$ = dispatch1(BEGIN, $4);
1007 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
1016 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
1024 $$ = dispatch2(stmts_add, $1, $3);
1039 yyerror(
"BEGIN is permitted only at toplevel");
1045 '{' top_compstmt
'}'
1054 $$ = dispatch1(BEGIN, $4);
1063 $$ = dispatch2(
alias, $2, $4);
1071 $$ = dispatch2(var_alias, $2, $3);
1079 buf[1] = (char)$3->
nd_nth;
1082 $$ = dispatch2(var_alias, $2, $3);
1088 yyerror(
"can't make alias for the number variables");
1091 $$ = dispatch2(var_alias, $2, $3);
1092 $$ = dispatch1(alias_error, $$);
1100 $$ = dispatch1(undef, $2);
1109 $$ = dispatch2(if_mod, $3, $1);
1118 $$ = dispatch2(unless_mod, $3, $1);
1131 $$ = dispatch2(while_mod, $3, $1);
1144 $$ = dispatch2(until_mod, $3, $1);
1153 $$ = dispatch2(rescue_mod, $1, $3);
1159 rb_warn0(
"END in method; use at_exit");
1165 $$ = dispatch1(
END, $3);
1176 $$ = dispatch2(massign, $1, $3);
1202 $$ = dispatch3(opassign, $$, $5, $6);
1221 $$ = dispatch2(const_path_field, $1, $3);
1222 $$ = dispatch3(opassign, $$, $4, $5);
1236 $$ = dispatch2(assign, dispatch1(var_field, $1), $3);
1237 $$ = dispatch1(assign_error, $$);
1246 $$ = dispatch2(assign, $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);
1417 $$ = dispatch4(
command_call, $1, ripper_id2sym(
'.'), $3, $4);
1418 $$ = method_add_block($$, $5);
1434 $5->nd_iter =
NEW_CALL($1, $3, $4);
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);
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);
2149 $$ = dispatch3(binary, $1,
ID2SYM(
'|'), $3);
2157 $$ = dispatch3(binary, $1,
ID2SYM(
'^'), $3);
2165 $$ = dispatch3(binary, $1,
ID2SYM(
'&'), $3);
2181 $$ = dispatch3(binary, $1,
ID2SYM(
'>'), $3);
2197 $$ = dispatch3(binary, $1,
ID2SYM(
'<'), $3);
2256 $$ = dispatch2(unary,
ID2SYM(
'!'), $2);
2264 $$ = dispatch2(unary,
ID2SYM(
'~'), $2);
2306 $$ = dispatch1(defined, $4);
2316 $$ = dispatch3(ifop, $1, $3, $6);
2342 | args
',' assocs trailer
2347 $$ = arg_add_assocs($1, $3);
2355 $$ = arg_add_assocs(arg_new(), $1);
2360 paren_args :
'(' opt_call_args rparen
2370 opt_paren_args : none
2374 opt_call_args : none
2380 | args
',' assocs
','
2385 $$ = arg_add_assocs($1, $3);
2393 $$ = arg_add_assocs(arg_new(), $1);
2404 $$ = arg_add(arg_new(), $1);
2407 | args opt_block_arg
2412 $$ = arg_add_optblock($1, $2);
2415 | assocs opt_block_arg
2421 $$ = arg_add_assocs(arg_new(), $1);
2422 $$ = arg_add_optblock($$, $2);
2425 | args
',' assocs opt_block_arg
2431 $$ = arg_add_optblock(arg_add_assocs($1, $3), $4);
2438 $$ = arg_add_block(arg_new(), $1);
2455 block_arg :
tAMPER arg_value
2465 opt_block_arg :
',' block_arg
2480 $$ = arg_add(arg_new(), $1);
2488 $$ = arg_add_star(arg_new(), $2);
2491 | args
',' arg_value
2502 $$ = arg_add($1, $3);
2505 | args
',' tSTAR arg_value
2516 $$ = arg_add_star($1, $4);
2525 mrhs : args
',' arg_value
2536 $$ = mrhs_add(args2mrhs($1), $3);
2539 | args
',' tSTAR arg_value
2551 $$ = mrhs_add_star(args2mrhs($1), $4);
2559 $$ = mrhs_add_star(mrhs_new(), $2);
2579 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2607 $$ = dispatch1(begin, $3);
2615 $$ = dispatch1(paren, 0);
2629 $$ = dispatch1(paren, $3);
2637 $$ = dispatch1(paren, $2);
2645 $$ = dispatch2(const_path_ref, $1, $3);
2653 $$ = dispatch1(top_const_ref, $2);
2690 $$ = dispatch1(yield, dispatch1(paren, $3));
2698 $$ = dispatch1(yield, dispatch1(paren, arg_new()));
2716 $$ = dispatch1(defined, $5);
2741 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2742 $$ = method_add_block($$, $2);
2746 | method_call brace_block
2753 $$ = method_add_block($1, $2);
2760 | k_if expr_value then
2772 | k_unless expr_value then
2792 $$ = dispatch2(
while, $3, $6);
2803 $$ = dispatch2(until, $3, $6);
2806 | k_case expr_value opt_terms
2814 $$ = dispatch2(
case, $2, $4);
2817 | k_case opt_terms case_body k_end
2822 $$ = dispatch2(
case,
Qnil, $3);
2884 tbl[0] = 1; tbl[1] =
id;
2888 $$ = dispatch3(
for, $2, $5, $8);
2891 | k_class cpath superclass
2894 yyerror(
"class definition in method body");
2908 $$ = dispatch3(
class, $2, $3, $5);
2930 $$ = dispatch2(sclass, $3, $7);
2939 yyerror(
"module definition in method body");
2953 $$ = dispatch2(module, $2, $4);
2974 $$ = dispatch3(def, $2, $4, $5);
2980 | k_def singleton dot_or_colon {
lex_state = EXPR_FNAME;} fname
2996 $$ = dispatch5(defs, $2, $3, $5, $7, $8);
3006 $$ = dispatch1(
break, arg_new());
3014 $$ = dispatch1(next, arg_new());
3035 primary_value : primary
3158 $$ = dispatch1(
else, $2);
3172 $$ = dispatch1(mlhs_paren, $$);
3180 $$ = dispatch1(mlhs_paren, $2);
3185 f_marg_list : f_marg
3190 $$ = mlhs_add(mlhs_new(), $1);
3193 | f_marg_list
',' f_marg
3198 $$ = mlhs_add($1, $3);
3203 f_margs : f_marg_list
3211 | f_marg_list
',' tSTAR f_norm_arg
3217 $$ = mlhs_add_star($1, $$);
3220 | f_marg_list
',' tSTAR f_norm_arg
',' f_marg_list
3226 $$ = mlhs_add_star($1, $$);
3229 | f_marg_list
',' tSTAR
3234 $$ = mlhs_add_star($1,
Qnil);
3237 | f_marg_list
',' tSTAR ',' f_marg_list
3242 $$ = mlhs_add_star($1, $5);
3251 $$ = mlhs_add_star(mlhs_new(), $$);
3254 |
tSTAR f_norm_arg
',' f_marg_list
3263 $$ = mlhs_add_star($$, $4);
3271 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3274 |
tSTAR ',' f_marg_list
3279 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3285 block_args_tail : f_block_kwarg
',' f_kwrest opt_f_block_arg
3289 | f_block_kwarg opt_f_block_arg
3293 | f_kwrest opt_f_block_arg
3303 opt_block_args_tail :
',' block_args_tail
3313 block_param : f_arg
',' f_block_optarg
',' f_rest_arg opt_block_args_tail
3317 | f_arg
',' f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3321 | f_arg
',' f_block_optarg opt_block_args_tail
3325 | f_arg
',' f_block_optarg
',' f_arg opt_block_args_tail
3329 | f_arg
',' f_rest_arg opt_block_args_tail
3338 dispatch1(excessed_comma, $$);
3341 | f_arg
',' f_rest_arg
',' f_arg opt_block_args_tail
3345 | f_arg opt_block_args_tail
3349 | f_block_optarg
',' f_rest_arg opt_block_args_tail
3353 | f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3357 | f_block_optarg opt_block_args_tail
3361 | f_block_optarg
',' f_arg opt_block_args_tail
3365 | f_rest_arg opt_block_args_tail
3369 | f_rest_arg
',' f_arg opt_block_args_tail
3379 opt_block_param : none
3386 block_param_def :
'|' opt_bv_decl
'|'
3404 |
'|' block_param opt_bv_decl
'|'
3415 opt_bv_decl : opt_nl
3419 | opt_nl
';' bv_decls opt_nl
3483 $$ = dispatch2(lambda, $3, $6);
3489 f_larglist :
'(' f_args opt_bv_decl
')'
3494 $$ = dispatch1(paren, $2);
3534 block_call : command do_block
3547 $$ = method_add_block($1, $2);
3550 | block_call dot_or_colon operation2 opt_paren_args
3555 $$ = dispatch3(call, $1, $2, $3);
3556 $$ = method_optarg($$, $4);
3559 | block_call dot_or_colon operation2 opt_paren_args brace_block
3563 $5->nd_iter =
NEW_CALL($1, $3, $4);
3568 $$ = method_add_block($$, $5);
3571 | block_call dot_or_colon operation2
command_args do_block
3575 $5->nd_iter =
NEW_CALL($1, $3, $4);
3580 $$ = method_add_block($$, $5);
3585 method_call : fcall paren_args
3591 $$ = method_arg(dispatch1(fcall, $1), $2);
3594 | primary_value
'.' operation2
3606 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3607 $$ = method_optarg($$, $5);
3610 | primary_value
tCOLON2 operation2
3622 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3623 $$ = method_optarg($$, $5);
3626 | primary_value
tCOLON2 operation3
3646 $$ = dispatch3(call, $1, ripper_id2sym(
'.'),
3648 $$ = method_optarg($$, $4);
3665 $$ = method_optarg($$, $4);
3673 $$ = dispatch1(super, $2);
3684 | primary_value
'[' opt_call_args rbracket
3766 $$ = dispatch4(rescue,
3776 exc_list : arg_value
3807 $$ = dispatch1(ensure, $2);
3819 $$ = dispatch1(symbol_literal, $1);
3849 $$ = dispatch2(string_concat, $1, $2);
3859 $$ = dispatch1(string_literal, $2);
3886 $$ = dispatch1(xstring_literal, $2);
3919 for (list = (prev = node)->
nd_next;
list; list = list->nd_next) {
3923 VALUE lit = prev == node ? prev->nd_lit : prev->nd_head->nd_lit;
3929 prev->nd_next = list->nd_next;
3942 if (!node->nd_next) {
3951 $$ = dispatch2(regexp_literal, $2, $3);
3962 $$ = dispatch1(array, $$);
3970 $$ = dispatch1(array, $2);
3983 | word_list word
' '
3988 $$ = dispatch2(words_add, $1, $2);
3993 word : string_content
3998 $$ = dispatch2(word_add, $$, $1);
4001 | word string_content
4006 $$ = dispatch2(word_add, $1, $2);
4017 $$ = dispatch1(array, $$);
4025 $$ = dispatch1(array, $2);
4038 | symbol_list word
' '
4051 $$ = dispatch2(symbols_add, $1, $2);
4062 $$ = dispatch1(array, $$);
4070 $$ = dispatch1(array, $2);
4081 $$ = dispatch1(array, $$);
4089 $$ = dispatch1(array, $2);
4107 $$ = dispatch2(qwords_add, $1, $2);
4129 $$ = dispatch2(qsymbols_add, $1, $2);
4142 | string_contents string_content
4147 $$ = dispatch2(string_add, $1, $2);
4160 | xstring_contents string_content
4165 $$ = dispatch2(xstring_add, $1, $2);
4178 | regexp_contents string_content
4202 $$ = dispatch2(regexp_add, $1, $2);
4221 $$ = dispatch1(string_dvar, $3);
4250 $$ = dispatch1(string_embexpr, $5);
4260 $$ = dispatch1(var_ref, $1);
4268 $$ = dispatch1(var_ref, $1);
4276 $$ = dispatch1(var_ref, $1);
4288 $$ = dispatch1(symbol, $2);
4305 $$ = dispatch1(dyna_symbol, $2);
4310 numeric : simple_numeric
4343 var_ref : user_variable
4348 if (id_is_var(
get_id($1))) {
4349 $$ = dispatch1(var_ref, $1);
4352 $$ = dispatch1(vcall, $1);
4361 $$ = dispatch1(var_ref, $1);
4366 var_lhs : user_variable
4371 $$ = dispatch1(var_field, $$);
4379 $$ = dispatch1(var_field, $$);
4417 f_arglist :
'(' f_args rparen
4422 $$ = dispatch1(paren, $2);
4440 args_tail : f_kwarg
',' f_kwrest opt_f_block_arg
4444 | f_kwarg opt_f_block_arg
4448 | f_kwrest opt_f_block_arg
4458 opt_args_tail :
',' args_tail
4468 f_args : f_arg
',' f_optarg
',' f_rest_arg opt_args_tail
4472 | f_arg
',' f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4476 | f_arg
',' f_optarg opt_args_tail
4480 | f_arg
',' f_optarg
',' f_arg opt_args_tail
4484 | f_arg
',' f_rest_arg opt_args_tail
4488 | f_arg
',' f_rest_arg
',' f_arg opt_args_tail
4492 | f_arg opt_args_tail
4496 | f_optarg
',' f_rest_arg opt_args_tail
4500 | f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4504 | f_optarg opt_args_tail
4508 | f_optarg
',' f_arg opt_args_tail
4512 | f_rest_arg opt_args_tail
4516 | f_rest_arg
',' f_arg opt_args_tail
4534 yyerror(
"formal argument cannot be a constant");
4537 $$ = dispatch1(param_error, $1);
4543 yyerror(
"formal argument cannot be an instance variable");
4546 $$ = dispatch1(param_error, $1);
4552 yyerror(
"formal argument cannot be a global variable");
4555 $$ = dispatch1(param_error, $1);
4561 yyerror(
"formal argument cannot be a class variable");
4564 $$ = dispatch1(param_error, $1);
4569 f_norm_arg : f_bad_arg
4577 f_arg_item : f_norm_arg
4600 $$ = dispatch1(mlhs_paren, $2);
4612 | f_arg
',' f_arg_item
4633 f_kw : f_label arg_value
4653 f_block_kw : f_label primary_value
4673 f_block_kwarg : f_block_kw
4681 | f_block_kwarg
',' f_block_kw
4686 while (kws->nd_next) {
4711 while (kws->nd_next) {
4737 f_opt : f_norm_arg
'=' arg_value
4749 f_block_opt : f_norm_arg
'=' primary_value
4761 f_block_optarg : f_block_opt
4769 | f_block_optarg
',' f_block_opt
4774 while (opts->nd_next) {
4775 opts = opts->nd_next;
4793 | f_optarg
',' f_opt
4798 while (opts->nd_next) {
4799 opts = opts->nd_next;
4817 yyerror(
"rest argument must be local variable");
4823 $$ = dispatch1(rest_param, $2);
4832 $$ = dispatch1(rest_param,
Qnil);
4845 yyerror(
"block argument must be local variable");
4847 yyerror(
"duplicated block argument name");
4853 $$ = dispatch1(blockarg, $2);
4858 opt_f_block_arg :
',' f_block_arg
4886 yyerror(
"can't define singleton method for ().");
4898 yyerror(
"can't define singleton method for literals");
4906 $$ = dispatch1(paren, $3);
4917 $$ = dispatch1(assoclist_from_args, $1);
4948 $$ = dispatch2(assoc_new, $1, $3);
4956 $$ = dispatch2(assoc_new, $1, $2);
4964 $$ = dispatch1(assoc_splat, $2);
5010 rbracket : opt_nl
']'
5039 # define yylval (*((YYSTYPE*)(parser->parser_yylval)))
5048 # define nextc() parser_nextc(parser)
5049 # define pushback(c) parser_pushback(parser, (c))
5050 # define newtok() parser_newtok(parser)
5051 # define tokspace(n) parser_tokspace(parser, (n))
5052 # define tokadd(c) parser_tokadd(parser, (c))
5053 # define tok_hex(numlen) parser_tok_hex(parser, (numlen))
5054 # define read_escape(flags,e) parser_read_escape(parser, (flags), (e))
5055 # define tokadd_escape(e) parser_tokadd_escape(parser, (e))
5056 # define regx_options() parser_regx_options(parser)
5057 # define tokadd_string(f,t,p,n,e) parser_tokadd_string(parser,(f),(t),(p),(n),(e))
5058 # define parse_string(n) parser_parse_string(parser,(n))
5059 # define tokaddmbc(c, enc) parser_tokaddmbc(parser, (c), (enc))
5060 # define here_document(n) parser_here_document(parser,(n))
5061 # define heredoc_identifier() parser_heredoc_identifier(parser)
5062 # define heredoc_restore(n) parser_heredoc_restore(parser,(n))
5063 # define whole_match_p(e,l,i) parser_whole_match_p(parser,(e),(l),(i))
5064 # define number_literal_suffix(f) parser_number_literal_suffix(parser, (f))
5065 # define set_number_literal(v, t, f) parser_set_number_literal(parser, (v), (t), (f))
5066 # define set_integer_literal(v, f) parser_set_integer_literal(parser, (v), (f))
5069 # define set_yylval_str(x) (yylval.node = NEW_STR(x))
5070 # define set_yylval_num(x) (yylval.num = (x))
5071 # define set_yylval_id(x) (yylval.id = (x))
5072 # define set_yylval_name(x) (yylval.id = (x))
5073 # define set_yylval_literal(x) (yylval.node = NEW_LIT(x))
5074 # define set_yylval_node(x) (yylval.node = (x))
5075 # define yylval_id() (yylval.id)
5078 ripper_yylval_id(
ID x)
5082 # define set_yylval_str(x) (void)(x)
5083 # define set_yylval_num(x) (void)(x)
5084 # define set_yylval_id(x) (void)(x)
5085 # define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(x))
5086 # define set_yylval_literal(x) (void)(x)
5087 # define set_yylval_node(x) (void)(x)
5088 # define yylval_id() yylval.id
5092 #define ripper_flush(p) (void)(p)
5094 #define ripper_flush(p) ((p)->tokp = (p)->parser_lex_p)
5096 #define yylval_rval (*(RB_TYPE_P(yylval.val, T_NODE) ? &yylval.node->nd_rval : &yylval.val))
5103 return lex_p > parser->tokp;
5116 ripper_dispatch_scan_event(
struct parser_params *parser,
int t)
5118 if (!ripper_has_scan_event(parser))
return;
5119 yylval_rval = ripper_scan_event_val(parser, t);
5123 ripper_dispatch_ignored_scan_event(
struct parser_params *parser,
int t)
5125 if (!ripper_has_scan_event(parser))
return;
5126 (
void)ripper_scan_event_val(parser, t);
5130 ripper_dispatch_delayed_token(
struct parser_params *parser,
int t)
5133 const char *saved_tokp = parser->tokp;
5136 parser->tokp =
lex_pbeg + parser->delayed_col;
5138 parser->delayed =
Qnil;
5140 parser->tokp = saved_tokp;
5151 #undef SIGN_EXTEND_CHAR
5153 # define SIGN_EXTEND_CHAR(c) ((signed char)(c))
5156 # define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
5159 #define parser_encoding_name() (current_enc->name)
5160 #define parser_mbclen() mbclen((lex_p-1),lex_pend,current_enc)
5161 #define parser_precise_mbclen() rb_enc_precise_mbclen((lex_p-1),lex_pend,current_enc)
5162 #define is_identchar(p,e,enc) (rb_enc_isalnum((unsigned char)(*(p)),(enc)) || (*(p)) == '_' || !ISASCII(*(p)))
5163 #define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,current_enc))
5165 #define parser_isascii() ISASCII(*(lex_p-1))
5173 for (p =
lex_pbeg; p < pend; p++) {
5175 column = (((column - 1) / 8) + 1) * 8;
5186 for (p =
lex_pbeg; p < pend; p++) {
5187 if (*p !=
' ' && *p !=
'\t') {
5194 #undef token_info_push
5211 #undef token_info_pop
5218 if (!ptinfo)
return;
5224 if (linenum == ptinfo->
linenum) {
5232 "mismatched indentations at '%s' with '%s' at %d",
5245 const int max_line_margin = 30;
5254 if (*p ==
'\n')
break;
5261 if (*pe ==
'\n')
break;
5268 const char *pre =
"", *post =
"";
5270 if (len > max_line_margin * 2 + 10) {
5271 if (
lex_p - p > max_line_margin) {
5275 if (pe -
lex_p > max_line_margin) {
5282 MEMCPY(buf, p,
char, len);
5287 p2 =
buf; pe = buf +
len;
5290 if (*p2 !=
'\t') *p2 =
' ';
5298 dispatch1(parse_error,
STR_NEW2(msg));
5310 CONST_ID(script_lines,
"SCRIPT_LINES__");
5331 RARRAY(lines)->as.heap.len =
n;
5428 char *beg, *
end, *pend;
5438 while (end < pend) {
5439 if (*end++ ==
'\n')
break;
5449 if (
NIL_P(line))
return line;
5560 #define STR_FUNC_ESCAPE 0x01
5561 #define STR_FUNC_EXPAND 0x02
5562 #define STR_FUNC_REGEXP 0x04
5563 #define STR_FUNC_QWORDS 0x08
5564 #define STR_FUNC_SYMBOL 0x10
5565 #define STR_FUNC_INDENT 0x20
5595 #define lex_goto_eol(parser) ((parser)->parser_lex_p = (parser)->parser_lex_pend)
5596 #define lex_eol_p() (lex_p >= lex_pend)
5597 #define peek(c) peek_n((c), 0)
5598 #define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
5621 if (
NIL_P(parser->delayed)) {
5625 parser->tokp,
lex_pend - parser->tokp);
5627 parser->delayed_col = (
int)(parser->tokp -
lex_pbeg);
5631 parser->tokp,
lex_pend - parser->tokp);
5647 c = (
unsigned char)*
lex_p++;
5665 if (c == -1)
return;
5672 #define was_bol() (lex_p == lex_pbeg + 1)
5674 #define tokfix() (tokenbuf[tokidx]='\0')
5675 #define tok() tokenbuf
5676 #define toklen() tokidx
5677 #define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
5724 yyerror(
"invalid hex escape");
5731 #define tokcopy(n) memcpy(tokspace(n), lex_p - (n), (n))
5736 int string_literal,
int symbol_literal,
int regexp_literal)
5756 yyerror(
"invalid Unicode escape");
5759 if (codepoint > 0x10ffff) {
5760 yyerror(
"invalid Unicode codepoint (too large)");
5764 if (regexp_literal) {
5767 else if (codepoint >= 0x80) {
5769 if (string_literal)
tokaddmbc(codepoint, *encp);
5771 else if (string_literal) {
5774 }
while (string_literal && (
peek(
' ') ||
peek(
'\t')));
5777 yyerror(
"unterminated Unicode escape");
5781 if (regexp_literal) {
tokadd(
'}'); }
5787 yyerror(
"invalid Unicode escape");
5791 if (regexp_literal) {
5794 else if (codepoint >= 0x80) {
5796 if (string_literal)
tokaddmbc(codepoint, *encp);
5798 else if (string_literal) {
5806 #define ESCAPE_CONTROL 1
5807 #define ESCAPE_META 2
5816 switch (c =
nextc()) {
5841 case '0':
case '1':
case '2':
case '3':
5842 case '4':
case '5':
case '6':
case '7':
5850 if (numlen == 0)
return 0;
5861 if ((c =
nextc()) !=
'-') {
5865 if ((c =
nextc()) ==
'\\') {
5866 if (
peek(
'u'))
goto eof;
5867 return read_escape(flags|ESCAPE_META, encp) | 0x80;
5869 else if (c == -1 || !
ISASCII(c))
goto eof;
5871 return ((c & 0xff) | 0x80);
5875 if ((c =
nextc()) !=
'-') {
5881 if ((c =
nextc())==
'\\') {
5882 if (
peek(
'u'))
goto eof;
5887 else if (c == -1 || !
ISASCII(c))
goto eof;
5892 yyerror(
"Invalid escape character syntax");
5915 switch (c =
nextc()) {
5919 case '0':
case '1':
case '2':
case '3':
5920 case '4':
case '5':
case '6':
case '7':
5923 if (numlen == 0)
goto eof;
5932 if (numlen == 0)
return -1;
5938 if (flags & ESCAPE_META)
goto eof;
5939 if ((c =
nextc()) !=
'-') {
5948 if (flags & ESCAPE_CONTROL)
goto eof;
5949 if ((c =
nextc()) !=
'-') {
5957 if (flags & ESCAPE_CONTROL)
goto eof;
5961 if ((c =
nextc()) ==
'\\') {
5964 else if (c == -1)
goto eof;
5970 yyerror(
"Invalid escape character syntax");
6037 #define tokadd_mbchar(c) parser_tokadd_mbchar(parser, (c))
6043 case '$':
case '*':
case '+':
case '.':
6044 case '?':
case '^':
case '|':
6045 case ')':
case ']':
case '}':
case '>':
6054 int func,
int term,
int paren,
long *nest,
6058 int has_nonascii = 0;
6061 static const char mixed_msg[] =
"%s mixed within %s source";
6063 #define mixed_error(enc1, enc2) if (!errbuf) { \
6064 size_t len = sizeof(mixed_msg) - 4; \
6065 len += strlen(rb_enc_name(enc1)); \
6066 len += strlen(rb_enc_name(enc2)); \
6067 errbuf = ALLOCA_N(char, len); \
6068 snprintf(errbuf, len, mixed_msg, \
6069 rb_enc_name(enc1), \
6070 rb_enc_name(enc2)); \
6073 #define mixed_escape(beg, enc1, enc2) do { \
6074 const char *pos = lex_p; \
6076 mixed_error((enc1), (enc2)); \
6080 while ((c =
nextc()) != -1) {
6081 if (paren && c == paren) {
6084 else if (c == term) {
6085 if (!nest || !*nest) {
6093 if (c2 ==
'$' || c2 ==
'@' || c2 ==
'{') {
6098 else if (c ==
'\\') {
6099 const char *beg =
lex_p - 1;
6104 if (func & STR_FUNC_EXPAND)
continue;
6113 if ((func & STR_FUNC_EXPAND) == 0) {
6119 func & STR_FUNC_REGEXP);
6120 if (has_nonascii && enc != *encp) {
6126 if (c == -1)
return -1;
6128 if ((func & STR_FUNC_EXPAND) == 0)
tokadd(
'\\');
6131 if (func & STR_FUNC_REGEXP) {
6139 if (has_nonascii && enc != *encp) {
6144 else if (func & STR_FUNC_EXPAND) {
6146 if (func & STR_FUNC_ESCAPE)
tokadd(
'\\');
6149 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6152 else if (c != term && !(paren && c == paren)) {
6169 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6186 #define NEW_STRTERM(func, term, paren) \
6187 rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
6193 if (!
NIL_P(parser->delayed)) {
6194 ptrdiff_t len =
lex_p - parser->tokp;
6199 parser->tokp =
lex_p;
6203 #define flush_string_content(enc) ripper_flush_string_content(parser, (enc))
6205 #define flush_string_content(enc) ((void)(enc))
6212 #define BIT(c, idx) (((c) / 32 - 1 == idx) ? (1U << ((c) % 32)) : 0)
6213 #define SPECIAL_PUNCT(idx) ( \
6214 BIT('~', idx) | BIT('*', idx) | BIT('$', idx) | BIT('?', idx) | \
6215 BIT('!', idx) | BIT('@', idx) | BIT('/', idx) | BIT('\\', idx) | \
6216 BIT(';', idx) | BIT(',', idx) | BIT('.', idx) | BIT('=', idx) | \
6217 BIT(':', idx) | BIT('<', idx) | BIT('>', idx) | BIT('\"', idx) | \
6218 BIT('&', idx) | BIT('`', idx) | BIT('\'', idx) | BIT('+', idx) | \
6226 #undef SPECIAL_PUNCT
6232 if (c <= 0x20 || 0x7e < c)
return 0;
6233 return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
6240 const char *p =
lex_p;
6246 if ((c = *p) ==
'-') {
6255 if ((c = *p) ==
'@') {
6275 int func = (
int)quote->nd_func;
6283 if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6287 if (c == term && !quote->nd_nest) {
6288 if (func & STR_FUNC_QWORDS) {
6289 quote->nd_func = -1;
6292 if (!(func & STR_FUNC_REGEXP))
return tSTRING_END;
6301 if ((func & STR_FUNC_EXPAND) && c ==
'#') {
6311 if (func & STR_FUNC_REGEXP) {
6333 int c =
nextc(), term, func = 0;
6351 while ((c =
nextc()) != -1 && c != term) {
6399 line = here->nd_orig;
6403 lex_p = lex_pbeg + here->nd_nth;
6413 const char *eos,
long len,
int indent)
6419 while (*p &&
ISSPACE(*p)) p++;
6422 if (n < 0)
return FALSE;
6423 if (n > 0 && p[len] !=
'\n') {
6424 if (p[len] !=
'\r')
return FALSE;
6425 if (n <= 1 || p[len+1] !=
'\n')
return FALSE;
6427 return strncmp(eos, p, len) == 0;
6430 #define NUM_SUFFIX_R (1<<0)
6431 #define NUM_SUFFIX_I (1<<1)
6432 #define NUM_SUFFIX_ALL 3
6438 const char *lastp =
lex_p;
6440 while ((c =
nextc()) != -1) {
6443 mask &= ~NUM_SUFFIX_I;
6450 mask &= ~NUM_SUFFIX_R;
6466 if (suffix & NUM_SUFFIX_I) {
6478 if (suffix & NUM_SUFFIX_R) {
6489 if (!
NIL_P(parser->delayed))
6492 ripper_dispatch_ignored_scan_event(parser,
tHEREDOC_END);
6495 #define dispatch_heredoc_end() ripper_dispatch_heredoc_end(parser)
6497 #define dispatch_heredoc_end() ((void)0)
6503 int c,
func, indent = 0;
6504 const char *eos, *
p, *pend;
6513 if ((c =
nextc()) == -1) {
6517 if (
NIL_P(parser->delayed)) {
6522 ((len =
lex_p - parser->tokp) > 0 &&
6523 (str =
STR_NEW3(parser->tokp, len, enc, func), 1))) {
6540 if (!(func & STR_FUNC_EXPAND)) {
6547 if (--pend == p || pend[-1] !=
'\r') {
6561 if (
nextc() == -1) {
6582 if (parser->
eofp)
goto error;
6592 if ((c =
nextc()) == -1)
goto error;
6609 rb_warning0(
"ambiguous first argument; put parentheses or even spaces");
6614 #define arg_ambiguous() (arg_ambiguous_gen(parser), 1)
6621 yyerror(
"formal argument must be local variable");
6639 if (len > 5 && name[nlen = len - 5] ==
'-') {
6643 if (len > 4 && name[nlen = len - 4] ==
'-') {
6646 if (
rb_memcicmp(name + nlen + 1,
"mac", 3) == 0 &&
6647 !(len == 8 &&
rb_memcicmp(name,
"utf8-mac", len) == 0))
6662 excargs[1] =
rb_sprintf(
"unknown encoding name: %s", name);
6679 for (i = 0; i <
n; ++
i) {
6754 if (str[i-1] ==
'*' && str[i-2] ==
'-') {
6760 if (i + 1 >= len)
return 0;
6761 if (str[i+1] !=
'-') {
6764 else if (str[i-1] !=
'-') {
6782 VALUE name = 0, val = 0;
6783 const char *beg, *
end, *vbeg, *vend;
6784 #define str_copy(_s, _p, _n) ((_s) \
6785 ? (void)(rb_str_resize((_s), (_n)), \
6786 MEMCPY(RSTRING_PTR(_s), (_p), char, (_n)), (_s)) \
6787 : (void)((_s) = STR_NEW((_p), (_n))))
6789 if (len <= 7)
return FALSE;
6793 len = end - beg - 3;
6804 for (; len > 0 && *
str; str++, --
len) {
6806 case '\'':
case '"':
case ':':
case ';':
6811 for (beg = str; len > 0; str++, --
len) {
6813 case '\'':
case '"':
case ':':
case ';':
6821 for (end = str; len > 0 &&
ISSPACE(*str); str++, --
len);
6823 if (*str !=
':')
continue;
6825 do str++;
while (--len > 0 &&
ISSPACE(*str));
6828 for (vbeg = ++str; --len > 0 && *str !=
'"'; str++) {
6841 for (vbeg = str; len > 0 && *str !=
'"' && *str !=
';' && !
ISSPACE(*str); --
len, str++);
6844 while (len > 0 && (*str ==
';' ||
ISSPACE(*str))) --len, str++;
6849 for (i = 0; i <
n; ++
i) {
6850 if (s[i] ==
'-') s[
i] =
'_';
6857 n = (*p->
length)(parser, vbeg, n);
6863 }
while (++p < magic_comments +
numberof(magic_comments));
6877 const char *beg =
str;
6881 if (send - str <= 6)
return;
6883 case 'C':
case 'c': str += 6;
continue;
6884 case 'O':
case 'o': str += 5;
continue;
6885 case 'D':
case 'd': str += 4;
continue;
6886 case 'I':
case 'i': str += 3;
continue;
6887 case 'N':
case 'n': str += 2;
continue;
6888 case 'G':
case 'g': str += 1;
continue;
6902 if (++str >= send)
return;
6905 if (*str !=
'=' && *str !=
':')
return;
6910 while ((*str ==
'-' || *str ==
'_' ||
ISALNUM(*str)) && ++str < send);
6926 (
unsigned char)
lex_p[0] == 0xbb &&
6927 (
unsigned char)
lex_p[1] == 0xbf) {
6941 #define IS_ARG() IS_lex_state(EXPR_ARG_ANY)
6942 #define IS_END() IS_lex_state(EXPR_END_ANY)
6943 #define IS_BEG() IS_lex_state(EXPR_BEG_ANY)
6944 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
6945 #define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG | EXPR_ENDFN) && !cmd_state) || IS_ARG())
6946 #define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1))
6947 #define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT)
6950 #define ambiguous_operator(op, syn) ( \
6951 rb_warning0("`"op"' after local variable or literal is interpreted as binary operator"), \
6952 rb_warning0("even though it seems like "syn""))
6954 #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn))
6956 #define warn_balanced(op, syn) ((void) \
6957 (!IS_lex_state_for(last_state, EXPR_CLASS|EXPR_DOT|EXPR_FNAME|EXPR_ENDFN|EXPR_ENDARG) && \
6958 space_seen && !ISSPACE(c) && \
6959 (ambiguous_operator(op, syn), 0)))
6967 const unsigned long nth_ref_max =
6968 ((FIXNUM_MAX < INT_MAX) ? FIXNUM_MAX : INT_MAX) >> 1;
6972 if (overflow || n > nth_ref_max) {
6974 rb_warnS(
"`%s' is too big for a number variable, always nil",
tok());
6992 int fallthru =
FALSE;
7018 switch (c =
nextc()) {
7026 case ' ':
case '\t':
case '\f':
case '\r':
7030 while ((c =
nextc())) {
7032 case ' ':
case '\t':
case '\f':
case '\r':
7041 ripper_dispatch_scan_event(parser,
tSP);
7054 ripper_dispatch_scan_event(parser,
tCOMMENT);
7059 if (
IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT | EXPR_LABELARG)) {
7067 goto normal_newline;
7071 while ((c =
nextc())) {
7073 case ' ':
case '\t':
case '\f':
case '\r':
7078 if ((c =
nextc()) !=
'.') {
7091 parser->tokp =
lex_p;
7094 goto normal_newline;
7103 if ((c =
nextc()) ==
'*') {
7104 if ((c =
nextc()) ==
'=') {
7111 rb_warning0(
"`**' interpreted as argument prefix");
7130 rb_warning0(
"`*' interpreted as argument prefix");
7178 ripper_dispatch_scan_event(parser,
tEMBDOC);
7187 if (c !=
'=')
continue;
7188 if (strncmp(
lex_p,
"end", 3) == 0 &&
7202 if ((c =
nextc()) ==
'=') {
7203 if ((c =
nextc()) ==
'=') {
7212 else if (c ==
'>') {
7224 (!
IS_ARG() || space_seen)) {
7226 if (token)
return token;
7237 if ((c =
nextc()) ==
'>') {
7244 if ((c =
nextc()) ==
'=') {
7258 if ((c =
nextc()) ==
'=') {
7262 if ((c =
nextc()) ==
'=') {
7330 rb_warnI(
"invalid character syntax; use ?\\%c", c2);
7347 else if (c ==
'\\') {
7376 if ((c =
nextc()) ==
'&') {
7378 if ((c =
nextc()) ==
'=') {
7386 else if (c ==
'=') {
7393 rb_warning0(
"`&' interpreted as argument prefix");
7407 if ((c =
nextc()) ==
'|') {
7409 if ((c =
nextc()) ==
'=') {
7489 if ((c =
nextc()) ==
'.') {
7490 if ((c =
nextc()) ==
'.') {
7498 yyerror(
"no .<digit> floating literal anymore; put 0 before dot");
7504 case '0':
case '1':
case '2':
case '3':
case '4':
7505 case '5':
case '6':
case '7':
case '8':
case '9':
7507 int is_float, seen_point, seen_e, nondigit;
7510 is_float = seen_point = seen_e = nondigit = 0;
7513 if (c ==
'-' || c ==
'+') {
7518 #define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
7521 if (c ==
'x' || c ==
'X') {
7527 if (nondigit)
break;
7534 }
while ((c =
nextc()) != -1);
7541 else if (nondigit)
goto trailing_uc;
7545 if (c ==
'b' || c ==
'B') {
7548 if (c ==
'0' || c ==
'1') {
7551 if (nondigit)
break;
7555 if (c !=
'0' && c !=
'1')
break;
7558 }
while ((c =
nextc()) != -1);
7565 else if (nondigit)
goto trailing_uc;
7569 if (c ==
'd' || c ==
'D') {
7575 if (nondigit)
break;
7582 }
while ((c =
nextc()) != -1);
7589 else if (nondigit)
goto trailing_uc;
7597 if (c ==
'o' || c ==
'O') {
7600 if (c == -1 || c ==
'_' || !
ISDIGIT(c)) {
7604 if (c >=
'0' && c <=
'7') {
7609 if (nondigit)
break;
7613 if (c < '0' || c >
'9')
break;
7614 if (c >
'7')
goto invalid_octal;
7617 }
while ((c =
nextc()) != -1);
7621 if (nondigit)
goto trailing_uc;
7630 if (c >
'7' && c <=
'9') {
7632 yyerror(
"Invalid octal digit");
7634 else if (c ==
'.' || c ==
'e' || c ==
'E') {
7646 case '0':
case '1':
case '2':
case '3':
case '4':
7647 case '5':
case '6':
case '7':
case '8':
case '9':
7653 if (nondigit)
goto trailing_uc;
7654 if (seen_point || seen_e) {
7659 if (c0 == -1 || !
ISDIGIT(c0)) {
7684 if (c !=
'-' && c !=
'+' && !
ISDIGIT(c)) {
7693 nondigit = (c ==
'-' || c ==
'+') ? c : 0;
7697 if (nondigit)
goto decode_num;
7712 snprintf(tmp,
sizeof(tmp),
"trailing `%c' in number", nondigit);
7721 if (suffix & NUM_SUFFIX_R) {
7722 char *point = &
tok()[seen_point];
7723 size_t fraclen =
toklen()-seen_point-1;
7725 memmove(point, point+1, fraclen+1);
7731 if (
errno == ERANGE) {
7809 if ((c =
nextc()) ==
'=') {
7829 if ((c =
nextc()) !=
'@') {
7856 if ((c =
nextc()) ==
']') {
7857 if ((c =
nextc()) ==
'=') {
7869 else if (
IS_ARG() && space_seen) {
7904 ripper_dispatch_scan_event(parser,
tSP);
7925 yyerror(
"unknown type of %string");
7929 if (c == -1 || term == -1) {
7934 if (term ==
'(') term =
')';
7935 else if (term ==
'[') term =
']';
7936 else if (term ==
'{') term =
'}';
7937 else if (term ==
'<') term =
'>';
7987 yyerror(
"unknown type of %string");
7991 if ((c =
nextc()) ==
'=') {
8067 case '1':
case '2':
case '3':
8068 case '4':
case '5':
case '6':
8069 case '7':
case '8':
case '9':
8074 }
while (c != -1 &&
ISDIGIT(c));
8120 ripper_dispatch_scan_event(parser,
k__END__);
8148 if ((c ==
'!' || c ==
'?') && !
peek(
'=')) {
8168 if (
tok()[1] ==
'@')
8237 if (kw->
id[0] != kw->
id[1])
8274 yylex(
void *lval,
void *p)
8288 if (!
NIL_P(parser->delayed)) {
8289 ripper_dispatch_delayed_token(parser, t);
8293 ripper_dispatch_scan_event(parser, t);
8335 if (orig == (
NODE*)1)
return;
8344 #define parser_warning(node, mesg) parser_warning(parser, (node), (mesg))
8351 #define parser_warn(node, mesg) parser_warn(parser, (node), (mesg))
8358 if (tail == 0)
return head;
8360 if (h == 0)
return tail;
8399 tail->nd_end =
tail;
8401 end->nd_next =
tail;
8402 h->nd_end = tail->nd_end;
8412 if (list == 0)
return NEW_LIST(item);
8413 if (list->nd_next) {
8414 last = list->nd_next->nd_end;
8422 list->nd_next->nd_end = last->nd_next;
8432 if (head->nd_next) {
8433 last = head->nd_next->nd_end;
8439 head->nd_alen += tail->nd_alen;
8440 last->nd_next =
tail;
8441 if (tail->nd_next) {
8442 head->nd_next->nd_end = tail->nd_next->nd_end;
8445 head->nd_next->nd_end =
tail;
8454 if (
NIL_P(tail))
return 1;
8475 if (!head)
return tail;
8476 if (!tail)
return head;
8486 if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8489 lit = headlast->nd_lit;
8512 tail->nd_lit = head->nd_lit;
8516 else if (
NIL_P(tail->nd_lit)) {
8518 head->nd_alen += tail->nd_alen - 1;
8519 head->nd_next->nd_end->nd_next = tail->nd_next;
8520 head->nd_next->nd_end = tail->nd_next->nd_end;
8523 else if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8525 lit = headlast->nd_lit;
8528 tail->nd_lit =
Qnil;
8533 tail->nd_head =
NEW_STR(tail->nd_lit);
8682 static const char names[][12] = {
8683 "EXPR_BEG",
"EXPR_END",
"EXPR_ENDARG",
"EXPR_ENDFN",
"EXPR_ARG",
8684 "EXPR_CMDARG",
"EXPR_MID",
"EXPR_FNAME",
"EXPR_DOT",
"EXPR_CLASS",
8689 return names[
ffs(state)];
8704 # define assignable_result(x) get_value(lhs)
8705 # define parser_yyerror(parser, x) dispatch1(assign_error, lhs)
8707 # define assignable_result(x) (x)
8712 yyerror(
"Can't change the value of self");
8715 yyerror(
"Can't assign to nil");
8718 yyerror(
"Can't assign to true");
8721 yyerror(
"Can't assign to false");
8724 yyerror(
"Can't assign to __FILE__");
8727 yyerror(
"Can't assign to __LINE__");
8730 yyerror(
"Can't assign to __ENCODING__");
8764 yyerror(
"dynamic constant assignment");
8773 #undef assignable_result
8774 #undef parser_yyerror
8781 if (name == idUScore)
return 1;
8788 #define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
8796 yyerror(
"duplicated argument name");
8809 yyerror(
"duplicated argument name");
8874 int scope = (
int)(
id & ID_SCOPE_MASK);
8883 id_type_names[scope],
ID2SYM(
id));
8887 id &= ~ID_SCOPE_MASK;
8916 if (!node2)
return node1;
8920 node1->nd_head =
arg_concat(node1->nd_head, node2);
8932 node1->nd_body =
list_concat(node1->nd_body, node2);
8941 if (!node1)
return NEW_LIST(node2);
8946 node1->nd_head =
arg_append(node1->nd_head, node2);
8979 lhs->nd_value = rhs;
8984 lhs->nd_args =
arg_append(lhs->nd_args, rhs);
9010 if (!cond)
yyerror(
"void value expression");
9015 while (node->nd_next) {
9016 node = node->nd_next;
9018 node = node->nd_head;
9022 node = node->nd_body;
9026 if (!node->nd_body) {
9027 node = node->nd_else;
9030 else if (!node->nd_else) {
9031 node = node->nd_body;
9035 node = node->nd_else;
9041 node = node->nd_2nd;
9055 const char *useless = 0;
9062 switch (node->nd_mid) {
9093 useless =
"a variable";
9096 useless =
"a constant";
9103 useless =
"a literal";
9128 useless =
"defined?";
9136 rb_warnS(
"possibly useless use of %s in void context", useless);
9149 if (!node->nd_next)
return;
9151 node = node->nd_next;
9158 NODE **n = &node, *n1 = node;
9160 *n = n1 = n1->nd_body;
9168 NODE **n = &node, *n1 = node;
9170 *n = n1 = n1->nd_body;
9184 #define subnodes(n1, n2) \
9185 ((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
9186 (!node->n2) ? (body = &node->n1, 1) : \
9187 (reduce_nodes(&node->n1), body = &node->n2, 1))
9197 *body = node = node->nd_stts;
9201 *body = node = node->nd_body;
9205 body = &node->nd_end->nd_head;
9211 body = &node->nd_body;
9220 if (node->nd_else) {
9221 body = &node->nd_resq;
9239 if (!node)
return 1;
9242 if (!(node = node->nd_head))
break;
9246 }
while ((node = node->nd_next) != 0);
9265 yyerror(
"multiple assignment in conditional");
9279 if (!node->nd_value)
return 1;
9282 parser_warn(node->nd_value,
"found = in conditional, should be ==");
9304 for (node = *rootnode; node; node = next) {
9308 next = node->nd_next;
9309 head = node->nd_head;
9312 switch (type =
nd_type(head)) {
9315 val =
rb_range_new(head->nd_beg->nd_lit, head->nd_end->nd_lit,
9335 if (node == 0)
return 0;
9343 return cond0(parser, node);
9349 if (!node)
return 1;
9370 if (node == 0)
return 0;
9377 rb_warn0(
"string literal in condition");
9387 node->nd_1st =
cond0(parser, node->nd_1st);
9388 node->nd_2nd =
cond0(parser, node->nd_2nd);
9393 node->nd_beg =
range_op(parser, node->nd_beg);
9394 node->nd_end =
range_op(parser, node->nd_end);
9427 if (node == 0)
return 0;
9428 return cond0(parser, node);
9436 NODE *node = left, *second;
9437 while ((second = node->nd_2nd) != 0 && (
enum node_type)
nd_type(second) == type) {
9440 node->nd_2nd =
NEW_NODE(type, second, right, 0);
9443 return NEW_NODE(type, left, right, 0);
9460 if (node->nd_next == 0) {
9461 node = node->nd_head;
9482 switch (
TYPE(node->nd_lit)) {
9504 rb_bug(
"unknown literal type passed to negate_lit");
9514 node2->nd_head = node1;
9528 args->
pre_init = m ? m->nd_next : 0;
9565 kw_rest_arg->nd_cflag =
check;
9606 ID vid = lhs->nd_vid;
9608 lhs->nd_value = rhs;
9615 lhs->nd_value = rhs;
9669 return dispatch3(opassign, lhs, op, rhs);
9675 VALUE recv = dispatch3(field, lhs, type, attr);
9676 return dispatch3(opassign, recv, op, rhs);
9686 if (!local->
used)
return;
9690 if (cnt != local->
vars->
pos) {
9691 rb_bug(
"local->used->pos != local->vars->pos");
9693 for (i = 0; i <
cnt; ++
i) {
9694 if (!v[i] || (u[i] &
LVAR_USED))
continue;
9709 local->
used = !(inherit_dvars &&
9738 int cnt = cnt_args + cnt_vars;
9742 if (cnt <= 0)
return 0;
9746 for (i = 0, j = cnt_args+1; i < cnt_vars; ++
i) {
9787 if (used) used = used->
prev;
9803 static const struct vtable *
9819 if ((tmp =
lvtbl->used) != 0) {
9835 while (
lvtbl->args != lvargs) {
9873 if (used) used = used->
prev;
9926 "regexp encoding option '%c' differs from source encoding '%s'",
9954 int back_num,
int *back_refs,
OnigRegex regex,
void *arg0)
9959 long len = name_end -
name;
9960 const char *s = (
const char *)name;
9977 rb_warningS(
"named capture conflicts a local variable - %s",
10057 NODE *scope = node;
10060 if (!node)
return node;
10064 node = node->nd_body;
10068 node = node->nd_body;
10075 prelude->nd_body = node;
10076 scope->nd_body = prelude;
10079 scope->nd_body = node;
10089 NODE *scope = node;
10092 if (!node)
return node;
10096 node = node->nd_body;
10100 node = node->nd_body;
10116 prelude->nd_body = node;
10117 scope->nd_body = prelude;
10120 scope->nd_body = node;
10126 static const struct {
10151 #define op_tbl_count numberof(op_tbl)
10153 #ifndef ENABLE_SELECTOR_NAMESPACE
10154 #define ENABLE_SELECTOR_NAMESPACE 0
10161 #if ENABLE_SELECTOR_NAMESPACE
10174 #if ENABLE_SELECTOR_NAMESPACE
10181 ivar2_cmp(
struct ivar2_key *key1,
struct ivar2_key *key2)
10183 if (key1->id == key2->id && key1->klass == key2->klass) {
10190 ivar2_hash(
struct ivar2_key *
key)
10192 return (key->id << 8) ^ (key->klass >> 2);
10206 #if ENABLE_SELECTOR_NAMESPACE
10214 (
void)lex_state_name(-1);
10247 if (m >= e)
return 0;
10251 else if (*m ==
'-') {
10252 if (++m >= e)
return 0;
10265 return m == e ? mb + 1 : 0;
10280 #define IDSET_ATTRSET_FOR_SYNTAX ((1U<<ID_LOCAL)|(1U<<ID_CONST))
10281 #define IDSET_ATTRSET_FOR_INTERN (~(~0U<<ID_SCOPE_MASK) & ~(1U<<ID_ATTRSET))
10286 const char *m =
name;
10287 const char *e = m +
len;
10290 if (!m || len <= 0)
return -1;
10310 case '<': ++
m;
break;
10311 case '=':
if (*++m ==
'>') ++
m;
break;
10318 case '>':
case '=': ++
m;
break;
10324 case '~': ++
m;
break;
10325 case '=':
if (*++m ==
'=') ++
m;
break;
10326 default:
return -1;
10331 if (*++m ==
'*') ++
m;
10334 case '+':
case '-':
10335 if (*++m ==
'@') ++
m;
10338 case '|':
case '^':
case '&':
case '/':
case '%':
case '~':
case '`':
10343 if (*++m !=
']')
return -1;
10344 if (*++m ==
'=') ++
m;
10348 if (len == 1)
return ID_JUNK;
10350 case '=':
case '~': ++
m;
break;
10351 default:
return -1;
10363 case '!':
case '?':
10369 if (!(allowed_attrset & (1
U << type)))
return -1;
10376 return m == e ? type : -1;
10444 fake_str->
as.
heap.ptr = (
char *)name;
10446 return (
VALUE)fake_str;
10468 const char *
name, *
m, *
e;
10490 if (len < 2)
goto junk;
10499 if (len < 3)
goto junk;
10504 if (len < 2)
goto junk;
10520 if (*
op_tbl[i].name == *m &&
10521 strcmp(
op_tbl[i].name, m) == 0) {
10529 if (name[last] ==
'=') {
10531 if (last > 1 && name[last-1] ==
'=')
10541 else if (
id == 0) {
10613 name[0] = (char)
id;
10624 if (
op_tbl[i].token ==
id) {
10640 if (
RBASIC(str)->klass == 0)
10646 ID id_stem = (
id & ~ID_SCOPE_MASK);
10663 if (
RBASIC(str)->klass == 0)
10676 if (!str)
return 0;
10770 VALUE name = *namep;
10821 fake_str.
as.
heap.len = len - 1;
10921 parser->delayed =
Qnil;
10923 parser->result =
Qnil;
10924 parser->parsing_thread =
Qnil;
10925 parser->toplevel_p =
TRUE;
10934 #define parser_mark ripper_parser_mark
10935 #define parser_free ripper_parser_free
10975 prev = local->
prev;
10986 size_t size =
sizeof(*p);
10988 if (!ptr)
return 0;
10991 size +=
sizeof(*local);
11012 #undef rb_reserved_word
11101 #define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
11102 #define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0)
11103 #define ADD2HEAP(n, c, p) ((parser->heap = (n))->u1.node = (p), \
11104 (n)->u3.cnt = (c), (p))
11109 size_t cnt =
HEAPCNT(1, size);
11119 size_t cnt =
HEAPCNT(nelem, size);
11121 void *ptr =
xcalloc(nelem, size);
11130 size_t cnt =
HEAPCNT(1, size);
11132 if (ptr && (n = parser->
heap) !=
NULL) {
11134 if (n->
u1.
node == ptr) {
11151 while ((n = *prev) !=
NULL) {
11152 if (n->
u1.
node == ptr) {
11165 #ifdef RIPPER_DEBUG
11166 extern int rb_is_pointer_to_heap(
VALUE);
11172 if (x ==
Qfalse)
return x;
11173 if (x ==
Qtrue)
return x;
11174 if (x ==
Qnil)
return x;
11179 if (!rb_is_pointer_to_heap(x))
11194 return ((
NODE *)x)->nd_rval;
11203 #define validate(x) ((x) = get_value(x))
11215 return rb_funcall(parser->value, mid, 1, a);
11223 return rb_funcall(parser->value, mid, 2, a, b);
11232 return rb_funcall(parser->value, mid, 3, a, b, c);
11242 return rb_funcall(parser->value, mid, 4, a, b, c, d);
11253 return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
11266 return rb_funcall(parser->value, mid, 7, a, b, c, d, e, f, g);
11269 static const struct kw_assoc {
11272 } keyword_to_name[] = {
11325 keyword_id_to_str(
ID id)
11327 const struct kw_assoc *
a;
11329 for (a = keyword_to_name; a->id; a++) {
11336 #undef ripper_id2sym
11338 ripper_id2sym(
ID id)
11348 if ((name = keyword_id_to_str(
id))) {
11361 rb_bug(
"cannot convert ID to string: %ld", (
unsigned long)
id);
11369 ripper_get_id(
VALUE v)
11379 ripper_get_value(
VALUE v)
11386 return nd->nd_rval;
11395 va_start(args, fmt);
11402 ripper_warn0(
struct parser_params *parser,
const char *fmt)
11408 ripper_warnI(
struct parser_params *parser,
const char *fmt,
int a)
11415 ripper_warnS(
struct parser_params *parser,
const char *fmt,
const char *str)
11422 ripper_warning0(
struct parser_params *parser,
const char *fmt)
11428 ripper_warningS(
struct parser_params *parser,
const char *fmt,
const char *str)
11453 #define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
11472 rb_scan_args(argc, argv,
"12", &src, &fname, &lineno);
11482 if (
NIL_P(fname)) {
11497 struct ripper_args {
11504 ripper_parse0(
VALUE parser_v)
11510 ripper_yyparse((
void*)parser);
11511 return parser->result;
11515 ripper_ensure(
VALUE parser_v)
11520 parser->parsing_thread =
Qnil;
11531 ripper_parse(
VALUE self)
11536 if (!ripper_initialized_p(parser)) {
11539 if (!
NIL_P(parser->parsing_thread)) {
11546 rb_ensure(ripper_parse0,
self, ripper_ensure,
self);
11548 return parser->result;
11559 ripper_column(
VALUE self)
11565 if (!ripper_initialized_p(parser)) {
11568 if (
NIL_P(parser->parsing_thread))
return Qnil;
11580 ripper_filename(
VALUE self)
11585 if (!ripper_initialized_p(parser)) {
11599 ripper_lineno(
VALUE self)
11604 if (!ripper_initialized_p(parser)) {
11607 if (
NIL_P(parser->parsing_thread))
return Qnil;
11611 #ifdef RIPPER_DEBUG
11647 InitVM_ripper(
void)
11664 #ifdef RIPPER_DEBUG
#define rb_enc_islower(c, enc)
char * parser_ruby_sourcefile
#define RB_TYPE_P(obj, type)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
#define NEW_ARGSCAT(a, b)
VALUE rb_const_get_at(VALUE, ID)
struct local_vars * parser_lvtbl
VALUE rb_ary_unshift(VALUE ary, VALUE item)
static ID ripper_token2eventid(int tok)
int rb_is_attrset_id(ID id)
int rb_enc_codelen(int c, rb_encoding *enc)
static NODE * remove_begin_all(NODE *)
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)
void rb_enc_copy(VALUE obj1, VALUE obj2)
void rb_mark_tbl(struct st_table *)
int rb_is_class_name(VALUE name)
NODE * rb_parser_compile_file(volatile VALUE vparser, const char *f, VALUE file, int start)
static int comment_at_top(struct parser_params *parser)
#define rb_gc_mark_locations(start, end)
size_t strlen(const char *)
static size_t parser_memsize(const void *ptr)
VALUE parser_lex_nextline
VALUE rb_make_exception(int argc, VALUE *argv)
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 void fixpos(NODE *, NODE *)
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)
VALUE rb_str_buf_append(VALUE, VALUE)
struct RString::@95::@96 heap
static ID shadowing_lvar_gen(struct parser_params *, ID)
#define set_number_literal(v, t, f)
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 NEW_OP_CDECL(v, op, val)
VALUE rb_rational_new(VALUE, VALUE)
#define IS_lex_state_for(x, ls)
rb_funcall(memo->yielder, id_lshift, 1, rb_assoc_new(memo->prev_value, memo->prev_elts))
SSL_METHOD *(* func)(void)
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 *)
RUBY_EXTERN void * memmove(void *, const void *, size_t)
static struct symbols global_symbols
VALUE rb_parser_end_seen_p(VALUE vparser)
static int literal_concat0(struct parser_params *, VALUE, VALUE)
#define reg_named_capture_assign(regexp, match)
struct token_info token_info
stack_type parser_cmdarg_stack
static NODE * parser_compile_string(volatile VALUE vparser, VALUE fname, VALUE s, int line)
static void rb_backref_error_gen(struct parser_params *, NODE *)
#define assignable(id, node)
VALUE rb_enc_from_encoding(rb_encoding *encoding)
static NODE * block_append_gen(struct parser_params *, NODE *, NODE *)
#define token_info_push(token)
#define IDSET_ATTRSET_FOR_SYNTAX
#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)
VALUE rb_ary_push(VALUE ary, VALUE item)
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)
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
#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 *)
#define warn_balanced(op, syn)
#define set_yylval_str(x)
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 *)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
void rb_compile_warn(const char *file, int line, const char *fmt,...)
static NODE * range_op(struct parser_params *parser, NODE *node)
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
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
static void parser_pushback(struct parser_params *parser, int c)
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)
static int parser_whole_match_p(struct parser_params *parser, const char *eos, long len, int indent)
VALUE rb_int_positive_pow(long x, unsigned long y)
#define NEW_OP_ASGN_OR(i, val)
static void parser_initialize(struct parser_params *parser)
#define ENCODING_IS_ASCII8BIT(obj)
static VALUE parse(int argc, VALUE *argv, VALUE self)
static void local_pop_gen(struct parser_params *)
ID rb_check_id(volatile VALUE *namep)
Returns ID for the given name if it is interned already, or 0.
#define STR_NEW3(p, n, e, func)
ID rb_check_id_cstr(const char *ptr, long len, rb_encoding *enc)
#define whole_match_p(e, l, i)
rb_encoding * rb_utf8_encoding(void)
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)
#define ENC_CODERANGE_BROKEN
VALUE rb_sym_all_symbols(void)
static VALUE lex_getline(struct parser_params *parser)
VALUE rb_str_new_frozen(VALUE)
#define RUBY_DTRACE_PARSE_BEGIN(arg0, arg1)
VALUE parser_ruby_sourcefile_string
#define NEW_CLASS(n, b, s)
#define reg_fragment_setenc(str, options)
int rb_enc_symname2_p(const char *name, long len, rb_encoding *enc)
static NODE * yycompile(struct parser_params *parser, VALUE fname, int line)
#define node_assign(node1, node2)
static int local_var_gen(struct parser_params *, ID)
VALUE rb_parser_set_yydebug(VALUE self, VALUE flag)
#define dvar_defined_get(id)
#define NEW_PRELUDE(p, b)
#define ruby_sourcefile_string
#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()
int rb_is_const_id(ID id)
#define block_dup_check(n1, n2)
int rb_is_instance_id(ID id)
#define RUBY_DTRACE_PARSE_END(arg0, arg1)
static void local_push_gen(struct parser_params *, int)
static int parser_number_literal_suffix(struct parser_params *parser, int mask)
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 **)
int rb_is_method_name(VALUE name)
static VALUE coverage(VALUE fname, int n)
#define NEW_OP_ASGN_AND(i, val)
static int parser_regx_options(struct parser_params *)
#define reg_fragment_check(str, options)
enum lex_state_e parser_lex_state
#define IS_LABEL_POSSIBLE()
VALUE parser_lex_lastline
#define lex_goto_eol(parser)
NODE * rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int line)
static ID * local_tbl_gen(struct parser_params *)
static int parser_yylex(struct parser_params *parser)
static VALUE parser_str_new(const char *p, long n, rb_encoding *enc, int func, rb_encoding *enc0)
#define scan_hex(s, l, e)
#define rb_intern_str(string)
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)
#define TypedData_Get_Struct(obj, type, data_type, sval)
void rb_compile_error_append(const char *fmt,...)
void rb_compile_error_with_enc(const char *file, int line, void *enc, const char *fmt,...)
static void parser_free(void *ptr)
static int parse_numvar(struct parser_params *parser)
#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)
VALUE rb_parser_encoding(VALUE vparser)
static void vtable_free(struct vtable *tbl)
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
NODE * rb_compile_string(const char *f, VALUE s, int line)
static struct vtable * vtable_alloc(struct vtable *prev)
#define RARRAY_AREF(a, i)
#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 *name, VALUE super)
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)
static struct st_hash_type symhash
#define parser_warning(node, mesg)
static void parser_tokadd(struct parser_params *parser, int c)
static void parser_mark(void *ptr)
#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)
NODE * rb_parser_append_print(VALUE vparser, NODE *node)
#define nd_set_line(n, l)
static void ripper_init_eventids1(void)
#define parser_precise_mbclen()
#define list_concat(h, t)
#define NEW_ARGS_AUX(r, b)
#define TypedData_Wrap_Struct(klass, data_type, sval)
#define rb_warningS(fmt, a)
static VALUE lex_get_str(struct parser_params *parser, VALUE s)
#define RUBY_FUNC_EXPORTED
#define literal_concat(h, t)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_suppress_tracing(VALUE(*func)(VALUE), VALUE arg)
VALUE rb_enc_associate_index(VALUE obj, int idx)
int rb_parse_in_main(void)
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)
NODE * rb_parser_while_loop(VALUE vparser, NODE *node, int chop, int split)
NODE * rb_compile_cstr(const char *f, const char *s, int len, int line)
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)
void * rb_parser_malloc(struct parser_params *parser, size_t size)
static VALUE setup_fake_str(struct RString *fake_str, const char *name, long len)
static int parser_peek_variable_name(struct parser_params *parser)
static NODE * splat_array(NODE *)
#define NEW_LASGN(v, val)
static VALUE yycompile0(VALUE arg)
VALUE rb_obj_as_string(VALUE)
#define NEW_OPT_ARG(i, v)
#define heredoc_identifier()
static int value_expr_gen(struct parser_params *, NODE *)
int rb_dvar_defined(ID id)
static void dispose_string(VALUE str)
VALUE rb_str_resize(VALUE, long)
int st_foreach(st_table *, int(*)(ANYARGS), st_data_t)
#define RUBY_DTRACE_PARSE_END_ENABLED()
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)
#define rb_rational_raw1(x)
int rb_symname_p(const char *name)
VALUE rb_thread_current(void)
static int shadowing_lvar_0(struct parser_params *parser, ID name)
mlhs_head tSTAR mlhs_node
#define token_info_pop(token)
#define rb_ascii8bit_encindex()
VALUE rb_range_new(VALUE, VALUE, int)
VALUE rb_sprintf(const char *format,...)
#define rb_enc_mbcput(c, buf, enc)
#define rb_node_newnode(type, a1, a2, a3)
static void vtable_add(struct vtable *tbl, ID id)
#define RUBY_TYPED_FREE_IMMEDIATELY
keyword_super command_args
static void set_file_encoding(struct parser_params *parser, const char *str, const char *send)
int rb_is_attrset_name(VALUE name)
#define NEW_DASGN(v, val)
int rb_enc_symname_p(const char *name, rb_encoding *enc)
#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 int parser_parse_string(struct parser_params *, NODE *)
#define tokadd_string(f, t, p, n, e)
int rb_is_local_id(ID id)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static NODE * new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs)
VALUE rb_assoc_new(VALUE car, VALUE cdr)
#define RE_OPTION_ENCODING_IDX(o)
static void Init_id(void)
rb_encoding * rb_usascii_encoding(void)
#define new_args(f, o, r, p, t)
#define set_integer_literal(v, f)
void rb_gc_mark_symbols(int full_mark)
static void arg_ambiguous_gen(struct parser_params *parser)
#define RBASIC_SET_CLASS_RAW(obj, cls)
static void parser_prepare(struct parser_params *parser)
#define reg_compile(str, options)
static int rb_enc_symname_type(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset)
#define rb_reserved_word(str, len)
#define NEW_UNTIL(c, b, n)
#define NEW_MATCH3(r, n2)
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)
rb_hash_aset(hash, RARRAY_AREF(key_value_pair, 0), RARRAY_AREF(key_value_pair, 1))
static int rb_str_symname_type(VALUE name, unsigned int allowed_attrset)
int rb_is_global_id(ID id)
#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)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
#define NEW_RESBODY(a, ex, n)
static struct @92 op_tbl[]
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
#define new_defined(expr)
static NODE * negate_lit(NODE *)
static int is_global_name_punct(const int c)
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
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)
int rb_is_const_name(VALUE name)
static void parser_tokaddmbc(struct parser_params *parser, int c, rb_encoding *enc)
int rb_is_local_name(VALUE name)
static NODE * literal_concat_gen(struct parser_params *, NODE *, NODE *)
unsigned long ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *overflow)
VALUE rb_str_cat(VALUE, const char *, long)
#define ENC_CODERANGE_7BIT
rb_encoding * rb_enc_get(VALUE obj)
#define NEW_WHILE(c, b, n)
#define NEW_DEFS(r, i, a, d)
void rb_gc_mark_parser(void)
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 *)
void rb_parser_free(struct parser_params *parser, void *ptr)
static struct magic_comment magic_comments[]
#define match_op(node1, node2)
static NODE * arg_concat_gen(struct parser_params *, NODE *, NODE *)
#define call_uni_op(recv, id)
void rb_set_errinfo(VALUE err)
#define rb_enc_isspace(c, enc)
NODE * parser_lex_strterm
#define RE_OPTION_ENCODING_NONE(o)
top_stmts dispatch0(stmts_new)
#define RUBY_DTRACE_SYMBOL_CREATE_ENABLED()
#define NEW_ATTRASGN(r, m, a)
VALUE rb_complex_raw(VALUE x, VALUE y)
static int token_info_get_column(struct parser_params *parser, const char *token)
#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)
static int parser_set_integer_literal(struct parser_params *parser, VALUE v, int suffix)
#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 *)
struct rb_encoding_entry * list
void * rb_parser_calloc(struct parser_params *parser, size_t nelem, size_t size)
#define STRNCASECMP(s1, s2, n)
VALUE rb_make_backtrace(void)
#define RE_OPTION_ENCODING(e)
#define rb_backref_error(n)
#define shadowing_lvar(name)
#define ADD2HEAP(n, c, p)
static const char * magic_comment_marker(const char *str, long len)
#define NEW_OP_ASGN1(p, id, a)
static NODE * list_concat_gen(struct parser_params *, NODE *, NODE *)
static int parser_magic_comment(struct parser_params *parser, const char *str, long len)
#define is_instance_id(id)
#define RUBY_DTRACE_SYMBOL_CREATE(arg0, arg1, arg2)
#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_is_class_id(ID id)
VALUE rb_parser_new(void)
struct parser_params * parser
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 rb_is_instance_name(VALUE name)
int parser_ruby_sourceline
const char * rb_id2name(ID id)
VALUE rb_str_intern(VALUE)
#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 RBASIC_CLEAR_CLASS(obj)
#define rb_enc_isascii(c, enc)
static struct vtable * dyna_push_gen(struct parser_params *)
int rb_str_hash_cmp(VALUE, VALUE)
NODE * rb_parser_compile_string_path(volatile VALUE vparser, VALUE f, VALUE s, int line)
static NODE * cond0(struct parser_params *, NODE *)
rb_encoding * rb_ascii8bit_encoding(void)
int rb_is_junk_name(VALUE name)
static int vtable_size(const struct vtable *tbl)
int rb_enc_find_index(const char *name)
static NODE * new_evstr_gen(struct parser_params *, NODE *)
RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e-0x20+31)/32]
#define RSTRING_GETMEM(str, ptrvar, lenvar)
static NODE * new_args_tail_gen(struct parser_params *, NODE *, ID, ID)
#define is_attrset_id(id)
ID rb_intern3(const char *name, long len, rb_encoding *enc)
#define IDSET_ATTRSET_FOR_INTERN
expr expr keyword_or expr
#define NEW_DEFN(i, a, d, p)
#define RARRAY_ASET(a, i, v)
void * rb_parser_realloc(struct parser_params *parser, void *ptr, size_t size)
st_table * st_init_numtable_with_size(st_index_t)
VALUE rb_cstr_to_inum(const char *str, int base, int badcheck)
static int parser_set_number_literal(struct parser_params *parser, VALUE v, int type, int suffix)
#define number_literal_suffix(f)
int rb_parse_in_eval(void)
#define ENCODING_SET(obj, i)
int rb_memcicmp(const void *, const void *, long)
VALUE rb_filesystem_str_new_cstr(const char *)
ID rb_intern2(const char *name, long len)
NODE * rb_compile_file(const char *f, VALUE file, int start)
static int is_special_global_name(const char *m, const char *e, rb_encoding *enc)
VALUE rb_parser_get_yydebug(VALUE self)
VALUE(* parser_lex_gets)(struct parser_params *, VALUE)
#define IS_LABEL_SUFFIX(n)
#define rb_enc_isalpha(c, enc)
static VALUE debug_lines(VALUE fname)
NODE * rb_parser_compile_cstr(volatile VALUE vparser, const char *f, const char *s, int len, int line)
VALUE rb_check_string_type(VALUE)
#define REALLOC_N(var, type, n)
#define NEW_STRTERM(func, term, paren)
#define set_yylval_node(x)
static struct kwtable * reserved_word(const char *, unsigned int)
int rb_enc_str_coderange(VALUE)
int rb_local_defined(ID id)
NODE * parser_eval_tree_begin
static int match(VALUE str, VALUE pat, VALUE hash, int(*cb)(VALUE, VALUE))
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define flush_string_content(enc)
static void warn_unless_e_option(struct parser_params *parser, NODE *node, const char *str)
#define ruby_eval_tree_begin
NODE * rb_parser_compile_file_path(volatile VALUE vparser, VALUE fname, VALUE file, int start)
static ID formal_argument_gen(struct parser_params *, ID)
#define RTYPEDDATA_TYPE(v)
unsigned long ruby_scan_oct(const char *, size_t, size_t *)
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)
rb_encoding * rb_enc_from_index(int index)
#define mixed_error(enc1, enc2)
#define NEW_BLOCK_PASS(b)
static ID register_symid_str(ID, VALUE)
int rb_is_global_name(VALUE name)
static int parser_tokadd_mbchar(struct parser_params *parser, int c)