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)
137 #define DVARS_INHERIT ((void*)1)
138 #define DVARS_TOPSCOPE NULL
139 #define DVARS_SPECIAL_P(tbl) (!POINTER_P(tbl))
140 #define POINTER_P(val) ((VALUE)(val) & ~(VALUE)3)
183 rb_bug(
"vtable_add: vtable is not allocated (%p)", (
void *)tbl);
200 for (i = 0; i < tbl->
pos; i++) {
201 if (tbl->
tbl[i] ==
id) {
286 VALUE parser_ruby_sourcefile_string;
294 VALUE parsing_thread;
299 #define STR_NEW(p,n) rb_enc_str_new((p),(n),current_enc)
300 #define STR_NEW0() rb_enc_str_new(0,0,current_enc)
301 #define STR_NEW2(p) rb_enc_str_new((p),strlen(p),current_enc)
302 #define STR_NEW3(p,n,e,func) parser_str_new((p),(n),(e),(func),current_enc)
303 #define ENC_SINGLE(cr) ((cr)==ENC_CODERANGE_7BIT)
304 #define TOK_INTERN(mb) rb_intern3(tok(), toklen(), current_enc)
307 #define yyerror(msg) parser_yyerror(parser, (msg))
309 #define lex_strterm (parser->parser_lex_strterm)
310 #define lex_state (parser->parser_lex_state)
311 #define cond_stack (parser->parser_cond_stack)
312 #define cmdarg_stack (parser->parser_cmdarg_stack)
313 #define class_nest (parser->parser_class_nest)
314 #define paren_nest (parser->parser_paren_nest)
315 #define lpar_beg (parser->parser_lpar_beg)
316 #define brace_nest (parser->parser_brace_nest)
317 #define in_single (parser->parser_in_single)
318 #define in_def (parser->parser_in_def)
319 #define compile_for_eval (parser->parser_compile_for_eval)
320 #define cur_mid (parser->parser_cur_mid)
321 #define in_defined (parser->parser_in_defined)
322 #define tokenbuf (parser->parser_tokenbuf)
323 #define tokidx (parser->parser_tokidx)
324 #define toksiz (parser->parser_toksiz)
325 #define tokline (parser->parser_tokline)
326 #define lex_input (parser->parser_lex_input)
327 #define lex_lastline (parser->parser_lex_lastline)
328 #define lex_nextline (parser->parser_lex_nextline)
329 #define lex_pbeg (parser->parser_lex_pbeg)
330 #define lex_p (parser->parser_lex_p)
331 #define lex_pend (parser->parser_lex_pend)
332 #define heredoc_end (parser->parser_heredoc_end)
333 #define command_start (parser->parser_command_start)
334 #define deferred_nodes (parser->parser_deferred_nodes)
335 #define lex_gets_ptr (parser->parser_lex_gets_ptr)
336 #define lex_gets (parser->parser_lex_gets)
337 #define lvtbl (parser->parser_lvtbl)
338 #define ruby__end__seen (parser->parser_ruby__end__seen)
339 #define ruby_sourceline (parser->parser_ruby_sourceline)
340 #define ruby_sourcefile (parser->parser_ruby_sourcefile)
341 #define current_enc (parser->enc)
342 #define yydebug (parser->parser_yydebug)
345 #define ruby_eval_tree (parser->parser_eval_tree)
346 #define ruby_eval_tree_begin (parser->parser_eval_tree_begin)
347 #define ruby_debug_lines (parser->debug_lines)
348 #define ruby_coverage (parser->coverage)
354 static int yylex(
void*);
358 #define yyparse ruby_yyparse
361 #define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3))
364 #define cond(node) cond_gen(parser, (node))
366 #define logop(type,node1,node2) logop_gen(parser, (type), (node1), (node2))
374 #define value_expr(node) value_expr_gen(parser, (node) = remove_begin(node))
375 #define void_expr0(node) void_expr_gen(parser, (node))
376 #define void_expr(node) void_expr0((node) = remove_begin(node))
378 #define void_stmts(node) void_stmts_gen(parser, (node))
380 #define reduce_nodes(n) reduce_nodes_gen(parser,(n))
382 #define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2))
385 #define block_append(h,t) block_append_gen(parser,(h),(t))
387 #define list_append(l,i) list_append_gen(parser,(l),(i))
389 #define list_concat(h,t) list_concat_gen(parser,(h),(t))
391 #define arg_append(h,t) arg_append_gen(parser,(h),(t))
393 #define arg_concat(h,t) arg_concat_gen(parser,(h),(t))
395 #define literal_concat(h,t) literal_concat_gen(parser,(h),(t))
398 #define new_evstr(n) new_evstr_gen(parser,(n))
400 #define evstr2dstr(n) evstr2dstr_gen(parser,(n))
404 #define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, (recv),(id),(arg1))
406 #define call_uni_op(recv,id) call_uni_op_gen(parser, (recv),(id))
409 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
411 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
415 #define ret_args(node) ret_args_gen(parser, (node))
418 #define new_yield(node) new_yield_gen(parser, (node))
420 #define dsym_node(node) dsym_node_gen(parser, (node))
423 #define gettable(id) gettable_gen(parser,(id))
425 #define assignable(id,node) assignable_gen(parser, (id), (node))
428 #define aryset(node1,node2) aryset_gen(parser, (node1), (node2))
430 #define attrset(node,id) attrset_gen(parser, (node), (id))
433 #define rb_backref_error(n) rb_backref_error_gen(parser,(n))
435 #define node_assign(node1, node2) node_assign_gen(parser, (node1), (node2))
439 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (attr), (op), (rhs))
441 #define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs))
444 #define match_op(node1,node2) match_op_gen(parser, (node1), (node2))
447 #define local_tbl() local_tbl_gen(parser)
452 #define reg_compile(str,options) reg_compile_gen(parser, (str), (options))
454 #define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options))
456 #define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options))
458 #define reg_named_capture_assign(regexp,match) reg_named_capture_assign_gen(parser,(regexp),(match))
460 #define get_id(id) (id)
461 #define get_value(val) (val)
463 #define value_expr(node) ((void)(node))
464 #define remove_begin(node) (node)
465 #define rb_dvar_defined(id) 0
466 #define rb_local_defined(id) 0
468 #define get_id(id) ripper_get_id(id)
470 #define get_value(val) ripper_get_value(val)
472 #define assignable(lhs,node) assignable_gen(parser, (lhs))
474 #define id_is_var(id) id_is_var_gen(parser, (id))
476 #define node_assign(node1, node2) dispatch2(assign, (node1), (node2))
480 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
484 #define new_op_assign(lhs, op, rhs) new_op_assign_gen(parser, (lhs), (op), (rhs))
487 #define formal_argument(id) formal_argument_gen(parser, (id))
489 #define shadowing_lvar(name) shadowing_lvar_gen(parser, (name))
491 #define new_bv(id) new_bv_gen(parser, (id))
494 #define local_push(top) local_push_gen(parser,(top))
496 #define local_pop() local_pop_gen(parser)
498 #define local_var(id) local_var_gen(parser, (id))
500 #define arg_var(id) arg_var_gen(parser, (id))
502 #define local_id(id) local_id_gen(parser, (id))
504 #define internal_id() internal_id_gen(parser)
507 #define dyna_push() dyna_push_gen(parser)
509 #define dyna_pop(node) dyna_pop_gen(parser, (node))
511 #define dyna_in_block() dyna_in_block_gen(parser)
512 #define dyna_var(id) local_var(id)
514 #define dvar_defined(id) dvar_defined_gen(parser, (id), 0)
515 #define dvar_defined_get(id) dvar_defined_gen(parser, (id), 1)
517 #define dvar_curr(id) dvar_curr_gen(parser, (id))
520 #define lvar_defined(id) lvar_defined_gen(parser, (id))
522 #define RE_OPTION_ONCE (1<<16)
523 #define RE_OPTION_ENCODING_SHIFT 8
524 #define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
525 #define RE_OPTION_ENCODING_IDX(o) (((o)>>RE_OPTION_ENCODING_SHIFT)&0xff)
526 #define RE_OPTION_ENCODING_NONE(o) ((o)&RE_OPTION_ARG_ENCODING_NONE)
527 #define RE_OPTION_MASK 0xff
528 #define RE_OPTION_ARG_ENCODING_NONE 32
530 #define NODE_STRTERM NODE_ZARRAY
531 #define NODE_HEREDOC NODE_ARRAY
532 #define SIGN_EXTEND(x,n) (((1<<(n)-1)^((x)&~(~0<<(n))))-(1<<(n)-1))
533 #define nd_func u1.id
534 #if SIZEOF_SHORT == 2
535 #define nd_term(node) ((signed short)(node)->u2.id)
537 #define nd_term(node) SIGN_EXTEND((node)->u2.id, CHAR_BIT*2)
539 #define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2)
540 #define nd_nest u3.cnt
545 #define RIPPER_VERSION "0.1.0"
558 #define dispatch0(n) ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
559 #define dispatch1(n,a) ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), (a))
560 #define dispatch2(n,a,b) ripper_dispatch2(parser, TOKEN_PASTE(ripper_id_, n), (a), (b))
561 #define dispatch3(n,a,b,c) ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
562 #define dispatch4(n,a,b,c,d) ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
563 #define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
564 #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))
566 #define yyparse ripper_yyparse
568 #define ripper_intern(s) ID2SYM(rb_intern(s))
569 static VALUE ripper_id2sym(
ID);
571 #define ripper_id2sym(id) ((id) < 256 && rb_ispunct(id) ? \
572 ID2SYM(id) : ripper_id2sym(id))
575 #define arg_new() dispatch0(args_new)
576 #define arg_add(l,a) dispatch2(args_add, (l), (a))
577 #define arg_add_star(l,a) dispatch2(args_add_star, (l), (a))
578 #define arg_add_block(l,b) dispatch2(args_add_block, (l), (b))
579 #define arg_add_optblock(l,b) ((b)==Qundef? (l) : dispatch2(args_add_block, (l), (b)))
580 #define bare_assoc(v) dispatch1(bare_assoc_hash, (v))
581 #define arg_add_assocs(l,b) arg_add((l), bare_assoc(b))
583 #define args2mrhs(a) dispatch1(mrhs_new_from_args, (a))
584 #define mrhs_new() dispatch0(mrhs_new)
585 #define mrhs_add(l,a) dispatch2(mrhs_add, (l), (a))
586 #define mrhs_add_star(l,a) dispatch2(mrhs_add_star, (l), (a))
588 #define mlhs_new() dispatch0(mlhs_new)
589 #define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
590 #define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
592 #define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
593 dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
595 #define blockvar_new(p,v) dispatch2(block_var, (p), (v))
596 #define blockvar_add_star(l,a) dispatch2(block_var_add_star, (l), (a))
597 #define blockvar_add_block(l,a) dispatch2(block_var_add_block, (l), (a))
599 #define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
600 #define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
601 #define method_add_block(m,b) dispatch2(method_add_block, (m), (b))
603 #define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
612 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
619 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
627 # define ifndef_ripper(x) (x)
630 # define ifndef_ripper(x)
634 # define rb_warn0(fmt) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt))
635 # define rb_warnI(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
636 # define rb_warnS(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
637 # define rb_warn4S(file,line,fmt,a) rb_compile_warn((file), (line), (fmt), (a))
638 # define rb_warning0(fmt) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt))
639 # define rb_warningS(fmt,a) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt), (a))
641 # define rb_warn0(fmt) ripper_warn0(parser, (fmt))
642 # define rb_warnI(fmt,a) ripper_warnI(parser, (fmt), (a))
643 # define rb_warnS(fmt,a) ripper_warnS(parser, (fmt), (a))
644 # define rb_warn4S(file,line,fmt,a) ripper_warnS(parser, (fmt), (a))
645 # define rb_warning0(fmt) ripper_warning0(parser, (fmt))
646 # define rb_warningS(fmt,a) ripper_warningS(parser, (fmt), (a))
647 static void ripper_warn0(
struct parser_params*,
const char*);
648 static void ripper_warnI(
struct parser_params*,
const char*,
int);
649 static void ripper_warnS(
struct parser_params*,
const char*,
const char*);
650 static void ripper_warning0(
struct parser_params*,
const char*);
651 static void ripper_warningS(
struct parser_params*,
const char*,
const char*);
655 static void ripper_compile_error(
struct parser_params*,
const char *
fmt, ...);
656 # define rb_compile_error ripper_compile_error
657 # define compile_error ripper_compile_error
658 # define PARSER_ARG parser,
660 # define rb_compile_error rb_compile_error_with_enc
661 # define compile_error parser->nerr++,rb_compile_error_with_enc
662 # define PARSER_ARG ruby_sourcefile, ruby_sourceline, current_enc,
670 #define YYMAXDEPTH 10000
677 #define token_info_push(token) (RTEST(ruby_verbose) ? token_info_push(parser, (token)) : (void)0)
678 #define token_info_pop(token) (RTEST(ruby_verbose) ? token_info_pop(parser, (token)) : (void)0)
680 #define token_info_push(token)
681 #define token_info_pop(token)
757 %type <val> singleton strings
string string1 xstring regexp
758 %type <val> string_contents xstring_contents regexp_contents string_content
759 %type <val> words
symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
760 %type <val> literal numeric dsym cpath
761 %type <val> top_compstmt top_stmts
top_stmt
763 %type <val> expr_value arg_value primary_value fcall
764 %type <val> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
766 %type <val> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
767 %type <val>
command_args aref_args opt_block_arg block_arg var_ref var_lhs
768 %type <val> command_asgn mrhs superclass block_call block_command
769 %type <val> f_block_optarg f_block_opt
770 %type <val> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
771 %type <val> assoc_list assocs
assoc undef_list backref string_dvar for_var
772 %type <val> block_param opt_block_param block_param_def f_opt
773 %type <val> f_kwarg f_kw f_block_kwarg f_block_kw
774 %type <val> bv_decls opt_bv_decl bvar
775 %type <val> lambda f_larglist lambda_body
779 %type <val> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
783 %type <val> program reswords then
do dot_or_colon
869 while (node->nd_next) {
870 node = node->nd_next;
878 parser->result = dispatch1(program, $$);
884 top_compstmt : top_stmts opt_terms
900 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
909 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
917 $$ = dispatch2(stmts_add, $1, $3);
943 $$ = dispatch1(BEGIN, $4);
959 rb_warn0(
"else without rescue is useless");
997 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
1006 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
1014 $$ = dispatch2(stmts_add, $1, $3);
1029 yyerror(
"BEGIN is permitted only at toplevel");
1035 '{' top_compstmt
'}'
1044 $$ = dispatch1(BEGIN, $4);
1053 $$ = dispatch2(
alias, $2, $4);
1061 $$ = dispatch2(var_alias, $2, $3);
1069 buf[1] = (char)$3->
nd_nth;
1072 $$ = dispatch2(var_alias, $2, $3);
1078 yyerror(
"can't make alias for the number variables");
1081 $$ = dispatch2(var_alias, $2, $3);
1082 $$ = dispatch1(alias_error, $$);
1090 $$ = dispatch1(undef, $2);
1099 $$ = dispatch2(if_mod, $3, $1);
1108 $$ = dispatch2(unless_mod, $3, $1);
1121 $$ = dispatch2(while_mod, $3, $1);
1134 $$ = dispatch2(until_mod, $3, $1);
1143 $$ = dispatch2(rescue_mod, $1, $3);
1149 rb_warn0(
"END in method; use at_exit");
1155 $$ = dispatch1(
END, $3);
1166 $$ = dispatch2(massign, $1, $3);
1192 $$ = dispatch3(opassign, $$, $5, $6);
1211 $$ = dispatch2(const_path_field, $1, $3);
1212 $$ = dispatch3(opassign, $$, $4, $5);
1226 $$ = dispatch2(assign, dispatch1(var_field, $1), $3);
1227 $$ = dispatch1(assign_error, $$);
1236 $$ = dispatch2(assign, $1, $3);
1239 | mlhs
'=' arg_value
1245 $$ = dispatch2(massign, $1, $3);
1254 $$ = dispatch2(massign, $1, $3);
1266 $$ = dispatch2(assign, $1, $3);
1275 $$ = dispatch2(assign, $1, $3);
1311 $$ = dispatch2(unary, ripper_id2sym(
'!'), $2);
1333 block_command : block_call
1339 $$ = dispatch3(call, $1, $2, $3);
1340 $$ = method_arg($$, $4);
1383 $$ = dispatch2(command, $1, $2);
1395 $$ = dispatch2(command, $1, $2);
1396 $$ = method_add_block($$, $3);
1405 $$ = dispatch4(
command_call, $1, ripper_id2sym(
'.'), $3, $4);
1412 $5->nd_iter =
NEW_CALL($1, $3, $4);
1417 $$ = method_add_block($$, $5);
1438 $$ = method_add_block($$, $5);
1447 $$ = dispatch1(super, $2);
1456 $$ = dispatch1(yield, $2);
1464 $$ = dispatch1(
return, $2);
1472 $$ = dispatch1(
break, $2);
1480 $$ = dispatch1(next, $2);
1491 $$ = dispatch1(mlhs_paren, $2);
1502 $$ = dispatch1(mlhs_paren, $2);
1520 $$ = mlhs_add($1, $2);
1528 $$ = mlhs_add_star($1, $3);
1536 $1 = mlhs_add_star($1, $3);
1537 $$ = mlhs_add($1, $5);
1545 $$ = mlhs_add_star($1,
Qnil);
1553 $1 = mlhs_add_star($1,
Qnil);
1554 $$ = mlhs_add($1, $4);
1562 $$ = mlhs_add_star(mlhs_new(), $2);
1570 $2 = mlhs_add_star(mlhs_new(), $2);
1571 $$ = mlhs_add($2, $4);
1579 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1587 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1588 $$ = mlhs_add($$, $3);
1599 $$ = dispatch1(mlhs_paren, $2);
1609 $$ = mlhs_add(mlhs_new(), $1);
1617 $$ = mlhs_add($1, $2);
1627 $$ = mlhs_add(mlhs_new(), $1);
1635 $$ = mlhs_add($1, $3);
1648 | primary_value
'[' opt_call_args rbracket
1661 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1669 $$ = dispatch2(const_path_field, $1, $3);
1677 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1684 yyerror(
"dynamic constant assignment");
1688 yyerror(
"dynamic constant assignment");
1689 $$ = dispatch2(const_path_field, $1, $3);
1696 yyerror(
"dynamic constant assignment");
1699 $$ = dispatch1(top_const_field, $2);
1708 $$ = dispatch1(var_field, $1);
1709 $$ = dispatch1(assign_error, $$);
1720 $$ = dispatch1(var_field, $$);
1729 $$ = dispatch1(var_field, $$);
1732 | primary_value
'[' opt_call_args rbracket
1745 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1761 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1768 yyerror(
"dynamic constant assignment");
1771 $$ = dispatch2(const_path_field, $1, $3);
1773 $$ = dispatch1(assign_error, $$);
1781 yyerror(
"dynamic constant assignment");
1784 $$ = dispatch1(top_const_field, $2);
1786 $$ = dispatch1(assign_error, $$);
1796 $$ = dispatch1(assign_error, $1);
1804 yyerror(
"class/module name must be CONSTANT");
1806 $$ = dispatch1(class_name_error, $1);
1817 $$ = dispatch1(top_const_ref, $2);
1825 $$ = dispatch1(const_ref, $1);
1833 $$ = dispatch2(const_path_ref, $1, $3);
1866 $$ = dispatch1(symbol_literal, $1);
1880 | undef_list
',' {
lex_state = EXPR_FNAME;} fitem
1942 $$ = dispatch2(assign, $1, $3);
1952 $$ = dispatch2(assign, $1, dispatch2(rescue_mod, $3, $5));
1966 $3 = dispatch2(rescue_mod, $3, $5);
1970 | primary_value
'[' opt_call_args rbracket
tOP_ASGN arg
1993 $$ = dispatch3(opassign, $1, $5, $6);
2017 $$ = dispatch2(const_path_field, $1, $3);
2018 $$ = dispatch3(opassign, $$, $4, $5);
2027 $$ = dispatch1(top_const_field, $2);
2028 $$ = dispatch3(opassign, $$, $3, $4);
2037 $$ = dispatch1(var_field, $1);
2038 $$ = dispatch3(opassign, $$, $2, $3);
2039 $$ = dispatch1(assign_error, $$);
2053 $$ = dispatch2(dot2, $1, $3);
2067 $$ = dispatch2(dot3, $1, $3);
2075 $$ = dispatch3(binary, $1,
ID2SYM(
'+'), $3);
2083 $$ = dispatch3(binary, $1,
ID2SYM(
'-'), $3);
2091 $$ = dispatch3(binary, $1,
ID2SYM(
'*'), $3);
2099 $$ = dispatch3(binary, $1,
ID2SYM(
'/'), $3);
2107 $$ = dispatch3(binary, $1,
ID2SYM(
'%'), $3);
2157 $$ = dispatch3(binary, $1,
ID2SYM(
'|'), $3);
2165 $$ = dispatch3(binary, $1,
ID2SYM(
'^'), $3);
2173 $$ = dispatch3(binary, $1,
ID2SYM(
'&'), $3);
2189 $$ = dispatch3(binary, $1,
ID2SYM(
'>'), $3);
2205 $$ = dispatch3(binary, $1,
ID2SYM(
'<'), $3);
2264 $$ = dispatch2(unary,
ID2SYM(
'!'), $2);
2272 $$ = dispatch2(unary,
ID2SYM(
'~'), $2);
2314 $$ = dispatch1(defined, $4);
2324 $$ = dispatch3(ifop, $1, $3, $6);
2350 | args
',' assocs trailer
2355 $$ = arg_add_assocs($1, $3);
2363 $$ = arg_add_assocs(arg_new(), $1);
2368 paren_args :
'(' opt_call_args rparen
2378 opt_paren_args : none
2382 opt_call_args : none
2388 | args
',' assocs
','
2393 $$ = arg_add_assocs($1, $3);
2401 $$ = arg_add_assocs(arg_new(), $1);
2412 $$ = arg_add(arg_new(), $1);
2415 | args opt_block_arg
2420 $$ = arg_add_optblock($1, $2);
2423 | assocs opt_block_arg
2429 $$ = arg_add_assocs(arg_new(), $1);
2430 $$ = arg_add_optblock($$, $2);
2433 | args
',' assocs opt_block_arg
2439 $$ = arg_add_optblock(arg_add_assocs($1, $3), $4);
2446 $$ = arg_add_block(arg_new(), $1);
2463 block_arg :
tAMPER arg_value
2473 opt_block_arg :
',' block_arg
2488 $$ = arg_add(arg_new(), $1);
2496 $$ = arg_add_star(arg_new(), $2);
2499 | args
',' arg_value
2510 $$ = arg_add($1, $3);
2513 | args
',' tSTAR arg_value
2524 $$ = arg_add_star($1, $4);
2529 mrhs : args
',' arg_value
2540 $$ = mrhs_add(args2mrhs($1), $3);
2543 | args
',' tSTAR arg_value
2555 $$ = mrhs_add_star(args2mrhs($1), $4);
2563 $$ = mrhs_add_star(mrhs_new(), $2);
2583 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2611 $$ = dispatch1(begin, $3);
2619 $$ = dispatch1(paren, 0);
2627 $$ = dispatch1(paren, $2);
2635 $$ = dispatch1(paren, $2);
2643 $$ = dispatch2(const_path_ref, $1, $3);
2651 $$ = dispatch1(top_const_ref, $2);
2688 $$ = dispatch1(yield, dispatch1(paren, $3));
2696 $$ = dispatch1(yield, dispatch1(paren, arg_new()));
2714 $$ = dispatch1(defined, $5);
2739 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2740 $$ = method_add_block($$, $2);
2744 | method_call brace_block
2751 $$ = method_add_block($1, $2);
2758 | k_if expr_value then
2770 | k_unless expr_value then
2790 $$ = dispatch2(
while, $3, $6);
2801 $$ = dispatch2(until, $3, $6);
2804 | k_case expr_value opt_terms
2812 $$ = dispatch2(
case, $2, $4);
2815 | k_case opt_terms case_body k_end
2820 $$ = dispatch2(
case,
Qnil, $3);
2882 tbl[0] = 1; tbl[1] =
id;
2886 $$ = dispatch3(
for, $2, $5, $8);
2889 | k_class cpath superclass
2892 yyerror(
"class definition in method body");
2906 $$ = dispatch3(
class, $2, $3, $5);
2928 $$ = dispatch2(sclass, $3, $7);
2937 yyerror(
"module definition in method body");
2951 $$ = dispatch2(module, $2, $4);
2972 $$ = dispatch3(def, $2, $4, $5);
2978 | k_def singleton dot_or_colon {
lex_state = EXPR_FNAME;} fname
2994 $$ = dispatch5(defs, $2, $3, $5, $7, $8);
3004 $$ = dispatch1(
break, arg_new());
3012 $$ = dispatch1(next, arg_new());
3033 primary_value : primary
3156 $$ = dispatch1(
else, $2);
3170 $$ = dispatch1(mlhs_paren, $$);
3178 $$ = dispatch1(mlhs_paren, $2);
3183 f_marg_list : f_marg
3188 $$ = mlhs_add(mlhs_new(), $1);
3191 | f_marg_list
',' f_marg
3196 $$ = mlhs_add($1, $3);
3201 f_margs : f_marg_list
3209 | f_marg_list
',' tSTAR f_norm_arg
3215 $$ = mlhs_add_star($1, $$);
3218 | f_marg_list
',' tSTAR f_norm_arg
',' f_marg_list
3224 $$ = mlhs_add_star($1, $$);
3227 | f_marg_list
',' tSTAR
3232 $$ = mlhs_add_star($1,
Qnil);
3235 | f_marg_list
',' tSTAR ',' f_marg_list
3240 $$ = mlhs_add_star($1, $5);
3249 $$ = mlhs_add_star(mlhs_new(), $$);
3252 |
tSTAR f_norm_arg
',' f_marg_list
3261 $$ = mlhs_add_star($$, $4);
3269 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3272 |
tSTAR ',' f_marg_list
3277 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3283 block_args_tail : f_block_kwarg
',' f_kwrest opt_f_block_arg
3287 | f_block_kwarg opt_f_block_arg
3291 | f_kwrest opt_f_block_arg
3301 opt_block_args_tail :
',' block_args_tail
3311 block_param : f_arg
',' f_block_optarg
',' f_rest_arg opt_block_args_tail
3315 | f_arg
',' f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3319 | f_arg
',' f_block_optarg opt_block_args_tail
3323 | f_arg
',' f_block_optarg
',' f_arg opt_block_args_tail
3327 | f_arg
',' f_rest_arg opt_block_args_tail
3336 dispatch1(excessed_comma, $$);
3339 | f_arg
',' f_rest_arg
',' f_arg opt_block_args_tail
3343 | f_arg opt_block_args_tail
3347 | f_block_optarg
',' f_rest_arg opt_block_args_tail
3351 | f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3355 | f_block_optarg opt_block_args_tail
3359 | f_block_optarg
',' f_arg opt_block_args_tail
3363 | f_rest_arg opt_block_args_tail
3367 | f_rest_arg
',' f_arg opt_block_args_tail
3377 opt_block_param : none
3384 block_param_def :
'|' opt_bv_decl
'|'
3402 |
'|' block_param opt_bv_decl
'|'
3413 opt_bv_decl : opt_nl
3417 | opt_nl
';' bv_decls opt_nl
3475 $$ = dispatch2(lambda, $3, $5);
3481 f_larglist :
'(' f_args opt_bv_decl
')'
3486 $$ = dispatch1(paren, $2);
3530 block_call : command do_block
3543 $$ = method_add_block($1, $2);
3546 | block_call dot_or_colon operation2 opt_paren_args
3551 $$ = dispatch3(call, $1, $2, $3);
3552 $$ = method_optarg($$, $4);
3555 | block_call dot_or_colon operation2 opt_paren_args brace_block
3559 $5->nd_iter =
NEW_CALL($1, $3, $4);
3564 $$ = method_add_block($$, $5);
3567 | block_call dot_or_colon operation2
command_args do_block
3571 $5->nd_iter =
NEW_CALL($1, $3, $4);
3576 $$ = method_add_block($$, $5);
3581 method_call : fcall paren_args
3587 $$ = method_arg(dispatch1(fcall, $1), $2);
3590 | primary_value
'.' operation2
3602 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3603 $$ = method_optarg($$, $5);
3606 | primary_value
tCOLON2 operation2
3618 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3619 $$ = method_optarg($$, $5);
3622 | primary_value
tCOLON2 operation3
3642 $$ = dispatch3(call, $1, ripper_id2sym(
'.'),
3644 $$ = method_optarg($$, $4);
3661 $$ = method_optarg($$, $4);
3669 $$ = dispatch1(super, $2);
3680 | primary_value
'[' opt_call_args rbracket
3762 $$ = dispatch4(rescue,
3772 exc_list : arg_value
3803 $$ = dispatch1(ensure, $2);
3815 $$ = dispatch1(symbol_literal, $1);
3845 $$ = dispatch2(string_concat, $1, $2);
3855 $$ = dispatch1(string_literal, $2);
3882 $$ = dispatch1(xstring_literal, $2);
3915 for (list = (prev = node)->
nd_next;
list; list = list->nd_next) {
3917 VALUE tail = list->nd_head->nd_lit;
3919 VALUE lit = prev == node ? prev->nd_lit : prev->nd_head->nd_lit;
3925 prev->nd_next = list->nd_next;
3938 if (!node->nd_next) {
3947 $$ = dispatch2(regexp_literal, $2, $3);
3958 $$ = dispatch1(array, $$);
3966 $$ = dispatch1(array, $2);
3979 | word_list word
' '
3984 $$ = dispatch2(words_add, $1, $2);
3989 word : string_content
3994 $$ = dispatch2(word_add, $$, $1);
3997 | word string_content
4002 $$ = dispatch2(word_add, $1, $2);
4013 $$ = dispatch1(array, $$);
4021 $$ = dispatch1(array, $2);
4034 | symbol_list word
' '
4041 $$ = dispatch2(symbols_add, $1, $2);
4052 $$ = dispatch1(array, $$);
4060 $$ = dispatch1(array, $2);
4071 $$ = dispatch1(array, $$);
4079 $$ = dispatch1(array, $2);
4097 $$ = dispatch2(qwords_add, $1, $2);
4119 $$ = dispatch2(qsymbols_add, $1, $2);
4132 | string_contents string_content
4137 $$ = dispatch2(string_add, $1, $2);
4150 | xstring_contents string_content
4155 $$ = dispatch2(xstring_add, $1, $2);
4168 | regexp_contents string_content
4192 $$ = dispatch2(regexp_add, $1, $2);
4211 $$ = dispatch1(string_dvar, $3);
4240 $$ = dispatch1(string_embexpr, $5);
4250 $$ = dispatch1(var_ref, $1);
4258 $$ = dispatch1(var_ref, $1);
4266 $$ = dispatch1(var_ref, $1);
4278 $$ = dispatch1(symbol, $2);
4295 $$ = dispatch1(dyna_symbol, $2);
4336 var_ref : user_variable
4341 if (id_is_var(
get_id($1))) {
4342 $$ = dispatch1(var_ref, $1);
4345 $$ = dispatch1(vcall, $1);
4354 $$ = dispatch1(var_ref, $1);
4359 var_lhs : user_variable
4364 $$ = dispatch1(var_field, $$);
4372 $$ = dispatch1(var_field, $$);
4410 f_arglist :
'(' f_args rparen
4415 $$ = dispatch1(paren, $2);
4428 args_tail : f_kwarg
',' f_kwrest opt_f_block_arg
4432 | f_kwarg opt_f_block_arg
4436 | f_kwrest opt_f_block_arg
4446 opt_args_tail :
',' args_tail
4456 f_args : f_arg
',' f_optarg
',' f_rest_arg opt_args_tail
4460 | f_arg
',' f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4464 | f_arg
',' f_optarg opt_args_tail
4468 | f_arg
',' f_optarg
',' f_arg opt_args_tail
4472 | f_arg
',' f_rest_arg opt_args_tail
4476 | f_arg
',' f_rest_arg
',' f_arg opt_args_tail
4480 | f_arg opt_args_tail
4484 | f_optarg
',' f_rest_arg opt_args_tail
4488 | f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4492 | f_optarg opt_args_tail
4496 | f_optarg
',' f_arg opt_args_tail
4500 | f_rest_arg opt_args_tail
4504 | f_rest_arg
',' f_arg opt_args_tail
4522 yyerror(
"formal argument cannot be a constant");
4525 $$ = dispatch1(param_error, $1);
4531 yyerror(
"formal argument cannot be an instance variable");
4534 $$ = dispatch1(param_error, $1);
4540 yyerror(
"formal argument cannot be a global variable");
4543 $$ = dispatch1(param_error, $1);
4549 yyerror(
"formal argument cannot be a class variable");
4552 $$ = dispatch1(param_error, $1);
4557 f_norm_arg : f_bad_arg
4565 f_arg_item : f_norm_arg
4588 $$ = dispatch1(mlhs_paren, $2);
4600 | f_arg
',' f_arg_item
4625 f_block_kw :
tLABEL primary_value
4637 f_block_kwarg : f_block_kw
4645 | f_block_kwarg
',' f_block_kw
4650 while (kws->nd_next) {
4675 while (kws->nd_next) {
4725 f_block_optarg : f_block_opt
4733 | f_block_optarg
',' f_block_opt
4738 while (opts->nd_next) {
4739 opts = opts->nd_next;
4757 | f_optarg
',' f_opt
4762 while (opts->nd_next) {
4763 opts = opts->nd_next;
4781 yyerror(
"rest argument must be local variable");
4787 $$ = dispatch1(rest_param, $2);
4796 $$ = dispatch1(rest_param,
Qnil);
4809 yyerror(
"block argument must be local variable");
4811 yyerror(
"duplicated block argument name");
4817 $$ = dispatch1(blockarg, $2);
4822 opt_f_block_arg :
',' f_block_arg
4850 yyerror(
"can't define singleton method for ().");
4862 yyerror(
"can't define singleton method for literals");
4870 $$ = dispatch1(paren, $3);
4881 $$ = dispatch1(assoclist_from_args, $1);
4908 $$ = dispatch2(assoc_new, $1, $3);
4916 $$ = dispatch2(assoc_new, $1, $2);
4924 $$ = dispatch1(assoc_splat, $2);
4970 rbracket : opt_nl
']'
4999 # define yylval (*((YYSTYPE*)(parser->parser_yylval)))
5008 # define nextc() parser_nextc(parser)
5009 # define pushback(c) parser_pushback(parser, (c))
5010 # define newtok() parser_newtok(parser)
5011 # define tokspace(n) parser_tokspace(parser, (n))
5012 # define tokadd(c) parser_tokadd(parser, (c))
5013 # define tok_hex(numlen) parser_tok_hex(parser, (numlen))
5014 # define read_escape(flags,e) parser_read_escape(parser, (flags), (e))
5015 # define tokadd_escape(e) parser_tokadd_escape(parser, (e))
5016 # define regx_options() parser_regx_options(parser)
5017 # define tokadd_string(f,t,p,n,e) parser_tokadd_string(parser,(f),(t),(p),(n),(e))
5018 # define parse_string(n) parser_parse_string(parser,(n))
5019 # define tokaddmbc(c, enc) parser_tokaddmbc(parser, (c), (enc))
5020 # define here_document(n) parser_here_document(parser,(n))
5021 # define heredoc_identifier() parser_heredoc_identifier(parser)
5022 # define heredoc_restore(n) parser_heredoc_restore(parser,(n))
5023 # define whole_match_p(e,l,i) parser_whole_match_p(parser,(e),(l),(i))
5026 # define set_yylval_str(x) (yylval.node = NEW_STR(x))
5027 # define set_yylval_num(x) (yylval.num = (x))
5028 # define set_yylval_id(x) (yylval.id = (x))
5029 # define set_yylval_name(x) (yylval.id = (x))
5030 # define set_yylval_literal(x) (yylval.node = NEW_LIT(x))
5031 # define set_yylval_node(x) (yylval.node = (x))
5032 # define yylval_id() (yylval.id)
5035 ripper_yylval_id(
ID x)
5039 # define set_yylval_str(x) (void)(x)
5040 # define set_yylval_num(x) (void)(x)
5041 # define set_yylval_id(x) (void)(x)
5042 # define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(x))
5043 # define set_yylval_literal(x) (void)(x)
5044 # define set_yylval_node(x) (void)(x)
5045 # define yylval_id() yylval.id
5049 #define ripper_flush(p) (void)(p)
5051 #define ripper_flush(p) ((p)->tokp = (p)->parser_lex_p)
5053 #define yylval_rval (*(RB_TYPE_P(yylval.val, T_NODE) ? &yylval.node->nd_rval : &yylval.val))
5060 return lex_p > parser->tokp;
5073 ripper_dispatch_scan_event(
struct parser_params *parser,
int t)
5075 if (!ripper_has_scan_event(parser))
return;
5076 yylval_rval = ripper_scan_event_val(parser, t);
5080 ripper_dispatch_ignored_scan_event(
struct parser_params *parser,
int t)
5082 if (!ripper_has_scan_event(parser))
return;
5083 (
void)ripper_scan_event_val(parser, t);
5087 ripper_dispatch_delayed_token(
struct parser_params *parser,
int t)
5090 const char *saved_tokp = parser->tokp;
5093 parser->tokp =
lex_pbeg + parser->delayed_col;
5095 parser->delayed =
Qnil;
5097 parser->tokp = saved_tokp;
5108 #undef SIGN_EXTEND_CHAR
5110 # define SIGN_EXTEND_CHAR(c) ((signed char)(c))
5113 # define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
5116 #define parser_encoding_name() (current_enc->name)
5117 #define parser_mbclen() mbclen((lex_p-1),lex_pend,current_enc)
5118 #define parser_precise_mbclen() rb_enc_precise_mbclen((lex_p-1),lex_pend,current_enc)
5119 #define is_identchar(p,e,enc) (rb_enc_isalnum(*(p),(enc)) || (*(p)) == '_' || !ISASCII(*(p)))
5120 #define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,current_enc))
5122 #define parser_isascii() ISASCII(*(lex_p-1))
5130 for (p =
lex_pbeg; p < pend; p++) {
5132 column = (((column - 1) / 8) + 1) * 8;
5143 for (p =
lex_pbeg; p < pend; p++) {
5144 if (*p !=
' ' && *p !=
'\t') {
5151 #undef token_info_push
5168 #undef token_info_pop
5175 if (!ptinfo)
return;
5181 if (linenum == ptinfo->
linenum) {
5189 "mismatched indentations at '%s' with '%s' at %d",
5202 const int max_line_margin = 30;
5211 if (*p ==
'\n')
break;
5218 if (*pe ==
'\n')
break;
5225 const char *pre =
"", *post =
"";
5227 if (len > max_line_margin * 2 + 10) {
5228 if (
lex_p - p > max_line_margin) {
5232 if (pe -
lex_p > max_line_margin) {
5239 MEMCPY(buf, p,
char, len);
5244 p2 =
buf; pe = buf +
len;
5247 if (*p2 !=
'\t') *p2 =
' ';
5255 dispatch1(parse_error,
STR_NEW2(msg));
5267 CONST_ID(script_lines,
"SCRIPT_LINES__");
5288 RBASIC(lines)->klass = 0;
5290 RARRAY(lines)->as.heap.len =
n;
5385 char *beg, *
end, *pend;
5395 while (end < pend) {
5396 if (*end++ ==
'\n')
break;
5406 if (
NIL_P(line))
return line;
5505 #define STR_FUNC_ESCAPE 0x01
5506 #define STR_FUNC_EXPAND 0x02
5507 #define STR_FUNC_REGEXP 0x04
5508 #define STR_FUNC_QWORDS 0x08
5509 #define STR_FUNC_SYMBOL 0x10
5510 #define STR_FUNC_INDENT 0x20
5540 #define lex_goto_eol(parser) ((parser)->parser_lex_p = (parser)->parser_lex_pend)
5541 #define lex_eol_p() (lex_p >= lex_pend)
5542 #define peek(c) peek_n((c), 0)
5543 #define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
5566 if (
NIL_P(parser->delayed)) {
5570 parser->tokp,
lex_pend - parser->tokp);
5572 parser->delayed_col = (
int)(parser->tokp -
lex_pbeg);
5576 parser->tokp,
lex_pend - parser->tokp);
5592 c = (
unsigned char)*
lex_p++;
5593 if (c ==
'\r' &&
peek(
'\n')) {
5604 if (c == -1)
return;
5611 #define was_bol() (lex_p == lex_pbeg + 1)
5613 #define tokfix() (tokenbuf[tokidx]='\0')
5614 #define tok() tokenbuf
5615 #define toklen() tokidx
5616 #define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
5663 yyerror(
"invalid hex escape");
5670 #define tokcopy(n) memcpy(tokspace(n), lex_p - (n), (n))
5675 int string_literal,
int symbol_literal,
int regexp_literal)
5695 yyerror(
"invalid Unicode escape");
5698 if (codepoint > 0x10ffff) {
5699 yyerror(
"invalid Unicode codepoint (too large)");
5703 if (regexp_literal) {
5706 else if (codepoint >= 0x80) {
5708 if (string_literal)
tokaddmbc(codepoint, *encp);
5710 else if (string_literal) {
5713 }
while (string_literal && (
peek(
' ') ||
peek(
'\t')));
5716 yyerror(
"unterminated Unicode escape");
5720 if (regexp_literal) {
tokadd(
'}'); }
5726 yyerror(
"invalid Unicode escape");
5730 if (regexp_literal) {
5733 else if (codepoint >= 0x80) {
5735 if (string_literal)
tokaddmbc(codepoint, *encp);
5737 else if (string_literal) {
5745 #define ESCAPE_CONTROL 1
5746 #define ESCAPE_META 2
5755 switch (c =
nextc()) {
5780 case '0':
case '1':
case '2':
case '3':
5781 case '4':
case '5':
case '6':
case '7':
5789 if (numlen == 0)
return 0;
5800 if ((c =
nextc()) !=
'-') {
5804 if ((c =
nextc()) ==
'\\') {
5805 if (
peek(
'u'))
goto eof;
5806 return read_escape(flags|ESCAPE_META, encp) | 0x80;
5808 else if (c == -1 || !
ISASCII(c))
goto eof;
5810 return ((c & 0xff) | 0x80);
5814 if ((c =
nextc()) !=
'-') {
5820 if ((c =
nextc())==
'\\') {
5821 if (
peek(
'u'))
goto eof;
5826 else if (c == -1 || !
ISASCII(c))
goto eof;
5831 yyerror(
"Invalid escape character syntax");
5854 switch (c =
nextc()) {
5858 case '0':
case '1':
case '2':
case '3':
5859 case '4':
case '5':
case '6':
case '7':
5862 if (numlen == 0)
goto eof;
5871 if (numlen == 0)
return -1;
5877 if (flags & ESCAPE_META)
goto eof;
5878 if ((c =
nextc()) !=
'-') {
5887 if (flags & ESCAPE_CONTROL)
goto eof;
5888 if ((c =
nextc()) !=
'-') {
5896 if (flags & ESCAPE_CONTROL)
goto eof;
5900 if ((c =
nextc()) ==
'\\') {
5903 else if (c == -1)
goto eof;
5909 yyerror(
"Invalid escape character syntax");
5976 #define tokadd_mbchar(c) parser_tokadd_mbchar(parser, (c))
5982 case '$':
case '*':
case '+':
case '.':
5983 case '?':
case '^':
case '|':
5984 case ')':
case ']':
case '}':
case '>':
5993 int func,
int term,
int paren,
long *nest,
5997 int has_nonascii = 0;
6000 static const char mixed_msg[] =
"%s mixed within %s source";
6002 #define mixed_error(enc1, enc2) if (!errbuf) { \
6003 size_t len = sizeof(mixed_msg) - 4; \
6004 len += strlen(rb_enc_name(enc1)); \
6005 len += strlen(rb_enc_name(enc2)); \
6006 errbuf = ALLOCA_N(char, len); \
6007 snprintf(errbuf, len, mixed_msg, \
6008 rb_enc_name(enc1), \
6009 rb_enc_name(enc2)); \
6012 #define mixed_escape(beg, enc1, enc2) do { \
6013 const char *pos = lex_p; \
6015 mixed_error((enc1), (enc2)); \
6019 while ((c =
nextc()) != -1) {
6020 if (paren && c == paren) {
6023 else if (c == term) {
6024 if (!nest || !*nest) {
6032 if (c2 ==
'$' || c2 ==
'@' || c2 ==
'{') {
6037 else if (c ==
'\\') {
6038 const char *beg =
lex_p - 1;
6043 if (func & STR_FUNC_EXPAND)
continue;
6052 if ((func & STR_FUNC_EXPAND) == 0) {
6058 func & STR_FUNC_REGEXP);
6059 if (has_nonascii && enc != *encp) {
6065 if (c == -1)
return -1;
6067 if ((func & STR_FUNC_EXPAND) == 0)
tokadd(
'\\');
6070 if (func & STR_FUNC_REGEXP) {
6078 if (has_nonascii && enc != *encp) {
6083 else if (func & STR_FUNC_EXPAND) {
6085 if (func & STR_FUNC_ESCAPE)
tokadd(
'\\');
6088 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6091 else if (c != term && !(paren && c == paren)) {
6108 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6125 #define NEW_STRTERM(func, term, paren) \
6126 rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
6132 if (!
NIL_P(parser->delayed)) {
6133 ptrdiff_t len =
lex_p - parser->tokp;
6138 parser->tokp =
lex_p;
6142 #define flush_string_content(enc) ripper_flush_string_content(parser, (enc))
6144 #define flush_string_content(enc) ((void)(enc))
6151 #define BIT(c, idx) (((c) / 32 - 1 == idx) ? (1U << ((c) % 32)) : 0)
6152 #define SPECIAL_PUNCT(idx) ( \
6153 BIT('~', idx) | BIT('*', idx) | BIT('$', idx) | BIT('?', idx) | \
6154 BIT('!', idx) | BIT('@', idx) | BIT('/', idx) | BIT('\\', idx) | \
6155 BIT(';', idx) | BIT(',', idx) | BIT('.', idx) | BIT('=', idx) | \
6156 BIT(':', idx) | BIT('<', idx) | BIT('>', idx) | BIT('\"', idx) | \
6157 BIT('&', idx) | BIT('`', idx) | BIT('\'', idx) | BIT('+', idx) | \
6165 #undef SPECIAL_PUNCT
6171 if (c <= 0x20 || 0x7e < c)
return 0;
6172 return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
6179 const char *p =
lex_p;
6185 if ((c = *p) ==
'-') {
6194 if ((c = *p) ==
'@') {
6214 int func = (
int)quote->nd_func;
6222 if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6226 if (c == term && !quote->nd_nest) {
6227 if (func & STR_FUNC_QWORDS) {
6228 quote->nd_func = -1;
6231 if (!(func & STR_FUNC_REGEXP))
return tSTRING_END;
6240 if ((func & STR_FUNC_EXPAND) && c ==
'#') {
6250 if (func & STR_FUNC_REGEXP) {
6272 int c =
nextc(), term, func = 0;
6290 while ((c =
nextc()) != -1 && c != term) {
6337 line = here->nd_orig;
6341 lex_p = lex_pbeg + here->nd_nth;
6351 const char *eos,
long len,
int indent)
6357 while (*p &&
ISSPACE(*p)) p++;
6360 if (n < 0 || (n > 0 && p[len] !=
'\n' && p[len] !=
'\r'))
return FALSE;
6361 return strncmp(eos, p, len) == 0;
6368 if (!
NIL_P(parser->delayed))
6371 ripper_dispatch_ignored_scan_event(parser,
tHEREDOC_END);
6374 #define dispatch_heredoc_end() ripper_dispatch_heredoc_end(parser)
6376 #define dispatch_heredoc_end() ((void)0)
6382 int c,
func, indent = 0;
6383 const char *eos, *
p, *pend;
6392 if ((c =
nextc()) == -1) {
6396 if (
NIL_P(parser->delayed)) {
6401 ((len =
lex_p - parser->tokp) > 0 &&
6402 (str =
STR_NEW3(parser->tokp, len, enc, func), 1))) {
6420 if (!(func & STR_FUNC_EXPAND)) {
6427 if (--pend == p || pend[-1] !=
'\r') {
6441 if (
nextc() == -1) {
6459 if (parser->
eofp)
goto error;
6469 if ((c =
nextc()) == -1)
goto error;
6486 rb_warning0(
"ambiguous first argument; put parentheses or even spaces");
6491 #define arg_ambiguous() (arg_ambiguous_gen(parser), 1)
6498 yyerror(
"formal argument must be local variable");
6516 if (len > 5 && name[nlen = len - 5] ==
'-') {
6520 if (len > 4 && name[nlen = len - 4] ==
'-') {
6523 if (
rb_memcicmp(name + nlen + 1,
"mac", 3) == 0 &&
6524 !(len == 8 &&
rb_memcicmp(name,
"utf8-mac", len) == 0))
6539 excargs[1] =
rb_sprintf(
"unknown encoding name: %s", name);
6556 for (i = 0; i <
n; ++
i) {
6631 if (str[i-1] ==
'*' && str[i-2] ==
'-') {
6637 if (i + 1 >= len)
return 0;
6638 if (str[i+1] !=
'-') {
6641 else if (str[i-1] !=
'-') {
6659 VALUE name = 0, val = 0;
6660 const char *beg, *
end, *vbeg, *vend;
6661 #define str_copy(_s, _p, _n) ((_s) \
6662 ? (void)(rb_str_resize((_s), (_n)), \
6663 MEMCPY(RSTRING_PTR(_s), (_p), char, (_n)), (_s)) \
6664 : (void)((_s) = STR_NEW((_p), (_n))))
6666 if (len <= 7)
return FALSE;
6670 len = end - beg - 3;
6681 for (; len > 0 && *
str; str++, --
len) {
6683 case '\'':
case '"':
case ':':
case ';':
6688 for (beg = str; len > 0; str++, --
len) {
6690 case '\'':
case '"':
case ':':
case ';':
6698 for (end = str; len > 0 &&
ISSPACE(*str); str++, --
len);
6700 if (*str !=
':')
continue;
6702 do str++;
while (--len > 0 &&
ISSPACE(*str));
6705 for (vbeg = ++str; --len > 0 && *str !=
'"'; str++) {
6718 for (vbeg = str; len > 0 && *str !=
'"' && *str !=
';' && !
ISSPACE(*str); --
len, str++);
6721 while (len > 0 && (*str ==
';' ||
ISSPACE(*str))) --len, str++;
6726 for (i = 0; i <
n; ++
i) {
6727 if (s[i] ==
'-') s[
i] =
'_';
6734 n = (*p->
length)(parser, vbeg, n);
6740 }
while (++p < magic_comments +
numberof(magic_comments));
6754 const char *beg =
str;
6758 if (send - str <= 6)
return;
6760 case 'C':
case 'c': str += 6;
continue;
6761 case 'O':
case 'o': str += 5;
continue;
6762 case 'D':
case 'd': str += 4;
continue;
6763 case 'I':
case 'i': str += 3;
continue;
6764 case 'N':
case 'n': str += 2;
continue;
6765 case 'G':
case 'g': str += 1;
continue;
6779 if (++str >= send)
return;
6782 if (*str !=
'=' && *str !=
':')
return;
6787 while ((*str ==
'-' || *str ==
'_' ||
ISALNUM(*str)) && ++str < send);
6803 (
unsigned char)
lex_p[0] == 0xbb &&
6804 (
unsigned char)
lex_p[1] == 0xbf) {
6818 #define IS_ARG() IS_lex_state(EXPR_ARG_ANY)
6819 #define IS_END() IS_lex_state(EXPR_END_ANY)
6820 #define IS_BEG() IS_lex_state(EXPR_BEG_ANY)
6821 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
6822 #define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG | EXPR_ENDFN) && !cmd_state) || IS_ARG())
6823 #define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1))
6824 #define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT)
6827 #define ambiguous_operator(op, syn) ( \
6828 rb_warning0("`"op"' after local variable is interpreted as binary operator"), \
6829 rb_warning0("even though it seems like "syn""))
6831 #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn))
6833 #define warn_balanced(op, syn) ((void) \
6834 (!IS_lex_state_for(last_state, EXPR_CLASS|EXPR_DOT|EXPR_FNAME|EXPR_ENDFN|EXPR_ENDARG) && \
6835 space_seen && !ISSPACE(c) && \
6836 (ambiguous_operator(op, syn), 0)))
6848 int fallthru =
FALSE;
6874 switch (c =
nextc()) {
6882 case ' ':
case '\t':
case '\f':
case '\r':
6886 while ((c =
nextc())) {
6888 case ' ':
case '\t':
case '\f':
case '\r':
6897 ripper_dispatch_scan_event(parser,
tSP);
6910 ripper_dispatch_scan_event(parser,
tCOMMENT);
6915 if (
IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT)) {
6924 while ((c =
nextc())) {
6926 case ' ':
case '\t':
case '\f':
case '\r':
6931 if ((c =
nextc()) !=
'.') {
6944 parser->tokp =
lex_p;
6947 goto normal_newline;
6956 if ((c =
nextc()) ==
'*') {
6957 if ((c =
nextc()) ==
'=') {
6964 rb_warning0(
"`**' interpreted as argument prefix");
6983 rb_warning0(
"`*' interpreted as argument prefix");
7031 ripper_dispatch_scan_event(parser,
tEMBDOC);
7040 if (c !=
'=')
continue;
7041 if (strncmp(
lex_p,
"end", 3) == 0 &&
7055 if ((c =
nextc()) ==
'=') {
7056 if ((c =
nextc()) ==
'=') {
7065 else if (c ==
'>') {
7077 (!
IS_ARG() || space_seen)) {
7079 if (token)
return token;
7090 if ((c =
nextc()) ==
'>') {
7097 if ((c =
nextc()) ==
'=') {
7111 if ((c =
nextc()) ==
'=') {
7115 if ((c =
nextc()) ==
'=') {
7183 rb_warnI(
"invalid character syntax; use ?\\%c", c2);
7200 else if (c ==
'\\') {
7229 if ((c =
nextc()) ==
'&') {
7231 if ((c =
nextc()) ==
'=') {
7239 else if (c ==
'=') {
7246 rb_warning0(
"`&' interpreted as argument prefix");
7260 if ((c =
nextc()) ==
'|') {
7262 if ((c =
nextc()) ==
'=') {
7342 if ((c =
nextc()) ==
'.') {
7343 if ((c =
nextc()) ==
'.') {
7351 yyerror(
"no .<digit> floating literal anymore; put 0 before dot");
7357 case '0':
case '1':
case '2':
case '3':
case '4':
7358 case '5':
case '6':
case '7':
case '8':
case '9':
7360 int is_float, seen_point, seen_e, nondigit;
7362 is_float = seen_point = seen_e = nondigit = 0;
7365 if (c ==
'-' || c ==
'+') {
7370 #define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
7373 if (c ==
'x' || c ==
'X') {
7379 if (nondigit)
break;
7386 }
while ((c =
nextc()) != -1);
7393 else if (nondigit)
goto trailing_uc;
7397 if (c ==
'b' || c ==
'B') {
7400 if (c ==
'0' || c ==
'1') {
7403 if (nondigit)
break;
7407 if (c !=
'0' && c !=
'1')
break;
7410 }
while ((c =
nextc()) != -1);
7417 else if (nondigit)
goto trailing_uc;
7421 if (c ==
'd' || c ==
'D') {
7427 if (nondigit)
break;
7434 }
while ((c =
nextc()) != -1);
7441 else if (nondigit)
goto trailing_uc;
7449 if (c ==
'o' || c ==
'O') {
7452 if (c == -1 || c ==
'_' || !
ISDIGIT(c)) {
7456 if (c >=
'0' && c <=
'7') {
7461 if (nondigit)
break;
7465 if (c < '0' || c >
'9')
break;
7466 if (c >
'7')
goto invalid_octal;
7469 }
while ((c =
nextc()) != -1);
7473 if (nondigit)
goto trailing_uc;
7482 if (c >
'7' && c <=
'9') {
7484 yyerror(
"Invalid octal digit");
7486 else if (c ==
'.' || c ==
'e' || c ==
'E') {
7498 case '0':
case '1':
case '2':
case '3':
case '4':
7499 case '5':
case '6':
case '7':
case '8':
case '9':
7505 if (nondigit)
goto trailing_uc;
7506 if (seen_point || seen_e) {
7511 if (c0 == -1 || !
ISDIGIT(c0)) {
7539 if (c !=
'-' && c !=
'+')
continue;
7545 if (nondigit)
goto decode_num;
7560 snprintf(tmp,
sizeof(tmp),
"trailing `%c' in number", nondigit);
7566 if (
errno == ERANGE) {
7643 if ((c =
nextc()) ==
'=') {
7663 if ((c =
nextc()) !=
'@') {
7690 if ((c =
nextc()) ==
']') {
7691 if ((c =
nextc()) ==
'=') {
7703 else if (
IS_ARG() && space_seen) {
7738 ripper_dispatch_scan_event(parser,
tSP);
7759 yyerror(
"unknown type of %string");
7763 if (c == -1 || term == -1) {
7768 if (term ==
'(') term =
')';
7769 else if (term ==
'[') term =
']';
7770 else if (term ==
'{') term =
'}';
7771 else if (term ==
'<') term =
'>';
7821 yyerror(
"unknown type of %string");
7825 if ((c =
nextc()) ==
'=') {
7902 case '1':
case '2':
case '3':
7903 case '4':
case '5':
case '6':
7904 case '7':
case '8':
case '9':
7909 }
while (c != -1 &&
ISDIGIT(c));
7955 ripper_dispatch_scan_event(parser,
k__END__);
7983 if ((c ==
'!' || c ==
'?') && !
peek(
'=')) {
8003 if (
tok()[1] ==
'@')
8049 if (state == EXPR_FNAME) {
8063 if (
CMDARG_P() && state != EXPR_CMDARG)
8065 if (state & (EXPR_BEG | EXPR_ENDARG))
8069 if (state & (EXPR_BEG | EXPR_VALUE))
8072 if (kw->
id[0] != kw->
id[1])
8109 yylex(
void *lval,
void *p)
8123 if (!
NIL_P(parser->delayed)) {
8124 ripper_dispatch_delayed_token(parser, t);
8128 ripper_dispatch_scan_event(parser, t);
8170 if (orig == (
NODE*)1)
return;
8179 #define parser_warning(node, mesg) parser_warning(parser, (node), (mesg))
8186 #define parser_warn(node, mesg) parser_warn(parser, (node), (mesg))
8193 if (tail == 0)
return head;
8195 if (h == 0)
return tail;
8234 tail->nd_end =
tail;
8236 end->nd_next =
tail;
8237 h->nd_end = tail->nd_end;
8247 if (list == 0)
return NEW_LIST(item);
8248 if (list->nd_next) {
8249 last = list->nd_next->nd_end;
8257 list->nd_next->nd_end = last->nd_next;
8267 if (head->nd_next) {
8268 last = head->nd_next->nd_end;
8274 head->nd_alen += tail->nd_alen;
8275 last->nd_next =
tail;
8276 if (tail->nd_next) {
8277 head->nd_next->nd_end = tail->nd_next->nd_end;
8280 head->nd_next->nd_end =
tail;
8289 if (
NIL_P(tail))
return 1;
8310 if (!head)
return tail;
8311 if (!tail)
return head;
8321 if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8324 lit = headlast->nd_lit;
8347 tail->nd_lit = head->nd_lit;
8351 else if (
NIL_P(tail->nd_lit)) {
8353 head->nd_alen += tail->nd_alen - 1;
8354 head->nd_next->nd_end->nd_next = tail->nd_next;
8355 head->nd_next->nd_end = tail->nd_next->nd_end;
8358 else if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8360 lit = headlast->nd_lit;
8363 tail->nd_lit =
Qnil;
8368 tail->nd_head =
NEW_STR(tail->nd_lit);
8518 static const char names[][12] = {
8519 "EXPR_BEG",
"EXPR_END",
"EXPR_ENDARG",
"EXPR_ENDFN",
"EXPR_ARG",
8520 "EXPR_CMDARG",
"EXPR_MID",
"EXPR_FNAME",
"EXPR_DOT",
"EXPR_CLASS",
8525 return names[
ffs(state)];
8540 # define assignable_result(x) get_value(lhs)
8541 # define parser_yyerror(parser, x) dispatch1(assign_error, lhs)
8543 # define assignable_result(x) (x)
8548 yyerror(
"Can't change the value of self");
8551 yyerror(
"Can't assign to nil");
8554 yyerror(
"Can't assign to true");
8557 yyerror(
"Can't assign to false");
8560 yyerror(
"Can't assign to __FILE__");
8563 yyerror(
"Can't assign to __LINE__");
8566 yyerror(
"Can't assign to __ENCODING__");
8600 yyerror(
"dynamic constant assignment");
8609 #undef assignable_result
8610 #undef parser_yyerror
8617 if (name == idUScore)
return 1;
8624 #define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
8632 yyerror(
"duplicated argument name");
8644 yyerror(
"duplicated argument name");
8683 id &= ~ID_SCOPE_MASK;
8712 if (!node2)
return node1;
8716 node1->nd_head =
arg_concat(node1->nd_head, node2);
8728 node1->nd_body =
list_concat(node1->nd_body, node2);
8737 if (!node1)
return NEW_LIST(node2);
8742 node1->nd_head =
arg_append(node1->nd_head, node2);
8775 lhs->nd_value = rhs;
8780 lhs->nd_args =
arg_append(lhs->nd_args, rhs);
8811 if (!cond)
yyerror(
"void value expression");
8816 while (node->nd_next) {
8817 node = node->nd_next;
8819 node = node->nd_head;
8823 node = node->nd_body;
8827 if (!node->nd_body) {
8828 node = node->nd_else;
8831 else if (!node->nd_else) {
8832 node = node->nd_body;
8836 node = node->nd_else;
8842 node = node->nd_2nd;
8856 const char *useless = 0;
8863 switch (node->nd_mid) {
8894 useless =
"a variable";
8897 useless =
"a constant";
8904 useless =
"a literal";
8929 useless =
"defined?";
8937 rb_warnS(
"possibly useless use of %s in void context", useless);
8950 if (!node->nd_next)
return;
8952 node = node->nd_next;
8959 NODE **n = &node, *n1 = node;
8961 *n = n1 = n1->nd_body;
8975 #define subnodes(n1, n2) \
8976 ((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
8977 (!node->n2) ? (body = &node->n1, 1) : \
8978 (reduce_nodes(&node->n1), body = &node->n2, 1))
8988 *body = node = node->nd_stts;
8992 *body = node = node->nd_body;
8996 body = &node->nd_end->nd_head;
9002 body = &node->nd_body;
9011 if (node->nd_else) {
9012 body = &node->nd_resq;
9030 if (!node)
return 1;
9033 if (!(node = node->nd_head))
break;
9037 }
while ((node = node->nd_next) != 0);
9056 yyerror(
"multiple assignment in conditional");
9070 if (!node->nd_value)
return 1;
9073 parser_warn(node->nd_value,
"found = in conditional, should be ==");
9095 for (node = *rootnode; node; node = next) {
9099 next = node->nd_next;
9100 head = node->nd_head;
9103 switch (type =
nd_type(head)) {
9106 val =
rb_range_new(head->nd_beg->nd_lit, head->nd_end->nd_lit,
9126 if (node == 0)
return 0;
9134 return cond0(parser, node);
9140 if (!node)
return 1;
9161 if (node == 0)
return 0;
9168 rb_warn0(
"string literal in condition");
9178 node->nd_1st =
cond0(parser, node->nd_1st);
9179 node->nd_2nd =
cond0(parser, node->nd_2nd);
9184 node->nd_beg =
range_op(parser, node->nd_beg);
9185 node->nd_end =
range_op(parser, node->nd_end);
9218 if (node == 0)
return 0;
9219 return cond0(parser, node);
9227 NODE *node = left, *second;
9228 while ((second = node->nd_2nd) != 0 && (
enum node_type)
nd_type(second) == type) {
9231 node->nd_2nd =
NEW_NODE(type, second, right, 0);
9234 return NEW_NODE(type, left, right, 0);
9251 if (node->nd_next == 0) {
9252 node = node->nd_head;
9273 switch (
TYPE(node->nd_lit)) {
9302 node2->nd_head = node1;
9316 args->
pre_init = m ? m->nd_next : 0;
9389 ID vid = lhs->nd_vid;
9391 lhs->nd_value = rhs;
9398 lhs->nd_value = rhs;
9452 return dispatch3(opassign, lhs, op, rhs);
9458 VALUE recv = dispatch3(field, lhs, type, attr);
9459 return dispatch3(opassign, recv, op, rhs);
9469 if (!local->
used)
return;
9473 if (cnt != local->
vars->
pos) {
9474 rb_bug(
"local->used->pos != local->vars->pos");
9476 for (i = 0; i <
cnt; ++
i) {
9477 if (!v[i] || (u[i] &
LVAR_USED))
continue;
9492 local->
used = !(inherit_dvars &&
9520 for (i = 0; i <
cnt; i++) {
9521 buf[
i] = src->
tbl[
i];
9534 if (cnt <= 0)
return 0;
9572 if (used) used = used->
prev;
9588 static const struct vtable *
9604 if ((tmp =
lvtbl->used) != 0) {
9620 while (
lvtbl->args != lvargs) {
9658 if (used) used = used->
prev;
9711 "regexp encoding option '%c' differs from source encoding '%s'",
9740 int back_num,
int *back_refs,
OnigRegex regex,
void *arg0)
9745 long len = name_end -
name;
9746 const char *s = (
const char *)name;
9763 rb_warningS(
"named capture conflicts a local variable - %s",
9846 if (!node)
return node;
9850 node = node->nd_body;
9854 node = node->nd_body;
9861 prelude->nd_body = node;
9862 scope->nd_body = prelude;
9865 scope->nd_body = node;
9878 if (!node)
return node;
9882 node = node->nd_body;
9886 node = node->nd_body;
9902 prelude->nd_body = node;
9903 scope->nd_body = prelude;
9906 scope->nd_body = node;
9912 static const struct {
9937 #define op_tbl_count numberof(op_tbl)
9939 #ifndef ENABLE_SELECTOR_NAMESPACE
9940 #define ENABLE_SELECTOR_NAMESPACE 0
9947 #if ENABLE_SELECTOR_NAMESPACE
9959 #if ENABLE_SELECTOR_NAMESPACE
9966 ivar2_cmp(
struct ivar2_key *key1,
struct ivar2_key *key2)
9968 if (key1->id == key2->id && key1->klass == key2->klass) {
9975 ivar2_hash(
struct ivar2_key *
key)
9977 return (key->id << 8) ^ (key->klass >> 2);
9991 #if ENABLE_SELECTOR_NAMESPACE
9999 (
void)lex_state_name(-1);
10028 if (m >= e)
return 0;
10032 else if (*m ==
'-') {
10046 return m == e ? mb + 1 : 0;
10064 const char *m =
name;
10065 const char *e = m +
len;
10068 if (!m || len <= 0)
return -1;
10088 case '<': ++
m;
break;
10089 case '=':
if (*++m ==
'>') ++
m;
break;
10096 case '>':
case '=': ++
m;
break;
10102 case '~': ++
m;
break;
10103 case '=':
if (*++m ==
'=') ++
m;
break;
10104 default:
return -1;
10109 if (*++m ==
'*') ++
m;
10112 case '+':
case '-':
10113 if (*++m ==
'@') ++
m;
10116 case '|':
case '^':
case '&':
case '/':
case '%':
case '~':
case '`':
10121 if (*++m !=
']')
return -1;
10122 if (*++m ==
'=') ++
m;
10126 if (len == 1)
return ID_JUNK;
10128 case '=':
case '~': ++
m;
break;
10129 default:
return -1;
10140 case '!':
case '?':
10153 return m == e ? type : -1;
10216 fake_str.as.heap.len =
len;
10217 fake_str.as.heap.ptr = (
char *)name;
10218 fake_str.as.heap.aux.capa =
len;
10219 str = (
VALUE)&fake_str;
10233 const char *
name, *
m, *
e;
10281 if (*
op_tbl[i].name == *m &&
10282 strcmp(
op_tbl[i].name, m) == 0) {
10289 if (m[last] ==
'=') {
10317 if (m - name < len)
id =
ID_JUNK;
10371 name[0] = (char)
id;
10380 if (
op_tbl[i].token ==
id) {
10394 if (
RBASIC(str)->klass == 0)
10405 id2 = (
id & ~ID_SCOPE_MASK) |
ID_CONST;
10412 if (
RBASIC(str)->klass == 0)
10425 if (!str)
return 0;
10519 VALUE name = *namep;
10548 fake_str.as.heap.aux.capa = fake_str.as.heap.len;
10569 fake_str.as.heap.len =
len;
10570 fake_str.as.heap.ptr = (
char *)ptr;
10571 fake_str.as.heap.aux.capa =
len;
10580 fake_str.as.heap.len = len - 1;
10678 parser->parser_ruby_sourcefile_string =
Qnil;
10679 parser->delayed =
Qnil;
10681 parser->result =
Qnil;
10682 parser->parsing_thread =
Qnil;
10683 parser->toplevel_p =
TRUE;
10692 #define parser_mark ripper_parser_mark
10693 #define parser_free ripper_parser_free
10711 rb_gc_mark(p->parser_ruby_sourcefile_string);
10733 prev = local->
prev;
10747 size_t size =
sizeof(*p);
10749 if (!ptr)
return 0;
10752 size +=
sizeof(*local);
10777 #undef rb_reserved_word
10866 #define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
10867 #define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0)
10868 #define ADD2HEAP(n, c, p) ((parser->heap = (n))->u1.node = (p), \
10869 (n)->u3.cnt = (c), (p))
10874 size_t cnt =
HEAPCNT(1, size);
10884 size_t cnt =
HEAPCNT(nelem, size);
10886 void *ptr =
xcalloc(nelem, size);
10895 size_t cnt =
HEAPCNT(1, size);
10897 if (ptr && (n = parser->
heap) !=
NULL) {
10899 if (n->
u1.
node == ptr) {
10916 while ((n = *prev) !=
NULL) {
10917 if (n->
u1.
node == ptr) {
10930 #ifdef RIPPER_DEBUG
10931 extern int rb_is_pointer_to_heap(
VALUE);
10937 if (x ==
Qfalse)
return x;
10938 if (x ==
Qtrue)
return x;
10939 if (x ==
Qnil)
return x;
10944 if (!rb_is_pointer_to_heap(x))
10957 return ((
NODE *)x)->nd_rval;
10966 #define validate(x) ((x) = get_value(x))
10978 return rb_funcall(parser->value, mid, 1, a);
10986 return rb_funcall(parser->value, mid, 2, a, b);
10995 return rb_funcall(parser->value, mid, 3, a, b, c);
11005 return rb_funcall(parser->value, mid, 4, a, b, c, d);
11016 return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
11029 return rb_funcall(parser->value, mid, 7, a, b, c, d, e, f, g);
11032 static const struct kw_assoc {
11035 } keyword_to_name[] = {
11088 keyword_id_to_str(
ID id)
11090 const struct kw_assoc *
a;
11092 for (a = keyword_to_name; a->id; a++) {
11099 #undef ripper_id2sym
11101 ripper_id2sym(
ID id)
11111 if ((name = keyword_id_to_str(
id))) {
11124 rb_bug(
"cannot convert ID to string: %ld", (
unsigned long)
id);
11132 ripper_get_id(
VALUE v)
11142 ripper_get_value(
VALUE v)
11149 return nd->nd_rval;
11158 va_start(args, fmt);
11165 ripper_warn0(
struct parser_params *parser,
const char *fmt)
11171 ripper_warnI(
struct parser_params *parser,
const char *fmt,
int a)
11178 ripper_warnS(
struct parser_params *parser,
const char *fmt,
const char *str)
11185 ripper_warning0(
struct parser_params *parser,
const char *fmt)
11191 ripper_warningS(
struct parser_params *parser,
const char *fmt,
const char *str)
11216 #define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
11235 rb_scan_args(argc, argv,
"12", &src, &fname, &lineno);
11245 if (
NIL_P(fname)) {
11253 parser->parser_ruby_sourcefile_string = fname;
11260 struct ripper_args {
11267 ripper_parse0(
VALUE parser_v)
11273 ripper_yyparse((
void*)parser);
11274 return parser->result;
11278 ripper_ensure(
VALUE parser_v)
11283 parser->parsing_thread =
Qnil;
11294 ripper_parse(
VALUE self)
11299 if (!ripper_initialized_p(parser)) {
11302 if (!
NIL_P(parser->parsing_thread)) {
11309 rb_ensure(ripper_parse0,
self, ripper_ensure,
self);
11311 return parser->result;
11322 ripper_column(
VALUE self)
11328 if (!ripper_initialized_p(parser)) {
11331 if (
NIL_P(parser->parsing_thread))
return Qnil;
11343 ripper_filename(
VALUE self)
11348 if (!ripper_initialized_p(parser)) {
11351 return parser->parser_ruby_sourcefile_string;
11362 ripper_lineno(
VALUE self)
11367 if (!ripper_initialized_p(parser)) {
11370 if (
NIL_P(parser->parsing_thread))
return Qnil;
11374 #ifdef RIPPER_DEBUG
11410 InitVM_ripper(
void)
11426 #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 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)
static VALUE debug_lines(const char *f)
#define rb_enc_isalnum(c, enc)
static int parser_here_document(struct parser_params *, NODE *)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
long(* rb_magic_comment_length_t)(struct parser_params *parser, const char *name, long len)
#define rb_enc_prev_char(s, p, e, enc)
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)
static NODE * yycompile(struct parser_params *parser, const char *f, int line)
static ID * vtable_tblcpy(ID *buf, const struct vtable *src)
#define whole_match_p(e, l, i)
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)
#define RUBY_DTRACE_PARSE_BEGIN(arg0, arg1)
#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)
#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 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)
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)
#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,...)
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[]
char * ruby_strdup(const char *)
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()
static NODE * parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int line)
#define list_concat(h, t)
#define NEW_ARGS_AUX(r, b)
#define TypedData_Wrap_Struct(klass, data_type, sval)
static VALUE coverage(const char *f, int n)
#define rb_warningS(fmt, a)
static VALUE lex_get_str(struct parser_params *parser, VALUE s)
#define RUBY_FUNC_EXPORTED
#define literal_concat(h, t)
unsigned char buf[MIME_BUF_SIZE]
VALUE rb_suppress_tracing(VALUE(*func)(VALUE), VALUE arg)
static int rb_str_symname_type(VALUE name)
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 int rb_enc_symname_type(const char *name, long len, rb_encoding *enc)
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)
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
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)
rb_encoding * rb_filesystem_encoding(void)
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)
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)
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)
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)
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)
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
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)