Ruby: rubyparser.h Source File

Ruby 4.0.6p0 (2026-07-14 revision 03b6d3f8898a28604fe6cb00eae3226b821168f4)

rubyparser.h
1#ifndef RUBY_RUBYPARSER_H
2#define RUBY_RUBYPARSER_H 1
3/*
4 * This is a header file for librubyparser interface
5 */
6
7#include <stdarg.h> /* for va_list */
8#include <assert.h>
9
10#ifdef UNIVERSAL_PARSER
11
12#define rb_encoding const void
13#define OnigCodePoint unsigned int
14#include "parser_st.h"
15#ifndef RUBY_RUBY_H
16#include "parser_value.h"
17#endif
18
19#else
20
21#include "ruby/encoding.h"
22
23#endif
24
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
36
37#if defined(__GNUC__)
38# if defined(__MINGW_PRINTF_FORMAT)
39# define RUBYPARSER_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(__MINGW_PRINTF_FORMAT, string_index, argument_index)))
40# else
41# define RUBYPARSER_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((format(printf, string_index, argument_index)))
42# endif
43#elif defined(__clang__)
44# define RUBYPARSER_ATTRIBUTE_FORMAT(string_index, argument_index) __attribute__((__format__(__printf__, string_index, argument_index)))
45#else
46# define RUBYPARSER_ATTRIBUTE_FORMAT(string_index, argument_index)
47#endif
48
49/*
50 * Parser String
51 */
52enum rb_parser_string_coderange_type {
54 RB_PARSER_ENC_CODERANGE_UNKNOWN = 0,
55 RB_PARSER_ENC_CODERANGE_7BIT = 1,
56 RB_PARSER_ENC_CODERANGE_VALID = 2,
57 RB_PARSER_ENC_CODERANGE_BROKEN = 3
58};
59
60 typedef struct rb_parser_string {
61 enum rb_parser_string_coderange_type coderange;
62 rb_encoding *enc;
63 /* Length of the string, not including terminating NUL character. */
64 long len;
65 /* Pointer to the contents of the string. */
66 char *ptr;
67} rb_parser_string_t;
68
69enum rb_parser_shareability {
70 rb_parser_shareable_none,
71 rb_parser_shareable_literal,
72 rb_parser_shareable_copy,
73 rb_parser_shareable_everything,
74};
75
76typedef void* rb_parser_input_data;
77
78/*
79 * AST Node
80 */
81enum node_type {
82 NODE_SCOPE,
83 NODE_BLOCK,
84 NODE_IF,
85 NODE_UNLESS,
86 NODE_CASE,
87 NODE_CASE2,
88 NODE_CASE3,
89 NODE_WHEN,
90 NODE_IN,
91 NODE_WHILE,
92 NODE_UNTIL,
93 NODE_ITER,
94 NODE_FOR,
95 NODE_FOR_MASGN,
96 NODE_BREAK,
97 NODE_NEXT,
98 NODE_REDO,
99 NODE_RETRY,
100 NODE_BEGIN,
101 NODE_RESCUE,
102 NODE_RESBODY,
103 NODE_ENSURE,
104 NODE_AND,
105 NODE_OR,
106 NODE_MASGN,
107 NODE_LASGN,
108 NODE_DASGN,
109 NODE_GASGN,
110 NODE_IASGN,
111 NODE_CDECL,
112 NODE_CVASGN,
113 NODE_OP_ASGN1,
114 NODE_OP_ASGN2,
115 NODE_OP_ASGN_AND,
116 NODE_OP_ASGN_OR,
117 NODE_OP_CDECL,
118 NODE_CALL,
119 NODE_OPCALL,
120 NODE_FCALL,
121 NODE_VCALL,
122 NODE_QCALL,
123 NODE_SUPER,
124 NODE_ZSUPER,
125 NODE_LIST,
126 NODE_ZLIST,
127 NODE_HASH,
128 NODE_RETURN,
129 NODE_YIELD,
130 NODE_LVAR,
131 NODE_DVAR,
132 NODE_GVAR,
133 NODE_IVAR,
134 NODE_CONST,
135 NODE_CVAR,
136 NODE_NTH_REF,
137 NODE_BACK_REF,
138 NODE_MATCH,
139 NODE_MATCH2,
140 NODE_MATCH3,
141 NODE_INTEGER,
142 NODE_FLOAT,
143 NODE_RATIONAL,
144 NODE_IMAGINARY,
145 NODE_STR,
146 NODE_DSTR,
147 NODE_XSTR,
148 NODE_DXSTR,
149 NODE_EVSTR,
150 NODE_REGX,
151 NODE_DREGX,
152 NODE_ONCE,
153 NODE_ARGS,
154 NODE_ARGS_AUX,
155 NODE_OPT_ARG,
156 NODE_KW_ARG,
157 NODE_POSTARG,
158 NODE_ARGSCAT,
159 NODE_ARGSPUSH,
160 NODE_SPLAT,
161 NODE_BLOCK_PASS,
162 NODE_DEFN,
163 NODE_DEFS,
164 NODE_ALIAS,
165 NODE_VALIAS,
166 NODE_UNDEF,
167 NODE_CLASS,
168 NODE_MODULE,
169 NODE_SCLASS,
170 NODE_COLON2,
171 NODE_COLON3,
172 NODE_DOT2,
173 NODE_DOT3,
174 NODE_FLIP2,
175 NODE_FLIP3,
176 NODE_SELF,
177 NODE_NIL,
178 NODE_TRUE,
179 NODE_FALSE,
180 NODE_ERRINFO,
181 NODE_DEFINED,
182 NODE_POSTEXE,
183 NODE_SYM,
184 NODE_DSYM,
185 NODE_ATTRASGN,
186 NODE_LAMBDA,
187 NODE_ARYPTN,
188 NODE_HSHPTN,
189 NODE_FNDPTN,
190 NODE_ERROR,
191 NODE_LINE,
192 NODE_FILE,
193 NODE_ENCODING,
194 NODE_LAST
195};
196
197 typedef struct rb_ast_id_table {
198 int size;
199 ID ids[FLEX_ARY_LEN];
200} rb_ast_id_table_t;
201
202 typedef struct rb_code_position_struct {
203 int lineno;
204 int column;
205} rb_code_position_t;
206
207 typedef struct rb_code_location_struct {
208 rb_code_position_t beg_pos;
209 rb_code_position_t end_pos;
210} rb_code_location_t;
211#define YYLTYPE rb_code_location_t
212#define YYLTYPE_IS_DECLARED 1
213
214 typedef struct rb_parser_ast_token {
215 int id;
216 const char *type_name;
217 rb_parser_string_t *str;
218 rb_code_location_t loc;
219} rb_parser_ast_token_t;
220
221/*
222 * Array-like object for parser
223 */
224typedef void* rb_parser_ary_data;
225
226enum rb_parser_ary_data_type {
227 PARSER_ARY_DATA_AST_TOKEN = 1,
228 PARSER_ARY_DATA_SCRIPT_LINE,
229 PARSER_ARY_DATA_NODE
230};
231
232 typedef struct rb_parser_ary {
233 enum rb_parser_ary_data_type data_type;
234 rb_parser_ary_data *data;
235 long len; // current size
236 long capa; // capacity
237} rb_parser_ary_t;
238
239/* Header part of AST Node */
240 typedef struct RNode {
241 VALUE flags;
242 rb_code_location_t nd_loc;
243 int node_id;
244} NODE;
245
246 typedef struct RNode_SCOPE {
247 NODE node;
248
249 rb_ast_id_table_t *nd_tbl;
250 struct RNode *nd_body;
251 struct RNode *nd_parent;
252 struct RNode_ARGS *nd_args;
253} rb_node_scope_t;
254
255 typedef struct RNode_BLOCK {
256 NODE node;
257
258 struct RNode *nd_head;
259 struct RNode *nd_end;
260 struct RNode *nd_next;
261} rb_node_block_t;
262
263 typedef struct RNode_IF {
264 NODE node;
265
266 struct RNode *nd_cond;
267 struct RNode *nd_body;
268 struct RNode *nd_else;
269 rb_code_location_t if_keyword_loc;
270 rb_code_location_t then_keyword_loc;
271 rb_code_location_t end_keyword_loc;
272} rb_node_if_t;
273
274 typedef struct RNode_UNLESS {
275 NODE node;
276
277 struct RNode *nd_cond;
278 struct RNode *nd_body;
279 struct RNode *nd_else;
280 rb_code_location_t keyword_loc;
281 rb_code_location_t then_keyword_loc;
282 rb_code_location_t end_keyword_loc;
283} rb_node_unless_t;
284
285 typedef struct RNode_CASE {
286 NODE node;
287
288 struct RNode *nd_head;
289 struct RNode *nd_body;
290 rb_code_location_t case_keyword_loc;
291 rb_code_location_t end_keyword_loc;
292} rb_node_case_t;
293
294 typedef struct RNode_CASE2 {
295 NODE node;
296
297 struct RNode *nd_head;
298 struct RNode *nd_body;
299 rb_code_location_t case_keyword_loc;
300 rb_code_location_t end_keyword_loc;
301} rb_node_case2_t;
302
303 typedef struct RNode_CASE3 {
304 NODE node;
305
306 struct RNode *nd_head;
307 struct RNode *nd_body;
308 rb_code_location_t case_keyword_loc;
309 rb_code_location_t end_keyword_loc;
310} rb_node_case3_t;
311
312 typedef struct RNode_WHEN {
313 NODE node;
314
315 struct RNode *nd_head;
316 struct RNode *nd_body;
317 struct RNode *nd_next;
318 rb_code_location_t keyword_loc;
319 rb_code_location_t then_keyword_loc;
320} rb_node_when_t;
321
322 typedef struct RNode_IN {
323 NODE node;
324
325 struct RNode *nd_head;
326 struct RNode *nd_body;
327 struct RNode *nd_next;
328 rb_code_location_t in_keyword_loc;
329 rb_code_location_t then_keyword_loc;
330 rb_code_location_t operator_loc;
331} rb_node_in_t;
332
333 typedef struct RNode_LOOP {
334 NODE node;
335
336 struct RNode *nd_cond;
337 struct RNode *nd_body;
338 long nd_state;
339 rb_code_location_t keyword_loc;
340 rb_code_location_t closing_loc;
341} rb_node_while_t, rb_node_until_t;
342
343 typedef struct RNode_ITER {
344 NODE node;
345
346 struct RNode *nd_body;
347 struct RNode *nd_iter;
348} rb_node_iter_t;
349
350 typedef struct RNode_FOR {
351 NODE node;
352
353 struct RNode *nd_body;
354 struct RNode *nd_iter;
355 rb_code_location_t for_keyword_loc;
356 rb_code_location_t in_keyword_loc;
357 rb_code_location_t do_keyword_loc;
358 rb_code_location_t end_keyword_loc;
359} rb_node_for_t;
360
361 typedef struct RNode_FOR_MASGN {
362 NODE node;
363
364 struct RNode *nd_var;
365} rb_node_for_masgn_t;
366
367 typedef struct RNode_EXITS {
368 NODE node;
369
370 struct RNode *nd_chain;
371 struct RNode *nd_stts;
372 rb_code_location_t keyword_loc;
373} rb_node_exits_t, rb_node_break_t, rb_node_next_t, rb_node_redo_t;
374
375 typedef struct RNode_RETRY {
376 NODE node;
377} rb_node_retry_t;
378
379 typedef struct RNode_BEGIN {
380 NODE node;
381
382 struct RNode *nd_body;
383} rb_node_begin_t;
384
385 typedef struct RNode_RESCUE {
386 NODE node;
387
388 struct RNode *nd_head;
389 struct RNode *nd_resq;
390 struct RNode *nd_else;
391} rb_node_rescue_t;
392
393 typedef struct RNode_RESBODY {
394 NODE node;
395
396 struct RNode *nd_args;
397 struct RNode *nd_exc_var;
398 struct RNode *nd_body;
399 struct RNode *nd_next;
400} rb_node_resbody_t;
401
402 typedef struct RNode_ENSURE {
403 NODE node;
404
405 struct RNode *nd_head;
406 struct RNode *nd_ensr;
407} rb_node_ensure_t;
408
409 typedef struct {
410 NODE node;
411
412 struct RNode *nd_1st;
413 struct RNode *nd_2nd;
414 rb_code_location_t operator_loc;
415} rb_node_and_t, rb_node_or_t;
416
417 typedef struct RNode_MASGN {
418 NODE node;
419
420 struct RNode *nd_head;
421 struct RNode *nd_value;
422 struct RNode *nd_args;
423} rb_node_masgn_t;
424
425 typedef struct RNode_LASGN {
426 NODE node;
427
428 ID nd_vid;
429 struct RNode *nd_value;
430} rb_node_lasgn_t;
431
432 typedef struct RNode_DASGN {
433 NODE node;
434
435 ID nd_vid;
436 struct RNode *nd_value;
437} rb_node_dasgn_t;
438
439 typedef struct RNode_GASGN {
440 NODE node;
441
442 ID nd_vid;
443 struct RNode *nd_value;
444} rb_node_gasgn_t;
445
446 typedef struct RNode_IASGN {
447 NODE node;
448
449 ID nd_vid;
450 struct RNode *nd_value;
451} rb_node_iasgn_t;
452
453 typedef struct RNode_CDECL {
454 NODE node;
455
456 ID nd_vid;
457 struct RNode *nd_value;
458 struct RNode *nd_else;
459 enum rb_parser_shareability shareability;
460} rb_node_cdecl_t;
461
462 typedef struct RNode_CVASGN {
463 NODE node;
464
465 ID nd_vid;
466 struct RNode *nd_value;
467} rb_node_cvasgn_t;
468
469 typedef struct RNode_OP_ASGN1 {
470 NODE node;
471
472 struct RNode *nd_recv;
473 ID nd_mid;
474 struct RNode *nd_index;
475 struct RNode *nd_rvalue;
476 rb_code_location_t call_operator_loc;
477 rb_code_location_t opening_loc;
478 rb_code_location_t closing_loc;
479 rb_code_location_t binary_operator_loc;
480} rb_node_op_asgn1_t;
481
482 typedef struct RNode_OP_ASGN2 {
483 NODE node;
484
485 struct RNode *nd_recv;
486 struct RNode *nd_value;
487 ID nd_vid;
488 ID nd_mid;
489 bool nd_aid;
490 rb_code_location_t call_operator_loc;
491 rb_code_location_t message_loc;
492 rb_code_location_t binary_operator_loc;
493} rb_node_op_asgn2_t;
494
495 typedef struct RNode_OP_ASGN_AND {
496 NODE node;
497
498 struct RNode *nd_head;
499 struct RNode *nd_value;
500} rb_node_op_asgn_and_t;
501
502 typedef struct RNode_OP_ASGN_OR {
503 NODE node;
504
505 struct RNode *nd_head;
506 struct RNode *nd_value;
507} rb_node_op_asgn_or_t;
508
509 typedef struct RNode_OP_CDECL {
510 NODE node;
511
512 struct RNode *nd_head;
513 struct RNode *nd_value;
514 ID nd_aid;
515 enum rb_parser_shareability shareability;
516} rb_node_op_cdecl_t;
517
518 typedef struct RNode_CALL {
519 NODE node;
520
521 struct RNode *nd_recv;
522 ID nd_mid;
523 struct RNode *nd_args;
524} rb_node_call_t;
525
526 typedef struct RNode_OPCALL {
527 NODE node;
528
529 struct RNode *nd_recv;
530 ID nd_mid;
531 struct RNode *nd_args;
532} rb_node_opcall_t;
533
534 typedef struct RNode_FCALL {
535 NODE node;
536
537 ID nd_mid;
538 struct RNode *nd_args;
539} rb_node_fcall_t;
540
541 typedef struct RNode_VCALL {
542 NODE node;
543
544 ID nd_mid;
545} rb_node_vcall_t;
546
547 typedef struct RNode_QCALL {
548 NODE node;
549
550 struct RNode *nd_recv;
551 ID nd_mid;
552 struct RNode *nd_args;
553} rb_node_qcall_t;
554
555 typedef struct RNode_SUPER {
556 NODE node;
557
558 struct RNode *nd_args;
559 rb_code_location_t keyword_loc;
560 rb_code_location_t lparen_loc;
561 rb_code_location_t rparen_loc;
562} rb_node_super_t;
563
564 typedef struct RNode_ZSUPER {
565 NODE node;
566} rb_node_zsuper_t;
567
568/*
569
570 Structure of LIST:
571
572 LIST +--> LIST
573 * head --> element | * head
574 * alen (length of list) | * nd_end (point to the last LIST)
575 * next -----------------+ * next
576
577*/
578 typedef struct RNode_LIST {
579 NODE node;
580
581 struct RNode *nd_head; /* element */
582 union {
583 long nd_alen;
584 struct RNode *nd_end; /* Second list node has this structure */
585 } as;
586 struct RNode *nd_next; /* next list node */
587} rb_node_list_t;
588
589 typedef struct RNode_ZLIST {
590 NODE node;
591} rb_node_zlist_t;
592
593 typedef struct RNode_HASH {
594 NODE node;
595
596 struct RNode *nd_head;
597 long nd_brace;
598} rb_node_hash_t;
599
600 typedef struct RNode_RETURN {
601 NODE node;
602
603 struct RNode *nd_stts;
604 rb_code_location_t keyword_loc;
605} rb_node_return_t;
606
607 typedef struct RNode_YIELD {
608 NODE node;
609
610 struct RNode *nd_head;
611 rb_code_location_t keyword_loc;
612 rb_code_location_t lparen_loc;
613 rb_code_location_t rparen_loc;
614} rb_node_yield_t;
615
616 typedef struct RNode_LVAR {
617 NODE node;
618
619 ID nd_vid;
620} rb_node_lvar_t;
621
622 typedef struct RNode_DVAR {
623 NODE node;
624
625 ID nd_vid;
626} rb_node_dvar_t;
627
628 typedef struct RNode_GVAR {
629 NODE node;
630
631 ID nd_vid;
632} rb_node_gvar_t;
633
634 typedef struct RNode_IVAR {
635 NODE node;
636
637 ID nd_vid;
638} rb_node_ivar_t;
639
640 typedef struct RNode_CONST {
641 NODE node;
642
643 ID nd_vid;
644} rb_node_const_t;
645
646 typedef struct RNode_CVAR {
647 NODE node;
648
649 ID nd_vid;
650} rb_node_cvar_t;
651
652 typedef struct RNode_NTH_REF {
653 NODE node;
654
655 long nd_nth;
656} rb_node_nth_ref_t;
657
658 typedef struct RNode_BACK_REF {
659 NODE node;
660
661 long nd_nth;
662} rb_node_back_ref_t;
663
664 typedef struct RNode_MATCH2 {
665 NODE node;
666
667 struct RNode *nd_recv;
668 struct RNode *nd_value;
669 struct RNode *nd_args;
670} rb_node_match2_t;
671
672 typedef struct RNode_MATCH3 {
673 NODE node;
674
675 struct RNode *nd_recv;
676 struct RNode *nd_value;
677} rb_node_match3_t;
678
679 typedef struct RNode_INTEGER {
680 NODE node;
681
682 char *val;
683 int minus;
684 int base;
685} rb_node_integer_t;
686
687 typedef struct RNode_FLOAT {
688 NODE node;
689
690 char *val;
691 int minus;
692} rb_node_float_t;
693
694 typedef struct RNode_RATIONAL {
695 NODE node;
696
697 char *val;
698 int minus;
699 int base;
700 int seen_point;
701} rb_node_rational_t;
702
703enum rb_numeric_type {
704 integer_literal,
705 float_literal,
706 rational_literal
707};
708
709 typedef struct RNode_IMAGINARY {
710 NODE node;
711
712 char *val;
713 int minus;
714 int base;
715 int seen_point;
716 enum rb_numeric_type type;
717} rb_node_imaginary_t;
718
719 typedef struct RNode_STR {
720 NODE node;
721
722 struct rb_parser_string *string;
723} rb_node_str_t;
724
725/* NODE_DSTR, NODE_DXSTR, NODE_DREGX, NODE_DSYM */
726 typedef struct RNode_DSTR {
727 NODE node;
728
729 struct rb_parser_string *string;
730 union {
731 long nd_alen;
732 long nd_cflag;
733 struct RNode *nd_end; /* Second dstr node has this structure. See also RNode_LIST */
734 } as;
735 struct RNode_LIST *nd_next;
736} rb_node_dstr_t;
737
738typedef rb_node_str_t rb_node_xstr_t;
739
740typedef rb_node_dstr_t rb_node_dxstr_t;
741
742 typedef struct RNode_EVSTR {
743 NODE node;
744
745 struct RNode *nd_body;
746 rb_code_location_t opening_loc;
747 rb_code_location_t closing_loc;
748} rb_node_evstr_t;
749
750 typedef struct RNode_REGX { /* also RNode_MATCH */
751 NODE node;
752
753 struct rb_parser_string *string;
754 int options;
755 rb_code_location_t opening_loc;
756 rb_code_location_t content_loc;
757 rb_code_location_t closing_loc;
758} rb_node_regx_t, rb_node_match_t;
759
760typedef rb_node_dstr_t rb_node_dregx_t;
761
762 typedef struct RNode_ONCE {
763 NODE node;
764
765 struct RNode *nd_body;
766} rb_node_once_t;
767
768 struct rb_args_info {
769 NODE *pre_init;
770 NODE *post_init;
771
772 int pre_args_num; /* count of mandatory pre-arguments */
773 int post_args_num; /* count of mandatory post-arguments */
774
775 ID first_post_arg;
776
777 ID rest_arg;
778 ID block_arg;
779
780 struct RNode_KW_ARG *kw_args;
781 NODE *kw_rest_arg;
782
783 struct RNode_OPT_ARG *opt_args;
784 unsigned int no_kwarg: 1;
785 unsigned int forwarding: 1;
786};
787
788 typedef struct RNode_ARGS {
789 NODE node;
790
791 struct rb_args_info nd_ainfo;
792} rb_node_args_t;
793
794 typedef struct RNode_ARGS_AUX {
795 NODE node;
796
797 ID nd_pid;
798 int nd_plen;
799 struct RNode *nd_next;
800} rb_node_args_aux_t;
801
802 typedef struct RNode_OPT_ARG {
803 NODE node;
804
805 struct RNode *nd_body;
806 struct RNode_OPT_ARG *nd_next;
807} rb_node_opt_arg_t;
808
809 typedef struct RNode_KW_ARG {
810 NODE node;
811
812 struct RNode *nd_body;
813 struct RNode_KW_ARG *nd_next;
814} rb_node_kw_arg_t;
815
816 typedef struct RNode_POSTARG {
817 NODE node;
818
819 struct RNode *nd_1st;
820 struct RNode *nd_2nd;
821} rb_node_postarg_t;
822
823 typedef struct RNode_ARGSCAT {
824 NODE node;
825
826 struct RNode *nd_head;
827 struct RNode *nd_body;
828} rb_node_argscat_t;
829
830 typedef struct RNode_ARGSPUSH {
831 NODE node;
832
833 struct RNode *nd_head;
834 struct RNode *nd_body;
835} rb_node_argspush_t;
836
837 typedef struct RNode_SPLAT {
838 NODE node;
839
840 struct RNode *nd_head;
841 rb_code_location_t operator_loc;
842} rb_node_splat_t;
843
844 typedef struct RNode_BLOCK_PASS {
845 NODE node;
846
847 struct RNode *nd_head;
848 struct RNode *nd_body;
849 unsigned int forwarding: 1;
850 rb_code_location_t operator_loc;
851} rb_node_block_pass_t;
852
853 typedef struct RNode_DEFN {
854 NODE node;
855
856 ID nd_mid;
857 struct RNode *nd_defn;
858} rb_node_defn_t;
859
860 typedef struct RNode_DEFS {
861 NODE node;
862
863 struct RNode *nd_recv;
864 ID nd_mid;
865 struct RNode *nd_defn;
866} rb_node_defs_t;
867
868 typedef struct RNode_ALIAS {
869 NODE node;
870
871 struct RNode *nd_1st;
872 struct RNode *nd_2nd;
873 rb_code_location_t keyword_loc;
874} rb_node_alias_t;
875
876 typedef struct RNode_VALIAS {
877 NODE node;
878
879 ID nd_alias;
880 ID nd_orig;
881 rb_code_location_t keyword_loc;
882} rb_node_valias_t;
883
884 typedef struct RNode_UNDEF {
885 NODE node;
886
887 rb_parser_ary_t *nd_undefs;
888 rb_code_location_t keyword_loc;
889} rb_node_undef_t;
890
891 typedef struct RNode_CLASS {
892 NODE node;
893
894 struct RNode *nd_cpath;
895 struct RNode *nd_body;
896 struct RNode *nd_super;
897 rb_code_location_t class_keyword_loc;
898 rb_code_location_t inheritance_operator_loc;
899 rb_code_location_t end_keyword_loc;
900} rb_node_class_t;
901
902 typedef struct RNode_MODULE {
903 NODE node;
904
905 struct RNode *nd_cpath;
906 struct RNode *nd_body;
907 rb_code_location_t module_keyword_loc;
908 rb_code_location_t end_keyword_loc;
909} rb_node_module_t;
910
911 typedef struct RNode_SCLASS {
912 NODE node;
913
914 struct RNode *nd_recv;
915 struct RNode *nd_body;
916 rb_code_location_t class_keyword_loc;
917 rb_code_location_t operator_loc;
918 rb_code_location_t end_keyword_loc;
919} rb_node_sclass_t;
920
921 typedef struct RNode_COLON2 {
922 NODE node;
923
924 struct RNode *nd_head;
925 ID nd_mid;
926 rb_code_location_t delimiter_loc;
927 rb_code_location_t name_loc;
928} rb_node_colon2_t;
929
930 typedef struct RNode_COLON3 {
931 NODE node;
932
933 ID nd_mid;
934 rb_code_location_t delimiter_loc;
935 rb_code_location_t name_loc;
936} rb_node_colon3_t;
937
938/* NODE_DOT2, NODE_DOT3, NODE_FLIP2, NODE_FLIP3 */
939 typedef struct RNode_DOTS {
940 NODE node;
941
942 struct RNode *nd_beg;
943 struct RNode *nd_end;
944 rb_code_location_t operator_loc;
945} rb_node_dot2_t, rb_node_dot3_t, rb_node_flip2_t, rb_node_flip3_t;
946
947 typedef struct RNode_SELF {
948 NODE node;
949
950 long nd_state; /* Default 1. See NEW_SELF. */
951} rb_node_self_t;
952
953 typedef struct RNode_NIL {
954 NODE node;
955} rb_node_nil_t;
956
957 typedef struct RNode_TRUE {
958 NODE node;
959} rb_node_true_t;
960
961 typedef struct RNode_FALSE {
962 NODE node;
963} rb_node_false_t;
964
965 typedef struct RNode_ERRINFO {
966 NODE node;
967} rb_node_errinfo_t;
968
969 typedef struct RNode_DEFINED {
970 NODE node;
971
972 struct RNode *nd_head;
973 rb_code_location_t keyword_loc;
974} rb_node_defined_t;
975
976 typedef struct RNode_POSTEXE {
977 NODE node;
978
979 struct RNode *nd_body;
980 rb_code_location_t keyword_loc;
981 rb_code_location_t opening_loc;
982 rb_code_location_t closing_loc;
983} rb_node_postexe_t;
984
985 typedef struct RNode_SYM {
986 NODE node;
987
988 struct rb_parser_string *string;
989} rb_node_sym_t;
990
991typedef rb_node_dstr_t rb_node_dsym_t;
992
993 typedef struct RNode_ATTRASGN {
994 NODE node;
995
996 struct RNode *nd_recv;
997 ID nd_mid;
998 struct RNode *nd_args;
999} rb_node_attrasgn_t;
1000
1001 typedef struct RNode_LAMBDA {
1002 NODE node;
1003
1004 struct RNode *nd_body;
1005 rb_code_location_t operator_loc;
1006 rb_code_location_t opening_loc;
1007 rb_code_location_t closing_loc;
1008} rb_node_lambda_t;
1009
1010 typedef struct RNode_ARYPTN {
1011 NODE node;
1012
1013 struct RNode *nd_pconst;
1014 NODE *pre_args;
1015 NODE *rest_arg;
1016 NODE *post_args;
1017} rb_node_aryptn_t;
1018
1019 typedef struct RNode_HSHPTN {
1020 NODE node;
1021
1022 struct RNode *nd_pconst;
1023 struct RNode *nd_pkwargs;
1024 struct RNode *nd_pkwrestarg;
1025} rb_node_hshptn_t;
1026
1027 typedef struct RNode_FNDPTN {
1028 NODE node;
1029
1030 struct RNode *nd_pconst;
1031 NODE *pre_rest_arg;
1032 NODE *args;
1033 NODE *post_rest_arg;
1034} rb_node_fndptn_t;
1035
1036 typedef struct RNode_LINE {
1037 NODE node;
1038} rb_node_line_t;
1039
1040 typedef struct RNode_FILE {
1041 NODE node;
1042
1043 struct rb_parser_string *path;
1044} rb_node_file_t;
1045
1046 typedef struct RNode_ENCODING {
1047 NODE node;
1048 rb_encoding *enc;
1049} rb_node_encoding_t;
1050
1051 typedef struct RNode_ERROR {
1052 NODE node;
1053} rb_node_error_t;
1054
1055#define RNODE(obj) ((NODE *)(obj))
1056
1057#define RNODE_SCOPE(node) ((rb_node_scope_t *)(node))
1058#define RNODE_BLOCK(node) ((rb_node_block_t *)(node))
1059#define RNODE_IF(node) ((rb_node_if_t *)(node))
1060#define RNODE_UNLESS(node) ((rb_node_unless_t *)(node))
1061#define RNODE_CASE(node) ((rb_node_case_t *)(node))
1062#define RNODE_CASE2(node) ((rb_node_case2_t *)(node))
1063#define RNODE_CASE3(node) ((rb_node_case3_t *)(node))
1064#define RNODE_WHEN(node) ((rb_node_when_t *)(node))
1065#define RNODE_IN(node) ((rb_node_in_t *)(node))
1066#define RNODE_WHILE(node) ((rb_node_while_t *)(node))
1067#define RNODE_UNTIL(node) ((rb_node_until_t *)(node))
1068#define RNODE_ITER(node) ((rb_node_iter_t *)(node))
1069#define RNODE_FOR(node) ((rb_node_for_t *)(node))
1070#define RNODE_FOR_MASGN(node) ((rb_node_for_masgn_t *)(node))
1071#define RNODE_BREAK(node) ((rb_node_break_t *)(node))
1072#define RNODE_NEXT(node) ((rb_node_next_t *)(node))
1073#define RNODE_REDO(node) ((rb_node_redo_t *)(node))
1074#define RNODE_RETRY(node) ((rb_node_retry_t *)(node))
1075#define RNODE_BEGIN(node) ((rb_node_begin_t *)(node))
1076#define RNODE_RESCUE(node) ((rb_node_rescue_t *)(node))
1077#define RNODE_RESBODY(node) ((rb_node_resbody_t *)(node))
1078#define RNODE_ENSURE(node) ((rb_node_ensure_t *)(node))
1079#define RNODE_AND(node) ((rb_node_and_t *)(node))
1080#define RNODE_OR(node) ((rb_node_or_t *)(node))
1081#define RNODE_MASGN(node) ((rb_node_masgn_t *)(node))
1082#define RNODE_LASGN(node) ((rb_node_lasgn_t *)(node))
1083#define RNODE_DASGN(node) ((rb_node_dasgn_t *)(node))
1084#define RNODE_GASGN(node) ((rb_node_gasgn_t *)(node))
1085#define RNODE_IASGN(node) ((rb_node_iasgn_t *)(node))
1086#define RNODE_CDECL(node) ((rb_node_cdecl_t *)(node))
1087#define RNODE_CVASGN(node) ((rb_node_cvasgn_t *)(node))
1088#define RNODE_OP_ASGN1(node) ((rb_node_op_asgn1_t *)(node))
1089#define RNODE_OP_ASGN2(node) ((rb_node_op_asgn2_t *)(node))
1090#define RNODE_OP_ASGN_AND(node) ((rb_node_op_asgn_and_t *)(node))
1091#define RNODE_OP_ASGN_OR(node) ((rb_node_op_asgn_or_t *)(node))
1092#define RNODE_OP_CDECL(node) ((rb_node_op_cdecl_t *)(node))
1093#define RNODE_CALL(node) ((rb_node_call_t *)(node))
1094#define RNODE_OPCALL(node) ((rb_node_opcall_t *)(node))
1095#define RNODE_FCALL(node) ((rb_node_fcall_t *)(node))
1096#define RNODE_VCALL(node) ((rb_node_vcall_t *)(node))
1097#define RNODE_QCALL(node) ((rb_node_qcall_t *)(node))
1098#define RNODE_SUPER(node) ((rb_node_super_t *)(node))
1099#define RNODE_ZSUPER(node) ((rb_node_zsuper_t *)(node))
1100#define RNODE_LIST(node) ((rb_node_list_t *)(node))
1101#define RNODE_ZLIST(node) ((rb_node_zlist_t *)(node))
1102#define RNODE_HASH(node) ((rb_node_hash_t *)(node))
1103#define RNODE_RETURN(node) ((rb_node_return_t *)(node))
1104#define RNODE_YIELD(node) ((rb_node_yield_t *)(node))
1105#define RNODE_LVAR(node) ((rb_node_lvar_t *)(node))
1106#define RNODE_DVAR(node) ((rb_node_dvar_t *)(node))
1107#define RNODE_GVAR(node) ((rb_node_gvar_t *)(node))
1108#define RNODE_IVAR(node) ((rb_node_ivar_t *)(node))
1109#define RNODE_CONST(node) ((rb_node_const_t *)(node))
1110#define RNODE_CVAR(node) ((rb_node_cvar_t *)(node))
1111#define RNODE_NTH_REF(node) ((rb_node_nth_ref_t *)(node))
1112#define RNODE_BACK_REF(node) ((rb_node_back_ref_t *)(node))
1113#define RNODE_MATCH(node) ((rb_node_match_t *)(node))
1114#define RNODE_MATCH2(node) ((rb_node_match2_t *)(node))
1115#define RNODE_MATCH3(node) ((rb_node_match3_t *)(node))
1116#define RNODE_INTEGER(node) ((rb_node_integer_t *)(node))
1117#define RNODE_FLOAT(node) ((rb_node_float_t *)(node))
1118#define RNODE_RATIONAL(node) ((rb_node_rational_t *)(node))
1119#define RNODE_IMAGINARY(node) ((rb_node_imaginary_t *)(node))
1120#define RNODE_STR(node) ((rb_node_str_t *)(node))
1121#define RNODE_DSTR(node) ((rb_node_dstr_t *)(node))
1122#define RNODE_XSTR(node) ((rb_node_xstr_t *)(node))
1123#define RNODE_DXSTR(node) ((rb_node_dxstr_t *)(node))
1124#define RNODE_EVSTR(node) ((rb_node_evstr_t *)(node))
1125#define RNODE_REGX(node) ((rb_node_regx_t *)(node))
1126#define RNODE_DREGX(node) ((rb_node_dregx_t *)(node))
1127#define RNODE_ONCE(node) ((rb_node_once_t *)(node))
1128#define RNODE_ARGS(node) ((rb_node_args_t *)(node))
1129#define RNODE_ARGS_AUX(node) ((rb_node_args_aux_t *)(node))
1130#define RNODE_OPT_ARG(node) ((rb_node_opt_arg_t *)(node))
1131#define RNODE_KW_ARG(node) ((rb_node_kw_arg_t *)(node))
1132#define RNODE_POSTARG(node) ((rb_node_postarg_t *)(node))
1133#define RNODE_ARGSCAT(node) ((rb_node_argscat_t *)(node))
1134#define RNODE_ARGSPUSH(node) ((rb_node_argspush_t *)(node))
1135#define RNODE_SPLAT(node) ((rb_node_splat_t *)(node))
1136#define RNODE_BLOCK_PASS(node) ((rb_node_block_pass_t *)(node))
1137#define RNODE_DEFN(node) ((rb_node_defn_t *)(node))
1138#define RNODE_DEFS(node) ((rb_node_defs_t *)(node))
1139#define RNODE_ALIAS(node) ((rb_node_alias_t *)(node))
1140#define RNODE_VALIAS(node) ((rb_node_valias_t *)(node))
1141#define RNODE_UNDEF(node) ((rb_node_undef_t *)(node))
1142#define RNODE_CLASS(node) ((rb_node_class_t *)(node))
1143#define RNODE_MODULE(node) ((rb_node_module_t *)(node))
1144#define RNODE_SCLASS(node) ((rb_node_sclass_t *)(node))
1145#define RNODE_COLON2(node) ((rb_node_colon2_t *)(node))
1146#define RNODE_COLON3(node) ((rb_node_colon3_t *)(node))
1147#define RNODE_DOT2(node) ((rb_node_dot2_t *)(node))
1148#define RNODE_DOT3(node) ((rb_node_dot3_t *)(node))
1149#define RNODE_FLIP2(node) ((rb_node_flip2_t *)(node))
1150#define RNODE_FLIP3(node) ((rb_node_flip3_t *)(node))
1151#define RNODE_SELF(node) ((rb_node_self_t *)(node))
1152#define RNODE_NIL(node) ((rb_node_nil_t *)(node))
1153#define RNODE_TRUE(node) ((rb_node_true_t *)(node))
1154#define RNODE_FALSE(node) ((rb_node_false_t *)(node))
1155#define RNODE_ERRINFO(node) ((rb_node_errinfo_t *)(node))
1156#define RNODE_DEFINED(node) ((rb_node_defined_t *)(node))
1157#define RNODE_POSTEXE(node) ((rb_node_postexe_t *)(node))
1158#define RNODE_SYM(node) ((rb_node_sym_t *)(node))
1159#define RNODE_DSYM(node) ((rb_node_dsym_t *)(node))
1160#define RNODE_ATTRASGN(node) ((rb_node_attrasgn_t *)(node))
1161#define RNODE_LAMBDA(node) ((rb_node_lambda_t *)(node))
1162#define RNODE_ARYPTN(node) ((rb_node_aryptn_t *)(node))
1163#define RNODE_HSHPTN(node) ((rb_node_hshptn_t *)(node))
1164#define RNODE_FNDPTN(node) ((rb_node_fndptn_t *)(node))
1165#define RNODE_LINE(node) ((rb_node_line_t *)(node))
1166#define RNODE_FILE(node) ((rb_node_file_t *)(node))
1167#define RNODE_ENCODING(node) ((rb_node_encoding_t *)(node))
1168
1169/* FL : 0..4: T_TYPES, 5: KEEP_WB, 6: PROMOTED, 7: FINALIZE, 8..10: UNUSED, 11: FREEZE */
1170/* NODE_FL: 0..4: UNUSED, 5: UNUSED, 6: UNUSED, 7: NODE_FL_NEWLINE,
1171 * 8..14: nd_type,
1172 * 15..: nd_line
1173 */
1174#define NODE_FL_NEWLINE (((VALUE)1)<<7)
1175
1176#define NODE_TYPESHIFT 8
1177#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
1178
1179#define nd_fl_newline(n) ((n)->flags & NODE_FL_NEWLINE)
1180#define nd_set_fl_newline(n) ((n)->flags |= NODE_FL_NEWLINE)
1181#define nd_unset_fl_newline(n) ((n)->flags &= ~NODE_FL_NEWLINE)
1182
1183#define nd_type(n) ((int) ((RNODE(n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
1184#define nd_set_type(n,t) \
1185 rb_node_set_type(n, t)
1186#define nd_init_type(n,t) \
1187 (n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK))
1188
1189typedef struct node_buffer_struct node_buffer_t;
1190
1191#ifdef UNIVERSAL_PARSER
1192typedef struct rb_parser_config_struct rb_parser_config_t;
1193#endif
1194
1195 typedef struct rb_ast_body_struct {
1196 const NODE *root;
1197 rb_parser_ary_t *script_lines;
1198 int line_count;
1199 signed int frozen_string_literal:2; /* -1: not specified, 0: false, 1: true */
1200 signed int coverage_enabled:2; /* -1: not specified, 0: false, 1: true */
1201} rb_ast_body_t;
1202 typedef struct rb_ast_struct {
1203 node_buffer_t *node_buffer;
1204 rb_ast_body_t body;
1205#ifdef UNIVERSAL_PARSER
1206 const rb_parser_config_t *config;
1207#endif
1208} rb_ast_t;
1209
1210
1211
1212/*
1213 * Parser Interface
1214 */
1215
1216
1217typedef struct parser_params rb_parser_t;
1218#ifndef INTERNAL_IMEMO_H
1219typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
1220#endif
1221
1222typedef NODE *(*rb_parser_assignable_func)(struct parser_params *p, ID id, NODE *val, const rb_code_location_t *loc);
1223
1224#ifdef UNIVERSAL_PARSER
1225typedef struct rb_parser_config_struct {
1226 /* Memory */
1227 void *(*malloc)(size_t size);
1228 void *(*calloc)(size_t number, size_t size);
1229 void *(*realloc)(void *ptr, size_t newsiz);
1230 void (*free)(void *ptr);
1231 void *(*alloc_n)(size_t nelems, size_t elemsiz);
1232 void *(*alloc)(size_t elemsiz);
1233 void *(*realloc_n)(void *ptr, size_t newelems, size_t newsiz);
1234 void *(*zalloc)(size_t elemsiz);
1235 void *(*rb_memmove)(void *dest, const void *src, size_t t, size_t n);
1236 void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
1237 void *(*xmalloc_mul_add)(size_t x, size_t y, size_t z);
1238
1239 // VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
1240 VALUE (*compile_callback)(VALUE (*func)(VALUE), VALUE arg);
1241 NODE *(*reg_named_capture_assign)(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc, rb_parser_assignable_func assignable);
1242
1243 /* Variable */
1244 VALUE (*attr_get)(VALUE obj, ID id);
1245
1246 /* Array */
1247 VALUE (*ary_new_from_args)(long n, ...);
1248 VALUE (*ary_unshift)(VALUE ary, VALUE item);
1249
1250 /* Symbol */
1251 ID (*make_temporary_id)(size_t n);
1252 int (*is_local_id)(ID);
1253 int (*is_attrset_id)(ID);
1254 int (*is_global_name_punct)(const int c);
1255 int (*id_type)(ID id);
1256 ID (*id_attrset)(ID);
1257 ID (*intern)(const char *name);
1258 ID (*intern2)(const char *name, long len);
1259 ID (*intern3)(const char *name, long len, rb_encoding *enc);
1260 ID (*intern_str)(VALUE str);
1261 int (*is_notop_id)(ID);
1262 int (*enc_symname_type)(const char *name, long len, rb_encoding *enc, unsigned int allowed_attrset);
1263 const char *(*id2name)(ID id);
1264 VALUE (*id2str)(ID id);
1265 VALUE (*id2sym)(ID x);
1266
1267 /* String */
1268 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
1269 VALUE (*str_catf)(VALUE str, const char *format, ...);
1270 VALUE (*str_cat_cstr)(VALUE str, const char *ptr);
1271 VALUE (*str_resize)(VALUE str, long len);
1272 VALUE (*str_new)(const char *ptr, long len);
1273 VALUE (*str_new_cstr)(const char *ptr);
1274 VALUE (*str_to_interned_str)(VALUE);
1275 VALUE (*enc_str_new)(const char *ptr, long len, rb_encoding *enc);
1276 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 0)
1277 VALUE (*str_vcatf)(VALUE str, const char *fmt, va_list ap);
1278 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
1279 VALUE (*rb_sprintf)(const char *format, ...);
1280 char *(*rstring_ptr)(VALUE str);
1281 long (*rstring_len)(VALUE str);
1282
1283 /* Numeric */
1284 VALUE (*int2num)(int v);
1285
1286 /* IO */
1287 int (*stderr_tty_p)(void);
1288 void (*write_error_str)(VALUE mesg);
1289 VALUE (*io_write)(VALUE io, VALUE str);
1290 VALUE (*io_flush)(VALUE io);
1291 VALUE (*io_puts)(int argc, const VALUE *argv, VALUE out);
1292
1293 /* IO (Ractor) */
1294 VALUE (*debug_output_stdout)(void);
1295 VALUE (*debug_output_stderr)(void);
1296
1297 /* Encoding */
1298 int (*is_usascii_enc)(rb_encoding *enc);
1299 int (*enc_isalnum)(OnigCodePoint c, rb_encoding *enc);
1300 int (*enc_precise_mbclen)(const char *p, const char *e, rb_encoding *enc);
1301 int (*mbclen_charfound_p)(int len);
1302 int (*mbclen_charfound_len)(int len);
1303 const char *(*enc_name)(rb_encoding *enc);
1304 char *(*enc_prev_char)(const char *s, const char *p, const char *e, rb_encoding *enc);
1305 rb_encoding* (*enc_get)(VALUE obj);
1306 int (*enc_asciicompat)(rb_encoding *enc);
1307 rb_encoding *(*utf8_encoding)(void);
1308 rb_encoding *(*ascii8bit_encoding)(void);
1309 int (*enc_codelen)(int c, rb_encoding *enc);
1310 int (*enc_mbcput)(unsigned int c, void *buf, rb_encoding *enc);
1311 int (*enc_find_index)(const char *name);
1312 rb_encoding *(*enc_from_index)(int idx);
1313 int (*enc_isspace)(OnigCodePoint c, rb_encoding *enc);
1314 int (*enc_mbminlen)(rb_encoding *enc);
1315 bool (*enc_isascii)(OnigCodePoint c, rb_encoding *enc);
1316 OnigCodePoint (*enc_mbc_to_codepoint)(const char *p, const char *e, rb_encoding *enc);
1317
1318 /* Compile */
1319 // int rb_local_defined(ID id, const rb_iseq_t *iseq);
1320 int (*local_defined)(ID, const void*);
1321 // int rb_dvar_defined(ID id, const rb_iseq_t *iseq);
1322 int (*dvar_defined)(ID, const void*);
1323
1324 /* Error (Exception) */
1325 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 6, 0)
1326 VALUE (*syntax_error_append)(VALUE, VALUE, int, int, rb_encoding*, const char*, va_list);
1327 RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
1328 void (*raise)(VALUE exc, const char *fmt, ...);
1329 VALUE (*syntax_error_new)(void);
1330
1331 /* Eval */
1332 VALUE (*errinfo)(void);
1333 void (*set_errinfo)(VALUE err);
1334 VALUE (*make_exception)(int argc, const VALUE *argv);
1335
1336 /* GC */
1337 void (*sized_xfree)(void *x, size_t size);
1338 void *(*sized_realloc_n)(void *ptr, size_t new_count, size_t element_size, size_t old_count);
1339 void (*gc_guard)(VALUE);
1340 void (*gc_mark)(VALUE);
1341
1342 /* Re */
1343 VALUE (*reg_compile)(VALUE str, int options, const char *sourcefile, int sourceline);
1344 VALUE (*reg_check_preprocess)(VALUE str);
1345 int (*memcicmp)(const void *x, const void *y, long len);
1346
1347 /* Error */
1348 void (*compile_warn)(const char *file, int line, const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(3, 4);
1349 void (*compile_warning)(const char *file, int line, const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(3, 4);
1350 void (*bug)(const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(1, 2);
1351 void (*fatal)(const char *fmt, ...) RUBYPARSER_ATTRIBUTE_FORMAT(1, 2);
1352 VALUE (*verbose)(void);
1353 int *(*errno_ptr)(void);
1354
1355 /* VM */
1356 VALUE (*make_backtrace)(void);
1357
1358 /* Util */
1359 unsigned long (*scan_hex)(const char *start, size_t len, size_t *retlen);
1360 unsigned long (*scan_oct)(const char *start, size_t len, size_t *retlen);
1361 unsigned long (*scan_digits)(const char *str, ssize_t len, int base, size_t *retlen, int *overflow);
1362 double (*strtod)(const char *s00, char **se);
1363
1364 /* Misc */
1365 int (*rtest)(VALUE obj);
1366 int (*nil_p)(VALUE obj);
1367 VALUE qnil;
1368 VALUE qfalse;
1369 VALUE (*eArgError)(void);
1370 int (*long2int)(long);
1371
1372 /* For Ripper */
1373 int enc_coderange_7bit;
1374 int enc_coderange_unknown;
1375 VALUE (*static_id2sym)(ID id);
1376 long (*str_coderange_scan_restartable)(const char *s, const char *e, rb_encoding *enc, int *cr);
1377} rb_parser_config_t;
1378
1379#undef rb_encoding
1380#undef OnigCodePoint
1381#endif /* UNIVERSAL_PARSER */
1382
1383RUBY_SYMBOL_EXPORT_BEGIN
1384void rb_ruby_parser_free(void *ptr);
1385
1386#ifdef UNIVERSAL_PARSER
1387rb_parser_t *rb_ruby_parser_allocate(const rb_parser_config_t *config);
1388rb_parser_t *rb_ruby_parser_new(const rb_parser_config_t *config);
1389#endif
1390
1391RUBY_SYMBOL_EXPORT_END
1392
1393#endif /* RUBY_RUBYPARSER_H */
assert.h
RBIMPL_ATTR_FORMAT
#define RBIMPL_ATTR_FORMAT(x, y, z)
Wraps (or simulates) __attribute__((format)).
Definition format.h:29
scan_hex
#define scan_hex(s, l, e)
Old name of ruby_scan_hex.
Definition util.h:108
scan_oct
#define scan_oct(s, l, e)
Old name of ruby_scan_oct.
Definition util.h:85
encoding.h
Encoding relates APIs.
len
int len
Length of the buffer.
Definition io.h:8
strtod
#define strtod(s, e)
Just another name of ruby_strtod.
Definition util.h:223
stdarg.h
Defines old _.
RNode_ALIAS
Definition rubyparser.h:868
RNode_ARGS_AUX
Definition rubyparser.h:794
RNode_ARGSCAT
Definition rubyparser.h:823
RNode_ARGS
Definition rubyparser.h:788
RNode_ARGSPUSH
Definition rubyparser.h:830
RNode_ARYPTN
Definition rubyparser.h:1010
RNode_ATTRASGN
Definition rubyparser.h:993
RNode_BACK_REF
Definition rubyparser.h:658
RNode_BEGIN
Definition rubyparser.h:379
RNode_BLOCK_PASS
Definition rubyparser.h:844
RNode_BLOCK
Definition rubyparser.h:255
RNode_CALL
Definition rubyparser.h:518
RNode_CASE2
Definition rubyparser.h:294
RNode_CASE3
Definition rubyparser.h:303
RNode_CASE
Definition rubyparser.h:285
RNode_CDECL
Definition rubyparser.h:453
RNode_CLASS
Definition rubyparser.h:891
RNode_COLON2
Definition rubyparser.h:921
RNode_COLON3
Definition rubyparser.h:930
RNode_CONST
Definition rubyparser.h:640
RNode_CVAR
Definition rubyparser.h:646
RNode_CVASGN
Definition rubyparser.h:462
RNode_DASGN
Definition rubyparser.h:432
RNode_DEFINED
Definition rubyparser.h:969
RNode_DEFN
Definition rubyparser.h:853
RNode_DEFS
Definition rubyparser.h:860
RNode_DOTS
Definition rubyparser.h:939
RNode_DSTR
Definition rubyparser.h:726
RNode_DVAR
Definition rubyparser.h:622
RNode_ENCODING
Definition rubyparser.h:1046
RNode_ENSURE
Definition rubyparser.h:402
RNode_ERRINFO
Definition rubyparser.h:965
RNode_ERROR
Definition rubyparser.h:1051
RNode_EVSTR
Definition rubyparser.h:742
RNode_EXITS
Definition rubyparser.h:367
RNode_FALSE
Definition rubyparser.h:961
RNode_FCALL
Definition rubyparser.h:534
RNode_FILE
Definition rubyparser.h:1040
RNode_FLOAT
Definition rubyparser.h:687
RNode_FNDPTN
Definition rubyparser.h:1027
RNode_FOR_MASGN
Definition rubyparser.h:361
RNode_FOR
Definition rubyparser.h:350
RNode_GASGN
Definition rubyparser.h:439
RNode_GVAR
Definition rubyparser.h:628
RNode_HASH
Definition rubyparser.h:593
RNode_HSHPTN
Definition rubyparser.h:1019
RNode_IASGN
Definition rubyparser.h:446
RNode_IF
Definition rubyparser.h:263
RNode_IMAGINARY
Definition rubyparser.h:709
RNode_IN
Definition rubyparser.h:322
RNode_INTEGER
Definition rubyparser.h:679
RNode_ITER
Definition rubyparser.h:343
RNode_IVAR
Definition rubyparser.h:634
RNode_KW_ARG
Definition rubyparser.h:809
RNode_LAMBDA
Definition rubyparser.h:1001
RNode_LASGN
Definition rubyparser.h:425
RNode_LINE
Definition rubyparser.h:1036
RNode_LIST
Definition rubyparser.h:578
RNode_LOOP
Definition rubyparser.h:333
RNode_LVAR
Definition rubyparser.h:616
RNode_MASGN
Definition rubyparser.h:417
RNode_MATCH2
Definition rubyparser.h:664
RNode_MATCH3
Definition rubyparser.h:672
RNode_MODULE
Definition rubyparser.h:902
RNode_NIL
Definition rubyparser.h:953
RNode_NTH_REF
Definition rubyparser.h:652
RNode_ONCE
Definition rubyparser.h:762
RNode_OP_ASGN1
Definition rubyparser.h:469
RNode_OP_ASGN2
Definition rubyparser.h:482
RNode_OP_ASGN_AND
Definition rubyparser.h:495
RNode_OP_ASGN_OR
Definition rubyparser.h:502
RNode_OP_CDECL
Definition rubyparser.h:509
RNode_OPCALL
Definition rubyparser.h:526
RNode_OPT_ARG
Definition rubyparser.h:802
RNode_POSTARG
Definition rubyparser.h:816
RNode_POSTEXE
Definition rubyparser.h:976
RNode_QCALL
Definition rubyparser.h:547
RNode_RATIONAL
Definition rubyparser.h:694
RNode_REGX
Definition rubyparser.h:750
RNode_RESBODY
Definition rubyparser.h:393
RNode_RESCUE
Definition rubyparser.h:385
RNode_RETRY
Definition rubyparser.h:375
RNode_RETURN
Definition rubyparser.h:600
RNode_SCLASS
Definition rubyparser.h:911
RNode_SCOPE
Definition rubyparser.h:246
RNode_SELF
Definition rubyparser.h:947
RNode_SPLAT
Definition rubyparser.h:837
RNode_STR
Definition rubyparser.h:719
RNode_SUPER
Definition rubyparser.h:555
RNode_SYM
Definition rubyparser.h:985
RNode_TRUE
Definition rubyparser.h:957
RNode_UNDEF
Definition rubyparser.h:884
RNode_UNLESS
Definition rubyparser.h:274
RNode_VALIAS
Definition rubyparser.h:876
RNode_VCALL
Definition rubyparser.h:541
RNode_WHEN
Definition rubyparser.h:312
RNode_YIELD
Definition rubyparser.h:607
RNode_ZLIST
Definition rubyparser.h:589
RNode_ZSUPER
Definition rubyparser.h:564
RNode
Definition rubyparser.h:240
node_buffer_struct
Definition node.h:33
parser_params
Definition parse.c:552
rb_args_info
Definition rubyparser.h:768
rb_ast_body_struct
Definition rubyparser.h:1195
rb_ast_id_table
Definition rubyparser.h:197
rb_ast_struct
Definition rubyparser.h:1202
rb_code_location_struct
Definition rubyparser.h:207
rb_code_position_struct
Definition rubyparser.h:202
rb_imemo_tmpbuf_struct
Definition imemo.h:95
rb_node_and_t
Definition rubyparser.h:409
rb_parser_ary
Definition rubyparser.h:232
rb_parser_ast_token
Definition rubyparser.h:214
rb_parser_string
Definition rubyparser.h:60
ID
uintptr_t ID
Type that represents a Ruby identifier such as a variable name.
Definition value.h:52
VALUE
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40