Remove rb_ary_push for parser
[ruby.git] / universal_parser.c
bloba381f9a86b4161dcf56deb590ab72adea3c91920
1 #include <alloca.h>
2 #include <string.h>
3 #include <stdarg.h>
4 #include <stdbool.h>
5 #include <stddef.h>
7 /* Dependency */
8 #include "internal/parse.h"
9 #include "node.h"
10 #include "id.h"
12 #include "internal/compilers.h"
13 #include "ruby/backward/2/inttypes.h"
14 #include "probes.h"
16 #define LIKELY(x) RB_LIKELY(x)
17 #define UNLIKELY(x) RB_UNLIKELY(x)
18 #ifndef TRUE
19 # define TRUE 1
20 #endif
22 #ifndef FALSE
23 # define FALSE 0
24 #endif
25 #define numberof(array) ((int)(sizeof(array) / sizeof((array)[0])))
26 #define rb_strlen_lit(str) ((sizeof(str "") / sizeof(str ""[0])) - 1)
27 #undef FIXNUM_MAX
28 #define FIXNUM_MAX (LONG_MAX / 2)
30 /* parser_st */
31 #define st_table parser_st_table
32 #define st_data_t parser_st_data_t
33 #define st_hash_type parser_st_hash_type
34 #define ST_CONTINUE ST2_CONTINUE
35 #define ST_STOP ST2_STOP
36 #define ST_DELETE ST2_DELETE
37 #define ST_CHECK ST2_CHECK
38 #define ST_REPLACE ST2_REPLACE
39 #undef st_init_numtable
40 #define st_init_numtable rb_parser_st_init_numtable
41 #undef st_free_table
42 #define st_free_table rb_parser_st_free_table
43 #undef st_init_table_with_size
44 #define st_init_table_with_size rb_parser_st_init_table_with_size
45 #undef st_insert
46 #define st_insert rb_parser_st_insert
47 #undef st_foreach
48 #define st_foreach rb_parser_st_foreach
49 #undef st_delete
50 #define st_delete rb_parser_st_delete
51 #undef st_is_member
52 #define st_is_member parser_st_is_member
53 #undef st_init_table
54 #define st_init_table rb_parser_st_init_table
55 #undef st_lookup
56 #define st_lookup rb_parser_st_lookup
58 #define rb_encoding const void
60 #undef xmalloc
61 #define xmalloc p->config->malloc
62 #undef xcalloc
63 #define xcalloc p->config->calloc
64 #undef xrealloc
65 #define xrealloc p->config->realloc
66 #undef ALLOC_N
67 #define ALLOC_N(type,n) ((type *)p->config->alloc_n((n), sizeof(type)))
68 #undef ALLOC
69 #define ALLOC(type) ((type *)p->config->alloc(sizeof(type)))
70 #undef xfree
71 #define xfree p->config->free
72 #undef ALLOCA_N
73 // alloca(rbimpl_size_mul_or_raise(x, y));
74 #define ALLOCA_N(type,n) ((type *)alloca(sizeof(type) * (n)))
75 #undef REALLOC_N
76 #define REALLOC_N(var,type,n) ((var) = (type *)p->config->realloc_n((void *)var, n, sizeof(type)))
77 #undef ZALLOC
78 #define ZALLOC(type) ((type *)p->config->zalloc(sizeof(type)))
79 #undef MEMMOVE
80 #define MEMMOVE(p1,p2,type,n) (p->config->rb_memmove((p1), (p2), sizeof(type), (n)))
81 #undef MEMCPY
82 #define MEMCPY(p1,p2,type,n) (p->config->nonempty_memcpy((p1), (p2), sizeof(type), (n)))
84 #define compile_callback p->config->compile_callback
85 #define reg_named_capture_assign p->config->reg_named_capture_assign
87 #define rb_attr_get p->config->attr_get
89 #undef rb_ary_new_from_args
90 #define rb_ary_new_from_args p->config->ary_new_from_args
91 #define rb_ary_unshift p->config->ary_unshift
93 #define rb_make_temporary_id p->config->make_temporary_id
94 #define is_local_id p->config->is_local_id
95 #define is_attrset_id p->config->is_attrset_id
96 #define is_global_name_punct p->config->is_global_name_punct
97 #define id_type p->config->id_type
98 #define rb_id_attrset p->config->id_attrset
99 #undef rb_intern
100 #define rb_intern p->config->intern
101 #define rb_intern2 p->config->intern2
102 #define rb_intern3 p->config->intern3
103 #define rb_intern_str p->config->intern_str
104 #define is_notop_id p->config->is_notop_id
105 #define rb_enc_symname_type p->config->enc_symname_type
106 #define rb_id2name p->config->id2name
107 #define rb_id2str p->config->id2str
108 #undef ID2SYM
109 #define ID2SYM p->config->id2sym
110 #undef SYM2ID
111 #define SYM2ID p->config->sym2id
113 #define rb_str_catf p->config->str_catf
114 #undef rb_str_cat_cstr
115 #define rb_str_cat_cstr p->config->str_cat_cstr
116 #define rb_str_resize p->config->str_resize
117 #undef rb_str_new
118 #define rb_str_new p->config->str_new
119 #undef rb_str_new_cstr
120 #define rb_str_new_cstr p->config->str_new_cstr
121 #define rb_str_to_interned_str p->config->str_to_interned_str
122 #define rb_enc_str_new p->config->enc_str_new
123 #define rb_str_vcatf p->config->str_vcatf
124 #define rb_sprintf p->config->rb_sprintf
125 #undef RSTRING_PTR
126 #define RSTRING_PTR p->config->rstring_ptr
127 #undef RSTRING_LEN
128 #define RSTRING_LEN p->config->rstring_len
129 #define rb_obj_as_string p->config->obj_as_string
131 #undef INT2NUM
132 #define INT2NUM p->config->int2num
134 #define rb_stderr_tty_p p->config->stderr_tty_p
135 #define rb_write_error_str p->config->write_error_str
136 #define rb_io_write p->config->io_write
137 #define rb_io_flush p->config->io_flush
138 #define rb_io_puts p->config->io_puts
140 #define rb_ractor_stdout p->config->debug_output_stdout
141 #define rb_ractor_stderr p->config->debug_output_stderr
143 #define rb_is_usascii_enc p->config->is_usascii_enc
144 #define rb_enc_isalnum p->config->enc_isalnum
145 #define rb_enc_precise_mbclen p->config->enc_precise_mbclen
146 #define MBCLEN_CHARFOUND_P p->config->mbclen_charfound_p
147 #define MBCLEN_CHARFOUND_LEN p->config->mbclen_charfound_len
148 #define rb_enc_name p->config->enc_name
149 #define rb_enc_prev_char p->config->enc_prev_char
150 #define rb_enc_get p->config->enc_get
151 #define rb_enc_asciicompat p->config->enc_asciicompat
152 #define rb_utf8_encoding p->config->utf8_encoding
153 #define rb_enc_associate p->config->enc_associate
154 #define rb_ascii8bit_encoding p->config->ascii8bit_encoding
155 #define rb_enc_codelen p->config->enc_codelen
156 #define rb_enc_mbcput p->config->enc_mbcput
157 #define rb_enc_find_index p->config->enc_find_index
158 #define rb_enc_from_index p->config->enc_from_index
159 #define rb_enc_isspace p->config->enc_isspace
160 #define ENC_CODERANGE_7BIT p->config->enc_coderange_7bit
161 #define ENC_CODERANGE_UNKNOWN p->config->enc_coderange_unknown
162 #define rb_usascii_encoding p->config->usascii_encoding
164 #define rb_local_defined p->config->local_defined
165 #define rb_dvar_defined p->config->dvar_defined
167 #define rb_syntax_error_append p->config->syntax_error_append
168 #define rb_raise p->config->raise
169 #define syntax_error_new p->config->syntax_error_new
171 #define rb_errinfo p->config->errinfo
172 #define rb_set_errinfo p->config->set_errinfo
173 #define rb_exc_raise p->config->exc_raise
174 #define rb_make_exception p->config->make_exception
176 #define ruby_sized_xfree p->config->sized_xfree
177 #define SIZED_REALLOC_N(v, T, m, n) ((v) = (T *)p->config->sized_realloc_n((void *)(v), (m), sizeof(T), (n)))
178 #undef RB_GC_GUARD
179 #define RB_GC_GUARD p->config->gc_guard
180 #define rb_gc_mark p->config->gc_mark
182 #define rb_reg_compile p->config->reg_compile
183 #define rb_reg_check_preprocess p->config->reg_check_preprocess
184 #define rb_memcicmp p->config->memcicmp
186 #define rb_compile_warn p->config->compile_warn
187 #define rb_compile_warning p->config->compile_warning
188 #define rb_bug p->config->bug
189 #define rb_fatal p->config->fatal
190 #undef ruby_verbose
191 #define ruby_verbose p->config->verbose()
192 #undef errno
193 #define errno (*p->config->errno_ptr())
195 #define rb_make_backtrace p->config->make_backtrace
197 #define ruby_scan_hex p->config->scan_hex
198 #define ruby_scan_oct p->config->scan_oct
199 #define ruby_scan_digits p->config->scan_digits
200 #define strtod p->config->strtod
202 #undef RTEST
203 #define RTEST p->config->rtest
204 #undef NIL_P
205 #define NIL_P p->config->nil_p
206 #undef Qnil
207 #define Qnil p->config->qnil
208 #undef Qfalse
209 #define Qfalse p->config->qfalse
210 #define rb_eArgError p->config->eArgError()
211 #undef rb_long2int
212 #define rb_long2int p->config->long2int
213 #define rb_enc_mbminlen p->config->enc_mbminlen
214 #define rb_enc_isascii p->config->enc_isascii
215 #define rb_enc_mbc_to_codepoint p->config->enc_mbc_to_codepoint
217 #define rb_ast_new() \
218 rb_ast_new(p->config)