Tempfile document updated.
[ruby.git] / universal_parser.c
blob9381c4285e40298fe96b991c257da088dbf5e993
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 "") - 1)
27 #undef FIXNUM_MAX
28 #define FIXNUM_MAX (LONG_MAX / 2)
29 #undef RSTRING_GETMEM
30 #define RSTRING_GETMEM(str, ptrvar, lenvar) \
31 ((ptrvar) = RSTRING_PTR(str), \
32 (lenvar) = RSTRING_LEN(str))
34 /* parser_st */
35 #define st_table parser_st_table
36 #define st_data_t parser_st_data_t
37 #define st_hash_type parser_st_hash_type
38 #define ST_CONTINUE ST2_CONTINUE
39 #define ST_STOP ST2_STOP
40 #define ST_DELETE ST2_DELETE
41 #define ST_CHECK ST2_CHECK
42 #define ST_REPLACE ST2_REPLACE
43 #undef st_init_numtable
44 #define st_init_numtable rb_parser_st_init_numtable
45 #undef st_free_table
46 #define st_free_table rb_parser_st_free_table
47 #undef st_init_table_with_size
48 #define st_init_table_with_size rb_parser_st_init_table_with_size
49 #undef st_insert
50 #define st_insert rb_parser_st_insert
51 #undef st_foreach
52 #define st_foreach rb_parser_st_foreach
53 #undef st_delete
54 #define st_delete rb_parser_st_delete
55 #undef st_is_member
56 #define st_is_member parser_st_is_member
57 #undef st_init_table
58 #define st_init_table rb_parser_st_init_table
59 #undef st_lookup
60 #define st_lookup rb_parser_st_lookup
62 #define rb_encoding const void
64 #undef xmalloc
65 #define xmalloc p->config->malloc
66 #undef xcalloc
67 #define xcalloc p->config->calloc
68 #undef xrealloc
69 #define xrealloc p->config->realloc
70 #undef ALLOC_N
71 #define ALLOC_N(type,n) ((type *)p->config->alloc_n((n), sizeof(type)))
72 #undef ALLOC
73 #define ALLOC(type) ((type *)p->config->alloc(sizeof(type)))
74 #undef xfree
75 #define xfree p->config->free
76 #undef ALLOCA_N
77 // alloca(rbimpl_size_mul_or_raise(x, y));
78 #define ALLOCA_N(type,n) ((type *)alloca(sizeof(type) * (n)))
79 #undef REALLOC_N
80 #define REALLOC_N(var,type,n) ((var) = (type *)p->config->realloc_n((void *)var, n, sizeof(type)))
81 #undef ZALLOC
82 #define ZALLOC(type) ((type *)p->config->zalloc(sizeof(type)))
83 #undef MEMMOVE
84 #define MEMMOVE(p1,p2,type,n) (p->config->rb_memmove((p1), (p2), sizeof(type), (n)))
85 #undef MEMCPY
86 #define MEMCPY(p1,p2,type,n) (p->config->nonempty_memcpy((p1), (p2), sizeof(type), (n)))
88 #define compile_callback p->config->compile_callback
89 #define reg_named_capture_assign p->config->reg_named_capture_assign
91 #define rb_attr_get p->config->attr_get
93 #define rb_ary_new p->config->ary_new
94 #define rb_ary_push p->config->ary_push
95 #undef rb_ary_new_from_args
96 #define rb_ary_new_from_args p->config->ary_new_from_args
97 #define rb_ary_unshift p->config->ary_unshift
99 #define rb_make_temporary_id p->config->make_temporary_id
100 #define is_local_id p->config->is_local_id
101 #define is_attrset_id p->config->is_attrset_id
102 #define is_global_name_punct p->config->is_global_name_punct
103 #define id_type p->config->id_type
104 #define rb_id_attrset p->config->id_attrset
105 #undef rb_intern
106 #define rb_intern p->config->intern
107 #define rb_intern2 p->config->intern2
108 #define rb_intern3 p->config->intern3
109 #define rb_intern_str p->config->intern_str
110 #define is_notop_id p->config->is_notop_id
111 #define rb_enc_symname_type p->config->enc_symname_type
112 #define rb_id2name p->config->id2name
113 #define rb_id2str p->config->id2str
114 #undef ID2SYM
115 #define ID2SYM p->config->id2sym
116 #undef SYM2ID
117 #define SYM2ID p->config->sym2id
119 #define rb_str_catf p->config->str_catf
120 #undef rb_str_cat_cstr
121 #define rb_str_cat_cstr p->config->str_cat_cstr
122 #define rb_str_modify p->config->str_modify
123 #define rb_str_set_len p->config->str_set_len
124 #define rb_str_cat p->config->str_cat
125 #define rb_str_resize p->config->str_resize
126 #undef rb_str_new
127 #define rb_str_new p->config->str_new
128 #undef rb_str_new_cstr
129 #define rb_str_new_cstr p->config->str_new_cstr
130 #define rb_str_to_interned_str p->config->str_to_interned_str
131 #define is_ascii_string p->config->is_ascii_string
132 #define rb_enc_str_new p->config->enc_str_new
133 #define rb_str_vcatf p->config->str_vcatf
134 #undef StringValueCStr
135 #define StringValueCStr(v) p->config->string_value_cstr(&(v))
136 #define rb_sprintf p->config->rb_sprintf
137 #undef RSTRING_PTR
138 #define RSTRING_PTR p->config->rstring_ptr
139 #undef RSTRING_END
140 #define RSTRING_END p->config->rstring_end
141 #undef RSTRING_LEN
142 #define RSTRING_LEN p->config->rstring_len
143 #define rb_obj_as_string p->config->obj_as_string
145 #undef INT2NUM
146 #define INT2NUM p->config->int2num
148 #define rb_stderr_tty_p p->config->stderr_tty_p
149 #define rb_write_error_str p->config->write_error_str
150 #define rb_io_write p->config->io_write
151 #define rb_io_flush p->config->io_flush
152 #define rb_io_puts p->config->io_puts
154 #define rb_ractor_stdout p->config->debug_output_stdout
155 #define rb_ractor_stderr p->config->debug_output_stderr
157 #define rb_is_usascii_enc p->config->is_usascii_enc
158 #define rb_enc_isalnum p->config->enc_isalnum
159 #define rb_enc_precise_mbclen p->config->enc_precise_mbclen
160 #define MBCLEN_CHARFOUND_P p->config->mbclen_charfound_p
161 #define MBCLEN_CHARFOUND_LEN p->config->mbclen_charfound_len
162 #define rb_enc_name p->config->enc_name
163 #define rb_enc_prev_char p->config->enc_prev_char
164 #define rb_enc_get p->config->enc_get
165 #define rb_enc_asciicompat p->config->enc_asciicompat
166 #define rb_utf8_encoding p->config->utf8_encoding
167 #define rb_enc_associate p->config->enc_associate
168 #define rb_ascii8bit_encoding p->config->ascii8bit_encoding
169 #define rb_enc_codelen p->config->enc_codelen
170 #define rb_enc_mbcput p->config->enc_mbcput
171 #define rb_enc_find_index p->config->enc_find_index
172 #define rb_enc_from_index p->config->enc_from_index
173 #define rb_enc_isspace p->config->enc_isspace
174 #define ENC_CODERANGE_7BIT p->config->enc_coderange_7bit
175 #define ENC_CODERANGE_UNKNOWN p->config->enc_coderange_unknown
176 #define rb_usascii_encoding p->config->usascii_encoding
178 #define rb_local_defined p->config->local_defined
179 #define rb_dvar_defined p->config->dvar_defined
181 #define rb_syntax_error_append p->config->syntax_error_append
182 #define rb_raise p->config->raise
183 #define syntax_error_new p->config->syntax_error_new
185 #define rb_errinfo p->config->errinfo
186 #define rb_set_errinfo p->config->set_errinfo
187 #define rb_exc_raise p->config->exc_raise
188 #define rb_make_exception p->config->make_exception
190 #define ruby_sized_xfree p->config->sized_xfree
191 #define SIZED_REALLOC_N(v, T, m, n) ((v) = (T *)p->config->sized_realloc_n((void *)(v), (m), sizeof(T), (n)))
192 #undef RB_GC_GUARD
193 #define RB_GC_GUARD p->config->gc_guard
194 #define rb_gc_mark p->config->gc_mark
196 #define rb_reg_compile p->config->reg_compile
197 #define rb_reg_check_preprocess p->config->reg_check_preprocess
198 #define rb_memcicmp p->config->memcicmp
200 #define rb_compile_warn p->config->compile_warn
201 #define rb_compile_warning p->config->compile_warning
202 #define rb_bug p->config->bug
203 #define rb_fatal p->config->fatal
204 #undef ruby_verbose
205 #define ruby_verbose p->config->verbose()
206 #undef errno
207 #define errno (*p->config->errno_ptr())
209 #define rb_make_backtrace p->config->make_backtrace
211 #define ruby_scan_hex p->config->scan_hex
212 #define ruby_scan_oct p->config->scan_oct
213 #define ruby_scan_digits p->config->scan_digits
214 #define strtod p->config->strtod
216 #undef RTEST
217 #define RTEST p->config->rtest
218 #undef NIL_P
219 #define NIL_P p->config->nil_p
220 #undef Qnil
221 #define Qnil p->config->qnil
222 #undef Qfalse
223 #define Qfalse p->config->qfalse
224 #define rb_eArgError p->config->eArgError()
225 #undef rb_long2int
226 #define rb_long2int p->config->long2int
227 #define rb_enc_mbminlen p->config->enc_mbminlen
228 #define rb_enc_isascii p->config->enc_isascii
229 #define rb_enc_mbc_to_codepoint p->config->enc_mbc_to_codepoint
231 #define rb_ast_new() \
232 rb_ast_new(p->config)