Ruby: rubyparser.h Source File

Ruby 3.3.5p100 (2024-09-03 revision ef084cc8f4958c1b6e4ead99136631bef6d8ddba)

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