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++) {
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 ruby_sourcefile_string (parser->parser_ruby_sourcefile_string)
343 #define current_enc (parser->enc)
344 #define yydebug (parser->parser_yydebug)
347 #define ruby_eval_tree (parser->parser_eval_tree)
348 #define ruby_eval_tree_begin (parser->parser_eval_tree_begin)
349 #define ruby_debug_lines (parser->debug_lines)
350 #define ruby_coverage (parser->coverage)
354 static int yylex(
void*,
void*);
356 static int yylex(
void*);
360 #define yyparse ruby_yyparse
363 #define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3))
366 #define cond(node) cond_gen(parser, (node))
368 #define logop(type,node1,node2) logop_gen(parser, (type), (node1), (node2))
376 #define value_expr(node) value_expr_gen(parser, (node) = remove_begin(node))
377 #define void_expr0(node) void_expr_gen(parser, (node))
378 #define void_expr(node) void_expr0((node) = remove_begin(node))
380 #define void_stmts(node) void_stmts_gen(parser, (node))
382 #define reduce_nodes(n) reduce_nodes_gen(parser,(n))
384 #define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2))
387 #define block_append(h,t) block_append_gen(parser,(h),(t))
389 #define list_append(l,i) list_append_gen(parser,(l),(i))
391 #define list_concat(h,t) list_concat_gen(parser,(h),(t))
393 #define arg_append(h,t) arg_append_gen(parser,(h),(t))
395 #define arg_concat(h,t) arg_concat_gen(parser,(h),(t))
397 #define literal_concat(h,t) literal_concat_gen(parser,(h),(t))
400 #define new_evstr(n) new_evstr_gen(parser,(n))
402 #define evstr2dstr(n) evstr2dstr_gen(parser,(n))
406 #define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, (recv),(id),(arg1))
408 #define call_uni_op(recv,id) call_uni_op_gen(parser, (recv),(id))
411 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
413 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
417 #define ret_args(node) ret_args_gen(parser, (node))
420 #define new_yield(node) new_yield_gen(parser, (node))
422 #define dsym_node(node) dsym_node_gen(parser, (node))
425 #define gettable(id) gettable_gen(parser,(id))
427 #define assignable(id,node) assignable_gen(parser, (id), (node))
430 #define aryset(node1,node2) aryset_gen(parser, (node1), (node2))
432 #define attrset(node,id) attrset_gen(parser, (node), (id))
435 #define rb_backref_error(n) rb_backref_error_gen(parser,(n))
437 #define node_assign(node1, node2) node_assign_gen(parser, (node1), (node2))
441 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (attr), (op), (rhs))
443 #define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs))
446 #define match_op(node1,node2) match_op_gen(parser, (node1), (node2))
449 #define local_tbl() local_tbl_gen(parser)
454 #define reg_compile(str,options) reg_compile_gen(parser, (str), (options))
456 #define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options))
458 #define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options))
460 #define reg_named_capture_assign(regexp,match) reg_named_capture_assign_gen(parser,(regexp),(match))
462 #define get_id(id) (id)
463 #define get_value(val) (val)
465 #define value_expr(node) ((void)(node))
466 #define remove_begin(node) (node)
467 #define rb_dvar_defined(id) 0
468 #define rb_local_defined(id) 0
470 #define get_id(id) ripper_get_id(id)
472 #define get_value(val) ripper_get_value(val)
474 #define assignable(lhs,node) assignable_gen(parser, (lhs))
476 #define id_is_var(id) id_is_var_gen(parser, (id))
478 #define node_assign(node1, node2) dispatch2(assign, (node1), (node2))
482 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
486 #define new_op_assign(lhs, op, rhs) new_op_assign_gen(parser, (lhs), (op), (rhs))
489 #define formal_argument(id) formal_argument_gen(parser, (id))
491 #define shadowing_lvar(name) shadowing_lvar_gen(parser, (name))
493 #define new_bv(id) new_bv_gen(parser, (id))
496 #define local_push(top) local_push_gen(parser,(top))
498 #define local_pop() local_pop_gen(parser)
500 #define local_var(id) local_var_gen(parser, (id))
502 #define arg_var(id) arg_var_gen(parser, (id))
504 #define local_id(id) local_id_gen(parser, (id))
506 #define internal_id() internal_id_gen(parser)
509 #define dyna_push() dyna_push_gen(parser)
511 #define dyna_pop(node) dyna_pop_gen(parser, (node))
513 #define dyna_in_block() dyna_in_block_gen(parser)
514 #define dyna_var(id) local_var(id)
516 #define dvar_defined(id) dvar_defined_gen(parser, (id), 0)
517 #define dvar_defined_get(id) dvar_defined_gen(parser, (id), 1)
519 #define dvar_curr(id) dvar_curr_gen(parser, (id))
522 #define lvar_defined(id) lvar_defined_gen(parser, (id))
524 #define RE_OPTION_ONCE (1<<16)
525 #define RE_OPTION_ENCODING_SHIFT 8
526 #define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
527 #define RE_OPTION_ENCODING_IDX(o) (((o)>>RE_OPTION_ENCODING_SHIFT)&0xff)
528 #define RE_OPTION_ENCODING_NONE(o) ((o)&RE_OPTION_ARG_ENCODING_NONE)
529 #define RE_OPTION_MASK 0xff
530 #define RE_OPTION_ARG_ENCODING_NONE 32
532 #define NODE_STRTERM NODE_ZARRAY
533 #define NODE_HEREDOC NODE_ARRAY
534 #define SIGN_EXTEND(x,n) (((1<<(n)-1)^((x)&~(~0<<(n))))-(1<<(n)-1))
535 #define nd_func u1.id
536 #if SIZEOF_SHORT == 2
537 #define nd_term(node) ((signed short)(node)->u2.id)
539 #define nd_term(node) SIGN_EXTEND((node)->u2.id, CHAR_BIT*2)
541 #define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2)
542 #define nd_nest u3.cnt
547 #define RIPPER_VERSION "0.1.0"
560 #define dispatch0(n) ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
561 #define dispatch1(n,a) ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), (a))
562 #define dispatch2(n,a,b) ripper_dispatch2(parser, TOKEN_PASTE(ripper_id_, n), (a), (b))
563 #define dispatch3(n,a,b,c) ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
564 #define dispatch4(n,a,b,c,d) ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
565 #define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
566 #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))
568 #define yyparse ripper_yyparse
570 #define ripper_intern(s) ID2SYM(rb_intern(s))
571 static VALUE ripper_id2sym(
ID);
573 #define ripper_id2sym(id) ((id) < 256 && rb_ispunct(id) ? \
574 ID2SYM(id) : ripper_id2sym(id))
577 #define arg_new() dispatch0(args_new)
578 #define arg_add(l,a) dispatch2(args_add, (l), (a))
579 #define arg_add_star(l,a) dispatch2(args_add_star, (l), (a))
580 #define arg_add_block(l,b) dispatch2(args_add_block, (l), (b))
581 #define arg_add_optblock(l,b) ((b)==Qundef? (l) : dispatch2(args_add_block, (l), (b)))
582 #define bare_assoc(v) dispatch1(bare_assoc_hash, (v))
583 #define arg_add_assocs(l,b) arg_add((l), bare_assoc(b))
585 #define args2mrhs(a) dispatch1(mrhs_new_from_args, (a))
586 #define mrhs_new() dispatch0(mrhs_new)
587 #define mrhs_add(l,a) dispatch2(mrhs_add, (l), (a))
588 #define mrhs_add_star(l,a) dispatch2(mrhs_add_star, (l), (a))
590 #define mlhs_new() dispatch0(mlhs_new)
591 #define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
592 #define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
594 #define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
595 dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
597 #define blockvar_new(p,v) dispatch2(block_var, (p), (v))
598 #define blockvar_add_star(l,a) dispatch2(block_var_add_star, (l), (a))
599 #define blockvar_add_block(l,a) dispatch2(block_var_add_block, (l), (a))
601 #define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
602 #define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
603 #define method_add_block(m,b) dispatch2(method_add_block, (m), (b))
605 #define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
614 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
621 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
629 # define ifndef_ripper(x) (x)
632 # define ifndef_ripper(x)
636 # define rb_warn0(fmt) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt))
637 # define rb_warnI(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
638 # define rb_warnS(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
639 # define rb_warn4S(file,line,fmt,a) rb_compile_warn((file), (line), (fmt), (a))
640 # define rb_warning0(fmt) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt))
641 # define rb_warningS(fmt,a) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt), (a))
643 # define rb_warn0(fmt) ripper_warn0(parser, (fmt))
644 # define rb_warnI(fmt,a) ripper_warnI(parser, (fmt), (a))
645 # define rb_warnS(fmt,a) ripper_warnS(parser, (fmt), (a))
646 # define rb_warn4S(file,line,fmt,a) ripper_warnS(parser, (fmt), (a))
647 # define rb_warning0(fmt) ripper_warning0(parser, (fmt))
648 # define rb_warningS(fmt,a) ripper_warningS(parser, (fmt), (a))
649 static void ripper_warn0(
struct parser_params*,
const char*);
650 static void ripper_warnI(
struct parser_params*,
const char*,
int);
651 static void ripper_warnS(
struct parser_params*,
const char*,
const char*);
652 static void ripper_warning0(
struct parser_params*,
const char*);
653 static void ripper_warningS(
struct parser_params*,
const char*,
const char*);
657 static void ripper_compile_error(
struct parser_params*,
const char *
fmt, ...);
658 # define rb_compile_error ripper_compile_error
659 # define compile_error ripper_compile_error
660 # define PARSER_ARG parser,
662 # define rb_compile_error rb_compile_error_with_enc
663 # define compile_error parser->nerr++,rb_compile_error_with_enc
664 # define PARSER_ARG ruby_sourcefile, ruby_sourceline, current_enc,
672 #define YYMAXDEPTH 10000
679 #define token_info_push(token) (RTEST(ruby_verbose) ? token_info_push(parser, (token)) : (void)0)
680 #define token_info_pop(token) (RTEST(ruby_verbose) ? token_info_pop(parser, (token)) : (void)0)
682 #define token_info_push(token)
683 #define token_info_pop(token)
759 %type <val> singleton strings
string string1 xstring regexp
760 %type <val> string_contents xstring_contents regexp_contents string_content
761 %type <val> words
symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
762 %type <val> literal numeric dsym cpath
763 %type <val> top_compstmt top_stmts
top_stmt
765 %type <val> expr_value arg_value primary_value fcall
766 %type <val> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
768 %type <val> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
769 %type <val>
command_args aref_args opt_block_arg block_arg var_ref var_lhs
770 %type <val> command_asgn mrhs superclass block_call block_command
771 %type <val> f_block_optarg f_block_opt
772 %type <val> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
773 %type <val> assoc_list assocs
assoc undef_list backref string_dvar for_var
774 %type <val> block_param opt_block_param block_param_def f_opt
775 %type <val> f_kwarg f_kw f_block_kwarg f_block_kw
776 %type <val> bv_decls opt_bv_decl bvar
777 %type <val> lambda f_larglist lambda_body
781 %type <val> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
785 %type <val> program reswords then
do dot_or_colon
871 while (node->nd_next) {
872 node = node->nd_next;
880 parser->result = dispatch1(program, $$);
886 top_compstmt : top_stmts opt_terms
902 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
919 $$ = dispatch2(stmts_add, $1, $3);
945 $$ = dispatch1(BEGIN, $4);
999 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
1008 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
1016 $$ = dispatch2(stmts_add, $1, $3);
1031 yyerror(
"BEGIN is permitted only at toplevel");
1037 '{' top_compstmt
'}'
1046 $$ = dispatch1(BEGIN, $4);
1055 $$ = dispatch2(
alias, $2, $4);
1063 $$ = dispatch2(var_alias, $2, $3);
1071 buf[1] = (char)$3->
nd_nth;
1074 $$ = dispatch2(var_alias, $2, $3);
1080 yyerror(
"can't make alias for the number variables");
1083 $$ = dispatch2(var_alias, $2, $3);
1084 $$ = dispatch1(alias_error, $$);
1092 $$ = dispatch1(undef, $2);
1101 $$ = dispatch2(if_mod, $3, $1);
1110 $$ = dispatch2(unless_mod, $3, $1);
1123 $$ = dispatch2(while_mod, $3, $1);
1136 $$ = dispatch2(until_mod, $3, $1);
1145 $$ = dispatch2(rescue_mod, $1, $3);
1151 rb_warn0(
"END in method; use at_exit");
1157 $$ = dispatch1(
END, $3);
1168 $$ = dispatch2(massign, $1, $3);
1194 $$ = dispatch3(opassign, $$, $5, $6);
1213 $$ = dispatch2(const_path_field, $1, $3);
1214 $$ = dispatch3(opassign, $$, $4, $5);
1228 $$ = dispatch2(assign, dispatch1(var_field, $1), $3);
1229 $$ = dispatch1(assign_error, $$);
1238 $$ = dispatch2(assign, $1, $3);
1241 | mlhs
'=' arg_value
1247 $$ = dispatch2(massign, $1, $3);
1256 $$ = dispatch2(massign, $1, $3);
1268 $$ = dispatch2(assign, $1, $3);
1277 $$ = dispatch2(assign, $1, $3);
1313 $$ = dispatch2(unary, ripper_id2sym(
'!'), $2);
1335 block_command : block_call
1341 $$ = dispatch3(call, $1, $2, $3);
1342 $$ = method_arg($$, $4);
1385 $$ = dispatch2(command, $1, $2);
1397 $$ = dispatch2(command, $1, $2);
1398 $$ = method_add_block($$, $3);
1407 $$ = dispatch4(
command_call, $1, ripper_id2sym(
'.'), $3, $4);
1419 $$ = method_add_block($$, $5);
1440 $$ = method_add_block($$, $5);
1449 $$ = dispatch1(super, $2);
1458 $$ = dispatch1(yield, $2);
1466 $$ = dispatch1(
return, $2);
1474 $$ = dispatch1(
break, $2);
1482 $$ = dispatch1(next, $2);
1493 $$ = dispatch1(mlhs_paren, $2);
1504 $$ = dispatch1(mlhs_paren, $2);
1522 $$ = mlhs_add($1, $2);
1530 $$ = mlhs_add_star($1, $3);
1538 $1 = mlhs_add_star($1, $3);
1539 $$ = mlhs_add($1, $5);
1547 $$ = mlhs_add_star($1,
Qnil);
1555 $1 = mlhs_add_star($1,
Qnil);
1556 $$ = mlhs_add($1, $4);
1564 $$ = mlhs_add_star(mlhs_new(), $2);
1572 $2 = mlhs_add_star(mlhs_new(), $2);
1573 $$ = mlhs_add($2, $4);
1581 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1589 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1590 $$ = mlhs_add($$, $3);
1601 $$ = dispatch1(mlhs_paren, $2);
1611 $$ = mlhs_add(mlhs_new(), $1);
1619 $$ = mlhs_add($1, $2);
1629 $$ = mlhs_add(mlhs_new(), $1);
1637 $$ = mlhs_add($1, $3);
1650 | primary_value
'[' opt_call_args rbracket
1663 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1671 $$ = dispatch2(const_path_field, $1, $3);
1679 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1686 yyerror(
"dynamic constant assignment");
1690 yyerror(
"dynamic constant assignment");
1691 $$ = dispatch2(const_path_field, $1, $3);
1698 yyerror(
"dynamic constant assignment");
1701 $$ = dispatch1(top_const_field, $2);
1710 $$ = dispatch1(var_field, $1);
1711 $$ = dispatch1(assign_error, $$);
1722 $$ = dispatch1(var_field, $$);
1731 $$ = dispatch1(var_field, $$);
1734 | primary_value
'[' opt_call_args rbracket
1747 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1763 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1770 yyerror(
"dynamic constant assignment");
1773 $$ = dispatch2(const_path_field, $1, $3);
1775 $$ = dispatch1(assign_error, $$);
1783 yyerror(
"dynamic constant assignment");
1786 $$ = dispatch1(top_const_field, $2);
1788 $$ = dispatch1(assign_error, $$);
1798 $$ = dispatch1(assign_error, $1);
1806 yyerror(
"class/module name must be CONSTANT");
1808 $$ = dispatch1(class_name_error, $1);
1819 $$ = dispatch1(top_const_ref, $2);
1827 $$ = dispatch1(const_ref, $1);
1835 $$ = dispatch2(const_path_ref, $1, $3);
1868 $$ = dispatch1(symbol_literal, $1);
1882 | undef_list
',' {
lex_state = EXPR_FNAME;} fitem
1944 $$ = dispatch2(assign, $1, $3);
1954 $$ = dispatch2(assign, $1, dispatch2(rescue_mod, $3, $5));
1968 $3 = dispatch2(rescue_mod, $3, $5);
1972 | primary_value
'[' opt_call_args rbracket
tOP_ASGN arg
1995 $$ = dispatch3(opassign, $1, $5, $6);
2019 $$ = dispatch2(const_path_field, $1, $3);
2020 $$ = dispatch3(opassign, $$, $4, $5);
2029 $$ = dispatch1(top_const_field, $2);
2030 $$ = dispatch3(opassign, $$, $3, $4);
2039 $$ = dispatch1(var_field, $1);
2040 $$ = dispatch3(opassign, $$, $2, $3);
2041 $$ = dispatch1(assign_error, $$);
2055 $$ = dispatch2(dot2, $1, $3);
2069 $$ = dispatch2(dot3, $1, $3);
2077 $$ = dispatch3(binary, $1,
ID2SYM(
'+'), $3);
2085 $$ = dispatch3(binary, $1,
ID2SYM(
'-'), $3);
2093 $$ = dispatch3(binary, $1,
ID2SYM(
'*'), $3);
2101 $$ = dispatch3(binary, $1,
ID2SYM(
'/'), $3);
2109 $$ = dispatch3(binary, $1,
ID2SYM(
'%'), $3);
2159 $$ = dispatch3(binary, $1,
ID2SYM(
'|'), $3);
2167 $$ = dispatch3(binary, $1,
ID2SYM(
'^'), $3);
2175 $$ = dispatch3(binary, $1,
ID2SYM(
'&'), $3);
2191 $$ = dispatch3(binary, $1,
ID2SYM(
'>'), $3);
2207 $$ = dispatch3(binary, $1,
ID2SYM(
'<'), $3);
2266 $$ = dispatch2(unary,
ID2SYM(
'!'), $2);
2274 $$ = dispatch2(unary,
ID2SYM(
'~'), $2);
2316 $$ = dispatch1(defined, $4);
2326 $$ = dispatch3(ifop, $1, $3, $6);
2352 | args
',' assocs trailer
2357 $$ = arg_add_assocs($1, $3);
2365 $$ = arg_add_assocs(arg_new(), $1);
2370 paren_args :
'(' opt_call_args rparen
2380 opt_paren_args : none
2384 opt_call_args : none
2390 | args
',' assocs
','
2395 $$ = arg_add_assocs($1, $3);
2403 $$ = arg_add_assocs(arg_new(), $1);
2414 $$ = arg_add(arg_new(), $1);
2417 | args opt_block_arg
2422 $$ = arg_add_optblock($1, $2);
2425 | assocs opt_block_arg
2431 $$ = arg_add_assocs(arg_new(), $1);
2432 $$ = arg_add_optblock($$, $2);
2435 | args
',' assocs opt_block_arg
2441 $$ = arg_add_optblock(arg_add_assocs($1, $3), $4);
2448 $$ = arg_add_block(arg_new(), $1);
2465 block_arg :
tAMPER arg_value
2475 opt_block_arg :
',' block_arg
2490 $$ = arg_add(arg_new(), $1);
2498 $$ = arg_add_star(arg_new(), $2);
2501 | args
',' arg_value
2512 $$ = arg_add($1, $3);
2515 | args
',' tSTAR arg_value
2526 $$ = arg_add_star($1, $4);
2531 mrhs : args
',' arg_value
2542 $$ = mrhs_add(args2mrhs($1), $3);
2545 | args
',' tSTAR arg_value
2557 $$ = mrhs_add_star(args2mrhs($1), $4);
2565 $$ = mrhs_add_star(mrhs_new(), $2);
2585 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2613 $$ = dispatch1(begin, $3);
2621 $$ = dispatch1(paren, 0);
2635 $$ = dispatch1(paren, $3);
2643 $$ = dispatch1(paren, $2);
2651 $$ = dispatch2(const_path_ref, $1, $3);
2659 $$ = dispatch1(top_const_ref, $2);
2696 $$ = dispatch1(yield, dispatch1(paren, $3));
2704 $$ = dispatch1(yield, dispatch1(paren, arg_new()));
2722 $$ = dispatch1(defined, $5);
2747 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2748 $$ = method_add_block($$, $2);
2752 | method_call brace_block
2759 $$ = method_add_block($1, $2);
2766 | k_if expr_value then
2778 | k_unless expr_value then
2798 $$ = dispatch2(
while, $3, $6);
2809 $$ = dispatch2(until, $3, $6);
2812 | k_case expr_value opt_terms
2820 $$ = dispatch2(
case, $2, $4);
2823 | k_case opt_terms case_body k_end
2828 $$ = dispatch2(
case,
Qnil, $3);
2890 tbl[0] = 1; tbl[1] =
id;
2894 $$ = dispatch3(
for, $2, $5, $8);
2897 | k_class cpath superclass
2900 yyerror(
"class definition in method body");
2914 $$ = dispatch3(
class, $2, $3, $5);
2936 $$ = dispatch2(sclass, $3, $7);
2945 yyerror(
"module definition in method body");
2959 $$ = dispatch2(module, $2, $4);
2980 $$ = dispatch3(def, $2, $4, $5);
2986 | k_def singleton dot_or_colon {
lex_state = EXPR_FNAME;} fname
3002 $$ = dispatch5(defs, $2, $3, $5, $7, $8);
3012 $$ = dispatch1(
break, arg_new());
3020 $$ = dispatch1(next, arg_new());
3041 primary_value : primary
3164 $$ = dispatch1(
else, $2);
3178 $$ = dispatch1(mlhs_paren, $$);
3186 $$ = dispatch1(mlhs_paren, $2);
3191 f_marg_list : f_marg
3196 $$ = mlhs_add(mlhs_new(), $1);
3199 | f_marg_list
',' f_marg
3204 $$ = mlhs_add($1, $3);
3209 f_margs : f_marg_list
3217 | f_marg_list
',' tSTAR f_norm_arg
3223 $$ = mlhs_add_star($1, $$);
3226 | f_marg_list
',' tSTAR f_norm_arg
',' f_marg_list
3232 $$ = mlhs_add_star($1, $$);
3235 | f_marg_list
',' tSTAR
3240 $$ = mlhs_add_star($1,
Qnil);
3243 | f_marg_list
',' tSTAR ',' f_marg_list
3248 $$ = mlhs_add_star($1, $5);
3257 $$ = mlhs_add_star(mlhs_new(), $$);
3260 |
tSTAR f_norm_arg
',' f_marg_list
3269 $$ = mlhs_add_star($$, $4);
3277 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3280 |
tSTAR ',' f_marg_list
3285 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3291 block_args_tail : f_block_kwarg
',' f_kwrest opt_f_block_arg
3295 | f_block_kwarg opt_f_block_arg
3299 | f_kwrest opt_f_block_arg
3309 opt_block_args_tail :
',' block_args_tail
3319 block_param : f_arg
',' f_block_optarg
',' f_rest_arg opt_block_args_tail
3323 | f_arg
',' f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3327 | f_arg
',' f_block_optarg opt_block_args_tail
3331 | f_arg
',' f_block_optarg
',' f_arg opt_block_args_tail
3335 | f_arg
',' f_rest_arg opt_block_args_tail
3344 dispatch1(excessed_comma, $$);
3347 | f_arg
',' f_rest_arg
',' f_arg opt_block_args_tail
3351 | f_arg opt_block_args_tail
3355 | f_block_optarg
',' f_rest_arg opt_block_args_tail
3359 | f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3363 | f_block_optarg opt_block_args_tail
3367 | f_block_optarg
',' f_arg opt_block_args_tail
3371 | f_rest_arg opt_block_args_tail
3375 | f_rest_arg
',' f_arg opt_block_args_tail
3385 opt_block_param : none
3392 block_param_def :
'|' opt_bv_decl
'|'
3410 |
'|' block_param opt_bv_decl
'|'
3421 opt_bv_decl : opt_nl
3425 | opt_nl
';' bv_decls opt_nl
3483 $$ = dispatch2(lambda, $3, $5);
3489 f_larglist :
'(' f_args opt_bv_decl
')'
3494 $$ = dispatch1(paren, $2);
3538 block_call : command do_block
3551 $$ = method_add_block($1, $2);
3554 | block_call dot_or_colon operation2 opt_paren_args
3559 $$ = dispatch3(call, $1, $2, $3);
3560 $$ = method_optarg($$, $4);
3563 | block_call dot_or_colon operation2 opt_paren_args brace_block
3567 $5->nd_iter =
NEW_CALL($1, $3, $4);
3572 $$ = method_add_block($$, $5);
3575 | block_call dot_or_colon operation2
command_args do_block
3579 $5->nd_iter =
NEW_CALL($1, $3, $4);
3584 $$ = method_add_block($$, $5);
3589 method_call : fcall paren_args
3595 $$ = method_arg(dispatch1(fcall, $1), $2);
3598 | primary_value
'.' operation2
3610 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3611 $$ = method_optarg($$, $5);
3614 | primary_value
tCOLON2 operation2
3626 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3627 $$ = method_optarg($$, $5);
3630 | primary_value
tCOLON2 operation3
3650 $$ = dispatch3(call, $1, ripper_id2sym(
'.'),
3652 $$ = method_optarg($$, $4);
3669 $$ = method_optarg($$, $4);
3677 $$ = dispatch1(super, $2);
3688 | primary_value
'[' opt_call_args rbracket
3770 $$ = dispatch4(rescue,
3780 exc_list : arg_value
3811 $$ = dispatch1(ensure, $2);
3823 $$ = dispatch1(symbol_literal, $1);
3853 $$ = dispatch2(string_concat, $1, $2);
3863 $$ = dispatch1(string_literal, $2);
3890 $$ = dispatch1(xstring_literal, $2);
3923 for (list = (prev = node)->
nd_next;
list; list = list->nd_next) {
3925 VALUE tail = list->nd_head->nd_lit;
3927 VALUE lit = prev == node ? prev->nd_lit : prev->nd_head->nd_lit;
3933 prev->nd_next = list->nd_next;
3946 if (!node->nd_next) {
3955 $$ = dispatch2(regexp_literal, $2, $3);
3966 $$ = dispatch1(array, $$);
3974 $$ = dispatch1(array, $2);
3987 | word_list word
' '
3992 $$ = dispatch2(words_add, $1, $2);
3997 word : string_content
4002 $$ = dispatch2(word_add, $$, $1);
4005 | word string_content
4010 $$ = dispatch2(word_add, $1, $2);
4021 $$ = dispatch1(array, $$);
4029 $$ = dispatch1(array, $2);
4042 | symbol_list word
' '
4049 $$ = dispatch2(symbols_add, $1, $2);
4060 $$ = dispatch1(array, $$);
4068 $$ = dispatch1(array, $2);
4079 $$ = dispatch1(array, $$);
4087 $$ = dispatch1(array, $2);
4105 $$ = dispatch2(qwords_add, $1, $2);
4127 $$ = dispatch2(qsymbols_add, $1, $2);
4140 | string_contents string_content
4145 $$ = dispatch2(string_add, $1, $2);
4158 | xstring_contents string_content
4163 $$ = dispatch2(xstring_add, $1, $2);
4176 | regexp_contents string_content
4200 $$ = dispatch2(regexp_add, $1, $2);
4219 $$ = dispatch1(string_dvar, $3);
4248 $$ = dispatch1(string_embexpr, $5);
4258 $$ = dispatch1(var_ref, $1);
4266 $$ = dispatch1(var_ref, $1);
4274 $$ = dispatch1(var_ref, $1);
4286 $$ = dispatch1(symbol, $2);
4303 $$ = dispatch1(dyna_symbol, $2);
4344 var_ref : user_variable
4349 if (id_is_var(
get_id($1))) {
4350 $$ = dispatch1(var_ref, $1);
4353 $$ = dispatch1(vcall, $1);
4362 $$ = dispatch1(var_ref, $1);
4367 var_lhs : user_variable
4372 $$ = dispatch1(var_field, $$);
4380 $$ = dispatch1(var_field, $$);
4418 f_arglist :
'(' f_args rparen
4423 $$ = dispatch1(paren, $2);
4436 args_tail : f_kwarg
',' f_kwrest opt_f_block_arg
4440 | f_kwarg opt_f_block_arg
4444 | f_kwrest opt_f_block_arg
4454 opt_args_tail :
',' args_tail
4464 f_args : f_arg
',' f_optarg
',' f_rest_arg opt_args_tail
4468 | f_arg
',' f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4472 | f_arg
',' f_optarg opt_args_tail
4476 | f_arg
',' f_optarg
',' f_arg opt_args_tail
4480 | f_arg
',' f_rest_arg opt_args_tail
4484 | f_arg
',' f_rest_arg
',' f_arg opt_args_tail
4488 | f_arg opt_args_tail
4492 | f_optarg
',' f_rest_arg opt_args_tail
4496 | f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4500 | f_optarg opt_args_tail
4504 | f_optarg
',' f_arg opt_args_tail
4508 | f_rest_arg opt_args_tail
4512 | f_rest_arg
',' f_arg opt_args_tail
4530 yyerror(
"formal argument cannot be a constant");
4533 $$ = dispatch1(param_error, $1);
4539 yyerror(
"formal argument cannot be an instance variable");
4542 $$ = dispatch1(param_error, $1);
4548 yyerror(
"formal argument cannot be a global variable");
4551 $$ = dispatch1(param_error, $1);
4557 yyerror(
"formal argument cannot be a class variable");
4560 $$ = dispatch1(param_error, $1);
4565 f_norm_arg : f_bad_arg
4573 f_arg_item : f_norm_arg
4596 $$ = dispatch1(mlhs_paren, $2);
4608 | f_arg
',' f_arg_item
4633 f_block_kw :
tLABEL primary_value
4645 f_block_kwarg : f_block_kw
4653 | f_block_kwarg
',' f_block_kw
4658 while (kws->nd_next) {
4683 while (kws->nd_next) {
4733 f_block_optarg : f_block_opt
4741 | f_block_optarg
',' f_block_opt
4746 while (opts->nd_next) {
4747 opts = opts->nd_next;
4765 | f_optarg
',' f_opt
4770 while (opts->nd_next) {
4771 opts = opts->nd_next;
4789 yyerror(
"rest argument must be local variable");
4795 $$ = dispatch1(rest_param, $2);
4804 $$ = dispatch1(rest_param,
Qnil);
4817 yyerror(
"block argument must be local variable");
4819 yyerror(
"duplicated block argument name");
4825 $$ = dispatch1(blockarg, $2);
4830 opt_f_block_arg :
',' f_block_arg
4858 yyerror(
"can't define singleton method for ().");
4870 yyerror(
"can't define singleton method for literals");
4878 $$ = dispatch1(paren, $3);
4889 $$ = dispatch1(assoclist_from_args, $1);
4916 $$ = dispatch2(assoc_new, $1, $3);
4924 $$ = dispatch2(assoc_new, $1, $2);
4932 $$ = dispatch1(assoc_splat, $2);
4978 rbracket : opt_nl
']'
5007 # define yylval (*((YYSTYPE*)(parser->parser_yylval)))
5016 # define nextc() parser_nextc(parser)
5017 # define pushback(c) parser_pushback(parser, (c))
5018 # define newtok() parser_newtok(parser)
5019 # define tokspace(n) parser_tokspace(parser, (n))
5020 # define tokadd(c) parser_tokadd(parser, (c))
5021 # define tok_hex(numlen) parser_tok_hex(parser, (numlen))
5022 # define read_escape(flags,e) parser_read_escape(parser, (flags), (e))
5023 # define tokadd_escape(e) parser_tokadd_escape(parser, (e))
5024 # define regx_options() parser_regx_options(parser)
5025 # define tokadd_string(f,t,p,n,e) parser_tokadd_string(parser,(f),(t),(p),(n),(e))
5026 # define parse_string(n) parser_parse_string(parser,(n))
5027 # define tokaddmbc(c, enc) parser_tokaddmbc(parser, (c), (enc))
5028 # define here_document(n) parser_here_document(parser,(n))
5029 # define heredoc_identifier() parser_heredoc_identifier(parser)
5030 # define heredoc_restore(n) parser_heredoc_restore(parser,(n))
5031 # define whole_match_p(e,l,i) parser_whole_match_p(parser,(e),(l),(i))
5034 # define set_yylval_str(x) (yylval.node = NEW_STR(x))
5035 # define set_yylval_num(x) (yylval.num = (x))
5036 # define set_yylval_id(x) (yylval.id = (x))
5037 # define set_yylval_name(x) (yylval.id = (x))
5038 # define set_yylval_literal(x) (yylval.node = NEW_LIT(x))
5039 # define set_yylval_node(x) (yylval.node = (x))
5040 # define yylval_id() (yylval.id)
5043 ripper_yylval_id(
ID x)
5047 # define set_yylval_str(x) (void)(x)
5048 # define set_yylval_num(x) (void)(x)
5049 # define set_yylval_id(x) (void)(x)
5050 # define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(x))
5051 # define set_yylval_literal(x) (void)(x)
5052 # define set_yylval_node(x) (void)(x)
5053 # define yylval_id() yylval.id
5057 #define ripper_flush(p) (void)(p)
5059 #define ripper_flush(p) ((p)->tokp = (p)->parser_lex_p)
5061 #define yylval_rval (*(RB_TYPE_P(yylval.val, T_NODE) ? &yylval.node->nd_rval : &yylval.val))
5068 return lex_p > parser->tokp;
5081 ripper_dispatch_scan_event(
struct parser_params *parser,
int t)
5083 if (!ripper_has_scan_event(parser))
return;
5084 yylval_rval = ripper_scan_event_val(parser, t);
5088 ripper_dispatch_ignored_scan_event(
struct parser_params *parser,
int t)
5090 if (!ripper_has_scan_event(parser))
return;
5091 (
void)ripper_scan_event_val(parser, t);
5095 ripper_dispatch_delayed_token(
struct parser_params *parser,
int t)
5098 const char *saved_tokp = parser->tokp;
5101 parser->tokp =
lex_pbeg + parser->delayed_col;
5103 parser->delayed =
Qnil;
5105 parser->tokp = saved_tokp;
5116 #undef SIGN_EXTEND_CHAR
5118 # define SIGN_EXTEND_CHAR(c) ((signed char)(c))
5121 # define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
5124 #define parser_encoding_name() (current_enc->name)
5125 #define parser_mbclen() mbclen((lex_p-1),lex_pend,current_enc)
5126 #define parser_precise_mbclen() rb_enc_precise_mbclen((lex_p-1),lex_pend,current_enc)
5127 #define is_identchar(p,e,enc) (rb_enc_isalnum(*(p),(enc)) || (*(p)) == '_' || !ISASCII(*(p)))
5128 #define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,current_enc))
5130 #define parser_isascii() ISASCII(*(lex_p-1))
5138 for (p =
lex_pbeg; p < pend; p++) {
5140 column = (((column - 1) / 8) + 1) * 8;
5151 for (p =
lex_pbeg; p < pend; p++) {
5152 if (*p !=
' ' && *p !=
'\t') {
5159 #undef token_info_push
5176 #undef token_info_pop
5183 if (!ptinfo)
return;
5189 if (linenum == ptinfo->
linenum) {
5197 "mismatched indentations at '%s' with '%s' at %d",
5210 const int max_line_margin = 30;
5219 if (*p ==
'\n')
break;
5226 if (*pe ==
'\n')
break;
5233 const char *pre =
"", *post =
"";
5235 if (len > max_line_margin * 2 + 10) {
5236 if (
lex_p - p > max_line_margin) {
5240 if (pe -
lex_p > max_line_margin) {
5247 MEMCPY(buf, p,
char, len);
5252 p2 =
buf; pe = buf +
len;
5255 if (*p2 !=
'\t') *p2 =
' ';
5263 dispatch1(parse_error,
STR_NEW2(msg));
5275 CONST_ID(script_lines,
"SCRIPT_LINES__");
5294 RBASIC(lines)->klass = 0;
5296 RARRAY(lines)->as.heap.len =
n;
5392 char *beg, *
end, *pend;
5402 while (end < pend) {
5403 if (*end++ ==
'\n')
break;
5413 if (
NIL_P(line))
return line;
5524 #define STR_FUNC_ESCAPE 0x01
5525 #define STR_FUNC_EXPAND 0x02
5526 #define STR_FUNC_REGEXP 0x04
5527 #define STR_FUNC_QWORDS 0x08
5528 #define STR_FUNC_SYMBOL 0x10
5529 #define STR_FUNC_INDENT 0x20
5559 #define lex_goto_eol(parser) ((parser)->parser_lex_p = (parser)->parser_lex_pend)
5560 #define lex_eol_p() (lex_p >= lex_pend)
5561 #define peek(c) peek_n((c), 0)
5562 #define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
5585 if (
NIL_P(parser->delayed)) {
5589 parser->tokp,
lex_pend - parser->tokp);
5591 parser->delayed_col = (
int)(parser->tokp -
lex_pbeg);
5595 parser->tokp,
lex_pend - parser->tokp);
5611 c = (
unsigned char)*
lex_p++;
5612 if (c ==
'\r' &&
peek(
'\n')) {
5623 if (c == -1)
return;
5630 #define was_bol() (lex_p == lex_pbeg + 1)
5632 #define tokfix() (tokenbuf[tokidx]='\0')
5633 #define tok() tokenbuf
5634 #define toklen() tokidx
5635 #define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
5682 yyerror(
"invalid hex escape");
5689 #define tokcopy(n) memcpy(tokspace(n), lex_p - (n), (n))
5694 int string_literal,
int symbol_literal,
int regexp_literal)
5714 yyerror(
"invalid Unicode escape");
5717 if (codepoint > 0x10ffff) {
5718 yyerror(
"invalid Unicode codepoint (too large)");
5722 if (regexp_literal) {
5725 else if (codepoint >= 0x80) {
5727 if (string_literal)
tokaddmbc(codepoint, *encp);
5729 else if (string_literal) {
5732 }
while (string_literal && (
peek(
' ') ||
peek(
'\t')));
5735 yyerror(
"unterminated Unicode escape");
5739 if (regexp_literal) {
tokadd(
'}'); }
5745 yyerror(
"invalid Unicode escape");
5749 if (regexp_literal) {
5752 else if (codepoint >= 0x80) {
5754 if (string_literal)
tokaddmbc(codepoint, *encp);
5756 else if (string_literal) {
5764 #define ESCAPE_CONTROL 1
5765 #define ESCAPE_META 2
5774 switch (c =
nextc()) {
5799 case '0':
case '1':
case '2':
case '3':
5800 case '4':
case '5':
case '6':
case '7':
5808 if (numlen == 0)
return 0;
5819 if ((c =
nextc()) !=
'-') {
5823 if ((c =
nextc()) ==
'\\') {
5824 if (
peek(
'u'))
goto eof;
5825 return read_escape(flags|ESCAPE_META, encp) | 0x80;
5827 else if (c == -1 || !
ISASCII(c))
goto eof;
5829 return ((c & 0xff) | 0x80);
5833 if ((c =
nextc()) !=
'-') {
5839 if ((c =
nextc())==
'\\') {
5840 if (
peek(
'u'))
goto eof;
5845 else if (c == -1 || !
ISASCII(c))
goto eof;
5850 yyerror(
"Invalid escape character syntax");
5873 switch (c =
nextc()) {
5877 case '0':
case '1':
case '2':
case '3':
5878 case '4':
case '5':
case '6':
case '7':
5881 if (numlen == 0)
goto eof;
5890 if (numlen == 0)
return -1;
5896 if (flags & ESCAPE_META)
goto eof;
5897 if ((c =
nextc()) !=
'-') {
5906 if (flags & ESCAPE_CONTROL)
goto eof;
5907 if ((c =
nextc()) !=
'-') {
5915 if (flags & ESCAPE_CONTROL)
goto eof;
5919 if ((c =
nextc()) ==
'\\') {
5922 else if (c == -1)
goto eof;
5928 yyerror(
"Invalid escape character syntax");
5995 #define tokadd_mbchar(c) parser_tokadd_mbchar(parser, (c))
6001 case '$':
case '*':
case '+':
case '.':
6002 case '?':
case '^':
case '|':
6003 case ')':
case ']':
case '}':
case '>':
6012 int func,
int term,
int paren,
long *nest,
6016 int has_nonascii = 0;
6019 static const char mixed_msg[] =
"%s mixed within %s source";
6021 #define mixed_error(enc1, enc2) if (!errbuf) { \
6022 size_t len = sizeof(mixed_msg) - 4; \
6023 len += strlen(rb_enc_name(enc1)); \
6024 len += strlen(rb_enc_name(enc2)); \
6025 errbuf = ALLOCA_N(char, len); \
6026 snprintf(errbuf, len, mixed_msg, \
6027 rb_enc_name(enc1), \
6028 rb_enc_name(enc2)); \
6031 #define mixed_escape(beg, enc1, enc2) do { \
6032 const char *pos = lex_p; \
6034 mixed_error((enc1), (enc2)); \
6038 while ((c =
nextc()) != -1) {
6039 if (paren && c == paren) {
6042 else if (c == term) {
6043 if (!nest || !*nest) {
6051 if (c2 ==
'$' || c2 ==
'@' || c2 ==
'{') {
6056 else if (c ==
'\\') {
6057 const char *beg =
lex_p - 1;
6062 if (func & STR_FUNC_EXPAND)
continue;
6071 if ((func & STR_FUNC_EXPAND) == 0) {
6077 func & STR_FUNC_REGEXP);
6078 if (has_nonascii && enc != *encp) {
6084 if (c == -1)
return -1;
6086 if ((func & STR_FUNC_EXPAND) == 0)
tokadd(
'\\');
6089 if (func & STR_FUNC_REGEXP) {
6097 if (has_nonascii && enc != *encp) {
6102 else if (func & STR_FUNC_EXPAND) {
6104 if (func & STR_FUNC_ESCAPE)
tokadd(
'\\');
6107 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6110 else if (c != term && !(paren && c == paren)) {
6127 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6144 #define NEW_STRTERM(func, term, paren) \
6145 rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
6151 if (!
NIL_P(parser->delayed)) {
6152 ptrdiff_t len =
lex_p - parser->tokp;
6157 parser->tokp =
lex_p;
6161 #define flush_string_content(enc) ripper_flush_string_content(parser, (enc))
6163 #define flush_string_content(enc) ((void)(enc))
6170 #define BIT(c, idx) (((c) / 32 - 1 == idx) ? (1U << ((c) % 32)) : 0)
6171 #define SPECIAL_PUNCT(idx) ( \
6172 BIT('~', idx) | BIT('*', idx) | BIT('$', idx) | BIT('?', idx) | \
6173 BIT('!', idx) | BIT('@', idx) | BIT('/', idx) | BIT('\\', idx) | \
6174 BIT(';', idx) | BIT(',', idx) | BIT('.', idx) | BIT('=', idx) | \
6175 BIT(':', idx) | BIT('<', idx) | BIT('>', idx) | BIT('\"', idx) | \
6176 BIT('&', idx) | BIT('`', idx) | BIT('\'', idx) | BIT('+', idx) | \
6184 #undef SPECIAL_PUNCT
6190 if (c <= 0x20 || 0x7e < c)
return 0;
6191 return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
6198 const char *p =
lex_p;
6204 if ((c = *p) ==
'-') {
6213 if ((c = *p) ==
'@') {
6233 int func = (
int)quote->nd_func;
6241 if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6245 if (c == term && !quote->nd_nest) {
6246 if (func & STR_FUNC_QWORDS) {
6247 quote->nd_func = -1;
6250 if (!(func & STR_FUNC_REGEXP))
return tSTRING_END;
6259 if ((func & STR_FUNC_EXPAND) && c ==
'#') {
6269 if (func & STR_FUNC_REGEXP) {
6291 int c =
nextc(), term, func = 0;
6309 while ((c =
nextc()) != -1 && c != term) {
6356 line = here->nd_orig;
6360 lex_p = lex_pbeg + here->nd_nth;
6370 const char *eos,
long len,
int indent)
6376 while (*p &&
ISSPACE(*p)) p++;
6379 if (n < 0 || (n > 0 && p[len] !=
'\n' && p[len] !=
'\r'))
return FALSE;
6380 return strncmp(eos, p, len) == 0;
6387 if (!
NIL_P(parser->delayed))
6390 ripper_dispatch_ignored_scan_event(parser,
tHEREDOC_END);
6393 #define dispatch_heredoc_end() ripper_dispatch_heredoc_end(parser)
6395 #define dispatch_heredoc_end() ((void)0)
6401 int c,
func, indent = 0;
6402 const char *eos, *
p, *pend;
6411 if ((c =
nextc()) == -1) {
6415 if (
NIL_P(parser->delayed)) {
6420 ((len =
lex_p - parser->tokp) > 0 &&
6421 (str =
STR_NEW3(parser->tokp, len, enc, func), 1))) {
6439 if (!(func & STR_FUNC_EXPAND)) {
6446 if (--pend == p || pend[-1] !=
'\r') {
6460 if (
nextc() == -1) {
6481 if (parser->
eofp)
goto error;
6491 if ((c =
nextc()) == -1)
goto error;
6508 rb_warning0(
"ambiguous first argument; put parentheses or even spaces");
6513 #define arg_ambiguous() (arg_ambiguous_gen(parser), 1)
6520 yyerror(
"formal argument must be local variable");
6538 if (len > 5 && name[nlen = len - 5] ==
'-') {
6542 if (len > 4 && name[nlen = len - 4] ==
'-') {
6545 if (
rb_memcicmp(name + nlen + 1,
"mac", 3) == 0 &&
6546 !(len == 8 &&
rb_memcicmp(name,
"utf8-mac", len) == 0))
6561 excargs[1] =
rb_sprintf(
"unknown encoding name: %s", name);
6578 for (i = 0; i <
n; ++
i) {
6653 if (str[i-1] ==
'*' && str[i-2] ==
'-') {
6659 if (i + 1 >= len)
return 0;
6660 if (str[i+1] !=
'-') {
6663 else if (str[i-1] !=
'-') {
6681 VALUE name = 0, val = 0;
6682 const char *beg, *
end, *vbeg, *vend;
6683 #define str_copy(_s, _p, _n) ((_s) \
6684 ? (void)(rb_str_resize((_s), (_n)), \
6685 MEMCPY(RSTRING_PTR(_s), (_p), char, (_n)), (_s)) \
6686 : (void)((_s) = STR_NEW((_p), (_n))))
6688 if (len <= 7)
return FALSE;
6692 len = end - beg - 3;
6703 for (; len > 0 && *
str; str++, --
len) {
6705 case '\'':
case '"':
case ':':
case ';':
6710 for (beg = str; len > 0; str++, --
len) {
6712 case '\'':
case '"':
case ':':
case ';':
6720 for (end = str; len > 0 &&
ISSPACE(*str); str++, --
len);
6722 if (*str !=
':')
continue;
6724 do str++;
while (--len > 0 &&
ISSPACE(*str));
6727 for (vbeg = ++str; --len > 0 && *str !=
'"'; str++) {
6740 for (vbeg = str; len > 0 && *str !=
'"' && *str !=
';' && !
ISSPACE(*str); --
len, str++);
6743 while (len > 0 && (*str ==
';' ||
ISSPACE(*str))) --len, str++;
6748 for (i = 0; i <
n; ++
i) {
6749 if (s[i] ==
'-') s[
i] =
'_';
6756 n = (*p->
length)(parser, vbeg, n);
6762 }
while (++p < magic_comments +
numberof(magic_comments));
6776 const char *beg =
str;
6780 if (send - str <= 6)
return;
6782 case 'C':
case 'c': str += 6;
continue;
6783 case 'O':
case 'o': str += 5;
continue;
6784 case 'D':
case 'd': str += 4;
continue;
6785 case 'I':
case 'i': str += 3;
continue;
6786 case 'N':
case 'n': str += 2;
continue;
6787 case 'G':
case 'g': str += 1;
continue;
6801 if (++str >= send)
return;
6804 if (*str !=
'=' && *str !=
':')
return;
6809 while ((*str ==
'-' || *str ==
'_' ||
ISALNUM(*str)) && ++str < send);
6825 (
unsigned char)
lex_p[0] == 0xbb &&
6826 (
unsigned char)
lex_p[1] == 0xbf) {
6840 #define IS_ARG() IS_lex_state(EXPR_ARG_ANY)
6841 #define IS_END() IS_lex_state(EXPR_END_ANY)
6842 #define IS_BEG() IS_lex_state(EXPR_BEG_ANY)
6843 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
6844 #define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG | EXPR_ENDFN) && !cmd_state) || IS_ARG())
6845 #define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1))
6846 #define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT)
6849 #define ambiguous_operator(op, syn) ( \
6850 rb_warning0("`"op"' after local variable is interpreted as binary operator"), \
6851 rb_warning0("even though it seems like "syn""))
6853 #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn))
6855 #define warn_balanced(op, syn) ((void) \
6856 (!IS_lex_state_for(last_state, EXPR_CLASS|EXPR_DOT|EXPR_FNAME|EXPR_ENDFN|EXPR_ENDARG) && \
6857 space_seen && !ISSPACE(c) && \
6858 (ambiguous_operator(op, syn), 0)))
6870 int fallthru =
FALSE;
6896 switch (c =
nextc()) {
6904 case ' ':
case '\t':
case '\f':
case '\r':
6908 while ((c =
nextc())) {
6910 case ' ':
case '\t':
case '\f':
case '\r':
6919 ripper_dispatch_scan_event(parser,
tSP);
6932 ripper_dispatch_scan_event(parser,
tCOMMENT);
6937 if (
IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT)) {
6946 while ((c =
nextc())) {
6948 case ' ':
case '\t':
case '\f':
case '\r':
6953 if ((c =
nextc()) !=
'.') {
6966 parser->tokp =
lex_p;
6969 goto normal_newline;
6978 if ((c =
nextc()) ==
'*') {
6979 if ((c =
nextc()) ==
'=') {
6986 rb_warning0(
"`**' interpreted as argument prefix");
7005 rb_warning0(
"`*' interpreted as argument prefix");
7053 ripper_dispatch_scan_event(parser,
tEMBDOC);
7062 if (c !=
'=')
continue;
7063 if (strncmp(
lex_p,
"end", 3) == 0 &&
7077 if ((c =
nextc()) ==
'=') {
7078 if ((c =
nextc()) ==
'=') {
7087 else if (c ==
'>') {
7099 (!
IS_ARG() || space_seen)) {
7101 if (token)
return token;
7112 if ((c =
nextc()) ==
'>') {
7119 if ((c =
nextc()) ==
'=') {
7133 if ((c =
nextc()) ==
'=') {
7137 if ((c =
nextc()) ==
'=') {
7205 rb_warnI(
"invalid character syntax; use ?\\%c", c2);
7222 else if (c ==
'\\') {
7251 if ((c =
nextc()) ==
'&') {
7253 if ((c =
nextc()) ==
'=') {
7261 else if (c ==
'=') {
7268 rb_warning0(
"`&' interpreted as argument prefix");
7282 if ((c =
nextc()) ==
'|') {
7284 if ((c =
nextc()) ==
'=') {
7364 if ((c =
nextc()) ==
'.') {
7365 if ((c =
nextc()) ==
'.') {
7373 yyerror(
"no .<digit> floating literal anymore; put 0 before dot");
7379 case '0':
case '1':
case '2':
case '3':
case '4':
7380 case '5':
case '6':
case '7':
case '8':
case '9':
7382 int is_float, seen_point, seen_e, nondigit;
7384 is_float = seen_point = seen_e = nondigit = 0;
7387 if (c ==
'-' || c ==
'+') {
7392 #define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
7395 if (c ==
'x' || c ==
'X') {
7401 if (nondigit)
break;
7408 }
while ((c =
nextc()) != -1);
7415 else if (nondigit)
goto trailing_uc;
7419 if (c ==
'b' || c ==
'B') {
7422 if (c ==
'0' || c ==
'1') {
7425 if (nondigit)
break;
7429 if (c !=
'0' && c !=
'1')
break;
7432 }
while ((c =
nextc()) != -1);
7439 else if (nondigit)
goto trailing_uc;
7443 if (c ==
'd' || c ==
'D') {
7449 if (nondigit)
break;
7456 }
while ((c =
nextc()) != -1);
7463 else if (nondigit)
goto trailing_uc;
7471 if (c ==
'o' || c ==
'O') {
7474 if (c == -1 || c ==
'_' || !
ISDIGIT(c)) {
7478 if (c >=
'0' && c <=
'7') {
7483 if (nondigit)
break;
7487 if (c < '0' || c >
'9')
break;
7488 if (c >
'7')
goto invalid_octal;
7491 }
while ((c =
nextc()) != -1);
7495 if (nondigit)
goto trailing_uc;
7504 if (c >
'7' && c <=
'9') {
7506 yyerror(
"Invalid octal digit");
7508 else if (c ==
'.' || c ==
'e' || c ==
'E') {
7520 case '0':
case '1':
case '2':
case '3':
case '4':
7521 case '5':
case '6':
case '7':
case '8':
case '9':
7527 if (nondigit)
goto trailing_uc;
7528 if (seen_point || seen_e) {
7533 if (c0 == -1 || !
ISDIGIT(c0)) {
7561 if (c !=
'-' && c !=
'+')
continue;
7567 if (nondigit)
goto decode_num;
7582 snprintf(tmp,
sizeof(tmp),
"trailing `%c' in number", nondigit);
7588 if (
errno == ERANGE) {
7665 if ((c =
nextc()) ==
'=') {
7685 if ((c =
nextc()) !=
'@') {
7712 if ((c =
nextc()) ==
']') {
7713 if ((c =
nextc()) ==
'=') {
7725 else if (
IS_ARG() && space_seen) {
7760 ripper_dispatch_scan_event(parser,
tSP);
7781 yyerror(
"unknown type of %string");
7785 if (c == -1 || term == -1) {
7790 if (term ==
'(') term =
')';
7791 else if (term ==
'[') term =
']';
7792 else if (term ==
'{') term =
'}';
7793 else if (term ==
'<') term =
'>';
7843 yyerror(
"unknown type of %string");
7847 if ((c =
nextc()) ==
'=') {
7924 case '1':
case '2':
case '3':
7925 case '4':
case '5':
case '6':
7926 case '7':
case '8':
case '9':
7931 }
while (c != -1 &&
ISDIGIT(c));
7977 ripper_dispatch_scan_event(parser,
k__END__);
8005 if ((c ==
'!' || c ==
'?') && !
peek(
'=')) {
8025 if (
tok()[1] ==
'@')
8071 if (state == EXPR_FNAME) {
8085 if (
CMDARG_P() && state != EXPR_CMDARG)
8087 if (state & (EXPR_BEG | EXPR_ENDARG))
8091 if (state & (EXPR_BEG | EXPR_VALUE))
8094 if (kw->
id[0] != kw->
id[1])
8131 yylex(
void *lval,
void *p)
8145 if (!
NIL_P(parser->delayed)) {
8146 ripper_dispatch_delayed_token(parser, t);
8150 ripper_dispatch_scan_event(parser, t);
8192 if (orig == (
NODE*)1)
return;
8201 #define parser_warning(node, mesg) parser_warning(parser, (node), (mesg))
8208 #define parser_warn(node, mesg) parser_warn(parser, (node), (mesg))
8215 if (tail == 0)
return head;
8217 if (h == 0)
return tail;
8256 tail->nd_end =
tail;
8258 end->nd_next =
tail;
8259 h->nd_end = tail->nd_end;
8269 if (list == 0)
return NEW_LIST(item);
8270 if (list->nd_next) {
8271 last = list->nd_next->nd_end;
8279 list->nd_next->nd_end = last->nd_next;
8289 if (head->nd_next) {
8290 last = head->nd_next->nd_end;
8296 head->nd_alen += tail->nd_alen;
8297 last->nd_next =
tail;
8298 if (tail->nd_next) {
8299 head->nd_next->nd_end = tail->nd_next->nd_end;
8302 head->nd_next->nd_end =
tail;
8311 if (
NIL_P(tail))
return 1;
8332 if (!head)
return tail;
8333 if (!tail)
return head;
8343 if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8346 lit = headlast->nd_lit;
8369 tail->nd_lit = head->nd_lit;
8373 else if (
NIL_P(tail->nd_lit)) {
8375 head->nd_alen += tail->nd_alen - 1;
8376 head->nd_next->nd_end->nd_next = tail->nd_next;
8377 head->nd_next->nd_end = tail->nd_next->nd_end;
8380 else if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8382 lit = headlast->nd_lit;
8385 tail->nd_lit =
Qnil;
8390 tail->nd_head =
NEW_STR(tail->nd_lit);
8539 static const char names[][12] = {
8540 "EXPR_BEG",
"EXPR_END",
"EXPR_ENDARG",
"EXPR_ENDFN",
"EXPR_ARG",
8541 "EXPR_CMDARG",
"EXPR_MID",
"EXPR_FNAME",
"EXPR_DOT",
"EXPR_CLASS",
8546 return names[
ffs(state)];
8561 # define assignable_result(x) get_value(lhs)
8562 # define parser_yyerror(parser, x) dispatch1(assign_error, lhs)
8564 # define assignable_result(x) (x)
8569 yyerror(
"Can't change the value of self");
8572 yyerror(
"Can't assign to nil");
8575 yyerror(
"Can't assign to true");
8578 yyerror(
"Can't assign to false");
8581 yyerror(
"Can't assign to __FILE__");
8584 yyerror(
"Can't assign to __LINE__");
8587 yyerror(
"Can't assign to __ENCODING__");
8621 yyerror(
"dynamic constant assignment");
8630 #undef assignable_result
8631 #undef parser_yyerror
8638 if (name == idUScore)
return 1;
8645 #define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
8653 yyerror(
"duplicated argument name");
8665 yyerror(
"duplicated argument name");
8723 int scope = (
int)(
id & ID_SCOPE_MASK);
8732 id_type_names[scope],
ID2SYM(
id));
8736 id &= ~ID_SCOPE_MASK;
8765 if (!node2)
return node1;
8769 node1->nd_head =
arg_concat(node1->nd_head, node2);
8781 node1->nd_body =
list_concat(node1->nd_body, node2);
8790 if (!node1)
return NEW_LIST(node2);
8795 node1->nd_head =
arg_append(node1->nd_head, node2);
8828 lhs->nd_value = rhs;
8833 lhs->nd_args =
arg_append(lhs->nd_args, rhs);
8864 if (!cond)
yyerror(
"void value expression");
8869 while (node->nd_next) {
8870 node = node->nd_next;
8872 node = node->nd_head;
8876 node = node->nd_body;
8880 if (!node->nd_body) {
8881 node = node->nd_else;
8884 else if (!node->nd_else) {
8885 node = node->nd_body;
8889 node = node->nd_else;
8895 node = node->nd_2nd;
8909 const char *useless = 0;
8916 switch (node->nd_mid) {
8947 useless =
"a variable";
8950 useless =
"a constant";
8957 useless =
"a literal";
8982 useless =
"defined?";
8990 rb_warnS(
"possibly useless use of %s in void context", useless);
9003 if (!node->nd_next)
return;
9005 node = node->nd_next;
9012 NODE **n = &node, *n1 = node;
9014 *n = n1 = n1->nd_body;
9028 #define subnodes(n1, n2) \
9029 ((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
9030 (!node->n2) ? (body = &node->n1, 1) : \
9031 (reduce_nodes(&node->n1), body = &node->n2, 1))
9041 *body = node = node->nd_stts;
9045 *body = node = node->nd_body;
9049 body = &node->nd_end->nd_head;
9055 body = &node->nd_body;
9064 if (node->nd_else) {
9065 body = &node->nd_resq;
9083 if (!node)
return 1;
9086 if (!(node = node->nd_head))
break;
9090 }
while ((node = node->nd_next) != 0);
9109 yyerror(
"multiple assignment in conditional");
9123 if (!node->nd_value)
return 1;
9126 parser_warn(node->nd_value,
"found = in conditional, should be ==");
9148 for (node = *rootnode; node; node = next) {
9152 next = node->nd_next;
9153 head = node->nd_head;
9156 switch (type =
nd_type(head)) {
9159 val =
rb_range_new(head->nd_beg->nd_lit, head->nd_end->nd_lit,
9179 if (node == 0)
return 0;
9187 return cond0(parser, node);
9193 if (!node)
return 1;
9214 if (node == 0)
return 0;
9221 rb_warn0(
"string literal in condition");
9231 node->nd_1st =
cond0(parser, node->nd_1st);
9232 node->nd_2nd =
cond0(parser, node->nd_2nd);
9237 node->nd_beg =
range_op(parser, node->nd_beg);
9238 node->nd_end =
range_op(parser, node->nd_end);
9271 if (node == 0)
return 0;
9272 return cond0(parser, node);
9280 NODE *node = left, *second;
9281 while ((second = node->nd_2nd) != 0 && (
enum node_type)
nd_type(second) == type) {
9284 node->nd_2nd =
NEW_NODE(type, second, right, 0);
9287 return NEW_NODE(type, left, right, 0);
9304 if (node->nd_next == 0) {
9305 node = node->nd_head;
9326 switch (
TYPE(node->nd_lit)) {
9355 node2->nd_head = node1;
9369 args->
pre_init = m ? m->nd_next : 0;
9442 ID vid = lhs->nd_vid;
9444 lhs->nd_value = rhs;
9451 lhs->nd_value = rhs;
9505 return dispatch3(opassign, lhs, op, rhs);
9511 VALUE recv = dispatch3(field, lhs, type, attr);
9512 return dispatch3(opassign, recv, op, rhs);
9522 if (!local->
used)
return;
9526 if (cnt != local->
vars->
pos) {
9527 rb_bug(
"local->used->pos != local->vars->pos");
9529 for (i = 0; i <
cnt; ++
i) {
9530 if (!v[i] || (u[i] &
LVAR_USED))
continue;
9545 local->
used = !(inherit_dvars &&
9574 int cnt = cnt_args + cnt_vars;
9578 if (cnt <= 0)
return 0;
9582 for (i = 0, j = cnt_args+1; i < cnt_vars; ++
i) {
9623 if (used) used = used->
prev;
9639 static const struct vtable *
9655 if ((tmp =
lvtbl->used) != 0) {
9671 while (
lvtbl->args != lvargs) {
9709 if (used) used = used->
prev;
9762 "regexp encoding option '%c' differs from source encoding '%s'",
9791 int back_num,
int *back_refs,
OnigRegex regex,
void *arg0)
9796 long len = name_end -
name;
9797 const char *s = (
const char *)name;
9814 rb_warningS(
"named capture conflicts a local variable - %s",
9897 if (!node)
return node;
9901 node = node->nd_body;
9905 node = node->nd_body;
9912 prelude->nd_body = node;
9913 scope->nd_body = prelude;
9916 scope->nd_body = node;
9929 if (!node)
return node;
9933 node = node->nd_body;
9937 node = node->nd_body;
9953 prelude->nd_body = node;
9954 scope->nd_body = prelude;
9957 scope->nd_body = node;
9963 static const struct {
9988 #define op_tbl_count numberof(op_tbl)
9990 #ifndef ENABLE_SELECTOR_NAMESPACE
9991 #define ENABLE_SELECTOR_NAMESPACE 0
9998 #if ENABLE_SELECTOR_NAMESPACE
10010 #if ENABLE_SELECTOR_NAMESPACE
10017 ivar2_cmp(
struct ivar2_key *key1,
struct ivar2_key *key2)
10019 if (key1->id == key2->id && key1->klass == key2->klass) {
10026 ivar2_hash(
struct ivar2_key *
key)
10028 return (key->id << 8) ^ (key->klass >> 2);
10042 #if ENABLE_SELECTOR_NAMESPACE
10050 (
void)lex_state_name(-1);
10079 if (m >= e)
return 0;
10083 else if (*m ==
'-') {
10097 return m == e ? mb + 1 : 0;
10112 #define IDSET_ATTRSET_FOR_SYNTAX ((1U<<ID_LOCAL)|(1U<<ID_CONST))
10113 #define IDSET_ATTRSET_FOR_INTERN (~(~0U<<(1<<ID_SCOPE_SHIFT)) & ~(1U<<ID_ATTRSET))
10118 const char *m =
name;
10119 const char *e = m +
len;
10122 if (!m || len <= 0)
return -1;
10142 case '<': ++
m;
break;
10143 case '=':
if (*++m ==
'>') ++
m;
break;
10150 case '>':
case '=': ++
m;
break;
10156 case '~': ++
m;
break;
10157 case '=':
if (*++m ==
'=') ++
m;
break;
10158 default:
return -1;
10163 if (*++m ==
'*') ++
m;
10166 case '+':
case '-':
10167 if (*++m ==
'@') ++
m;
10170 case '|':
case '^':
case '&':
case '/':
case '%':
case '~':
case '`':
10175 if (*++m !=
']')
return -1;
10176 if (*++m ==
'=') ++
m;
10180 if (len == 1)
return ID_JUNK;
10182 case '=':
case '~': ++
m;
break;
10183 default:
return -1;
10195 case '!':
case '?':
10199 if (m + 1 < e || *m !=
'=')
break;
10202 if (!(allowed_atttset & (1
U << type)))
return -1;
10209 return m == e ? type : -1;
10272 fake_str.as.heap.len =
len;
10273 fake_str.as.heap.ptr = (
char *)name;
10274 fake_str.as.heap.aux.capa =
len;
10275 str = (
VALUE)&fake_str;
10289 const char *
name, *
m, *
e;
10311 if (len < 2)
goto junk;
10320 if (len < 3)
goto junk;
10325 if (len < 2)
goto junk;
10341 if (*
op_tbl[i].name == *m &&
10342 strcmp(
op_tbl[i].name, m) == 0) {
10350 if (name[last] ==
'=') {
10352 if (last > 1 && name[last-1] ==
'=')
10362 else if (
id == 0) {
10434 name[0] = (char)
id;
10443 if (
op_tbl[i].token ==
id) {
10457 if (
RBASIC(str)->klass == 0)
10463 ID id_stem = (
id & ~ID_SCOPE_MASK);
10480 if (
RBASIC(str)->klass == 0)
10493 if (!str)
return 0;
10587 VALUE name = *namep;
10616 fake_str.as.heap.aux.capa = fake_str.as.heap.len;
10637 fake_str.as.heap.len =
len;
10638 fake_str.as.heap.ptr = (
char *)ptr;
10639 fake_str.as.heap.aux.capa =
len;
10648 fake_str.as.heap.len = len - 1;
10747 parser->delayed =
Qnil;
10749 parser->result =
Qnil;
10750 parser->parsing_thread =
Qnil;
10751 parser->toplevel_p =
TRUE;
10760 #define parser_mark ripper_parser_mark
10761 #define parser_free ripper_parser_free
10801 prev = local->
prev;
10812 size_t size =
sizeof(*p);
10814 if (!ptr)
return 0;
10817 size +=
sizeof(*local);
10837 #undef rb_reserved_word
10926 #define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
10927 #define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0)
10928 #define ADD2HEAP(n, c, p) ((parser->heap = (n))->u1.node = (p), \
10929 (n)->u3.cnt = (c), (p))
10934 size_t cnt =
HEAPCNT(1, size);
10944 size_t cnt =
HEAPCNT(nelem, size);
10946 void *ptr =
xcalloc(nelem, size);
10955 size_t cnt =
HEAPCNT(1, size);
10957 if (ptr && (n = parser->
heap) !=
NULL) {
10959 if (n->
u1.
node == ptr) {
10976 while ((n = *prev) !=
NULL) {
10977 if (n->
u1.
node == ptr) {
10990 #ifdef RIPPER_DEBUG
10991 extern int rb_is_pointer_to_heap(
VALUE);
10997 if (x ==
Qfalse)
return x;
10998 if (x ==
Qtrue)
return x;
10999 if (x ==
Qnil)
return x;
11004 if (!rb_is_pointer_to_heap(x))
11017 return ((
NODE *)x)->nd_rval;
11026 #define validate(x) ((x) = get_value(x))
11038 return rb_funcall(parser->value, mid, 1, a);
11046 return rb_funcall(parser->value, mid, 2, a, b);
11055 return rb_funcall(parser->value, mid, 3, a, b, c);
11065 return rb_funcall(parser->value, mid, 4, a, b, c, d);
11076 return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
11089 return rb_funcall(parser->value, mid, 7, a, b, c, d, e, f, g);
11092 static const struct kw_assoc {
11095 } keyword_to_name[] = {
11148 keyword_id_to_str(
ID id)
11150 const struct kw_assoc *
a;
11152 for (a = keyword_to_name; a->id; a++) {
11159 #undef ripper_id2sym
11161 ripper_id2sym(
ID id)
11171 if ((name = keyword_id_to_str(
id))) {
11184 rb_bug(
"cannot convert ID to string: %ld", (
unsigned long)
id);
11192 ripper_get_id(
VALUE v)
11202 ripper_get_value(
VALUE v)
11209 return nd->nd_rval;
11218 va_start(args, fmt);
11225 ripper_warn0(
struct parser_params *parser,
const char *fmt)
11231 ripper_warnI(
struct parser_params *parser,
const char *fmt,
int a)
11238 ripper_warnS(
struct parser_params *parser,
const char *fmt,
const char *str)
11245 ripper_warning0(
struct parser_params *parser,
const char *fmt)
11251 ripper_warningS(
struct parser_params *parser,
const char *fmt,
const char *str)
11276 #define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
11295 rb_scan_args(argc, argv,
"12", &src, &fname, &lineno);
11305 if (
NIL_P(fname)) {
11320 struct ripper_args {
11327 ripper_parse0(
VALUE parser_v)
11333 ripper_yyparse((
void*)parser);
11334 return parser->result;
11338 ripper_ensure(
VALUE parser_v)
11343 parser->parsing_thread =
Qnil;
11354 ripper_parse(
VALUE self)
11359 if (!ripper_initialized_p(parser)) {
11362 if (!
NIL_P(parser->parsing_thread)) {
11369 rb_ensure(ripper_parse0,
self, ripper_ensure,
self);
11371 return parser->result;
11382 ripper_column(
VALUE self)
11388 if (!ripper_initialized_p(parser)) {
11391 if (
NIL_P(parser->parsing_thread))
return Qnil;
11403 ripper_filename(
VALUE self)
11408 if (!ripper_initialized_p(parser)) {
11422 ripper_lineno(
VALUE self)
11427 if (!ripper_initialized_p(parser)) {
11430 if (
NIL_P(parser->parsing_thread))
return Qnil;
11434 #ifdef RIPPER_DEBUG
11470 InitVM_ripper(
void)
11486 #ifdef RIPPER_DEBUG
#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)
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(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)
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 NEW_OP_CDECL(v, op, val)
#define IS_lex_state_for(x, ls)
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 *)
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)
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 *)
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)
VALUE rb_ary_new3(long n,...)
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)
#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_append(VALUE, VALUE)
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 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)
#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
static struct @60 op_tbl[]
NODE * rb_compile_string(const char *f, VALUE s, int line)
static struct vtable * vtable_alloc(struct vtable *prev)
int rb_ascii8bit_encindex(void)
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 *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)
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)
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
void rb_gc_mark_symbols(void)
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 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)
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
#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)
int rb_symname_p(const char *name)
VALUE rb_thread_current(void)
mlhs_head tSTAR mlhs_node
#define token_info_pop(token)
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)
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)
static void arg_ambiguous_gen(struct parser_params *parser)
static void parser_prepare(struct parser_params *parser)
#define reg_compile(str, options)
#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)
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 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
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 *)
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 NEW_ATTRASGN(r, m, a)
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)
#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 call_bin_op(recv, id, arg1)
#define read_escape(flags, e)
VALUE rb_ary_new2(long capa)
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)
#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)
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)
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)
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)
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)
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)