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