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 YYLEX_PARAM parser
311 #define lex_strterm (parser->parser_lex_strterm)
312 #define lex_state (parser->parser_lex_state)
313 #define cond_stack (parser->parser_cond_stack)
314 #define cmdarg_stack (parser->parser_cmdarg_stack)
315 #define class_nest (parser->parser_class_nest)
316 #define paren_nest (parser->parser_paren_nest)
317 #define lpar_beg (parser->parser_lpar_beg)
318 #define brace_nest (parser->parser_brace_nest)
319 #define in_single (parser->parser_in_single)
320 #define in_def (parser->parser_in_def)
321 #define compile_for_eval (parser->parser_compile_for_eval)
322 #define cur_mid (parser->parser_cur_mid)
323 #define in_defined (parser->parser_in_defined)
324 #define tokenbuf (parser->parser_tokenbuf)
325 #define tokidx (parser->parser_tokidx)
326 #define toksiz (parser->parser_toksiz)
327 #define tokline (parser->parser_tokline)
328 #define lex_input (parser->parser_lex_input)
329 #define lex_lastline (parser->parser_lex_lastline)
330 #define lex_nextline (parser->parser_lex_nextline)
331 #define lex_pbeg (parser->parser_lex_pbeg)
332 #define lex_p (parser->parser_lex_p)
333 #define lex_pend (parser->parser_lex_pend)
334 #define heredoc_end (parser->parser_heredoc_end)
335 #define command_start (parser->parser_command_start)
336 #define deferred_nodes (parser->parser_deferred_nodes)
337 #define lex_gets_ptr (parser->parser_lex_gets_ptr)
338 #define lex_gets (parser->parser_lex_gets)
339 #define lvtbl (parser->parser_lvtbl)
340 #define ruby__end__seen (parser->parser_ruby__end__seen)
341 #define ruby_sourceline (parser->parser_ruby_sourceline)
342 #define ruby_sourcefile (parser->parser_ruby_sourcefile)
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)
353 static int yylex(
void*,
void*);
356 #define yyparse ruby_yyparse
359 #define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3))
362 #define cond(node) cond_gen(parser, (node))
364 #define logop(type,node1,node2) logop_gen(parser, (type), (node1), (node2))
372 #define value_expr(node) value_expr_gen(parser, (node) = remove_begin(node))
373 #define void_expr0(node) void_expr_gen(parser, (node))
374 #define void_expr(node) void_expr0((node) = remove_begin(node))
376 #define void_stmts(node) void_stmts_gen(parser, (node))
378 #define reduce_nodes(n) reduce_nodes_gen(parser,(n))
380 #define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2))
383 #define block_append(h,t) block_append_gen(parser,(h),(t))
385 #define list_append(l,i) list_append_gen(parser,(l),(i))
387 #define list_concat(h,t) list_concat_gen(parser,(h),(t))
389 #define arg_append(h,t) arg_append_gen(parser,(h),(t))
391 #define arg_concat(h,t) arg_concat_gen(parser,(h),(t))
393 #define literal_concat(h,t) literal_concat_gen(parser,(h),(t))
396 #define new_evstr(n) new_evstr_gen(parser,(n))
398 #define evstr2dstr(n) evstr2dstr_gen(parser,(n))
402 #define call_bin_op(recv,id,arg1) call_bin_op_gen(parser, (recv),(id),(arg1))
404 #define call_uni_op(recv,id) call_uni_op_gen(parser, (recv),(id))
407 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
409 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
413 #define ret_args(node) ret_args_gen(parser, (node))
416 #define new_yield(node) new_yield_gen(parser, (node))
418 #define dsym_node(node) dsym_node_gen(parser, (node))
421 #define gettable(id) gettable_gen(parser,(id))
423 #define assignable(id,node) assignable_gen(parser, (id), (node))
426 #define aryset(node1,node2) aryset_gen(parser, (node1), (node2))
428 #define attrset(node,id) attrset_gen(parser, (node), (id))
431 #define rb_backref_error(n) rb_backref_error_gen(parser,(n))
433 #define node_assign(node1, node2) node_assign_gen(parser, (node1), (node2))
437 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (attr), (op), (rhs))
439 #define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs))
442 #define match_op(node1,node2) match_op_gen(parser, (node1), (node2))
445 #define local_tbl() local_tbl_gen(parser)
450 #define reg_compile(str,options) reg_compile_gen(parser, (str), (options))
452 #define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options))
454 #define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options))
456 #define reg_named_capture_assign(regexp,match) reg_named_capture_assign_gen(parser,(regexp),(match))
458 #define get_id(id) (id)
459 #define get_value(val) (val)
461 #define value_expr(node) ((void)(node))
462 #define remove_begin(node) (node)
463 #define rb_dvar_defined(id) 0
464 #define rb_local_defined(id) 0
466 #define get_id(id) ripper_get_id(id)
468 #define get_value(val) ripper_get_value(val)
470 #define assignable(lhs,node) assignable_gen(parser, (lhs))
472 #define id_is_var(id) id_is_var_gen(parser, (id))
474 #define node_assign(node1, node2) dispatch2(assign, (node1), (node2))
478 #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs))
482 #define new_op_assign(lhs, op, rhs) new_op_assign_gen(parser, (lhs), (op), (rhs))
485 #define formal_argument(id) formal_argument_gen(parser, (id))
487 #define shadowing_lvar(name) shadowing_lvar_gen(parser, (name))
489 #define new_bv(id) new_bv_gen(parser, (id))
492 #define local_push(top) local_push_gen(parser,(top))
494 #define local_pop() local_pop_gen(parser)
496 #define local_var(id) local_var_gen(parser, (id))
498 #define arg_var(id) arg_var_gen(parser, (id))
500 #define local_id(id) local_id_gen(parser, (id))
502 #define internal_id() internal_id_gen(parser)
505 #define dyna_push() dyna_push_gen(parser)
507 #define dyna_pop(node) dyna_pop_gen(parser, (node))
509 #define dyna_in_block() dyna_in_block_gen(parser)
510 #define dyna_var(id) local_var(id)
512 #define dvar_defined(id) dvar_defined_gen(parser, (id), 0)
513 #define dvar_defined_get(id) dvar_defined_gen(parser, (id), 1)
515 #define dvar_curr(id) dvar_curr_gen(parser, (id))
518 #define lvar_defined(id) lvar_defined_gen(parser, (id))
520 #define RE_OPTION_ONCE (1<<16)
521 #define RE_OPTION_ENCODING_SHIFT 8
522 #define RE_OPTION_ENCODING(e) (((e)&0xff)<<RE_OPTION_ENCODING_SHIFT)
523 #define RE_OPTION_ENCODING_IDX(o) (((o)>>RE_OPTION_ENCODING_SHIFT)&0xff)
524 #define RE_OPTION_ENCODING_NONE(o) ((o)&RE_OPTION_ARG_ENCODING_NONE)
525 #define RE_OPTION_MASK 0xff
526 #define RE_OPTION_ARG_ENCODING_NONE 32
528 #define NODE_STRTERM NODE_ZARRAY
529 #define NODE_HEREDOC NODE_ARRAY
530 #define SIGN_EXTEND(x,n) (((1<<(n)-1)^((x)&~(~0<<(n))))-(1<<(n)-1))
531 #define nd_func u1.id
532 #if SIZEOF_SHORT == 2
533 #define nd_term(node) ((signed short)(node)->u2.id)
535 #define nd_term(node) SIGN_EXTEND((node)->u2.id, CHAR_BIT*2)
537 #define nd_paren(node) (char)((node)->u2.id >> CHAR_BIT*2)
538 #define nd_nest u3.cnt
543 #define RIPPER_VERSION "0.1.0"
556 #define dispatch0(n) ripper_dispatch0(parser, TOKEN_PASTE(ripper_id_, n))
557 #define dispatch1(n,a) ripper_dispatch1(parser, TOKEN_PASTE(ripper_id_, n), (a))
558 #define dispatch2(n,a,b) ripper_dispatch2(parser, TOKEN_PASTE(ripper_id_, n), (a), (b))
559 #define dispatch3(n,a,b,c) ripper_dispatch3(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c))
560 #define dispatch4(n,a,b,c,d) ripper_dispatch4(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d))
561 #define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), (a), (b), (c), (d), (e))
562 #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))
564 #define yyparse ripper_yyparse
566 #define ripper_intern(s) ID2SYM(rb_intern(s))
567 static VALUE ripper_id2sym(
ID);
569 #define ripper_id2sym(id) ((id) < 256 && rb_ispunct(id) ? \
570 ID2SYM(id) : ripper_id2sym(id))
573 #define arg_new() dispatch0(args_new)
574 #define arg_add(l,a) dispatch2(args_add, (l), (a))
575 #define arg_add_star(l,a) dispatch2(args_add_star, (l), (a))
576 #define arg_add_block(l,b) dispatch2(args_add_block, (l), (b))
577 #define arg_add_optblock(l,b) ((b)==Qundef? (l) : dispatch2(args_add_block, (l), (b)))
578 #define bare_assoc(v) dispatch1(bare_assoc_hash, (v))
579 #define arg_add_assocs(l,b) arg_add((l), bare_assoc(b))
581 #define args2mrhs(a) dispatch1(mrhs_new_from_args, (a))
582 #define mrhs_new() dispatch0(mrhs_new)
583 #define mrhs_add(l,a) dispatch2(mrhs_add, (l), (a))
584 #define mrhs_add_star(l,a) dispatch2(mrhs_add_star, (l), (a))
586 #define mlhs_new() dispatch0(mlhs_new)
587 #define mlhs_add(l,a) dispatch2(mlhs_add, (l), (a))
588 #define mlhs_add_star(l,a) dispatch2(mlhs_add_star, (l), (a))
590 #define params_new(pars, opts, rest, pars2, kws, kwrest, blk) \
591 dispatch7(params, (pars), (opts), (rest), (pars2), (kws), (kwrest), (blk))
593 #define blockvar_new(p,v) dispatch2(block_var, (p), (v))
594 #define blockvar_add_star(l,a) dispatch2(block_var_add_star, (l), (a))
595 #define blockvar_add_block(l,a) dispatch2(block_var_add_block, (l), (a))
597 #define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a)))
598 #define method_arg(m,a) dispatch2(method_add_arg,(m),(a))
599 #define method_add_block(m,b) dispatch2(method_add_block, (m), (b))
601 #define escape_Qundef(x) ((x)==Qundef ? Qnil : (x))
610 #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t))
617 #define new_args_tail(k,kr,b) new_args_tail_gen(parser, (k),(kr),(b))
625 # define ifndef_ripper(x) (x)
628 # define ifndef_ripper(x)
632 # define rb_warn0(fmt) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt))
633 # define rb_warnI(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
634 # define rb_warnS(fmt,a) rb_compile_warn(ruby_sourcefile, ruby_sourceline, (fmt), (a))
635 # define rb_warn4S(file,line,fmt,a) rb_compile_warn((file), (line), (fmt), (a))
636 # define rb_warning0(fmt) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt))
637 # define rb_warningS(fmt,a) rb_compile_warning(ruby_sourcefile, ruby_sourceline, (fmt), (a))
639 # define rb_warn0(fmt) ripper_warn0(parser, (fmt))
640 # define rb_warnI(fmt,a) ripper_warnI(parser, (fmt), (a))
641 # define rb_warnS(fmt,a) ripper_warnS(parser, (fmt), (a))
642 # define rb_warn4S(file,line,fmt,a) ripper_warnS(parser, (fmt), (a))
643 # define rb_warning0(fmt) ripper_warning0(parser, (fmt))
644 # define rb_warningS(fmt,a) ripper_warningS(parser, (fmt), (a))
645 static void ripper_warn0(
struct parser_params*,
const char*);
646 static void ripper_warnI(
struct parser_params*,
const char*,
int);
647 static void ripper_warnS(
struct parser_params*,
const char*,
const char*);
648 static void ripper_warning0(
struct parser_params*,
const char*);
649 static void ripper_warningS(
struct parser_params*,
const char*,
const char*);
653 static void ripper_compile_error(
struct parser_params*,
const char *
fmt, ...);
654 # define rb_compile_error ripper_compile_error
655 # define compile_error ripper_compile_error
656 # define PARSER_ARG parser,
658 # define rb_compile_error rb_compile_error_with_enc
659 # define compile_error parser->nerr++,rb_compile_error_with_enc
660 # define PARSER_ARG ruby_sourcefile, ruby_sourceline, current_enc,
668 #define YYMAXDEPTH 10000
675 #define token_info_push(token) (RTEST(ruby_verbose) ? token_info_push(parser, (token)) : (void)0)
676 #define token_info_pop(token) (RTEST(ruby_verbose) ? token_info_pop(parser, (token)) : (void)0)
678 #define token_info_push(token)
679 #define token_info_pop(token)
754 %type <val> singleton strings
string string1 xstring regexp
755 %type <val> string_contents xstring_contents regexp_contents string_content
756 %type <val> words
symbols symbol_list qwords qsymbols word_list qword_list qsym_list word
757 %type <val> literal numeric dsym cpath
758 %type <val> top_compstmt top_stmts
top_stmt
760 %type <val> expr_value arg_value primary_value fcall
761 %type <val> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
763 %type <val> paren_args opt_paren_args args_tail opt_args_tail block_args_tail opt_block_args_tail
764 %type <val>
command_args aref_args opt_block_arg block_arg var_ref var_lhs
765 %type <val> command_asgn mrhs superclass block_call block_command
766 %type <val> f_block_optarg f_block_opt
767 %type <val> f_arglist f_args f_arg f_arg_item f_optarg f_marg f_marg_list f_margs
768 %type <val> assoc_list assocs
assoc undef_list backref string_dvar for_var
769 %type <val> block_param opt_block_param block_param_def f_opt
770 %type <val> f_kwarg f_kw f_block_kwarg f_block_kw
771 %type <val> bv_decls opt_bv_decl bvar
772 %type <val> lambda f_larglist lambda_body
776 %type <val> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
780 %type <val> program reswords then
do dot_or_colon
866 while (node->nd_next) {
867 node = node->nd_next;
875 parser->result = dispatch1(program, $$);
881 top_compstmt : top_stmts opt_terms
897 $$ = dispatch2(stmts_add,
dispatch0(stmts_new),
906 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
914 $$ = dispatch2(stmts_add, $1, $3);
940 $$ = dispatch1(BEGIN, $4);
956 rb_warn0(
"else without rescue is useless");
1003 $$ = dispatch2(stmts_add,
dispatch0(stmts_new), $1);
1011 $$ = dispatch2(stmts_add, $1, $3);
1026 yyerror(
"BEGIN is permitted only at toplevel");
1032 '{' top_compstmt
'}'
1041 $$ = dispatch1(BEGIN, $4);
1050 $$ = dispatch2(
alias, $2, $4);
1058 $$ = dispatch2(var_alias, $2, $3);
1069 $$ = dispatch2(var_alias, $2, $3);
1075 yyerror(
"can't make alias for the number variables");
1078 $$ = dispatch2(var_alias, $2, $3);
1079 $$ = dispatch1(alias_error, $$);
1087 $$ = dispatch1(undef, $2);
1096 $$ = dispatch2(if_mod, $3, $1);
1105 $$ = dispatch2(unless_mod, $3, $1);
1118 $$ = dispatch2(while_mod, $3, $1);
1131 $$ = dispatch2(until_mod, $3, $1);
1140 $$ = dispatch2(rescue_mod, $1, $3);
1146 rb_warn0(
"END in method; use at_exit");
1152 $$ = dispatch1(
END, $3);
1163 $$ = dispatch2(massign, $1, $3);
1189 $$ = dispatch3(opassign, $$, $5, $6);
1208 $$ = dispatch2(const_path_field, $1, $3);
1209 $$ = dispatch3(opassign, $$, $4, $5);
1223 $$ = dispatch2(assign, dispatch1(var_field, $1), $3);
1224 $$ = dispatch1(assign_error, $$);
1233 $$ = dispatch2(assign, $1, $3);
1236 | mlhs
'=' arg_value
1242 $$ = dispatch2(massign, $1, $3);
1251 $$ = dispatch2(massign, $1, $3);
1263 $$ = dispatch2(assign, $1, $3);
1272 $$ = dispatch2(assign, $1, $3);
1308 $$ = dispatch2(unary, ripper_id2sym(
'!'), $2);
1330 block_command : block_call
1336 $$ = dispatch3(call, $1, $2, $3);
1337 $$ = method_arg($$, $4);
1380 $$ = dispatch2(command, $1, $2);
1392 $$ = dispatch2(command, $1, $2);
1393 $$ = method_add_block($$, $3);
1402 $$ = dispatch4(
command_call, $1, ripper_id2sym(
'.'), $3, $4);
1409 $5->nd_iter =
NEW_CALL($1, $3, $4);
1413 $$ = dispatch4(
command_call, $1, ripper_id2sym(
'.'), $3, $4);
1414 $$ = method_add_block($$, $5);
1435 $$ = method_add_block($$, $5);
1444 $$ = dispatch1(super, $2);
1453 $$ = dispatch1(yield, $2);
1461 $$ = dispatch1(
return, $2);
1469 $$ = dispatch1(
break, $2);
1477 $$ = dispatch1(next, $2);
1488 $$ = dispatch1(mlhs_paren, $2);
1499 $$ = dispatch1(mlhs_paren, $2);
1517 $$ = mlhs_add($1, $2);
1525 $$ = mlhs_add_star($1, $3);
1533 $1 = mlhs_add_star($1, $3);
1534 $$ = mlhs_add($1, $5);
1542 $$ = mlhs_add_star($1,
Qnil);
1550 $1 = mlhs_add_star($1,
Qnil);
1551 $$ = mlhs_add($1, $4);
1559 $$ = mlhs_add_star(mlhs_new(), $2);
1567 $2 = mlhs_add_star(mlhs_new(), $2);
1568 $$ = mlhs_add($2, $4);
1576 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1584 $$ = mlhs_add_star(mlhs_new(),
Qnil);
1585 $$ = mlhs_add($$, $3);
1596 $$ = dispatch1(mlhs_paren, $2);
1606 $$ = mlhs_add(mlhs_new(), $1);
1614 $$ = mlhs_add($1, $2);
1624 $$ = mlhs_add(mlhs_new(), $1);
1632 $$ = mlhs_add($1, $3);
1645 | primary_value
'[' opt_call_args rbracket
1658 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1666 $$ = dispatch2(const_path_field, $1, $3);
1674 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1681 yyerror(
"dynamic constant assignment");
1685 yyerror(
"dynamic constant assignment");
1686 $$ = dispatch2(const_path_field, $1, $3);
1693 yyerror(
"dynamic constant assignment");
1696 $$ = dispatch1(top_const_field, $2);
1705 $$ = dispatch1(var_field, $1);
1706 $$ = dispatch1(assign_error, $$);
1717 $$ = dispatch1(var_field, $$);
1726 $$ = dispatch1(var_field, $$);
1729 | primary_value
'[' opt_call_args rbracket
1742 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1758 $$ = dispatch3(field, $1, ripper_id2sym(
'.'), $3);
1765 yyerror(
"dynamic constant assignment");
1768 $$ = dispatch2(const_path_field, $1, $3);
1770 $$ = dispatch1(assign_error, $$);
1778 yyerror(
"dynamic constant assignment");
1781 $$ = dispatch1(top_const_field, $2);
1783 $$ = dispatch1(assign_error, $$);
1793 $$ = dispatch1(assign_error, $1);
1801 yyerror(
"class/module name must be CONSTANT");
1803 $$ = dispatch1(class_name_error, $1);
1814 $$ = dispatch1(top_const_ref, $2);
1822 $$ = dispatch1(const_ref, $1);
1830 $$ = dispatch2(const_path_ref, $1, $3);
1863 $$ = dispatch1(symbol_literal, $1);
1877 | undef_list
',' {
lex_state = EXPR_FNAME;} fitem
1939 $$ = dispatch2(assign, $1, $3);
1949 $$ = dispatch2(assign, $1, dispatch2(rescue_mod, $3, $5));
1963 $3 = dispatch2(rescue_mod, $3, $5);
1967 | primary_value
'[' opt_call_args rbracket
tOP_ASGN arg
1990 $$ = dispatch3(opassign, $1, $5, $6);
2014 $$ = dispatch2(const_path_field, $1, $3);
2015 $$ = dispatch3(opassign, $$, $4, $5);
2024 $$ = dispatch1(top_const_field, $2);
2025 $$ = dispatch3(opassign, $$, $3, $4);
2034 $$ = dispatch1(var_field, $1);
2035 $$ = dispatch3(opassign, $$, $2, $3);
2036 $$ = dispatch1(assign_error, $$);
2050 $$ = dispatch2(dot2, $1, $3);
2064 $$ = dispatch2(dot3, $1, $3);
2072 $$ = dispatch3(binary, $1,
ID2SYM(
'+'), $3);
2080 $$ = dispatch3(binary, $1,
ID2SYM(
'-'), $3);
2088 $$ = dispatch3(binary, $1,
ID2SYM(
'*'), $3);
2096 $$ = dispatch3(binary, $1,
ID2SYM(
'/'), $3);
2104 $$ = dispatch3(binary, $1,
ID2SYM(
'%'), $3);
2154 $$ = dispatch3(binary, $1,
ID2SYM(
'|'), $3);
2162 $$ = dispatch3(binary, $1,
ID2SYM(
'^'), $3);
2170 $$ = dispatch3(binary, $1,
ID2SYM(
'&'), $3);
2186 $$ = dispatch3(binary, $1,
ID2SYM(
'>'), $3);
2202 $$ = dispatch3(binary, $1,
ID2SYM(
'<'), $3);
2261 $$ = dispatch2(unary,
ID2SYM(
'!'), $2);
2269 $$ = dispatch2(unary,
ID2SYM(
'~'), $2);
2311 $$ = dispatch1(defined, $4);
2321 $$ = dispatch3(ifop, $1, $3, $6);
2347 | args
',' assocs trailer
2352 $$ = arg_add_assocs($1, $3);
2360 $$ = arg_add_assocs(arg_new(), $1);
2365 paren_args :
'(' opt_call_args rparen
2375 opt_paren_args : none
2379 opt_call_args : none
2385 | args
',' assocs
','
2390 $$ = arg_add_assocs($1, $3);
2398 $$ = arg_add_assocs(arg_new(), $1);
2409 $$ = arg_add(arg_new(), $1);
2412 | args opt_block_arg
2417 $$ = arg_add_optblock($1, $2);
2420 | assocs opt_block_arg
2426 $$ = arg_add_assocs(arg_new(), $1);
2427 $$ = arg_add_optblock($$, $2);
2430 | args
',' assocs opt_block_arg
2436 $$ = arg_add_optblock(arg_add_assocs($1, $3), $4);
2443 $$ = arg_add_block(arg_new(), $1);
2460 block_arg :
tAMPER arg_value
2470 opt_block_arg :
',' block_arg
2485 $$ = arg_add(arg_new(), $1);
2493 $$ = arg_add_star(arg_new(), $2);
2496 | args
',' arg_value
2507 $$ = arg_add($1, $3);
2510 | args
',' tSTAR arg_value
2521 $$ = arg_add_star($1, $4);
2526 mrhs : args
',' arg_value
2537 $$ = mrhs_add(args2mrhs($1), $3);
2540 | args
',' tSTAR arg_value
2552 $$ = mrhs_add_star(args2mrhs($1), $4);
2560 $$ = mrhs_add_star(mrhs_new(), $2);
2580 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2608 $$ = dispatch1(begin, $3);
2616 $$ = dispatch1(paren, 0);
2624 $$ = dispatch1(paren, $2);
2632 $$ = dispatch1(paren, $2);
2640 $$ = dispatch2(const_path_ref, $1, $3);
2648 $$ = dispatch1(top_const_ref, $2);
2685 $$ = dispatch1(yield, dispatch1(paren, $3));
2693 $$ = dispatch1(yield, dispatch1(paren, arg_new()));
2711 $$ = dispatch1(defined, $5);
2736 $$ = method_arg(dispatch1(fcall, $1), arg_new());
2737 $$ = method_add_block($$, $2);
2741 | method_call brace_block
2748 $$ = method_add_block($1, $2);
2755 | k_if expr_value then
2767 | k_unless expr_value then
2787 $$ = dispatch2(
while, $3, $6);
2798 $$ = dispatch2(until, $3, $6);
2801 | k_case expr_value opt_terms
2809 $$ = dispatch2(
case, $2, $4);
2812 | k_case opt_terms case_body k_end
2817 $$ = dispatch2(
case,
Qnil, $3);
2879 tbl[0] = 1; tbl[1] =
id;
2883 $$ = dispatch3(
for, $2, $5, $8);
2886 | k_class cpath superclass
2889 yyerror(
"class definition in method body");
2903 $$ = dispatch3(
class, $2, $3, $5);
2925 $$ = dispatch2(sclass, $3, $7);
2934 yyerror(
"module definition in method body");
2948 $$ = dispatch2(module, $2, $4);
2969 $$ = dispatch3(def, $2, $4, $5);
2975 | k_def singleton dot_or_colon {
lex_state = EXPR_FNAME;} fname
2991 $$ = dispatch5(defs, $2, $3, $5, $7, $8);
3001 $$ = dispatch1(
break, arg_new());
3009 $$ = dispatch1(next, arg_new());
3030 primary_value : primary
3153 $$ = dispatch1(
else, $2);
3167 $$ = dispatch1(mlhs_paren, $$);
3175 $$ = dispatch1(mlhs_paren, $2);
3180 f_marg_list : f_marg
3185 $$ = mlhs_add(mlhs_new(), $1);
3188 | f_marg_list
',' f_marg
3193 $$ = mlhs_add($1, $3);
3198 f_margs : f_marg_list
3206 | f_marg_list
',' tSTAR f_norm_arg
3212 $$ = mlhs_add_star($1, $$);
3215 | f_marg_list
',' tSTAR f_norm_arg
',' f_marg_list
3221 $$ = mlhs_add_star($1, $$);
3224 | f_marg_list
',' tSTAR
3229 $$ = mlhs_add_star($1,
Qnil);
3232 | f_marg_list
',' tSTAR ',' f_marg_list
3237 $$ = mlhs_add_star($1, $5);
3246 $$ = mlhs_add_star(mlhs_new(), $$);
3249 |
tSTAR f_norm_arg
',' f_marg_list
3258 $$ = mlhs_add_star($$, $4);
3266 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3269 |
tSTAR ',' f_marg_list
3274 $$ = mlhs_add_star(mlhs_new(),
Qnil);
3280 block_args_tail : f_block_kwarg
',' f_kwrest opt_f_block_arg
3284 | f_block_kwarg opt_f_block_arg
3288 | f_kwrest opt_f_block_arg
3298 opt_block_args_tail :
',' block_args_tail
3308 block_param : f_arg
',' f_block_optarg
',' f_rest_arg opt_block_args_tail
3312 | f_arg
',' f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3316 | f_arg
',' f_block_optarg opt_block_args_tail
3320 | f_arg
',' f_block_optarg
',' f_arg opt_block_args_tail
3324 | f_arg
',' f_rest_arg opt_block_args_tail
3333 dispatch1(excessed_comma, $$);
3336 | f_arg
',' f_rest_arg
',' f_arg opt_block_args_tail
3340 | f_arg opt_block_args_tail
3344 | f_block_optarg
',' f_rest_arg opt_block_args_tail
3348 | f_block_optarg
',' f_rest_arg
',' f_arg opt_block_args_tail
3352 | f_block_optarg opt_block_args_tail
3356 | f_block_optarg
',' f_arg opt_block_args_tail
3360 | f_rest_arg opt_block_args_tail
3364 | f_rest_arg
',' f_arg opt_block_args_tail
3374 opt_block_param : none
3381 block_param_def :
'|' opt_bv_decl
'|'
3399 |
'|' block_param opt_bv_decl
'|'
3410 opt_bv_decl : opt_nl
3414 | opt_nl
';' bv_decls opt_nl
3468 $$ = dispatch2(lambda, $3, $4);
3474 f_larglist :
'(' f_args opt_bv_decl
')'
3479 $$ = dispatch1(paren, $2);
3523 block_call : command do_block
3536 $$ = method_add_block($1, $2);
3539 | block_call dot_or_colon operation2 opt_paren_args
3544 $$ = dispatch3(call, $1, $2, $3);
3545 $$ = method_optarg($$, $4);
3548 | block_call dot_or_colon operation2 opt_paren_args brace_block
3552 $5->nd_iter =
NEW_CALL($1, $3, $4);
3557 $$ = method_add_block($$, $5);
3560 | block_call dot_or_colon operation2
command_args do_block
3564 $5->nd_iter =
NEW_CALL($1, $3, $4);
3569 $$ = method_add_block($$, $5);
3574 method_call : fcall paren_args
3580 $$ = method_arg(dispatch1(fcall, $1), $2);
3583 | primary_value
'.' operation2
3595 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3596 $$ = method_optarg($$, $5);
3599 | primary_value
tCOLON2 operation2
3611 $$ = dispatch3(call, $1, ripper_id2sym(
'.'), $3);
3612 $$ = method_optarg($$, $5);
3615 | primary_value
tCOLON2 operation3
3635 $$ = dispatch3(call, $1, ripper_id2sym(
'.'),
3637 $$ = method_optarg($$, $4);
3654 $$ = method_optarg($$, $4);
3662 $$ = dispatch1(super, $2);
3673 | primary_value
'[' opt_call_args rbracket
3755 $$ = dispatch4(rescue,
3765 exc_list : arg_value
3796 $$ = dispatch1(ensure, $2);
3808 $$ = dispatch1(symbol_literal, $1);
3838 $$ = dispatch2(string_concat, $1, $2);
3848 $$ = dispatch1(string_literal, $2);
3875 $$ = dispatch1(xstring_literal, $2);
3908 for (list = (prev = node)->
nd_next;
list; list = list->nd_next) {
3910 VALUE tail = list->nd_head->nd_lit;
3912 VALUE lit = prev == node ? prev->nd_lit : prev->nd_head->nd_lit;
3918 prev->nd_next = list->nd_next;
3931 if (!node->nd_next) {
3940 $$ = dispatch2(regexp_literal, $2, $3);
3951 $$ = dispatch1(array, $$);
3959 $$ = dispatch1(array, $2);
3972 | word_list word
' '
3977 $$ = dispatch2(words_add, $1, $2);
3982 word : string_content
3987 $$ = dispatch2(word_add, $$, $1);
3990 | word string_content
3995 $$ = dispatch2(word_add, $1, $2);
4006 $$ = dispatch1(array, $$);
4014 $$ = dispatch1(array, $2);
4027 | symbol_list word
' '
4034 $$ = dispatch2(symbols_add, $1, $2);
4045 $$ = dispatch1(array, $$);
4053 $$ = dispatch1(array, $2);
4064 $$ = dispatch1(array, $$);
4072 $$ = dispatch1(array, $2);
4090 $$ = dispatch2(qwords_add, $1, $2);
4112 $$ = dispatch2(qsymbols_add, $1, $2);
4125 | string_contents string_content
4130 $$ = dispatch2(string_add, $1, $2);
4143 | xstring_contents string_content
4148 $$ = dispatch2(xstring_add, $1, $2);
4161 | regexp_contents string_content
4185 $$ = dispatch2(regexp_add, $1, $2);
4204 $$ = dispatch1(string_dvar, $3);
4233 $$ = dispatch1(string_embexpr, $5);
4243 $$ = dispatch1(var_ref, $1);
4251 $$ = dispatch1(var_ref, $1);
4259 $$ = dispatch1(var_ref, $1);
4271 $$ = dispatch1(symbol, $2);
4288 $$ = dispatch1(dyna_symbol, $2);
4329 var_ref : user_variable
4334 if (id_is_var(
get_id($1))) {
4335 $$ = dispatch1(var_ref, $1);
4338 $$ = dispatch1(vcall, $1);
4347 $$ = dispatch1(var_ref, $1);
4352 var_lhs : user_variable
4357 $$ = dispatch1(var_field, $$);
4365 $$ = dispatch1(var_field, $$);
4403 f_arglist :
'(' f_args rparen
4408 $$ = dispatch1(paren, $2);
4421 args_tail : f_kwarg
',' f_kwrest opt_f_block_arg
4425 | f_kwarg opt_f_block_arg
4429 | f_kwrest opt_f_block_arg
4439 opt_args_tail :
',' args_tail
4449 f_args : f_arg
',' f_optarg
',' f_rest_arg opt_args_tail
4453 | f_arg
',' f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4457 | f_arg
',' f_optarg opt_args_tail
4461 | f_arg
',' f_optarg
',' f_arg opt_args_tail
4465 | f_arg
',' f_rest_arg opt_args_tail
4469 | f_arg
',' f_rest_arg
',' f_arg opt_args_tail
4473 | f_arg opt_args_tail
4477 | f_optarg
',' f_rest_arg opt_args_tail
4481 | f_optarg
',' f_rest_arg
',' f_arg opt_args_tail
4485 | f_optarg opt_args_tail
4489 | f_optarg
',' f_arg opt_args_tail
4493 | f_rest_arg opt_args_tail
4497 | f_rest_arg
',' f_arg opt_args_tail
4515 yyerror(
"formal argument cannot be a constant");
4518 $$ = dispatch1(param_error, $1);
4524 yyerror(
"formal argument cannot be an instance variable");
4527 $$ = dispatch1(param_error, $1);
4533 yyerror(
"formal argument cannot be a global variable");
4536 $$ = dispatch1(param_error, $1);
4542 yyerror(
"formal argument cannot be a class variable");
4545 $$ = dispatch1(param_error, $1);
4550 f_norm_arg : f_bad_arg
4558 f_arg_item : f_norm_arg
4581 $$ = dispatch1(mlhs_paren, $2);
4593 | f_arg
',' f_arg_item
4618 f_block_kw :
tLABEL primary_value
4630 f_block_kwarg : f_block_kw
4638 | f_block_kwarg
',' f_block_kw
4643 while (kws->nd_next) {
4668 while (kws->nd_next) {
4718 f_block_optarg : f_block_opt
4726 | f_block_optarg
',' f_block_opt
4731 while (opts->nd_next) {
4732 opts = opts->nd_next;
4750 | f_optarg
',' f_opt
4755 while (opts->nd_next) {
4756 opts = opts->nd_next;
4774 yyerror(
"rest argument must be local variable");
4780 $$ = dispatch1(rest_param, $2);
4789 $$ = dispatch1(rest_param,
Qnil);
4802 yyerror(
"block argument must be local variable");
4804 yyerror(
"duplicated block argument name");
4810 $$ = dispatch1(blockarg, $2);
4815 opt_f_block_arg :
',' f_block_arg
4843 yyerror(
"can't define singleton method for ().");
4855 yyerror(
"can't define singleton method for literals");
4863 $$ = dispatch1(paren, $3);
4874 $$ = dispatch1(assoclist_from_args, $1);
4901 $$ = dispatch2(assoc_new, $1, $3);
4909 $$ = dispatch2(assoc_new, $1, $2);
4917 $$ = dispatch1(assoc_splat, $2);
4963 rbracket : opt_nl
']'
4992 # define yylval (*((YYSTYPE*)(parser->parser_yylval)))
5001 # define nextc() parser_nextc(parser)
5002 # define pushback(c) parser_pushback(parser, (c))
5003 # define newtok() parser_newtok(parser)
5004 # define tokspace(n) parser_tokspace(parser, (n))
5005 # define tokadd(c) parser_tokadd(parser, (c))
5006 # define tok_hex(numlen) parser_tok_hex(parser, (numlen))
5007 # define read_escape(flags,e) parser_read_escape(parser, (flags), (e))
5008 # define tokadd_escape(e) parser_tokadd_escape(parser, (e))
5009 # define regx_options() parser_regx_options(parser)
5010 # define tokadd_string(f,t,p,n,e) parser_tokadd_string(parser,(f),(t),(p),(n),(e))
5011 # define parse_string(n) parser_parse_string(parser,(n))
5012 # define tokaddmbc(c, enc) parser_tokaddmbc(parser, (c), (enc))
5013 # define here_document(n) parser_here_document(parser,(n))
5014 # define heredoc_identifier() parser_heredoc_identifier(parser)
5015 # define heredoc_restore(n) parser_heredoc_restore(parser,(n))
5016 # define whole_match_p(e,l,i) parser_whole_match_p(parser,(e),(l),(i))
5019 # define set_yylval_str(x) (yylval.node = NEW_STR(x))
5020 # define set_yylval_num(x) (yylval.num = (x))
5021 # define set_yylval_id(x) (yylval.id = (x))
5022 # define set_yylval_name(x) (yylval.id = (x))
5023 # define set_yylval_literal(x) (yylval.node = NEW_LIT(x))
5024 # define set_yylval_node(x) (yylval.node = (x))
5025 # define yylval_id() (yylval.id)
5028 ripper_yylval_id(
ID x)
5032 # define set_yylval_str(x) (void)(x)
5033 # define set_yylval_num(x) (void)(x)
5034 # define set_yylval_id(x) (void)(x)
5035 # define set_yylval_name(x) (void)(yylval.val = ripper_yylval_id(x))
5036 # define set_yylval_literal(x) (void)(x)
5037 # define set_yylval_node(x) (void)(x)
5038 # define yylval_id() yylval.id
5042 #define ripper_flush(p) (void)(p)
5044 #define ripper_flush(p) ((p)->tokp = (p)->parser_lex_p)
5046 #define yylval_rval (*(RB_TYPE_P(yylval.val, T_NODE) ? &yylval.node->nd_rval : &yylval.val))
5053 return lex_p > parser->tokp;
5066 ripper_dispatch_scan_event(
struct parser_params *parser,
int t)
5068 if (!ripper_has_scan_event(parser))
return;
5069 yylval_rval = ripper_scan_event_val(parser, t);
5073 ripper_dispatch_ignored_scan_event(
struct parser_params *parser,
int t)
5075 if (!ripper_has_scan_event(parser))
return;
5076 (
void)ripper_scan_event_val(parser, t);
5080 ripper_dispatch_delayed_token(
struct parser_params *parser,
int t)
5083 const char *saved_tokp = parser->tokp;
5086 parser->tokp =
lex_pbeg + parser->delayed_col;
5088 parser->delayed =
Qnil;
5090 parser->tokp = saved_tokp;
5101 #undef SIGN_EXTEND_CHAR
5103 # define SIGN_EXTEND_CHAR(c) ((signed char)(c))
5106 # define SIGN_EXTEND_CHAR(c) ((((unsigned char)(c)) ^ 128) - 128)
5109 #define parser_encoding_name() (current_enc->name)
5110 #define parser_mbclen() mbclen((lex_p-1),lex_pend,current_enc)
5111 #define parser_precise_mbclen() rb_enc_precise_mbclen((lex_p-1),lex_pend,current_enc)
5112 #define is_identchar(p,e,enc) (rb_enc_isalnum(*(p),(enc)) || (*(p)) == '_' || !ISASCII(*(p)))
5113 #define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,current_enc))
5115 #define parser_isascii() ISASCII(*(lex_p-1))
5123 for (p =
lex_pbeg; p < pend; p++) {
5125 column = (((column - 1) / 8) + 1) * 8;
5136 for (p =
lex_pbeg; p < pend; p++) {
5137 if (*p !=
' ' && *p !=
'\t') {
5144 #undef token_info_push
5161 #undef token_info_pop
5168 if (!ptinfo)
return;
5174 if (linenum == ptinfo->
linenum) {
5182 "mismatched indentations at '%s' with '%s' at %d",
5195 const int max_line_margin = 30;
5204 if (*p ==
'\n')
break;
5211 if (*pe ==
'\n')
break;
5218 const char *pre =
"", *post =
"";
5220 if (len > max_line_margin * 2 + 10) {
5221 if (
lex_p - p > max_line_margin) {
5225 if (pe -
lex_p > max_line_margin) {
5232 MEMCPY(buf, p,
char, len);
5237 p2 =
buf; pe = buf +
len;
5240 if (*p2 !=
'\t') *p2 =
' ';
5248 dispatch1(parse_error,
STR_NEW2(msg));
5260 CONST_ID(script_lines,
"SCRIPT_LINES__");
5281 RBASIC(lines)->klass = 0;
5283 RARRAY(lines)->as.heap.len =
n;
5378 char *beg, *
end, *pend;
5388 while (end < pend) {
5389 if (*end++ ==
'\n')
break;
5399 if (
NIL_P(line))
return line;
5498 #define STR_FUNC_ESCAPE 0x01
5499 #define STR_FUNC_EXPAND 0x02
5500 #define STR_FUNC_REGEXP 0x04
5501 #define STR_FUNC_QWORDS 0x08
5502 #define STR_FUNC_SYMBOL 0x10
5503 #define STR_FUNC_INDENT 0x20
5533 #define lex_goto_eol(parser) ((parser)->parser_lex_p = (parser)->parser_lex_pend)
5534 #define lex_eol_p() (lex_p >= lex_pend)
5535 #define peek(c) peek_n((c), 0)
5536 #define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
5559 if (
NIL_P(parser->delayed)) {
5563 parser->tokp,
lex_pend - parser->tokp);
5565 parser->delayed_col = (
int)(parser->tokp -
lex_pbeg);
5569 parser->tokp,
lex_pend - parser->tokp);
5585 c = (
unsigned char)*
lex_p++;
5586 if (c ==
'\r' &&
peek(
'\n')) {
5597 if (c == -1)
return;
5604 #define was_bol() (lex_p == lex_pbeg + 1)
5606 #define tokfix() (tokenbuf[tokidx]='\0')
5607 #define tok() tokenbuf
5608 #define toklen() tokidx
5609 #define toklast() (tokidx>0?tokenbuf[tokidx-1]:0)
5656 yyerror(
"invalid hex escape");
5663 #define tokcopy(n) memcpy(tokspace(n), lex_p - (n), (n))
5668 int string_literal,
int symbol_literal,
int regexp_literal)
5688 yyerror(
"invalid Unicode escape");
5691 if (codepoint > 0x10ffff) {
5692 yyerror(
"invalid Unicode codepoint (too large)");
5696 if (regexp_literal) {
5699 else if (codepoint >= 0x80) {
5701 if (string_literal)
tokaddmbc(codepoint, *encp);
5703 else if (string_literal) {
5706 }
while (string_literal && (
peek(
' ') ||
peek(
'\t')));
5709 yyerror(
"unterminated Unicode escape");
5713 if (regexp_literal) {
tokadd(
'}'); }
5719 yyerror(
"invalid Unicode escape");
5723 if (regexp_literal) {
5726 else if (codepoint >= 0x80) {
5728 if (string_literal)
tokaddmbc(codepoint, *encp);
5730 else if (string_literal) {
5738 #define ESCAPE_CONTROL 1
5739 #define ESCAPE_META 2
5748 switch (c =
nextc()) {
5773 case '0':
case '1':
case '2':
case '3':
5774 case '4':
case '5':
case '6':
case '7':
5782 if (numlen == 0)
return 0;
5793 if ((c =
nextc()) !=
'-') {
5797 if ((c =
nextc()) ==
'\\') {
5798 if (
peek(
'u'))
goto eof;
5799 return read_escape(flags|ESCAPE_META, encp) | 0x80;
5801 else if (c == -1 || !
ISASCII(c))
goto eof;
5803 return ((c & 0xff) | 0x80);
5807 if ((c =
nextc()) !=
'-') {
5813 if ((c =
nextc())==
'\\') {
5814 if (
peek(
'u'))
goto eof;
5819 else if (c == -1 || !
ISASCII(c))
goto eof;
5824 yyerror(
"Invalid escape character syntax");
5847 switch (c =
nextc()) {
5851 case '0':
case '1':
case '2':
case '3':
5852 case '4':
case '5':
case '6':
case '7':
5855 if (numlen == 0)
goto eof;
5864 if (numlen == 0)
return -1;
5870 if (flags & ESCAPE_META)
goto eof;
5871 if ((c =
nextc()) !=
'-') {
5880 if (flags & ESCAPE_CONTROL)
goto eof;
5881 if ((c =
nextc()) !=
'-') {
5889 if (flags & ESCAPE_CONTROL)
goto eof;
5893 if ((c =
nextc()) ==
'\\') {
5896 else if (c == -1)
goto eof;
5902 yyerror(
"Invalid escape character syntax");
5969 #define tokadd_mbchar(c) parser_tokadd_mbchar(parser, (c))
5975 case '$':
case '*':
case '+':
case '.':
5976 case '?':
case '^':
case '|':
5977 case ')':
case ']':
case '}':
case '>':
5986 int func,
int term,
int paren,
long *nest,
5990 int has_nonascii = 0;
5993 static const char mixed_msg[] =
"%s mixed within %s source";
5995 #define mixed_error(enc1, enc2) if (!errbuf) { \
5996 size_t len = sizeof(mixed_msg) - 4; \
5997 len += strlen(rb_enc_name(enc1)); \
5998 len += strlen(rb_enc_name(enc2)); \
5999 errbuf = ALLOCA_N(char, len); \
6000 snprintf(errbuf, len, mixed_msg, \
6001 rb_enc_name(enc1), \
6002 rb_enc_name(enc2)); \
6005 #define mixed_escape(beg, enc1, enc2) do { \
6006 const char *pos = lex_p; \
6008 mixed_error((enc1), (enc2)); \
6012 while ((c =
nextc()) != -1) {
6013 if (paren && c == paren) {
6016 else if (c == term) {
6017 if (!nest || !*nest) {
6025 if (c2 ==
'$' || c2 ==
'@' || c2 ==
'{') {
6030 else if (c ==
'\\') {
6031 const char *beg =
lex_p - 1;
6036 if (func & STR_FUNC_EXPAND)
continue;
6045 if ((func & STR_FUNC_EXPAND) == 0) {
6051 func & STR_FUNC_REGEXP);
6052 if (has_nonascii && enc != *encp) {
6058 if (c == -1)
return -1;
6060 if ((func & STR_FUNC_EXPAND) == 0)
tokadd(
'\\');
6063 if (func & STR_FUNC_REGEXP) {
6071 if (has_nonascii && enc != *encp) {
6076 else if (func & STR_FUNC_EXPAND) {
6078 if (func & STR_FUNC_ESCAPE)
tokadd(
'\\');
6081 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6084 else if (c != term && !(paren && c == paren)) {
6101 else if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6118 #define NEW_STRTERM(func, term, paren) \
6119 rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0)
6125 if (!
NIL_P(parser->delayed)) {
6126 ptrdiff_t len =
lex_p - parser->tokp;
6131 parser->tokp =
lex_p;
6135 #define flush_string_content(enc) ripper_flush_string_content(parser, (enc))
6137 #define flush_string_content(enc) ((void)(enc))
6144 #define BIT(c, idx) (((c) / 32 - 1 == idx) ? (1U << ((c) % 32)) : 0)
6145 #define SPECIAL_PUNCT(idx) ( \
6146 BIT('~', idx) | BIT('*', idx) | BIT('$', idx) | BIT('?', idx) | \
6147 BIT('!', idx) | BIT('@', idx) | BIT('/', idx) | BIT('\\', idx) | \
6148 BIT(';', idx) | BIT(',', idx) | BIT('.', idx) | BIT('=', idx) | \
6149 BIT(':', idx) | BIT('<', idx) | BIT('>', idx) | BIT('\"', idx) | \
6150 BIT('&', idx) | BIT('`', idx) | BIT('\'', idx) | BIT('+', idx) | \
6158 #undef SPECIAL_PUNCT
6164 if (c <= 0x20 || 0x7e < c)
return 0;
6165 return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1;
6172 const char *p =
lex_p;
6178 if ((c = *p) ==
'-') {
6187 if ((c = *p) ==
'@') {
6207 int func = (
int)quote->nd_func;
6215 if ((func & STR_FUNC_QWORDS) &&
ISSPACE(c)) {
6219 if (c == term && !quote->nd_nest) {
6220 if (func & STR_FUNC_QWORDS) {
6221 quote->nd_func = -1;
6224 if (!(func & STR_FUNC_REGEXP))
return tSTRING_END;
6233 if ((func & STR_FUNC_EXPAND) && c ==
'#') {
6243 if (func & STR_FUNC_REGEXP) {
6265 int c =
nextc(), term, func = 0;
6283 while ((c =
nextc()) != -1 && c != term) {
6330 line = here->nd_orig;
6334 lex_p = lex_pbeg + here->nd_nth;
6344 const char *eos,
long len,
int indent)
6350 while (*p &&
ISSPACE(*p)) p++;
6353 if (n < 0 || (n > 0 && p[len] !=
'\n' && p[len] !=
'\r'))
return FALSE;
6354 return strncmp(eos, p, len) == 0;
6361 if (!
NIL_P(parser->delayed))
6364 ripper_dispatch_ignored_scan_event(parser,
tHEREDOC_END);
6367 #define dispatch_heredoc_end() ripper_dispatch_heredoc_end(parser)
6369 #define dispatch_heredoc_end() ((void)0)
6375 int c,
func, indent = 0;
6376 const char *eos, *
p, *pend;
6385 if ((c =
nextc()) == -1) {
6389 if (
NIL_P(parser->delayed)) {
6394 ((len =
lex_p - parser->tokp) > 0 &&
6395 (str =
STR_NEW3(parser->tokp, len, enc, func), 1))) {
6413 if (!(func & STR_FUNC_EXPAND)) {
6420 if (--pend == p || pend[-1] !=
'\r') {
6434 if (
nextc() == -1) {
6452 if (parser->
eofp)
goto error;
6462 if ((c =
nextc()) == -1)
goto error;
6479 rb_warning0(
"ambiguous first argument; put parentheses or even spaces");
6484 #define arg_ambiguous() (arg_ambiguous_gen(parser), 1)
6491 yyerror(
"formal argument must be local variable");
6509 if (len > 5 && name[nlen = len - 5] ==
'-') {
6513 if (len > 4 && name[nlen = len - 4] ==
'-') {
6516 if (
rb_memcicmp(name + nlen + 1,
"mac", 3) == 0 &&
6517 !(len == 8 &&
rb_memcicmp(name,
"utf8-mac", len) == 0))
6532 excargs[1] =
rb_sprintf(
"unknown encoding name: %s", name);
6549 for (i = 0; i <
n; ++
i) {
6624 if (str[i-1] ==
'*' && str[i-2] ==
'-') {
6630 if (i + 1 >= len)
return 0;
6631 if (str[i+1] !=
'-') {
6634 else if (str[i-1] !=
'-') {
6652 VALUE name = 0, val = 0;
6653 const char *beg, *
end, *vbeg, *vend;
6654 #define str_copy(_s, _p, _n) ((_s) \
6655 ? (void)(rb_str_resize((_s), (_n)), \
6656 MEMCPY(RSTRING_PTR(_s), (_p), char, (_n)), (_s)) \
6657 : (void)((_s) = STR_NEW((_p), (_n))))
6659 if (len <= 7)
return FALSE;
6663 len = end - beg - 3;
6674 for (; len > 0 && *
str; str++, --
len) {
6676 case '\'':
case '"':
case ':':
case ';':
6681 for (beg = str; len > 0; str++, --
len) {
6683 case '\'':
case '"':
case ':':
case ';':
6691 for (end = str; len > 0 &&
ISSPACE(*str); str++, --
len);
6693 if (*str !=
':')
continue;
6695 do str++;
while (--len > 0 &&
ISSPACE(*str));
6698 for (vbeg = ++str; --len > 0 && *str !=
'"'; str++) {
6711 for (vbeg = str; len > 0 && *str !=
'"' && *str !=
';' && !
ISSPACE(*str); --
len, str++);
6714 while (len > 0 && (*str ==
';' ||
ISSPACE(*str))) --len, str++;
6719 for (i = 0; i <
n; ++
i) {
6720 if (s[i] ==
'-') s[
i] =
'_';
6727 n = (*p->
length)(parser, vbeg, n);
6733 }
while (++p < magic_comments +
numberof(magic_comments));
6747 const char *beg =
str;
6751 if (send - str <= 6)
return;
6753 case 'C':
case 'c': str += 6;
continue;
6754 case 'O':
case 'o': str += 5;
continue;
6755 case 'D':
case 'd': str += 4;
continue;
6756 case 'I':
case 'i': str += 3;
continue;
6757 case 'N':
case 'n': str += 2;
continue;
6758 case 'G':
case 'g': str += 1;
continue;
6772 if (++str >= send)
return;
6775 if (*str !=
'=' && *str !=
':')
return;
6780 while ((*str ==
'-' || *str ==
'_' ||
ISALNUM(*str)) && ++str < send);
6796 (
unsigned char)
lex_p[0] == 0xbb &&
6797 (
unsigned char)
lex_p[1] == 0xbf) {
6811 #define IS_ARG() IS_lex_state(EXPR_ARG_ANY)
6812 #define IS_END() IS_lex_state(EXPR_END_ANY)
6813 #define IS_BEG() IS_lex_state(EXPR_BEG_ANY)
6814 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
6815 #define IS_LABEL_POSSIBLE() ((IS_lex_state(EXPR_BEG | EXPR_ENDFN) && !cmd_state) || IS_ARG())
6816 #define IS_LABEL_SUFFIX(n) (peek_n(':',(n)) && !peek_n(':', (n)+1))
6817 #define IS_AFTER_OPERATOR() IS_lex_state(EXPR_FNAME | EXPR_DOT)
6820 #define ambiguous_operator(op, syn) ( \
6821 rb_warning0("`"op"' after local variable is interpreted as binary operator"), \
6822 rb_warning0("even though it seems like "syn""))
6824 #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn))
6826 #define warn_balanced(op, syn) ((void) \
6827 (!IS_lex_state_for(last_state, EXPR_CLASS|EXPR_DOT|EXPR_FNAME|EXPR_ENDFN|EXPR_ENDARG) && \
6828 space_seen && !ISSPACE(c) && \
6829 (ambiguous_operator(op, syn), 0)))
6841 int fallthru =
FALSE;
6867 switch (c =
nextc()) {
6875 case ' ':
case '\t':
case '\f':
case '\r':
6879 while ((c =
nextc())) {
6881 case ' ':
case '\t':
case '\f':
case '\r':
6890 ripper_dispatch_scan_event(parser,
tSP);
6903 ripper_dispatch_scan_event(parser,
tCOMMENT);
6908 if (
IS_lex_state(EXPR_BEG | EXPR_VALUE | EXPR_CLASS | EXPR_FNAME | EXPR_DOT)) {
6917 while ((c =
nextc())) {
6919 case ' ':
case '\t':
case '\f':
case '\r':
6924 if ((c =
nextc()) !=
'.') {
6937 parser->tokp =
lex_p;
6940 goto normal_newline;
6949 if ((c =
nextc()) ==
'*') {
6950 if ((c =
nextc()) ==
'=') {
6957 rb_warning0(
"`**' interpreted as argument prefix");
6976 rb_warning0(
"`*' interpreted as argument prefix");
7024 ripper_dispatch_scan_event(parser,
tEMBDOC);
7033 if (c !=
'=')
continue;
7034 if (strncmp(
lex_p,
"end", 3) == 0 &&
7048 if ((c =
nextc()) ==
'=') {
7049 if ((c =
nextc()) ==
'=') {
7058 else if (c ==
'>') {
7070 (!
IS_ARG() || space_seen)) {
7072 if (token)
return token;
7083 if ((c =
nextc()) ==
'>') {
7090 if ((c =
nextc()) ==
'=') {
7104 if ((c =
nextc()) ==
'=') {
7108 if ((c =
nextc()) ==
'=') {
7176 rb_warnI(
"invalid character syntax; use ?\\%c", c2);
7193 else if (c ==
'\\') {
7222 if ((c =
nextc()) ==
'&') {
7224 if ((c =
nextc()) ==
'=') {
7232 else if (c ==
'=') {
7239 rb_warning0(
"`&' interpreted as argument prefix");
7253 if ((c =
nextc()) ==
'|') {
7255 if ((c =
nextc()) ==
'=') {
7335 if ((c =
nextc()) ==
'.') {
7336 if ((c =
nextc()) ==
'.') {
7344 yyerror(
"no .<digit> floating literal anymore; put 0 before dot");
7350 case '0':
case '1':
case '2':
case '3':
case '4':
7351 case '5':
case '6':
case '7':
case '8':
case '9':
7353 int is_float, seen_point, seen_e, nondigit;
7355 is_float = seen_point = seen_e = nondigit = 0;
7358 if (c ==
'-' || c ==
'+') {
7363 #define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
7366 if (c ==
'x' || c ==
'X') {
7372 if (nondigit)
break;
7379 }
while ((c =
nextc()) != -1);
7386 else if (nondigit)
goto trailing_uc;
7390 if (c ==
'b' || c ==
'B') {
7393 if (c ==
'0' || c ==
'1') {
7396 if (nondigit)
break;
7400 if (c !=
'0' && c !=
'1')
break;
7403 }
while ((c =
nextc()) != -1);
7410 else if (nondigit)
goto trailing_uc;
7414 if (c ==
'd' || c ==
'D') {
7420 if (nondigit)
break;
7427 }
while ((c =
nextc()) != -1);
7434 else if (nondigit)
goto trailing_uc;
7442 if (c ==
'o' || c ==
'O') {
7445 if (c == -1 || c ==
'_' || !
ISDIGIT(c)) {
7449 if (c >=
'0' && c <=
'7') {
7454 if (nondigit)
break;
7458 if (c < '0' || c >
'9')
break;
7459 if (c >
'7')
goto invalid_octal;
7462 }
while ((c =
nextc()) != -1);
7466 if (nondigit)
goto trailing_uc;
7475 if (c >
'7' && c <=
'9') {
7477 yyerror(
"Invalid octal digit");
7479 else if (c ==
'.' || c ==
'e' || c ==
'E') {
7491 case '0':
case '1':
case '2':
case '3':
case '4':
7492 case '5':
case '6':
case '7':
case '8':
case '9':
7498 if (nondigit)
goto trailing_uc;
7499 if (seen_point || seen_e) {
7504 if (c0 == -1 || !
ISDIGIT(c0)) {
7532 if (c !=
'-' && c !=
'+')
continue;
7538 if (nondigit)
goto decode_num;
7553 snprintf(tmp,
sizeof(tmp),
"trailing `%c' in number", nondigit);
7559 if (
errno == ERANGE) {
7636 if ((c =
nextc()) ==
'=') {
7656 if ((c =
nextc()) !=
'@') {
7683 if ((c =
nextc()) ==
']') {
7684 if ((c =
nextc()) ==
'=') {
7696 else if (
IS_ARG() && space_seen) {
7731 ripper_dispatch_scan_event(parser,
tSP);
7752 yyerror(
"unknown type of %string");
7756 if (c == -1 || term == -1) {
7761 if (term ==
'(') term =
')';
7762 else if (term ==
'[') term =
']';
7763 else if (term ==
'{') term =
'}';
7764 else if (term ==
'<') term =
'>';
7814 yyerror(
"unknown type of %string");
7818 if ((c =
nextc()) ==
'=') {
7895 case '1':
case '2':
case '3':
7896 case '4':
case '5':
case '6':
7897 case '7':
case '8':
case '9':
7902 }
while (c != -1 &&
ISDIGIT(c));
7948 ripper_dispatch_scan_event(parser,
k__END__);
7976 if ((c ==
'!' || c ==
'?') && !
peek(
'=')) {
7996 if (
tok()[1] ==
'@')
8042 if (state == EXPR_FNAME) {
8056 if (
CMDARG_P() && state != EXPR_CMDARG)
8058 if (state & (EXPR_BEG | EXPR_ENDARG))
8062 if (state & (EXPR_BEG | EXPR_VALUE))
8065 if (kw->
id[0] != kw->
id[1])
8102 yylex(
void *lval,
void *p)
8116 if (!
NIL_P(parser->delayed)) {
8117 ripper_dispatch_delayed_token(parser, t);
8121 ripper_dispatch_scan_event(parser, t);
8163 if (orig == (
NODE*)1)
return;
8172 #define parser_warning(node, mesg) parser_warning(parser, (node), (mesg))
8179 #define parser_warn(node, mesg) parser_warn(parser, (node), (mesg))
8186 if (tail == 0)
return head;
8188 if (h == 0)
return tail;
8227 tail->nd_end =
tail;
8229 end->nd_next =
tail;
8230 h->nd_end = tail->nd_end;
8240 if (list == 0)
return NEW_LIST(item);
8241 if (list->nd_next) {
8242 last = list->nd_next->nd_end;
8250 list->nd_next->nd_end = last->nd_next;
8260 if (head->nd_next) {
8261 last = head->nd_next->nd_end;
8267 head->nd_alen += tail->nd_alen;
8268 last->nd_next =
tail;
8269 if (tail->nd_next) {
8270 head->nd_next->nd_end = tail->nd_next->nd_end;
8273 head->nd_next->nd_end =
tail;
8282 if (
NIL_P(tail))
return 1;
8303 if (!head)
return tail;
8304 if (!tail)
return head;
8314 if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8317 lit = headlast->nd_lit;
8340 tail->nd_lit = head->nd_lit;
8344 else if (
NIL_P(tail->nd_lit)) {
8346 head->nd_alen += tail->nd_alen - 1;
8347 head->nd_next->nd_end->nd_next = tail->nd_next;
8348 head->nd_next->nd_end = tail->nd_next->nd_end;
8351 else if (htype ==
NODE_DSTR && (headlast = head->nd_next->nd_end->nd_head) &&
8353 lit = headlast->nd_lit;
8356 tail->nd_lit =
Qnil;
8361 tail->nd_head =
NEW_STR(tail->nd_lit);
8511 static const char names[][12] = {
8512 "EXPR_BEG",
"EXPR_END",
"EXPR_ENDARG",
"EXPR_ENDFN",
"EXPR_ARG",
8513 "EXPR_CMDARG",
"EXPR_MID",
"EXPR_FNAME",
"EXPR_DOT",
"EXPR_CLASS",
8518 return names[
ffs(state)];
8533 # define assignable_result(x) get_value(lhs)
8534 # define parser_yyerror(parser, x) dispatch1(assign_error, lhs)
8536 # define assignable_result(x) (x)
8541 yyerror(
"Can't change the value of self");
8544 yyerror(
"Can't assign to nil");
8547 yyerror(
"Can't assign to true");
8550 yyerror(
"Can't assign to false");
8553 yyerror(
"Can't assign to __FILE__");
8556 yyerror(
"Can't assign to __LINE__");
8559 yyerror(
"Can't assign to __ENCODING__");
8593 yyerror(
"dynamic constant assignment");
8602 #undef assignable_result
8603 #undef parser_yyerror
8610 if (name == idUScore)
return 1;
8617 #define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1))
8625 yyerror(
"duplicated argument name");
8637 yyerror(
"duplicated argument name");
8676 id &= ~ID_SCOPE_MASK;
8705 if (!node2)
return node1;
8709 node1->nd_head =
arg_concat(node1->nd_head, node2);
8721 node1->nd_body =
list_concat(node1->nd_body, node2);
8730 if (!node1)
return NEW_LIST(node2);
8735 node1->nd_head =
arg_append(node1->nd_head, node2);
8768 lhs->nd_value = rhs;
8773 lhs->nd_args =
arg_append(lhs->nd_args, rhs);
8804 if (!cond)
yyerror(
"void value expression");
8809 while (node->nd_next) {
8810 node = node->nd_next;
8812 node = node->nd_head;
8816 node = node->nd_body;
8820 if (!node->nd_body) {
8821 node = node->nd_else;
8824 else if (!node->nd_else) {
8825 node = node->nd_body;
8829 node = node->nd_else;
8835 node = node->nd_2nd;
8849 const char *useless = 0;
8856 switch (node->nd_mid) {
8887 useless =
"a variable";
8890 useless =
"a constant";
8897 useless =
"a literal";
8922 useless =
"defined?";
8930 rb_warnS(
"possibly useless use of %s in void context", useless);
8943 if (!node->nd_next)
return;
8945 node = node->nd_next;
8952 NODE **n = &node, *n1 = node;
8954 *n = n1 = n1->nd_body;
8968 #define subnodes(n1, n2) \
8969 ((!node->n1) ? (node->n2 ? (body = &node->n2, 1) : 0) : \
8970 (!node->n2) ? (body = &node->n1, 1) : \
8971 (reduce_nodes(&node->n1), body = &node->n2, 1))
8981 *body = node = node->nd_stts;
8985 *body = node = node->nd_body;
8989 body = &node->nd_end->nd_head;
8995 body = &node->nd_body;
9004 if (node->nd_else) {
9005 body = &node->nd_resq;
9023 if (!node)
return 1;
9026 if (!(node = node->nd_head))
break;
9030 }
while ((node = node->nd_next) != 0);
9049 yyerror(
"multiple assignment in conditional");
9063 if (!node->nd_value)
return 1;
9066 parser_warn(node->nd_value,
"found = in conditional, should be ==");
9088 for (node = *rootnode; node; node = next) {
9092 next = node->nd_next;
9093 head = node->nd_head;
9096 switch (type =
nd_type(head)) {
9099 val =
rb_range_new(head->nd_beg->nd_lit, head->nd_end->nd_lit,
9119 if (node == 0)
return 0;
9127 return cond0(parser, node);
9133 if (!node)
return 1;
9154 if (node == 0)
return 0;
9161 rb_warn0(
"string literal in condition");
9171 node->nd_1st =
cond0(parser, node->nd_1st);
9172 node->nd_2nd =
cond0(parser, node->nd_2nd);
9177 node->nd_beg =
range_op(parser, node->nd_beg);
9178 node->nd_end =
range_op(parser, node->nd_end);
9211 if (node == 0)
return 0;
9212 return cond0(parser, node);
9220 NODE *node = left, *second;
9221 while ((second = node->nd_2nd) != 0 && (
enum node_type)
nd_type(second) == type) {
9224 node->nd_2nd =
NEW_NODE(type, second, right, 0);
9227 return NEW_NODE(type, left, right, 0);
9244 if (node->nd_next == 0) {
9245 node = node->nd_head;
9266 switch (
TYPE(node->nd_lit)) {
9295 node2->nd_head = node1;
9309 args->
pre_init = m ? m->nd_next : 0;
9382 ID vid = lhs->nd_vid;
9384 lhs->nd_value = rhs;
9391 lhs->nd_value = rhs;
9445 return dispatch3(opassign, lhs, op, rhs);
9451 VALUE recv = dispatch3(field, lhs, type, attr);
9452 return dispatch3(opassign, recv, op, rhs);
9462 if (!local->
used)
return;
9466 if (cnt != local->
vars->
pos) {
9467 rb_bug(
"local->used->pos != local->vars->pos");
9469 for (i = 0; i <
cnt; ++
i) {
9470 if (!v[i] || (u[i] &
LVAR_USED))
continue;
9485 local->
used = !(inherit_dvars &&
9513 for (i = 0; i <
cnt; i++) {
9514 buf[
i] = src->
tbl[
i];
9527 if (cnt <= 0)
return 0;
9565 if (used) used = used->
prev;
9581 static const struct vtable *
9597 if ((tmp =
lvtbl->used) != 0) {
9613 while (
lvtbl->args != lvargs) {
9651 if (used) used = used->
prev;
9704 "regexp encoding option '%c' differs from source encoding '%s'",
9733 int back_num,
int *back_refs,
OnigRegex regex,
void *arg0)
9738 long len = name_end -
name;
9739 const char *s = (
const char *)name;
9756 rb_warningS(
"named capture conflicts a local variable - %s",
9839 if (!node)
return node;
9843 node = node->nd_body;
9847 node = node->nd_body;
9854 prelude->nd_body = node;
9855 scope->nd_body = prelude;
9858 scope->nd_body = node;
9871 if (!node)
return node;
9875 node = node->nd_body;
9879 node = node->nd_body;
9895 prelude->nd_body = node;
9896 scope->nd_body = prelude;
9899 scope->nd_body = node;
9905 static const struct {
9932 #define op_tbl_count numberof(op_tbl)
9934 #ifndef ENABLE_SELECTOR_NAMESPACE
9935 #define ENABLE_SELECTOR_NAMESPACE 0
9942 #if ENABLE_SELECTOR_NAMESPACE
9954 #if ENABLE_SELECTOR_NAMESPACE
9961 ivar2_cmp(
struct ivar2_key *key1,
struct ivar2_key *key2)
9963 if (key1->id == key2->id && key1->klass == key2->klass) {
9970 ivar2_hash(
struct ivar2_key *
key)
9972 return (key->id << 8) ^ (key->klass >> 2);
9986 #if ENABLE_SELECTOR_NAMESPACE
9994 (
void)lex_state_name(-1);
10023 if (m >= e)
return 0;
10027 else if (*m ==
'-') {
10041 return m == e ? mb + 1 : 0;
10059 const char *m =
name;
10060 const char *e = m +
len;
10063 if (!m || len <= 0)
return -1;
10083 case '<': ++
m;
break;
10084 case '=':
if (*++m ==
'>') ++
m;
break;
10091 case '>':
case '=': ++
m;
break;
10097 case '~': ++
m;
break;
10098 case '=':
if (*++m ==
'=') ++
m;
break;
10099 default:
return -1;
10104 if (*++m ==
'*') ++
m;
10107 case '+':
case '-':
10108 if (*++m ==
'@') ++
m;
10111 case '|':
case '^':
case '&':
case '/':
case '%':
case '~':
case '`':
10116 if (*++m !=
']')
return -1;
10117 if (*++m ==
'=') ++
m;
10121 if (len == 1)
return ID_JUNK;
10123 case '=':
case '~': ++
m;
break;
10124 default:
return -1;
10135 case '!':
case '?':
10148 return m == e ? type : -1;
10211 fake_str.as.heap.len =
len;
10212 fake_str.as.heap.ptr = (
char *)name;
10213 fake_str.as.heap.aux.capa =
len;
10214 str = (
VALUE)&fake_str;
10228 const char *
name, *
m, *
e;
10276 if (*
op_tbl[i].name == *m &&
10277 strcmp(
op_tbl[i].name, m) == 0) {
10284 if (m[last] ==
'=') {
10312 if (m - name < len)
id =
ID_JUNK;
10366 name[0] = (char)
id;
10375 if (
op_tbl[i].token ==
id) {
10389 if (
RBASIC(str)->klass == 0)
10400 id2 = (
id & ~ID_SCOPE_MASK) |
ID_CONST;
10407 if (
RBASIC(str)->klass == 0)
10420 if (!str)
return 0;
10514 VALUE name = *namep;
10543 fake_str.as.heap.aux.capa = fake_str.as.heap.len;
10564 fake_str.as.heap.len =
len;
10565 fake_str.as.heap.ptr = (
char *)ptr;
10566 fake_str.as.heap.aux.capa =
len;
10575 fake_str.as.heap.len = len - 1;
10673 parser->parser_ruby_sourcefile_string =
Qnil;
10674 parser->delayed =
Qnil;
10676 parser->result =
Qnil;
10677 parser->parsing_thread =
Qnil;
10678 parser->toplevel_p =
TRUE;
10687 #define parser_mark ripper_parser_mark
10688 #define parser_free ripper_parser_free
10706 rb_gc_mark(p->parser_ruby_sourcefile_string);
10728 prev = local->
prev;
10742 size_t size =
sizeof(*p);
10744 if (!ptr)
return 0;
10747 size +=
sizeof(*local);
10772 #undef rb_reserved_word
10861 #define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE))
10862 #define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0)
10863 #define ADD2HEAP(n, c, p) ((parser->heap = (n))->u1.node = (p), \
10864 (n)->u3.cnt = (c), (p))
10869 size_t cnt =
HEAPCNT(1, size);
10879 size_t cnt =
HEAPCNT(nelem, size);
10881 void *ptr =
xcalloc(nelem, size);
10890 size_t cnt =
HEAPCNT(1, size);
10892 if (ptr && (n = parser->
heap) !=
NULL) {
10894 if (n->
u1.
node == ptr) {
10911 while ((n = *prev) !=
NULL) {
10912 if (n->
u1.
node == ptr) {
10925 #ifdef RIPPER_DEBUG
10926 extern int rb_is_pointer_to_heap(
VALUE);
10932 if (x ==
Qfalse)
return x;
10933 if (x ==
Qtrue)
return x;
10934 if (x ==
Qnil)
return x;
10939 if (!rb_is_pointer_to_heap(x))
10952 return ((
NODE *)x)->nd_rval;
10961 #define validate(x) ((x) = get_value(x))
10973 return rb_funcall(parser->value, mid, 1, a);
10981 return rb_funcall(parser->value, mid, 2, a, b);
10990 return rb_funcall(parser->value, mid, 3, a, b, c);
11000 return rb_funcall(parser->value, mid, 4, a, b, c, d);
11011 return rb_funcall(parser->value, mid, 5, a, b, c, d, e);
11024 return rb_funcall(parser->value, mid, 7, a, b, c, d, e, f, g);
11027 static const struct kw_assoc {
11030 } keyword_to_name[] = {
11083 keyword_id_to_str(
ID id)
11085 const struct kw_assoc *
a;
11087 for (a = keyword_to_name; a->id; a++) {
11094 #undef ripper_id2sym
11096 ripper_id2sym(
ID id)
11106 if ((name = keyword_id_to_str(
id))) {
11119 rb_bug(
"cannot convert ID to string: %ld", (
unsigned long)
id);
11127 ripper_get_id(
VALUE v)
11137 ripper_get_value(
VALUE v)
11144 return nd->nd_rval;
11153 va_start(args, fmt);
11160 ripper_warn0(
struct parser_params *parser,
const char *fmt)
11166 ripper_warnI(
struct parser_params *parser,
const char *fmt,
int a)
11173 ripper_warnS(
struct parser_params *parser,
const char *fmt,
const char *str)
11180 ripper_warning0(
struct parser_params *parser,
const char *fmt)
11186 ripper_warningS(
struct parser_params *parser,
const char *fmt,
const char *str)
11211 #define ripper_initialized_p(r) ((r)->parser_lex_input != 0)
11230 rb_scan_args(argc, argv,
"12", &src, &fname, &lineno);
11240 if (
NIL_P(fname)) {
11248 parser->parser_ruby_sourcefile_string = fname;
11255 struct ripper_args {
11262 ripper_parse0(
VALUE parser_v)
11268 ripper_yyparse((
void*)parser);
11269 return parser->result;
11273 ripper_ensure(
VALUE parser_v)
11278 parser->parsing_thread =
Qnil;
11289 ripper_parse(
VALUE self)
11294 if (!ripper_initialized_p(parser)) {
11297 if (!
NIL_P(parser->parsing_thread)) {
11304 rb_ensure(ripper_parse0,
self, ripper_ensure,
self);
11306 return parser->result;
11317 ripper_column(
VALUE self)
11323 if (!ripper_initialized_p(parser)) {
11326 if (
NIL_P(parser->parsing_thread))
return Qnil;
11338 ripper_filename(
VALUE self)
11343 if (!ripper_initialized_p(parser)) {
11346 return parser->parser_ruby_sourcefile_string;
11357 ripper_lineno(
VALUE self)
11362 if (!ripper_initialized_p(parser)) {
11365 if (
NIL_P(parser->parsing_thread))
return Qnil;
11369 #ifdef RIPPER_DEBUG
11405 InitVM_ripper(
void)
11421 #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)
#define keyword_do_LAMBDA
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
#define keyword__ENCODING__
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)
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)
struct parser_params * parser
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 int yylex(void *, void *)
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)
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)