Ruby
3.5.0dev (2025-01-10 revision 5fab31b15e32622c4b71d1d347a41937e9f9c212)
universal_parser.c (5fab31b15e32622c4b71d1d347a41937e9f9c212)
1
#include <alloca.h>
2
#include <string.h>
3
#include <
stdarg.h
>
4
#include <
stdbool.h
>
5
#include <stddef.h>
6
7
/* Dependency */
8
#include "internal/parse.h"
9
#include "
node.h
"
10
#include "id.h"
11
12
#include "internal/compilers.h"
13
#include "ruby/backward/2/inttypes.h"
14
#include "probes.h"
15
16
#define LIKELY(x) RB_LIKELY(x)
17
#define UNLIKELY(x) RB_UNLIKELY(x)
18
#ifndef TRUE
19
# define TRUE 1
20
#endif
21
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)
29
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
57
58
#define rb_encoding const void
59
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)))
83
84
#define compile_callback p->config->compile_callback
85
#define reg_named_capture_assign p->config->reg_named_capture_assign
86
87
#define rb_attr_get p->config->attr_get
88
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
92
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
111
#define rb_str_catf p->config->str_catf
112
#undef rb_str_cat_cstr
113
#define rb_str_cat_cstr p->config->str_cat_cstr
114
#define rb_str_resize p->config->str_resize
115
#undef rb_str_new
116
#define rb_str_new p->config->str_new
117
#undef rb_str_new_cstr
118
#define rb_str_new_cstr p->config->str_new_cstr
119
#define rb_str_to_interned_str p->config->str_to_interned_str
120
#define rb_enc_str_new p->config->enc_str_new
121
#define rb_str_vcatf p->config->str_vcatf
122
#define rb_sprintf p->config->rb_sprintf
123
#undef RSTRING_PTR
124
#define RSTRING_PTR p->config->rstring_ptr
125
#undef RSTRING_LEN
126
#define RSTRING_LEN p->config->rstring_len
127
#define rb_obj_as_string p->config->obj_as_string
128
129
#undef INT2NUM
130
#define INT2NUM p->config->int2num
131
132
#define rb_stderr_tty_p p->config->stderr_tty_p
133
#define rb_write_error_str p->config->write_error_str
134
#define rb_io_write p->config->io_write
135
#define rb_io_flush p->config->io_flush
136
#define rb_io_puts p->config->io_puts
137
138
#define rb_ractor_stdout p->config->debug_output_stdout
139
#define rb_ractor_stderr p->config->debug_output_stderr
140
141
#define rb_is_usascii_enc p->config->is_usascii_enc
142
#define rb_enc_isalnum p->config->enc_isalnum
143
#define rb_enc_precise_mbclen p->config->enc_precise_mbclen
144
#define MBCLEN_CHARFOUND_P p->config->mbclen_charfound_p
145
#define MBCLEN_CHARFOUND_LEN p->config->mbclen_charfound_len
146
#define rb_enc_name p->config->enc_name
147
#define rb_enc_prev_char p->config->enc_prev_char
148
#define rb_enc_get p->config->enc_get
149
#define rb_enc_asciicompat p->config->enc_asciicompat
150
#define rb_utf8_encoding p->config->utf8_encoding
151
#define rb_enc_associate p->config->enc_associate
152
#define rb_ascii8bit_encoding p->config->ascii8bit_encoding
153
#define rb_enc_codelen p->config->enc_codelen
154
#define rb_enc_mbcput p->config->enc_mbcput
155
#define rb_enc_find_index p->config->enc_find_index
156
#define rb_enc_from_index p->config->enc_from_index
157
#define rb_enc_isspace p->config->enc_isspace
158
#define ENC_CODERANGE_7BIT p->config->enc_coderange_7bit
159
#define ENC_CODERANGE_UNKNOWN p->config->enc_coderange_unknown
160
#define rb_usascii_encoding p->config->usascii_encoding
161
162
#define rb_local_defined p->config->local_defined
163
#define rb_dvar_defined p->config->dvar_defined
164
165
#define rb_syntax_error_append p->config->syntax_error_append
166
#define rb_raise p->config->raise
167
#define syntax_error_new p->config->syntax_error_new
168
169
#define rb_errinfo p->config->errinfo
170
#define rb_set_errinfo p->config->set_errinfo
171
#define rb_exc_raise p->config->exc_raise
172
#define rb_make_exception p->config->make_exception
173
174
#define ruby_sized_xfree p->config->sized_xfree
175
#define SIZED_REALLOC_N(v, T, m, n) ((v) = (T *)p->config->sized_realloc_n((void *)(v), (m), sizeof(T), (n)))
176
#undef RB_GC_GUARD
177
#define RB_GC_GUARD p->config->gc_guard
178
#define rb_gc_mark p->config->gc_mark
179
180
#define rb_reg_compile p->config->reg_compile
181
#define rb_reg_check_preprocess p->config->reg_check_preprocess
182
#define rb_memcicmp p->config->memcicmp
183
184
#define rb_compile_warn p->config->compile_warn
185
#define rb_compile_warning p->config->compile_warning
186
#define rb_bug p->config->bug
187
#define rb_fatal p->config->fatal
188
#undef ruby_verbose
189
#define ruby_verbose p->config->verbose()
190
#undef errno
191
#define errno (*p->config->errno_ptr())
192
193
#define rb_make_backtrace p->config->make_backtrace
194
195
#define ruby_scan_hex p->config->scan_hex
196
#define ruby_scan_oct p->config->scan_oct
197
#define ruby_scan_digits p->config->scan_digits
198
#define strtod p->config->strtod
199
200
#undef RTEST
201
#define RTEST p->config->rtest
202
#undef NIL_P
203
#define NIL_P p->config->nil_p
204
#undef Qnil
205
#define Qnil p->config->qnil
206
#undef Qfalse
207
#define Qfalse p->config->qfalse
208
#define rb_eArgError p->config->eArgError()
209
#undef rb_long2int
210
#define rb_long2int p->config->long2int
211
#define rb_enc_mbminlen p->config->enc_mbminlen
212
#define rb_enc_isascii p->config->enc_isascii
213
#define rb_enc_mbc_to_codepoint p->config->enc_mbc_to_codepoint
214
215
#define rb_ast_new() \
216
rb_ast_new(p->config)
node.h
Functions related to nodes in the AST.
stdarg.h
Defines old _.
stdbool.h
C99 shim for <stdbool.h>
Generated by
1.9.8