Remove not used universal parser macros and functions
[ruby.git] / rubyparser.h
blobab8a39367d4a5efcd036d11b1ee4dd8ebde49c61
1 #ifndef RUBY_RUBYPARSER_H
2 #define RUBY_RUBYPARSER_H 1
3 /*
4 * This is a header file for librubyparser interface
5 */
7 #include <stdarg.h> /* for va_list */
8 #include <assert.h>
10 #ifdef UNIVERSAL_PARSER
12 #define rb_encoding void
13 #define OnigCodePoint unsigned int
14 #include "parser_st.h"
15 #ifndef RUBY_RUBY_H
16 #include "parser_value.h"
17 #endif
19 #else
21 #include "ruby/encoding.h"
23 #endif
25 #ifndef FLEX_ARY_LEN
26 /* From internal/compilers.h */
27 /* A macro for defining a flexible array, like: VALUE ary[FLEX_ARY_LEN]; */
28 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
29 # define FLEX_ARY_LEN /* VALUE ary[]; */
30 #elif defined(__GNUC__) && !defined(__STRICT_ANSI__)
31 # define FLEX_ARY_LEN 0 /* VALUE ary[0]; */
32 #else
33 # define FLEX_ARY_LEN 1 /* VALUE ary[1]; */
34 #endif
35 #endif
38 * Parser String
40 enum rb_parser_string_coderange_type {
41 /** The object's coderange is unclear yet. */
42 RB_PARSER_ENC_CODERANGE_UNKNOWN = 0,
43 RB_PARSER_ENC_CODERANGE_7BIT = 1,
44 RB_PARSER_ENC_CODERANGE_VALID = 2,
45 RB_PARSER_ENC_CODERANGE_BROKEN = 3
48 typedef struct rb_parser_string {
49 enum rb_parser_string_coderange_type coderange;
50 rb_encoding *enc;
51 /* Length of the string, not including terminating NUL character. */
52 long len;
53 /* Pointer to the contents of the string. */
54 char *ptr;
55 } rb_parser_string_t;
58 * AST Node
60 enum node_type {
61 NODE_SCOPE,
62 NODE_BLOCK,
63 NODE_IF,
64 NODE_UNLESS,
65 NODE_CASE,
66 NODE_CASE2,
67 NODE_CASE3,
68 NODE_WHEN,
69 NODE_IN,
70 NODE_WHILE,
71 NODE_UNTIL,
72 NODE_ITER,
73 NODE_FOR,
74 NODE_FOR_MASGN,
75 NODE_BREAK,
76 NODE_NEXT,
77 NODE_REDO,
78 NODE_RETRY,
79 NODE_BEGIN,
80 NODE_RESCUE,
81 NODE_RESBODY,
82 NODE_ENSURE,
83 NODE_AND,
84 NODE_OR,
85 NODE_MASGN,
86 NODE_LASGN,
87 NODE_DASGN,
88 NODE_GASGN,
89 NODE_IASGN,
90 NODE_CDECL,
91 NODE_CVASGN,
92 NODE_OP_ASGN1,
93 NODE_OP_ASGN2,
94 NODE_OP_ASGN_AND,
95 NODE_OP_ASGN_OR,
96 NODE_OP_CDECL,
97 NODE_CALL,
98 NODE_OPCALL,
99 NODE_FCALL,
100 NODE_VCALL,
101 NODE_QCALL,
102 NODE_SUPER,
103 NODE_ZSUPER,
104 NODE_LIST,
105 NODE_ZLIST,
106 NODE_HASH,
107 NODE_RETURN,
108 NODE_YIELD,
109 NODE_LVAR,
110 NODE_DVAR,
111 NODE_GVAR,
112 NODE_IVAR,
113 NODE_CONST,
114 NODE_CVAR,
115 NODE_NTH_REF,
116 NODE_BACK_REF,
117 NODE_MATCH,
118 NODE_MATCH2,
119 NODE_MATCH3,
120 NODE_LIT,
121 NODE_INTEGER,
122 NODE_FLOAT,
123 NODE_RATIONAL,
124 NODE_IMAGINARY,
125 NODE_STR,
126 NODE_DSTR,
127 NODE_XSTR,
128 NODE_DXSTR,
129 NODE_EVSTR,
130 NODE_REGX,
131 NODE_DREGX,
132 NODE_ONCE,
133 NODE_ARGS,
134 NODE_ARGS_AUX,
135 NODE_OPT_ARG,
136 NODE_KW_ARG,
137 NODE_POSTARG,
138 NODE_ARGSCAT,
139 NODE_ARGSPUSH,
140 NODE_SPLAT,
141 NODE_BLOCK_PASS,
142 NODE_DEFN,
143 NODE_DEFS,
144 NODE_ALIAS,
145 NODE_VALIAS,
146 NODE_UNDEF,
147 NODE_CLASS,
148 NODE_MODULE,
149 NODE_SCLASS,
150 NODE_COLON2,
151 NODE_COLON3,
152 NODE_DOT2,
153 NODE_DOT3,
154 NODE_FLIP2,
155 NODE_FLIP3,
156 NODE_SELF,
157 NODE_NIL,
158 NODE_TRUE,
159 NODE_FALSE,
160 NODE_ERRINFO,
161 NODE_DEFINED,
162 NODE_POSTEXE,
163 NODE_SYM,
164 NODE_DSYM,
165 NODE_ATTRASGN,
166 NODE_LAMBDA,
167 NODE_ARYPTN,
168 NODE_HSHPTN,
169 NODE_FNDPTN,
170 NODE_ERROR,
171 NODE_LINE,
172 NODE_FILE,
173 NODE_ENCODING,
174 NODE_LAST
177 typedef struct rb_ast_id_table {
178 int size;
179 ID ids[FLEX_ARY_LEN];
180 } rb_ast_id_table_t;
182 typedef struct rb_code_position_struct {
183 int lineno;
184 int column;
185 } rb_code_position_t;
187 typedef struct rb_code_location_struct {
188 rb_code_position_t beg_pos;
189 rb_code_position_t end_pos;
190 } rb_code_location_t;
192 /* Header part of AST Node */
193 typedef struct RNode {
194 VALUE flags;
195 rb_code_location_t nd_loc;
196 int node_id;
197 } NODE;
199 typedef struct RNode_SCOPE {
200 NODE node;
202 rb_ast_id_table_t *nd_tbl;
203 struct RNode *nd_body;
204 struct RNode_ARGS *nd_args;
205 } rb_node_scope_t;
207 typedef struct RNode_BLOCK {
208 NODE node;
210 struct RNode *nd_head;
211 struct RNode *nd_end;
212 struct RNode *nd_next;
213 } rb_node_block_t;
215 typedef struct RNode_IF {
216 NODE node;
218 struct RNode *nd_cond;
219 struct RNode *nd_body;
220 struct RNode *nd_else;
221 } rb_node_if_t;
223 typedef struct RNode_UNLESS {
224 NODE node;
226 struct RNode *nd_cond;
227 struct RNode *nd_body;
228 struct RNode *nd_else;
229 } rb_node_unless_t;
231 typedef struct RNode_CASE {
232 NODE node;
234 struct RNode *nd_head;
235 struct RNode *nd_body;
236 } rb_node_case_t;
238 typedef struct RNode_CASE2 {
239 NODE node;
241 struct RNode *nd_head;
242 struct RNode *nd_body;
243 } rb_node_case2_t;
245 typedef struct RNode_CASE3 {
246 NODE node;
248 struct RNode *nd_head;
249 struct RNode *nd_body;
250 } rb_node_case3_t;
252 typedef struct RNode_WHEN {
253 NODE node;
255 struct RNode *nd_head;
256 struct RNode *nd_body;
257 struct RNode *nd_next;
258 } rb_node_when_t;
260 typedef struct RNode_IN {
261 NODE node;
263 struct RNode *nd_head;
264 struct RNode *nd_body;
265 struct RNode *nd_next;
266 } rb_node_in_t;
268 /* RNode_WHILE and RNode_UNTIL should be same structure */
269 typedef struct RNode_WHILE {
270 NODE node;
272 struct RNode *nd_cond;
273 struct RNode *nd_body;
274 long nd_state;
275 } rb_node_while_t;
277 typedef struct RNode_UNTIL {
278 NODE node;
280 struct RNode *nd_cond;
281 struct RNode *nd_body;
282 long nd_state;
283 } rb_node_until_t;
285 /* RNode_ITER and RNode_FOR should be same structure */
286 typedef struct RNode_ITER {
287 NODE node;
289 struct RNode *nd_body;
290 struct RNode *nd_iter;
291 } rb_node_iter_t;
293 typedef struct RNode_FOR {
294 NODE node;
296 struct RNode *nd_body;
297 struct RNode *nd_iter;
298 } rb_node_for_t;
300 typedef struct RNode_FOR_MASGN {
301 NODE node;
303 struct RNode *nd_var;
304 } rb_node_for_masgn_t;
306 /* RNode_BREAK, RNode_NEXT and RNode_REDO should be same structure */
307 typedef struct RNode_BREAK {
308 NODE node;
310 struct RNode *nd_chain;
311 struct RNode *nd_stts;
312 } rb_node_break_t;
314 typedef struct RNode_NEXT {
315 NODE node;
317 struct RNode *nd_chain;
318 struct RNode *nd_stts;
319 } rb_node_next_t;
321 typedef struct RNode_REDO {
322 NODE node;
324 struct RNode *nd_chain;
325 } rb_node_redo_t;
327 typedef struct RNode_RETRY {
328 NODE node;
329 } rb_node_retry_t;
331 typedef struct RNode_BEGIN {
332 NODE node;
334 struct RNode *nd_body;
335 } rb_node_begin_t;
337 typedef struct RNode_RESCUE {
338 NODE node;
340 struct RNode *nd_head;
341 struct RNode *nd_resq;
342 struct RNode *nd_else;
343 } rb_node_rescue_t;
345 typedef struct RNode_RESBODY {
346 NODE node;
348 struct RNode *nd_args;
349 struct RNode *nd_body;
350 struct RNode *nd_next;
351 } rb_node_resbody_t;
353 typedef struct RNode_ENSURE {
354 NODE node;
356 struct RNode *nd_head;
357 struct RNode *nd_ensr;
358 } rb_node_ensure_t;
360 /* RNode_AND and RNode_OR should be same structure */
361 typedef struct RNode_AND {
362 NODE node;
364 struct RNode *nd_1st;
365 struct RNode *nd_2nd;
366 } rb_node_and_t;
368 typedef struct RNode_OR {
369 NODE node;
371 struct RNode *nd_1st;
372 struct RNode *nd_2nd;
373 } rb_node_or_t;
375 typedef struct RNode_MASGN {
376 NODE node;
378 struct RNode *nd_head;
379 struct RNode *nd_value;
380 struct RNode *nd_args;
381 } rb_node_masgn_t;
383 typedef struct RNode_LASGN {
384 NODE node;
386 ID nd_vid;
387 struct RNode *nd_value;
388 } rb_node_lasgn_t;
390 typedef struct RNode_DASGN {
391 NODE node;
393 ID nd_vid;
394 struct RNode *nd_value;
395 } rb_node_dasgn_t;
397 typedef struct RNode_GASGN {
398 NODE node;
400 ID nd_vid;
401 struct RNode *nd_value;
402 } rb_node_gasgn_t;
404 typedef struct RNode_IASGN {
405 NODE node;
407 ID nd_vid;
408 struct RNode *nd_value;
409 } rb_node_iasgn_t;
411 typedef struct RNode_CDECL {
412 NODE node;
414 ID nd_vid;
415 struct RNode *nd_value;
416 struct RNode *nd_else;
417 } rb_node_cdecl_t;
419 typedef struct RNode_CVASGN {
420 NODE node;
422 ID nd_vid;
423 struct RNode *nd_value;
424 } rb_node_cvasgn_t;
426 typedef struct RNode_OP_ASGN1 {
427 NODE node;
429 struct RNode *nd_recv;
430 ID nd_mid;
431 struct RNode *nd_index;
432 struct RNode *nd_rvalue;
433 } rb_node_op_asgn1_t;
435 typedef struct RNode_OP_ASGN2 {
436 NODE node;
438 struct RNode *nd_recv;
439 struct RNode *nd_value;
440 ID nd_vid;
441 ID nd_mid;
442 bool nd_aid;
443 } rb_node_op_asgn2_t;
445 typedef struct RNode_OP_ASGN_AND {
446 NODE node;
448 struct RNode *nd_head;
449 struct RNode *nd_value;
450 } rb_node_op_asgn_and_t;
452 typedef struct RNode_OP_ASGN_OR {
453 NODE node;
455 struct RNode *nd_head;
456 struct RNode *nd_value;
457 } rb_node_op_asgn_or_t;
459 typedef struct RNode_OP_CDECL {
460 NODE node;
462 struct RNode *nd_head;
463 struct RNode *nd_value;
464 ID nd_aid;
465 } rb_node_op_cdecl_t;
467 typedef struct RNode_CALL {
468 NODE node;
470 struct RNode *nd_recv;
471 ID nd_mid;
472 struct RNode *nd_args;
473 } rb_node_call_t;
475 typedef struct RNode_OPCALL {
476 NODE node;
478 struct RNode *nd_recv;
479 ID nd_mid;
480 struct RNode *nd_args;
481 } rb_node_opcall_t;
483 typedef struct RNode_FCALL {
484 NODE node;
486 ID nd_mid;
487 struct RNode *nd_args;
488 } rb_node_fcall_t;
490 typedef struct RNode_VCALL {
491 NODE node;
493 ID nd_mid;
494 } rb_node_vcall_t;
496 typedef struct RNode_QCALL {
497 NODE node;
499 struct RNode *nd_recv;
500 ID nd_mid;
501 struct RNode *nd_args;
502 } rb_node_qcall_t;
504 typedef struct RNode_SUPER {
505 NODE node;
507 struct RNode *nd_args;
508 } rb_node_super_t;
510 typedef struct RNode_ZSUPER {
511 NODE node;
512 } rb_node_zsuper_t;
516 Structure of LIST:
518 LIST +--> LIST
519 * head --> element | * head
520 * alen (length of list) | * nd_end (point to the last LIST)
521 * next -----------------+ * next
524 RNode_LIST and RNode_VALUES should be same structure
526 typedef struct RNode_LIST {
527 NODE node;
529 struct RNode *nd_head; /* element */
530 union {
531 long nd_alen;
532 struct RNode *nd_end; /* Second list node has this structure */
533 } as;
534 struct RNode *nd_next; /* next list node */
535 } rb_node_list_t;
537 typedef struct RNode_ZLIST {
538 NODE node;
539 } rb_node_zlist_t;
541 typedef struct RNode_VALUES {
542 NODE node;
544 struct RNode *nd_head;
545 long nd_alen;
546 struct RNode *nd_next;
547 } rb_node_values_t;
549 typedef struct RNode_HASH {
550 NODE node;
552 struct RNode *nd_head;
553 long nd_brace;
554 } rb_node_hash_t;
556 typedef struct RNode_RETURN {
557 NODE node;
559 struct RNode *nd_stts;
560 } rb_node_return_t;
562 typedef struct RNode_YIELD {
563 NODE node;
565 struct RNode *nd_head;
566 } rb_node_yield_t;
568 typedef struct RNode_LVAR {
569 NODE node;
571 ID nd_vid;
572 } rb_node_lvar_t;
574 typedef struct RNode_DVAR {
575 NODE node;
577 ID nd_vid;
578 } rb_node_dvar_t;
580 typedef struct RNode_GVAR {
581 NODE node;
583 ID nd_vid;
584 } rb_node_gvar_t;
586 typedef struct RNode_IVAR {
587 NODE node;
589 ID nd_vid;
590 } rb_node_ivar_t;
592 typedef struct RNode_CONST {
593 NODE node;
595 ID nd_vid;
596 } rb_node_const_t;
598 typedef struct RNode_CVAR {
599 NODE node;
601 ID nd_vid;
602 } rb_node_cvar_t;
604 typedef struct RNode_NTH_REF {
605 NODE node;
607 long nd_nth;
608 } rb_node_nth_ref_t;
610 typedef struct RNode_BACK_REF {
611 NODE node;
613 long nd_nth;
614 } rb_node_back_ref_t;
616 /* RNode_MATCH and RNode_REGX should be same structure */
617 typedef struct RNode_MATCH {
618 NODE node;
620 struct rb_parser_string *string;
621 int options;
622 } rb_node_match_t;
624 typedef struct RNode_MATCH2 {
625 NODE node;
627 struct RNode *nd_recv;
628 struct RNode *nd_value;
629 struct RNode *nd_args;
630 } rb_node_match2_t;
632 typedef struct RNode_MATCH3 {
633 NODE node;
635 struct RNode *nd_recv;
636 struct RNode *nd_value;
637 } rb_node_match3_t;
639 typedef struct RNode_LIT {
640 NODE node;
642 VALUE nd_lit;
643 } rb_node_lit_t;
645 typedef struct RNode_INTEGER {
646 NODE node;
648 char* val;
649 int minus;
650 int base;
651 } rb_node_integer_t;
653 typedef struct RNode_FLOAT {
654 NODE node;
656 char* val;
657 int minus;
658 } rb_node_float_t;
660 typedef struct RNode_RATIONAL {
661 NODE node;
663 char* val;
664 int minus;
665 int base;
666 int seen_point;
667 } rb_node_rational_t;
669 enum rb_numeric_type {
670 integer_literal,
671 float_literal,
672 rational_literal
675 typedef struct RNode_IMAGINARY {
676 NODE node;
678 char* val;
679 int minus;
680 int base;
681 int seen_point;
682 enum rb_numeric_type type;
683 } rb_node_imaginary_t;
685 /* RNode_STR and RNode_XSTR should be same structure */
686 typedef struct RNode_STR {
687 NODE node;
689 struct rb_parser_string *string;
690 } rb_node_str_t;
692 /* RNode_DSTR, RNode_DXSTR and RNode_DSYM should be same structure */
693 typedef struct RNode_DSTR {
694 NODE node;
696 struct rb_parser_string *string;
697 union {
698 long nd_alen;
699 struct RNode *nd_end; /* Second dstr node has this structure. See also RNode_LIST */
700 } as;
701 struct RNode_LIST *nd_next;
702 } rb_node_dstr_t;
704 typedef struct RNode_XSTR {
705 NODE node;
707 struct rb_parser_string *string;
708 } rb_node_xstr_t;
710 typedef struct RNode_DXSTR {
711 NODE node;
713 struct rb_parser_string *string;
714 long nd_alen;
715 struct RNode_LIST *nd_next;
716 } rb_node_dxstr_t;
718 typedef struct RNode_EVSTR {
719 NODE node;
721 struct RNode *nd_body;
722 } rb_node_evstr_t;
724 typedef struct RNode_REGX {
725 NODE node;
727 struct rb_parser_string *string;
728 int options;
729 } rb_node_regx_t;
731 typedef struct RNode_DREGX {
732 NODE node;
734 struct rb_parser_string *string;
735 ID nd_cflag;
736 struct RNode_LIST *nd_next;
737 } rb_node_dregx_t;
739 typedef struct RNode_ONCE {
740 NODE node;
742 struct RNode *nd_body;
743 } rb_node_once_t;
745 struct rb_args_info {
746 NODE *pre_init;
747 NODE *post_init;
749 int pre_args_num; /* count of mandatory pre-arguments */
750 int post_args_num; /* count of mandatory post-arguments */
752 ID first_post_arg;
754 ID rest_arg;
755 ID block_arg;
757 struct RNode_KW_ARG *kw_args;
758 NODE *kw_rest_arg;
760 struct RNode_OPT_ARG *opt_args;
761 unsigned int no_kwarg: 1;
762 unsigned int ruby2_keywords: 1;
763 unsigned int forwarding: 1;
766 typedef struct RNode_ARGS {
767 NODE node;
769 struct rb_args_info nd_ainfo;
770 } rb_node_args_t;
772 typedef struct RNode_ARGS_AUX {
773 NODE node;
775 ID nd_pid;
776 long nd_plen;
777 struct RNode *nd_next;
778 } rb_node_args_aux_t;
780 typedef struct RNode_OPT_ARG {
781 NODE node;
783 struct RNode *nd_body;
784 struct RNode_OPT_ARG *nd_next;
785 } rb_node_opt_arg_t;
787 typedef struct RNode_KW_ARG {
788 NODE node;
790 struct RNode *nd_body;
791 struct RNode_KW_ARG *nd_next;
792 } rb_node_kw_arg_t;
794 typedef struct RNode_POSTARG {
795 NODE node;
797 struct RNode *nd_1st;
798 struct RNode *nd_2nd;
799 } rb_node_postarg_t;
801 typedef struct RNode_ARGSCAT {
802 NODE node;
804 struct RNode *nd_head;
805 struct RNode *nd_body;
806 } rb_node_argscat_t;
808 typedef struct RNode_ARGSPUSH {
809 NODE node;
811 struct RNode *nd_head;
812 struct RNode *nd_body;
813 } rb_node_argspush_t;
815 typedef struct RNode_SPLAT {
816 NODE node;
818 struct RNode *nd_head;
819 } rb_node_splat_t;
821 typedef struct RNode_BLOCK_PASS {
822 NODE node;
824 struct RNode *nd_head;
825 struct RNode *nd_body;
826 } rb_node_block_pass_t;
828 typedef struct RNode_DEFN {
829 NODE node;
831 ID nd_mid;
832 struct RNode *nd_defn;
833 } rb_node_defn_t;
835 typedef struct RNode_DEFS {
836 NODE node;
838 struct RNode *nd_recv;
839 ID nd_mid;
840 struct RNode *nd_defn;
841 } rb_node_defs_t;
843 typedef struct RNode_ALIAS {
844 NODE node;
846 struct RNode *nd_1st;
847 struct RNode *nd_2nd;
848 } rb_node_alias_t;
850 typedef struct RNode_VALIAS {
851 NODE node;
853 ID nd_alias;
854 ID nd_orig;
855 } rb_node_valias_t;
857 typedef struct RNode_UNDEF {
858 NODE node;
860 struct RNode *nd_undef;
861 } rb_node_undef_t;
863 typedef struct RNode_CLASS {
864 NODE node;
866 struct RNode *nd_cpath;
867 struct RNode *nd_body;
868 struct RNode *nd_super;
869 } rb_node_class_t;
871 typedef struct RNode_MODULE {
872 NODE node;
874 struct RNode *nd_cpath;
875 struct RNode *nd_body;
876 } rb_node_module_t;
878 typedef struct RNode_SCLASS {
879 NODE node;
881 struct RNode *nd_recv;
882 struct RNode *nd_body;
883 } rb_node_sclass_t;
885 typedef struct RNode_COLON2 {
886 NODE node;
888 struct RNode *nd_head;
889 ID nd_mid;
890 } rb_node_colon2_t;
892 typedef struct RNode_COLON3 {
893 NODE node;
895 ID nd_mid;
896 } rb_node_colon3_t;
898 /* RNode_DOT2, RNode_DOT3, RNode_FLIP2 and RNode_FLIP3 should be same structure */
899 typedef struct RNode_DOT2 {
900 NODE node;
902 struct RNode *nd_beg;
903 struct RNode *nd_end;
904 } rb_node_dot2_t;
906 typedef struct RNode_DOT3 {
907 NODE node;
909 struct RNode *nd_beg;
910 struct RNode *nd_end;
911 } rb_node_dot3_t;
913 typedef struct RNode_FLIP2 {
914 NODE node;
916 struct RNode *nd_beg;
917 struct RNode *nd_end;
918 } rb_node_flip2_t;
920 typedef struct RNode_FLIP3 {
921 NODE node;
923 struct RNode *nd_beg;
924 struct RNode *nd_end;
925 } rb_node_flip3_t;
927 typedef struct RNode_SELF {
928 NODE node;
930 long nd_state; /* Default 1. See NEW_SELF. */
931 } rb_node_self_t;
933 typedef struct RNode_NIL {
934 NODE node;
935 } rb_node_nil_t;
937 typedef struct RNode_TRUE {
938 NODE node;
939 } rb_node_true_t;
941 typedef struct RNode_FALSE {
942 NODE node;
943 } rb_node_false_t;
945 typedef struct RNode_ERRINFO {
946 NODE node;
947 } rb_node_errinfo_t;
949 typedef struct RNode_DEFINED {
950 NODE node;
952 struct RNode *nd_head;
953 } rb_node_defined_t;
955 typedef struct RNode_POSTEXE {
956 NODE node;
958 struct RNode *nd_body;
959 } rb_node_postexe_t;
961 typedef struct RNode_SYM {
962 NODE node;
964 struct rb_parser_string *string;
965 } rb_node_sym_t;
967 typedef struct RNode_DSYM {
968 NODE node;
970 struct rb_parser_string *string;
971 long nd_alen;
972 struct RNode_LIST *nd_next;
973 } rb_node_dsym_t;
975 typedef struct RNode_ATTRASGN {
976 NODE node;
978 struct RNode *nd_recv;
979 ID nd_mid;
980 struct RNode *nd_args;
981 } rb_node_attrasgn_t;
983 typedef struct RNode_LAMBDA {
984 NODE node;
986 struct RNode *nd_body;
987 } rb_node_lambda_t;
989 typedef struct RNode_ARYPTN {
990 NODE node;
992 struct RNode *nd_pconst;
993 NODE *pre_args;
994 NODE *rest_arg;
995 NODE *post_args;
996 } rb_node_aryptn_t;
998 typedef struct RNode_HSHPTN {
999 NODE node;
1001 struct RNode *nd_pconst;
1002 struct RNode *nd_pkwargs;
1003 struct RNode *nd_pkwrestarg;
1004 } rb_node_hshptn_t;
1006 typedef struct RNode_FNDPTN {
1007 NODE node;
1009 struct RNode *nd_pconst;
1010 NODE *pre_rest_arg;
1011 NODE *args;
1012 NODE *post_rest_arg;
1013 } rb_node_fndptn_t;
1015 typedef struct RNode_LINE {
1016 NODE node;
1017 } rb_node_line_t;
1019 typedef struct RNode_FILE {
1020 NODE node;
1022 struct rb_parser_string *path;
1023 } rb_node_file_t;
1025 typedef struct RNode_ENCODING {
1026 NODE node;
1027 rb_encoding *enc;
1028 } rb_node_encoding_t;
1030 typedef struct RNode_ERROR {
1031 NODE node;
1032 } rb_node_error_t;
1034 #define RNODE(obj) ((struct RNode *)(obj))
1036 #define RNODE_SCOPE(node) ((struct RNode_SCOPE *)(node))
1037 #define RNODE_BLOCK(node) ((struct RNode_BLOCK *)(node))
1038 #define RNODE_IF(node) ((struct RNode_IF *)(node))
1039 #define RNODE_UNLESS(node) ((struct RNode_UNLESS *)(node))
1040 #define RNODE_CASE(node) ((struct RNode_CASE *)(node))
1041 #define RNODE_CASE2(node) ((struct RNode_CASE2 *)(node))
1042 #define RNODE_CASE3(node) ((struct RNode_CASE3 *)(node))
1043 #define RNODE_WHEN(node) ((struct RNode_WHEN *)(node))
1044 #define RNODE_IN(node) ((struct RNode_IN *)(node))
1045 #define RNODE_WHILE(node) ((struct RNode_WHILE *)(node))
1046 #define RNODE_UNTIL(node) ((struct RNode_UNTIL *)(node))
1047 #define RNODE_ITER(node) ((struct RNode_ITER *)(node))
1048 #define RNODE_FOR(node) ((struct RNode_FOR *)(node))
1049 #define RNODE_FOR_MASGN(node) ((struct RNode_FOR_MASGN *)(node))
1050 #define RNODE_BREAK(node) ((struct RNode_BREAK *)(node))
1051 #define RNODE_NEXT(node) ((struct RNode_NEXT *)(node))
1052 #define RNODE_REDO(node) ((struct RNode_REDO *)(node))
1053 #define RNODE_RETRY(node) ((struct RNode_RETRY *)(node))
1054 #define RNODE_BEGIN(node) ((struct RNode_BEGIN *)(node))
1055 #define RNODE_RESCUE(node) ((struct RNode_RESCUE *)(node))
1056 #define RNODE_RESBODY(node) ((struct RNode_RESBODY *)(node))
1057 #define RNODE_ENSURE(node) ((struct RNode_ENSURE *)(node))
1058 #define RNODE_AND(node) ((struct RNode_AND *)(node))
1059 #define RNODE_OR(node) ((struct RNode_OR *)(node))
1060 #define RNODE_MASGN(node) ((struct RNode_MASGN *)(node))
1061 #define RNODE_LASGN(node) ((struct RNode_LASGN *)(node))
1062 #define RNODE_DASGN(node) ((struct RNode_DASGN *)(node))
1063 #define RNODE_GASGN(node) ((struct RNode_GASGN *)(node))
1064 #define RNODE_IASGN(node) ((struct RNode_IASGN *)(node))
1065 #define RNODE_CDECL(node) ((struct RNode_CDECL *)(node))
1066 #define RNODE_CVASGN(node) ((struct RNode_CVASGN *)(node))
1067 #define RNODE_OP_ASGN1(node) ((struct RNode_OP_ASGN1 *)(node))
1068 #define RNODE_OP_ASGN2(node) ((struct RNode_OP_ASGN2 *)(node))
1069 #define RNODE_OP_ASGN_AND(node) ((struct RNode_OP_ASGN_AND *)(node))
1070 #define RNODE_OP_ASGN_OR(node) ((struct RNode_OP_ASGN_OR *)(node))
1071 #define RNODE_OP_CDECL(node) ((struct RNode_OP_CDECL *)(node))
1072 #define RNODE_CALL(node) ((struct RNode_CALL *)(node))
1073 #define RNODE_OPCALL(node) ((struct RNode_OPCALL *)(node))
1074 #define RNODE_FCALL(node) ((struct RNode_FCALL *)(node))
1075 #define RNODE_VCALL(node) ((struct RNode_VCALL *)(node))
1076 #define RNODE_QCALL(node) ((struct RNode_QCALL *)(node))
1077 #define RNODE_SUPER(node) ((struct RNode_SUPER *)(node))
1078 #define RNODE_ZSUPER(node) ((struct RNode_ZSUPER *)(node))
1079 #define RNODE_LIST(node) ((struct RNode_LIST *)(node))
1080 #define RNODE_ZLIST(node) ((struct RNode_ZLIST *)(node))
1081 #define RNODE_HASH(node) ((struct RNode_HASH *)(node))
1082 #define RNODE_RETURN(node) ((struct RNode_RETURN *)(node))
1083 #define RNODE_YIELD(node) ((struct RNode_YIELD *)(node))
1084 #define RNODE_LVAR(node) ((struct RNode_LVAR *)(node))
1085 #define RNODE_DVAR(node) ((struct RNode_DVAR *)(node))
1086 #define RNODE_GVAR(node) ((struct RNode_GVAR *)(node))
1087 #define RNODE_IVAR(node) ((struct RNode_IVAR *)(node))
1088 #define RNODE_CONST(node) ((struct RNode_CONST *)(node))
1089 #define RNODE_CVAR(node) ((struct RNode_CVAR *)(node))
1090 #define RNODE_NTH_REF(node) ((struct RNode_NTH_REF *)(node))
1091 #define RNODE_BACK_REF(node) ((struct RNode_BACK_REF *)(node))
1092 #define RNODE_MATCH(node) ((struct RNode_MATCH *)(node))
1093 #define RNODE_MATCH2(node) ((struct RNode_MATCH2 *)(node))
1094 #define RNODE_MATCH3(node) ((struct RNode_MATCH3 *)(node))
1095 #define RNODE_LIT(node) ((struct RNode_LIT *)(node))
1096 #define RNODE_INTEGER(node) ((struct RNode_INTEGER *)(node))
1097 #define RNODE_FLOAT(node) ((struct RNode_FLOAT *)(node))
1098 #define RNODE_RATIONAL(node) ((struct RNode_RATIONAL *)(node))
1099 #define RNODE_IMAGINARY(node) ((struct RNode_IMAGINARY *)(node))
1100 #define RNODE_STR(node) ((struct RNode_STR *)(node))
1101 #define RNODE_DSTR(node) ((struct RNode_DSTR *)(node))
1102 #define RNODE_XSTR(node) ((struct RNode_XSTR *)(node))
1103 #define RNODE_DXSTR(node) ((struct RNode_DXSTR *)(node))
1104 #define RNODE_EVSTR(node) ((struct RNode_EVSTR *)(node))
1105 #define RNODE_REGX(node) ((struct RNode_REGX *)(node))
1106 #define RNODE_DREGX(node) ((struct RNode_DREGX *)(node))
1107 #define RNODE_ONCE(node) ((struct RNode_ONCE *)(node))
1108 #define RNODE_ARGS(node) ((struct RNode_ARGS *)(node))
1109 #define RNODE_ARGS_AUX(node) ((struct RNode_ARGS_AUX *)(node))
1110 #define RNODE_OPT_ARG(node) ((struct RNode_OPT_ARG *)(node))
1111 #define RNODE_KW_ARG(node) ((struct RNode_KW_ARG *)(node))
1112 #define RNODE_POSTARG(node) ((struct RNode_POSTARG *)(node))
1113 #define RNODE_ARGSCAT(node) ((struct RNode_ARGSCAT *)(node))
1114 #define RNODE_ARGSPUSH(node) ((struct RNode_ARGSPUSH *)(node))
1115 #define RNODE_SPLAT(node) ((struct RNode_SPLAT *)(node))
1116 #define RNODE_BLOCK_PASS(node) ((struct RNode_BLOCK_PASS *)(node))
1117 #define RNODE_DEFN(node) ((struct RNode_DEFN *)(node))
1118 #define RNODE_DEFS(node) ((struct RNode_DEFS *)(node))
1119 #define RNODE_ALIAS(node) ((struct RNode_ALIAS *)(node))
1120 #define RNODE_VALIAS(node) ((struct RNode_VALIAS *)(node))
1121 #define RNODE_UNDEF(node) ((struct RNode_UNDEF *)(node))
1122 #define RNODE_CLASS(node) ((struct RNode_CLASS *)(node))
1123 #define RNODE_MODULE(node) ((struct RNode_MODULE *)(node))
1124 #define RNODE_SCLASS(node) ((struct RNode_SCLASS *)(node))
1125 #define RNODE_COLON2(node) ((struct RNode_COLON2 *)(node))
1126 #define RNODE_COLON3(node) ((struct RNode_COLON3 *)(node))
1127 #define RNODE_DOT2(node) ((struct RNode_DOT2 *)(node))
1128 #define RNODE_DOT3(node) ((struct RNode_DOT3 *)(node))
1129 #define RNODE_FLIP2(node) ((struct RNode_FLIP2 *)(node))
1130 #define RNODE_FLIP3(node) ((struct RNode_FLIP3 *)(node))
1131 #define RNODE_SELF(node) ((struct RNode_SELF *)(node))
1132 #define RNODE_NIL(node) ((struct RNode_NIL *)(node))
1133 #define RNODE_TRUE(node) ((struct RNode_TRUE *)(node))
1134 #define RNODE_FALSE(node) ((struct RNode_FALSE *)(node))
1135 #define RNODE_ERRINFO(node) ((struct RNode_ERRINFO *)(node))
1136 #define RNODE_DEFINED(node) ((struct RNode_DEFINED *)(node))
1137 #define RNODE_POSTEXE(node) ((struct RNode_POSTEXE *)(node))
1138 #define RNODE_SYM(node) ((struct RNode_SYM *)(node))
1139 #define RNODE_DSYM(node) ((struct RNode_DSYM *)(node))
1140 #define RNODE_ATTRASGN(node) ((struct RNode_ATTRASGN *)(node))
1141 #define RNODE_LAMBDA(node) ((struct RNode_LAMBDA *)(node))
1142 #define RNODE_ARYPTN(node) ((struct RNode_ARYPTN *)(node))
1143 #define RNODE_HSHPTN(node) ((struct RNode_HSHPTN *)(node))
1144 #define RNODE_FNDPTN(node) ((struct RNode_FNDPTN *)(node))
1145 #define RNODE_LINE(node) ((struct RNode_LINE *)(node))
1146 #define RNODE_FILE(node) ((struct RNode_FILE *)(node))
1147 #define RNODE_ENCODING(node) ((struct RNode_ENCODING *)(node))
1149 /* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8: UNUSED, 9: UNUSED, 10: EXIVAR, 11: FREEZE */
1150 /* NODE_FL: 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: NODE_FL_NEWLINE,
1151 * 8..14: nd_type,
1152 * 15..: nd_line
1154 #define NODE_FL_NEWLINE (((VALUE)1)<<7)
1156 #define NODE_TYPESHIFT 8
1157 #define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
1159 #define nd_fl_newline(n) (n)->flags & NODE_FL_NEWLINE
1160 #define nd_set_fl_newline(n) (n)->flags |= NODE_FL_NEWLINE
1161 #define nd_unset_fl_newline(n) (n)->flags &= ~NODE_FL_NEWLINE
1163 #define nd_type(n) ((int) ((RNODE(n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
1164 #define nd_set_type(n,t) \
1165 rb_node_set_type(n, t)
1166 #define nd_init_type(n,t) \
1167 (n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
1169 typedef struct node_buffer_struct node_buffer_t;
1170 /* T_IMEMO/ast */
1171 typedef struct rb_ast_body_struct {
1172 const NODE *root;
1173 VALUE script_lines;
1174 // script_lines is either:
1175 // - a Fixnum that represents the line count of the original source, or
1176 // - an Array that contains the lines of the original source
1177 signed int frozen_string_literal:2; /* -1: not specified, 0: false, 1: true */
1178 signed int coverage_enabled:2; /* -1: not specified, 0: false, 1: true */
1179 } rb_ast_body_t;
1180 typedef struct rb_ast_struct {
1181 VALUE flags;
1182 node_buffer_t *node_buffer;
1183 rb_ast_body_t body;
1184 } rb_ast_t;
1189 * Parser Interface
1193 typedef struct parser_params rb_parser_t;
1194 #ifndef INTERNAL_IMEMO_H
1195 typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
1196 #endif
1198 #ifdef UNIVERSAL_PARSER
1199 typedef struct rb_parser_config_struct {
1200 /* Memory */
1201 void *(*malloc)(size_t size);
1202 void *(*calloc)(size_t number, size_t size);
1203 void *(*realloc)(void *ptr, size_t newsiz);
1204 void (*free)(void *ptr);
1205 void *(*alloc_n)(size_t nelems, size_t elemsiz);
1206 void *(*alloc)(size_t elemsiz);
1207 void *(*realloc_n)(void *ptr, size_t newelems, size_t newsiz);
1208 void *(*zalloc)(size_t elemsiz);
1209 void *(*rb_memmove)(void *dest, const void *src, size_t t, size_t n);
1210 void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
1211 void *(*xmalloc_mul_add)(size_t x, size_t y, size_t z);
1213 /* imemo */
1214 rb_imemo_tmpbuf_t *(*tmpbuf_parser_heap)(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
1215 rb_ast_t *(*ast_new)(VALUE nb);
1217 // VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
1218 VALUE (*compile_callback)(VALUE (*func)(VALUE), VALUE arg);
1219 NODE *(*reg_named_capture_assign)(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc);
1221 /* Object */
1222 VALUE (*obj_freeze)(VALUE obj);
1223 VALUE (*obj_hide)(VALUE obj);
1224 void (*obj_freeze_raw)(VALUE obj);
1226 int (*fixnum_p)(VALUE);
1227 int (*symbol_p)(VALUE);
1229 /* Variable */
1230 VALUE (*attr_get)(VALUE obj, ID id);
1232 /* Array */
1233 VALUE (*ary_new)(void);
1234 VALUE (*ary_push)(VALUE ary, VALUE elem);
1235 VALUE (*ary_new_from_args)(long n, ...);
1236 VALUE (*ary_unshift)(VALUE ary, VALUE item);
1237 VALUE (*ary_new2)(long capa); // ary_new_capa
1238 VALUE (*ary_clear)(VALUE ary);
1239 void (*ary_modify)(VALUE ary);
1240 long (*array_len)(VALUE a);
1241 VALUE (*array_aref)(VALUE, long);
1243 /* Symbol */
1244 ID (*make_temporary_id)(size_t n);
1245 int (*is_local_id)(ID);
1246 int (*is_attrset_id)(ID);
1247 int (*is_global_name_punct)(const int c);
1248 int (*id_type)(ID id);
1249 ID (*id_attrset)(ID);
1250 ID (*intern)(const char *name);
1251 ID (*intern2)(const char *name, long len);
1252 ID (*intern3)(const char *name, long len, rb_encoding *enc);
1253 ID (*intern_str)(VALUE str);
1254 int (*is_notop_id)(ID);
1255 int (*enc_symname_type)(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset);
1256 const char *(*id2name)(ID id);
1257 VALUE (*id2str)(ID id);
1258 VALUE (*id2sym)(ID x);
1259 ID (*sym2id)(VALUE sym);
1261 /* String */
1262 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
1263 VALUE (*str_catf)(VALUE str, const char *format, ...);
1264 VALUE (*str_cat_cstr)(VALUE str, const char *ptr);
1265 VALUE (*str_subseq)(VALUE str, long beg, long len);
1266 VALUE (*str_new_frozen)(VALUE orig);
1267 VALUE (*str_buf_new)(long capa);
1268 VALUE (*str_buf_cat)(VALUE, const char*, long);
1269 void (*str_modify)(VALUE str);
1270 void (*str_set_len)(VALUE str, long len);
1271 VALUE (*str_cat)(VALUE str, const char *ptr, long len);
1272 VALUE (*str_resize)(VALUE str, long len);
1273 VALUE (*str_new)(const char *ptr, long len);
1274 VALUE (*str_new_cstr)(const char *ptr);
1275 VALUE (*fstring)(VALUE);
1276 int (*is_ascii_string)(VALUE str);
1277 VALUE (*enc_str_new)(const char *ptr, long len, rb_encoding *enc);
1278 VALUE (*enc_str_buf_cat)(VALUE str, const char *ptr, long len, rb_encoding *enc);
1279 VALUE (*str_buf_append)(VALUE str, VALUE str2);
1280 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 0)
1281 VALUE (*str_vcatf)(VALUE str, const char *fmt, va_list ap);
1282 char *(*string_value_cstr)(volatile VALUE *ptr);
1283 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
1284 VALUE (*rb_sprintf)(const char *format, ...);
1285 char *(*rstring_ptr)(VALUE str);
1286 char *(*rstring_end)(VALUE str);
1287 long (*rstring_len)(VALUE str);
1288 VALUE (*filesystem_str_new_cstr)(const char *ptr);
1289 VALUE (*obj_as_string)(VALUE);
1291 /* Hash */
1292 VALUE (*hash_clear)(VALUE hash);
1293 VALUE (*hash_new)(void);
1294 VALUE (*hash_aset)(VALUE hash, VALUE key, VALUE val);
1295 VALUE (*hash_delete)(VALUE hash, VALUE key);
1296 VALUE (*hash_lookup)(VALUE hash, VALUE key);
1297 VALUE (*ident_hash_new)(void);
1299 /* Numeric */
1300 int (*num2int)(VALUE val);
1301 VALUE (*int2num)(int v);
1303 /* IO */
1304 int (*stderr_tty_p)(void);
1305 void (*write_error_str)(VALUE mesg);
1306 VALUE (*default_rs)(void);
1307 VALUE (*io_write)(VALUE io, VALUE str);
1308 VALUE (*io_flush)(VALUE io);
1309 VALUE (*io_puts)(int argc, const VALUE *argv, VALUE out);
1310 VALUE (*io_gets_internal)(VALUE io);
1312 /* IO (Ractor) */
1313 VALUE (*debug_output_stdout)(void);
1314 VALUE (*debug_output_stderr)(void);
1316 /* Encoding */
1317 int (*is_usascii_enc)(rb_encoding *enc);
1318 int (*enc_isalnum)(OnigCodePoint c, rb_encoding *enc);
1319 int (*enc_precise_mbclen)(const char *p, const char *e, rb_encoding *enc);
1320 int (*mbclen_charfound_p)(int len);
1321 int (*mbclen_charfound_len)(int len);
1322 const char *(*enc_name)(rb_encoding *enc);
1323 char *(*enc_prev_char)(const char *s, const char *p, const char *e, rb_encoding *enc);
1324 rb_encoding* (*enc_get)(VALUE obj);
1325 int (*enc_asciicompat)(rb_encoding *enc);
1326 rb_encoding *(*utf8_encoding)(void);
1327 VALUE (*enc_associate)(VALUE obj, rb_encoding *enc);
1328 rb_encoding *(*ascii8bit_encoding)(void);
1329 int (*enc_codelen)(int c, rb_encoding *enc);
1330 int (*enc_mbcput)(unsigned int c, void *buf, rb_encoding *enc);
1331 int (*char_to_option_kcode)(int c, int *option, int *kcode);
1332 int (*ascii8bit_encindex)(void);
1333 int (*enc_find_index)(const char *name);
1334 rb_encoding *(*enc_from_index)(int idx);
1335 VALUE (*enc_associate_index)(VALUE obj, int encindex);
1336 int (*enc_isspace)(OnigCodePoint c, rb_encoding *enc);
1337 rb_encoding *(*enc_compatible)(VALUE str1, VALUE str2);
1338 VALUE (*enc_from_encoding)(rb_encoding *enc);
1339 int (*encoding_get)(VALUE obj);
1340 void (*encoding_set)(VALUE obj, int encindex);
1341 int (*encoding_is_ascii8bit)(VALUE obj);
1342 rb_encoding *(*usascii_encoding)(void);
1344 /* Ractor */
1345 VALUE (*ractor_make_shareable)(VALUE obj);
1347 /* Compile */
1348 // int rb_local_defined(ID id, const rb_iseq_t *iseq);
1349 int (*local_defined)(ID, const void*);
1350 // int rb_dvar_defined(ID id, const rb_iseq_t *iseq);
1351 int (*dvar_defined)(ID, const void*);
1353 /* Compile (parse.y) */
1354 int (*literal_cmp)(VALUE val, VALUE lit);
1355 parser_st_index_t (*literal_hash)(VALUE a);
1357 /* Error (Exception) */
1358 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 6, 0)
1359 VALUE (*syntax_error_append)(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
1360 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
1361 void (*raise)(VALUE exc, const char *fmt, ...);
1362 VALUE (*syntax_error_new)(void);
1364 /* Eval */
1365 VALUE (*errinfo)(void);
1366 void (*set_errinfo)(VALUE err);
1367 void (*exc_raise)(VALUE mesg);
1368 VALUE (*make_exception)(int argc, const VALUE *argv);
1370 /* GC */
1371 void (*sized_xfree)(void *x, size_t size);
1372 void *(*sized_realloc_n)(void *ptr, size_t new_count, size_t element_size, size_t old_count);
1373 VALUE (*obj_write)(VALUE, VALUE *, VALUE);
1374 VALUE (*obj_written)(VALUE, VALUE, VALUE);
1375 void (*gc_guard)(VALUE);
1376 void (*gc_mark)(VALUE);
1377 void (*gc_mark_and_move)(VALUE *ptr);
1378 VALUE (*gc_location)(VALUE value);
1380 /* Re */
1381 VALUE (*reg_compile)(VALUE str, int options, const char *sourcefile, int sourceline);
1382 VALUE (*reg_check_preprocess)(VALUE str);
1383 int (*memcicmp)(const void *x, const void *y, long len);
1385 /* Error */
1386 void (*compile_warn)(const char *file, int line, const char *fmt, ...);
1387 void (*compile_warning)(const char *file, int line, const char *fmt, ...);
1388 void (*bug)(const char *fmt, ...);
1389 void (*fatal)(const char *fmt, ...);
1390 VALUE (*verbose)(void);
1391 int *(*errno_ptr)(void);
1393 /* VM */
1394 VALUE (*make_backtrace)(void);
1396 /* Util */
1397 unsigned long (*scan_hex)(const char *start, size_t len, size_t *retlen);
1398 unsigned long (*scan_oct)(const char *start, size_t len, size_t *retlen);
1399 unsigned long (*scan_digits)(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
1400 double (*strtod)(const char *s00, char **se);
1402 /* Misc */
1403 VALUE (*rbool)(VALUE);
1404 int (*undef_p)(VALUE);
1405 int (*rtest)(VALUE obj);
1406 int (*nil_p)(VALUE obj);
1407 VALUE qnil;
1408 VALUE qtrue;
1409 VALUE qfalse;
1410 VALUE qundef;
1411 VALUE (*eArgError)(void);
1412 VALUE (*mRubyVMFrozenCore)(void);
1413 int (*long2int)(long);
1415 VALUE (*node_case_when_optimizable_literal)(const NODE *const node);
1417 /* For Ripper */
1418 int enc_coderange_7bit;
1419 int enc_coderange_unknown;
1420 VALUE (*static_id2sym)(ID id);
1421 long (*str_coderange_scan_restartable)(const char *s, const char *e, rb_encoding *enc, int *cr);
1422 } rb_parser_config_t;
1424 #undef rb_encoding
1425 #undef OnigCodePoint
1426 #endif /* UNIVERSAL_PARSER */
1428 RUBY_SYMBOL_EXPORT_BEGIN
1429 void rb_ruby_parser_free(void *ptr);
1430 rb_ast_t* rb_ruby_parser_compile_string(rb_parser_t *p, const char *f, VALUE s, int line);
1432 #ifdef UNIVERSAL_PARSER
1433 rb_parser_t *rb_ruby_parser_allocate(const rb_parser_config_t *config);
1434 rb_parser_t *rb_ruby_parser_new(const rb_parser_config_t *config);
1435 #endif
1437 long rb_parser_string_length(rb_parser_string_t *str);
1438 char *rb_parser_string_pointer(rb_parser_string_t *str);
1440 RUBY_SYMBOL_EXPORT_END
1442 #endif /* RUBY_RUBYPARSER_H */