Debian Codegraph @

include/prism/parser.h

raw symbols SCIP
1 /**
2 * @file parser.h
3 *
4 * The parser used to parse Ruby source.
5 */
6 #ifndef PRISM_PARSER_H
7 #define PRISM_PARSER_Hcxx . . $ `include/prism/parser.h:7:9`!
8
9 #include "prism/defines.h"cxx . . $ `<file>/include/prism/defines.h`/
10 #include "prism/ast.h"cxx . . $ `<file>/include/prism/ast.h`/
11 #include "prism/encoding.h"cxx . . $ `<file>/include/prism/encoding.h`/
12 #include "prism/options.h"cxx . . $ `<file>/include/prism/options.h`/
13 #include "prism/static_literals.h"cxx . . $ `<file>/include/prism/static_literals.h`/
14 #include "prism/util/pm_constant_pool.h"cxx . . $ `<file>/include/prism/util/pm_constant_pool.h`/
15 #include "prism/util/pm_list.h"cxx . . $ `<file>/include/prism/util/pm_list.h`/
16 #include "prism/util/pm_newline_list.h"cxx . . $ `<file>/include/prism/util/pm_newline_list.h`/
17 #include "prism/util/pm_string.h"cxx . . $ `<file>/include/prism/util/pm_string.h`/
18
19 #include <stdbool.h>
20
21 /**
22 * This enum provides various bits that represent different kinds of states that
23 * the lexer can track. This is used to determine which kind of token to return
24 * based on the context of the parser.
25 */
26 typedef enumcxx . . $ $anonymous_type_6783de56df90b181_0# {
27 PM_LEX_STATE_BIT_BEGcxx . . $ PM_LEX_STATE_BIT_BEG.,
28 PM_LEX_STATE_BIT_ENDcxx . . $ PM_LEX_STATE_BIT_END.,
29 PM_LEX_STATE_BIT_ENDARGcxx . . $ PM_LEX_STATE_BIT_ENDARG.,
30 PM_LEX_STATE_BIT_ENDFNcxx . . $ PM_LEX_STATE_BIT_ENDFN.,
31 PM_LEX_STATE_BIT_ARGcxx . . $ PM_LEX_STATE_BIT_ARG.,
32 PM_LEX_STATE_BIT_CMDARGcxx . . $ PM_LEX_STATE_BIT_CMDARG.,
33 PM_LEX_STATE_BIT_MIDcxx . . $ PM_LEX_STATE_BIT_MID.,
34 PM_LEX_STATE_BIT_FNAMEcxx . . $ PM_LEX_STATE_BIT_FNAME.,
35 PM_LEX_STATE_BIT_DOTcxx . . $ PM_LEX_STATE_BIT_DOT.,
36 PM_LEX_STATE_BIT_CLASScxx . . $ PM_LEX_STATE_BIT_CLASS.,
37 PM_LEX_STATE_BIT_LABELcxx . . $ PM_LEX_STATE_BIT_LABEL.,
38 PM_LEX_STATE_BIT_LABELEDcxx . . $ PM_LEX_STATE_BIT_LABELED.,
39 PM_LEX_STATE_BIT_FITEMcxx . . $ PM_LEX_STATE_BIT_FITEM.
40 } pm_lex_state_bit_tcxx . . $ pm_lex_state_bit_t#;
41
42 /**
43 * This enum combines the various bits from the above enum into individual
44 * values that represent the various states of the lexer.
45 */
46 typedef enumcxx . . $ $anonymous_type_6783de56df90b181_1# {
47 PM_LEX_STATE_NONEcxx . . $ PM_LEX_STATE_NONE. = 0,
48 PM_LEX_STATE_BEGcxx . . $ PM_LEX_STATE_BEG. = (1 << PM_LEX_STATE_BIT_BEGcxx . . $ PM_LEX_STATE_BIT_BEG.),
49 PM_LEX_STATE_ENDcxx . . $ PM_LEX_STATE_END. = (1 << PM_LEX_STATE_BIT_ENDcxx . . $ PM_LEX_STATE_BIT_END.),
50 PM_LEX_STATE_ENDARGcxx . . $ PM_LEX_STATE_ENDARG. = (1 << PM_LEX_STATE_BIT_ENDARGcxx . . $ PM_LEX_STATE_BIT_ENDARG.),
51 PM_LEX_STATE_ENDFNcxx . . $ PM_LEX_STATE_ENDFN. = (1 << PM_LEX_STATE_BIT_ENDFNcxx . . $ PM_LEX_STATE_BIT_ENDFN.),
52 PM_LEX_STATE_ARGcxx . . $ PM_LEX_STATE_ARG. = (1 << PM_LEX_STATE_BIT_ARGcxx . . $ PM_LEX_STATE_BIT_ARG.),
53 PM_LEX_STATE_CMDARGcxx . . $ PM_LEX_STATE_CMDARG. = (1 << PM_LEX_STATE_BIT_CMDARGcxx . . $ PM_LEX_STATE_BIT_CMDARG.),
54 PM_LEX_STATE_MIDcxx . . $ PM_LEX_STATE_MID. = (1 << PM_LEX_STATE_BIT_MIDcxx . . $ PM_LEX_STATE_BIT_MID.),
55 PM_LEX_STATE_FNAMEcxx . . $ PM_LEX_STATE_FNAME. = (1 << PM_LEX_STATE_BIT_FNAMEcxx . . $ PM_LEX_STATE_BIT_FNAME.),
56 PM_LEX_STATE_DOTcxx . . $ PM_LEX_STATE_DOT. = (1 << PM_LEX_STATE_BIT_DOTcxx . . $ PM_LEX_STATE_BIT_DOT.),
57 PM_LEX_STATE_CLASScxx . . $ PM_LEX_STATE_CLASS. = (1 << PM_LEX_STATE_BIT_CLASScxx . . $ PM_LEX_STATE_BIT_CLASS.),
58 PM_LEX_STATE_LABELcxx . . $ PM_LEX_STATE_LABEL. = (1 << PM_LEX_STATE_BIT_LABELcxx . . $ PM_LEX_STATE_BIT_LABEL.),
59 PM_LEX_STATE_LABELEDcxx . . $ PM_LEX_STATE_LABELED. = (1 << PM_LEX_STATE_BIT_LABELEDcxx . . $ PM_LEX_STATE_BIT_LABELED.),
60 PM_LEX_STATE_FITEMcxx . . $ PM_LEX_STATE_FITEM. = (1 << PM_LEX_STATE_BIT_FITEMcxx . . $ PM_LEX_STATE_BIT_FITEM.),
61 PM_LEX_STATE_BEG_ANYcxx . . $ PM_LEX_STATE_BEG_ANY. = PM_LEX_STATE_BEGcxx . . $ PM_LEX_STATE_BEG. | PM_LEX_STATE_MIDcxx . . $ PM_LEX_STATE_MID. | PM_LEX_STATE_CLASScxx . . $ PM_LEX_STATE_CLASS.,
62 PM_LEX_STATE_ARG_ANYcxx . . $ PM_LEX_STATE_ARG_ANY. = PM_LEX_STATE_ARGcxx . . $ PM_LEX_STATE_ARG. | PM_LEX_STATE_CMDARGcxx . . $ PM_LEX_STATE_CMDARG.,
63 PM_LEX_STATE_END_ANYcxx . . $ PM_LEX_STATE_END_ANY. = PM_LEX_STATE_ENDcxx . . $ PM_LEX_STATE_END. | PM_LEX_STATE_ENDARGcxx . . $ PM_LEX_STATE_ENDARG. | PM_LEX_STATE_ENDFNcxx . . $ PM_LEX_STATE_ENDFN.
64 } pm_lex_state_tcxx . . $ pm_lex_state_t#;
65
66 /**
67 * The type of quote that a heredoc uses.
68 */
69 typedef enumcxx . . $ $anonymous_type_6783de56df90b181_2# {
70 PM_HEREDOC_QUOTE_NONEcxx . . $ PM_HEREDOC_QUOTE_NONE.,
71 PM_HEREDOC_QUOTE_SINGLEcxx . . $ PM_HEREDOC_QUOTE_SINGLE. = '\'',
72 PM_HEREDOC_QUOTE_DOUBLEcxx . . $ PM_HEREDOC_QUOTE_DOUBLE. = '"',
73 PM_HEREDOC_QUOTE_BACKTICKcxx . . $ PM_HEREDOC_QUOTE_BACKTICK. = '`',
74 } pm_heredoc_quote_tcxx . . $ pm_heredoc_quote_t#;
75
76 /**
77 * The type of indentation that a heredoc uses.
78 */
79 typedef enumcxx . . $ $anonymous_type_6783de56df90b181_3# {
80 PM_HEREDOC_INDENT_NONEcxx . . $ PM_HEREDOC_INDENT_NONE.,
81 PM_HEREDOC_INDENT_DASHcxx . . $ PM_HEREDOC_INDENT_DASH.,
82 PM_HEREDOC_INDENT_TILDEcxx . . $ PM_HEREDOC_INDENT_TILDE.,
83 } pm_heredoc_indent_tcxx . . $ pm_heredoc_indent_t#;
84
85 /**
86 * All of the information necessary to store to lexing a heredoc.
87 */
88 typedef structcxx . . $ $anonymous_type_6783de56df90b181_4# {
89 /** A pointer to the start of the heredoc identifier. */
90 const uint8_tcxx . . $ uint8_t# *ident_startcxx . . $ $anonymous_type_6783de56df90b181_4#ident_start.;
91
92 /** The length of the heredoc identifier. */
93 size_t ident_lengthcxx . . $ $anonymous_type_6783de56df90b181_4#ident_length.;
94
95 /** The type of quote that the heredoc uses. */
96 pm_heredoc_quote_tcxx . . $ pm_heredoc_quote_t# quotecxx . . $ $anonymous_type_6783de56df90b181_4#quote.;
97
98 /** The type of indentation that the heredoc uses. */
99 pm_heredoc_indent_tcxx . . $ pm_heredoc_indent_t# indentcxx . . $ $anonymous_type_6783de56df90b181_4#indent.;
100 } pm_heredoc_lex_mode_tcxx . . $ pm_heredoc_lex_mode_t#;
101
102 /**
103 * When lexing Ruby source, the lexer has a small amount of state to tell which
104 * kind of token it is currently lexing. For example, when we find the start of
105 * a string, the first token that we return is a TOKEN_STRING_BEGIN token. After
106 * that the lexer is now in the PM_LEX_STRING mode, and will return tokens that
107 * are found as part of a string.
108 */
109 typedef struct pm_lex_modecxx . . $ pm_lex_mode# {
110 /** The type of this lex mode. */
111 enumcxx . . $ pm_lex_mode#$anonymous_type_5# {
112 /** This state is used when any given token is being lexed. */
113 PM_LEX_DEFAULTcxx . . $ pm_lex_mode#PM_LEX_DEFAULT.,
114
115 /**
116 * This state is used when we're lexing as normal but inside an embedded
117 * expression of a string.
118 */
119 PM_LEX_EMBEXPRcxx . . $ pm_lex_mode#PM_LEX_EMBEXPR.,
120
121 /**
122 * This state is used when we're lexing a variable that is embedded
123 * directly inside of a string with the # shorthand.
124 */
125 PM_LEX_EMBVARcxx . . $ pm_lex_mode#PM_LEX_EMBVAR.,
126
127 /** This state is used when you are inside the content of a heredoc. */
128 PM_LEX_HEREDOCcxx . . $ pm_lex_mode#PM_LEX_HEREDOC.,
129
130 /**
131 * This state is used when we are lexing a list of tokens, as in a %w
132 * word list literal or a %i symbol list literal.
133 */
134 PM_LEX_LISTcxx . . $ pm_lex_mode#PM_LEX_LIST.,
135
136 /**
137 * This state is used when a regular expression has been begun and we
138 * are looking for the terminator.
139 */
140 PM_LEX_REGEXPcxx . . $ pm_lex_mode#PM_LEX_REGEXP.,
141
142 /**
143 * This state is used when we are lexing a string or a string-like
144 * token, as in string content with either quote or an xstring.
145 */
146 PM_LEX_STRINGcxx . . $ pm_lex_mode#PM_LEX_STRING.
147 } modecxx . . $ pm_lex_mode#mode.;
148
149 /** The data associated with this type of lex mode. */
150 unioncxx . . $ pm_lex_mode#$anonymous_type_6# {
151 structcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_7# {
152 /** This keeps track of the nesting level of the list. */
153 size_t nestingcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_7#nesting.;
154
155 /** Whether or not interpolation is allowed in this list. */
156 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! interpolationcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_7#interpolation.;
157
158 /**
159 * When lexing a list, it takes into account balancing the
160 * terminator if the terminator is one of (), [], {}, or <>.
161 */
162 uint8_tcxx . . $ uint8_t# incrementorcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_7#incrementor.;
163
164 /** This is the terminator of the list literal. */
165 uint8_tcxx . . $ uint8_t# terminatorcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_7#terminator.;
166
167 /**
168 * This is the character set that should be used to delimit the
169 * tokens within the list.
170 */
171 uint8_tcxx . . $ uint8_t# breakpointscxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_7#breakpoints.[11];
172 } listcxx . . $ pm_lex_mode#$anonymous_type_6#list.;
173
174 structcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_8# {
175 /**
176 * This keeps track of the nesting level of the regular expression.
177 */
178 size_t nestingcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_8#nesting.;
179
180 /**
181 * When lexing a regular expression, it takes into account balancing
182 * the terminator if the terminator is one of (), [], {}, or <>.
183 */
184 uint8_tcxx . . $ uint8_t# incrementorcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_8#incrementor.;
185
186 /** This is the terminator of the regular expression. */
187 uint8_tcxx . . $ uint8_t# terminatorcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_8#terminator.;
188
189 /**
190 * This is the character set that should be used to delimit the
191 * tokens within the regular expression.
192 */
193 uint8_tcxx . . $ uint8_t# breakpointscxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_8#breakpoints.[7];
194 } regexpcxx . . $ pm_lex_mode#$anonymous_type_6#regexp.;
195
196 structcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_9# {
197 /** This keeps track of the nesting level of the string. */
198 size_t nestingcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_9#nesting.;
199
200 /** Whether or not interpolation is allowed in this string. */
201 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! interpolationcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_9#interpolation.;
202
203 /**
204 * Whether or not at the end of the string we should allow a :,
205 * which would indicate this was a dynamic symbol instead of a
206 * string.
207 */
208 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! label_allowedcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_9#label_allowed.;
209
210 /**
211 * When lexing a string, it takes into account balancing the
212 * terminator if the terminator is one of (), [], {}, or <>.
213 */
214 uint8_tcxx . . $ uint8_t# incrementorcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_9#incrementor.;
215
216 /**
217 * This is the terminator of the string. It is typically either a
218 * single or double quote.
219 */
220 uint8_tcxx . . $ uint8_t# terminatorcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_9#terminator.;
221
222 /**
223 * This is the character set that should be used to delimit the
224 * tokens within the string.
225 */
226 uint8_tcxx . . $ uint8_t# breakpointscxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_9#breakpoints.[7];
227 } stringcxx . . $ pm_lex_mode#$anonymous_type_6#string.;
228
229 structcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_10# {
230 /**
231 * All of the data necessary to lex a heredoc.
232 */
233 pm_heredoc_lex_mode_tcxx . . $ pm_heredoc_lex_mode_t# basecxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_10#base.;
234
235 /**
236 * This is the pointer to the character where lexing should resume
237 * once the heredoc has been completely processed.
238 */
239 const uint8_tcxx . . $ uint8_t# *next_startcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_10#next_start.;
240
241 /**
242 * This is used to track the amount of common whitespace on each
243 * line so that we know how much to dedent each line in the case of
244 * a tilde heredoc.
245 */
246 size_t *common_whitespacecxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_10#common_whitespace.;
247
248 /** True if the previous token ended with a line continuation. */
249 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! line_continuationcxx . . $ pm_lex_mode#$anonymous_type_6#$anonymous_type_10#line_continuation.;
250 } heredoccxx . . $ pm_lex_mode#$anonymous_type_6#heredoc.;
251 } ascxx . . $ pm_lex_mode#as.;
252
253 /** The previous lex state so that it knows how to pop. */
254 struct pm_lex_modecxx . . $ pm_lex_mode# *prevcxx . . $ pm_lex_mode#prev.;
255 } pm_lex_mode_tcxx . . $ pm_lex_mode_t#;
256
257 /**
258 * We pre-allocate a certain number of lex states in order to avoid having to
259 * call malloc too many times while parsing. You really shouldn't need more than
260 * this because you only really nest deeply when doing string interpolation.
261 */
262 #define PM_LEX_STACK_SIZEcxx . . $ `include/prism/parser.h:262:9`! 4
263
264 /**
265 * The parser used to parse Ruby source.
266 */
267 typedef struct pm_parsercxx . . $ pm_parser# pm_parser_tcxx . . $ pm_parser_t#;
268
269 /**
270 * While parsing, we keep track of a stack of contexts. This is helpful for
271 * error recovery so that we can pop back to a previous context when we hit a
272 * token that is understood by a parent context but not by the current context.
273 */
274 typedef enumcxx . . $ $anonymous_type_6783de56df90b181_11# {
275 /** a null context, used for returning a value from a function */
276 PM_CONTEXT_NONEcxx . . $ PM_CONTEXT_NONE. = 0,
277
278 /** a begin statement */
279 PM_CONTEXT_BEGINcxx . . $ PM_CONTEXT_BEGIN.,
280
281 /** an ensure statement with an explicit begin */
282 PM_CONTEXT_BEGIN_ENSUREcxx . . $ PM_CONTEXT_BEGIN_ENSURE.,
283
284 /** a rescue else statement with an explicit begin */
285 PM_CONTEXT_BEGIN_ELSEcxx . . $ PM_CONTEXT_BEGIN_ELSE.,
286
287 /** a rescue statement with an explicit begin */
288 PM_CONTEXT_BEGIN_RESCUEcxx . . $ PM_CONTEXT_BEGIN_RESCUE.,
289
290 /** expressions in block arguments using braces */
291 PM_CONTEXT_BLOCK_BRACEScxx . . $ PM_CONTEXT_BLOCK_BRACES.,
292
293 /** expressions in block arguments using do..end */
294 PM_CONTEXT_BLOCK_KEYWORDScxx . . $ PM_CONTEXT_BLOCK_KEYWORDS.,
295
296 /** an ensure statement within a do..end block */
297 PM_CONTEXT_BLOCK_ENSUREcxx . . $ PM_CONTEXT_BLOCK_ENSURE.,
298
299 /** a rescue else statement within a do..end block */
300 PM_CONTEXT_BLOCK_ELSEcxx . . $ PM_CONTEXT_BLOCK_ELSE.,
301
302 /** expressions in block parameters `foo do |...| end ` */
303 PM_CONTEXT_BLOCK_PARAMETERScxx . . $ PM_CONTEXT_BLOCK_PARAMETERS.,
304
305 /** a rescue statement within a do..end block */
306 PM_CONTEXT_BLOCK_RESCUEcxx . . $ PM_CONTEXT_BLOCK_RESCUE.,
307
308 /** a case when statements */
309 PM_CONTEXT_CASE_WHENcxx . . $ PM_CONTEXT_CASE_WHEN.,
310
311 /** a case in statements */
312 PM_CONTEXT_CASE_INcxx . . $ PM_CONTEXT_CASE_IN.,
313
314 /** a class declaration */
315 PM_CONTEXT_CLASScxx . . $ PM_CONTEXT_CLASS.,
316
317 /** an ensure statement within a class statement */
318 PM_CONTEXT_CLASS_ENSUREcxx . . $ PM_CONTEXT_CLASS_ENSURE.,
319
320 /** a rescue else statement within a class statement */
321 PM_CONTEXT_CLASS_ELSEcxx . . $ PM_CONTEXT_CLASS_ELSE.,
322
323 /** a rescue statement within a class statement */
324 PM_CONTEXT_CLASS_RESCUEcxx . . $ PM_CONTEXT_CLASS_RESCUE.,
325
326 /** a method definition */
327 PM_CONTEXT_DEFcxx . . $ PM_CONTEXT_DEF.,
328
329 /** an ensure statement within a method definition */
330 PM_CONTEXT_DEF_ENSUREcxx . . $ PM_CONTEXT_DEF_ENSURE.,
331
332 /** a rescue else statement within a method definition */
333 PM_CONTEXT_DEF_ELSEcxx . . $ PM_CONTEXT_DEF_ELSE.,
334
335 /** a rescue statement within a method definition */
336 PM_CONTEXT_DEF_RESCUEcxx . . $ PM_CONTEXT_DEF_RESCUE.,
337
338 /** a method definition's parameters */
339 PM_CONTEXT_DEF_PARAMScxx . . $ PM_CONTEXT_DEF_PARAMS.,
340
341 /** a defined? expression */
342 PM_CONTEXT_DEFINEDcxx . . $ PM_CONTEXT_DEFINED.,
343
344 /** a method definition's default parameter */
345 PM_CONTEXT_DEFAULT_PARAMScxx . . $ PM_CONTEXT_DEFAULT_PARAMS.,
346
347 /** an else clause */
348 PM_CONTEXT_ELSEcxx . . $ PM_CONTEXT_ELSE.,
349
350 /** an elsif clause */
351 PM_CONTEXT_ELSIFcxx . . $ PM_CONTEXT_ELSIF.,
352
353 /** an interpolated expression */
354 PM_CONTEXT_EMBEXPRcxx . . $ PM_CONTEXT_EMBEXPR.,
355
356 /** a for loop */
357 PM_CONTEXT_FORcxx . . $ PM_CONTEXT_FOR.,
358
359 /** a for loop's index */
360 PM_CONTEXT_FOR_INDEXcxx . . $ PM_CONTEXT_FOR_INDEX.,
361
362 /** an if statement */
363 PM_CONTEXT_IFcxx . . $ PM_CONTEXT_IF.,
364
365 /** a lambda expression with braces */
366 PM_CONTEXT_LAMBDA_BRACEScxx . . $ PM_CONTEXT_LAMBDA_BRACES.,
367
368 /** a lambda expression with do..end */
369 PM_CONTEXT_LAMBDA_DO_ENDcxx . . $ PM_CONTEXT_LAMBDA_DO_END.,
370
371 /** an ensure statement within a lambda expression */
372 PM_CONTEXT_LAMBDA_ENSUREcxx . . $ PM_CONTEXT_LAMBDA_ENSURE.,
373
374 /** a rescue else statement within a lambda expression */
375 PM_CONTEXT_LAMBDA_ELSEcxx . . $ PM_CONTEXT_LAMBDA_ELSE.,
376
377 /** a rescue statement within a lambda expression */
378 PM_CONTEXT_LAMBDA_RESCUEcxx . . $ PM_CONTEXT_LAMBDA_RESCUE.,
379
380 /** the predicate clause of a loop statement */
381 PM_CONTEXT_LOOP_PREDICATEcxx . . $ PM_CONTEXT_LOOP_PREDICATE.,
382
383 /** the top level context */
384 PM_CONTEXT_MAINcxx . . $ PM_CONTEXT_MAIN.,
385
386 /** a module declaration */
387 PM_CONTEXT_MODULEcxx . . $ PM_CONTEXT_MODULE.,
388
389 /** an ensure statement within a module statement */
390 PM_CONTEXT_MODULE_ENSUREcxx . . $ PM_CONTEXT_MODULE_ENSURE.,
391
392 /** a rescue else statement within a module statement */
393 PM_CONTEXT_MODULE_ELSEcxx . . $ PM_CONTEXT_MODULE_ELSE.,
394
395 /** a rescue statement within a module statement */
396 PM_CONTEXT_MODULE_RESCUEcxx . . $ PM_CONTEXT_MODULE_RESCUE.,
397
398 /** a multiple target expression */
399 PM_CONTEXT_MULTI_TARGETcxx . . $ PM_CONTEXT_MULTI_TARGET.,
400
401 /** a parenthesized expression */
402 PM_CONTEXT_PARENScxx . . $ PM_CONTEXT_PARENS.,
403
404 /** an END block */
405 PM_CONTEXT_POSTEXEcxx . . $ PM_CONTEXT_POSTEXE.,
406
407 /** a predicate inside an if/elsif/unless statement */
408 PM_CONTEXT_PREDICATEcxx . . $ PM_CONTEXT_PREDICATE.,
409
410 /** a BEGIN block */
411 PM_CONTEXT_PREEXEcxx . . $ PM_CONTEXT_PREEXE.,
412
413 /** a modifier rescue clause */
414 PM_CONTEXT_RESCUE_MODIFIERcxx . . $ PM_CONTEXT_RESCUE_MODIFIER.,
415
416 /** a singleton class definition */
417 PM_CONTEXT_SCLASScxx . . $ PM_CONTEXT_SCLASS.,
418
419 /** an ensure statement with a singleton class */
420 PM_CONTEXT_SCLASS_ENSUREcxx . . $ PM_CONTEXT_SCLASS_ENSURE.,
421
422 /** a rescue else statement with a singleton class */
423 PM_CONTEXT_SCLASS_ELSEcxx . . $ PM_CONTEXT_SCLASS_ELSE.,
424
425 /** a rescue statement with a singleton class */
426 PM_CONTEXT_SCLASS_RESCUEcxx . . $ PM_CONTEXT_SCLASS_RESCUE.,
427
428 /** a ternary expression */
429 PM_CONTEXT_TERNARYcxx . . $ PM_CONTEXT_TERNARY.,
430
431 /** an unless statement */
432 PM_CONTEXT_UNLESScxx . . $ PM_CONTEXT_UNLESS.,
433
434 /** an until statement */
435 PM_CONTEXT_UNTILcxx . . $ PM_CONTEXT_UNTIL.,
436
437 /** a while statement */
438 PM_CONTEXT_WHILEcxx . . $ PM_CONTEXT_WHILE.,
439 } pm_context_tcxx . . $ pm_context_t#;
440
441 /** This is a node in a linked list of contexts. */
442 typedef struct pm_context_nodecxx . . $ pm_context_node# {
443 /** The context that this node represents. */
444 pm_context_tcxx . . $ pm_context_t# contextcxx . . $ pm_context_node#context.;
445
446 /** A pointer to the previous context in the linked list. */
447 struct pm_context_nodecxx . . $ pm_context_node# *prevcxx . . $ pm_context_node#prev.;
448 } pm_context_node_tcxx . . $ pm_context_node_t#;
449
450 /** This is the type of a comment that we've found while parsing. */
451 typedef enumcxx . . $ $anonymous_type_6783de56df90b181_12# {
452 PM_COMMENT_INLINEcxx . . $ PM_COMMENT_INLINE.,
453 PM_COMMENT_EMBDOCcxx . . $ PM_COMMENT_EMBDOC.
454 } pm_comment_type_tcxx . . $ pm_comment_type_t#;
455
456 /**
457 * This is a node in the linked list of comments that we've found while parsing.
458 *
459 * @extends pm_list_node_t
460 */
461 typedef struct pm_commentcxx . . $ pm_comment# {
462 /** The embedded base node. */
463 pm_list_node_tcxx . . $ pm_list_node_t# nodecxx . . $ pm_comment#node.;
464
465 /** The location of the comment in the source. */
466 pm_location_tcxx . . $ pm_location_t# locationcxx . . $ pm_comment#location.;
467
468 /** The type of comment that we've found. */
469 pm_comment_type_tcxx . . $ pm_comment_type_t# typecxx . . $ pm_comment#type.;
470 } pm_comment_tcxx . . $ pm_comment_t#;
471
472 /**
473 * This is a node in the linked list of magic comments that we've found while
474 * parsing.
475 *
476 * @extends pm_list_node_t
477 */
478 typedef structcxx . . $ $anonymous_type_6783de56df90b181_13# {
479 /** The embedded base node. */
480 pm_list_node_tcxx . . $ pm_list_node_t# nodecxx . . $ $anonymous_type_6783de56df90b181_13#node.;
481
482 /** A pointer to the start of the key in the source. */
483 const uint8_tcxx . . $ uint8_t# *key_startcxx . . $ $anonymous_type_6783de56df90b181_13#key_start.;
484
485 /** A pointer to the start of the value in the source. */
486 const uint8_tcxx . . $ uint8_t# *value_startcxx . . $ $anonymous_type_6783de56df90b181_13#value_start.;
487
488 /** The length of the key in the source. */
489 uint32_tcxx . . $ uint32_t# key_lengthcxx . . $ $anonymous_type_6783de56df90b181_13#key_length.;
490
491 /** The length of the value in the source. */
492 uint32_tcxx . . $ uint32_t# value_lengthcxx . . $ $anonymous_type_6783de56df90b181_13#value_length.;
493 } pm_magic_comment_tcxx . . $ pm_magic_comment_t#;
494
495 /**
496 * When the encoding that is being used to parse the source is changed by prism,
497 * we provide the ability here to call out to a user-defined function.
498 */
499 typedef void (*pm_encoding_changed_callback_tcxx . . $ pm_encoding_changed_callback_t#)(pm_parser_tcxx . . $ pm_parser_t# *parser);
500
501 /**
502 * When you are lexing through a file, the lexer needs all of the information
503 * that the parser additionally provides (for example, the local table). So if
504 * you want to properly lex Ruby, you need to actually lex it in the context of
505 * the parser. In order to provide this functionality, we optionally allow a
506 * struct to be attached to the parser that calls back out to a user-provided
507 * callback when each token is lexed.
508 */
509 typedef structcxx . . $ $anonymous_type_6783de56df90b181_14# {
510 /**
511 * This opaque pointer is used to provide whatever information the user
512 * deemed necessary to the callback. In our case we use it to pass the array
513 * that the tokens get appended into.
514 */
515 void *datacxx . . $ $anonymous_type_6783de56df90b181_14#data.;
516
517 /**
518 * This is the callback that is called when a token is lexed. It is passed
519 * the opaque data pointer, the parser, and the token that was lexed.
520 */
521 void (*callbackcxx . . $ $anonymous_type_6783de56df90b181_14#callback.)(void *data, pm_parser_tcxx . . $ pm_parser_t# *parser, pm_token_tcxx . . $ pm_token_t# *token);
522 } pm_lex_callback_tcxx . . $ pm_lex_callback_t#;
523
524 /** The type of shareable constant value that can be set. */
525 typedef uint8_tcxx . . $ uint8_t# pm_shareable_constant_value_tcxx . . $ pm_shareable_constant_value_t#;
526 static const pm_shareable_constant_value_tcxx . . $ pm_shareable_constant_value_t# PM_SCOPE_SHAREABLE_CONSTANT_NONEcxx . . $ PM_SCOPE_SHAREABLE_CONSTANT_NONE. = 0x0;
527 static const pm_shareable_constant_value_tcxx . . $ pm_shareable_constant_value_t# PM_SCOPE_SHAREABLE_CONSTANT_LITERALcxx . . $ PM_SCOPE_SHAREABLE_CONSTANT_LITERAL. = PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERALcxx . . $ PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERAL.;
528 static const pm_shareable_constant_value_tcxx . . $ pm_shareable_constant_value_t# PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_EVERYTHINGcxx . . $ PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_EVERYTHING. = PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHINGcxx . . $ PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHING.;
529 static const pm_shareable_constant_value_tcxx . . $ pm_shareable_constant_value_t# PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_COPYcxx . . $ PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_COPY. = PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPYcxx . . $ PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY.;
530
531 /**
532 * This tracks an individual local variable in a certain lexical context, as
533 * well as the number of times is it read.
534 */
535 typedef structcxx . . $ $anonymous_type_6783de56df90b181_15# {
536 /** The name of the local variable. */
537 pm_constant_id_tcxx . . $ pm_constant_id_t# namecxx . . $ $anonymous_type_6783de56df90b181_15#name.;
538
539 /** The location of the local variable in the source. */
540 pm_location_tcxx . . $ pm_location_t# locationcxx . . $ $anonymous_type_6783de56df90b181_15#location.;
541
542 /** The index of the local variable in the local table. */
543 uint32_tcxx . . $ uint32_t# indexcxx . . $ $anonymous_type_6783de56df90b181_15#index.;
544
545 /** The number of times the local variable is read. */
546 uint32_tcxx . . $ uint32_t# readscxx . . $ $anonymous_type_6783de56df90b181_15#reads.;
547
548 /** The hash of the local variable. */
549 uint32_tcxx . . $ uint32_t# hashcxx . . $ $anonymous_type_6783de56df90b181_15#hash.;
550 } pm_local_tcxx . . $ pm_local_t#;
551
552 /**
553 * This is a set of local variables in a certain lexical context (method, class,
554 * module, etc.). We need to track how many times these variables are read in
555 * order to warn if they only get written.
556 */
557 typedef struct pm_localscxx . . $ pm_locals# {
558 /** The number of local variables in the set. */
559 uint32_tcxx . . $ uint32_t# sizecxx . . $ pm_locals#size.;
560
561 /** The capacity of the local variables set. */
562 uint32_tcxx . . $ uint32_t# capacitycxx . . $ pm_locals#capacity.;
563
564 /** The nullable allocated memory for the local variables in the set. */
565 pm_local_tcxx . . $ pm_local_t# *localscxx . . $ pm_locals#locals.;
566 } pm_locals_tcxx . . $ pm_locals_t#;
567
568 /** The flags about scope parameters that can be set. */
569 typedef uint8_tcxx . . $ uint8_t# pm_scope_parameters_tcxx . . $ pm_scope_parameters_t#;
570 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_NONEcxx . . $ PM_SCOPE_PARAMETERS_NONE. = 0x0;
571 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALScxx . . $ PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALS. = 0x1;
572 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDScxx . . $ PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDS. = 0x2;
573 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_FORWARDING_BLOCKcxx . . $ PM_SCOPE_PARAMETERS_FORWARDING_BLOCK. = 0x4;
574 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_FORWARDING_ALLcxx . . $ PM_SCOPE_PARAMETERS_FORWARDING_ALL. = 0x8;
575 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_IMPLICIT_DISALLOWEDcxx . . $ PM_SCOPE_PARAMETERS_IMPLICIT_DISALLOWED. = 0x10;
576 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_NUMBERED_INNERcxx . . $ PM_SCOPE_PARAMETERS_NUMBERED_INNER. = 0x20;
577 static const pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# PM_SCOPE_PARAMETERS_NUMBERED_FOUNDcxx . . $ PM_SCOPE_PARAMETERS_NUMBERED_FOUND. = 0x40;
578
579 /**
580 * This struct represents a node in a linked list of scopes. Some scopes can see
581 * into their parent scopes, while others cannot.
582 */
583 typedef struct pm_scopecxx . . $ pm_scope# {
584 /** A pointer to the previous scope in the linked list. */
585 struct pm_scopecxx . . $ pm_scope# *previouscxx . . $ pm_scope#previous.;
586
587 /** The IDs of the locals in the given scope. */
588 pm_locals_tcxx . . $ pm_locals_t# localscxx . . $ pm_scope#locals.;
589
590 /**
591 * This is a list of the implicit parameters contained within the block.
592 * These will be processed after the block is parsed to determine the kind
593 * of parameters node that should be used and to check if any errors need to
594 * be added.
595 */
596 pm_node_list_tcxx . . $ pm_node_list_t# implicit_parameterscxx . . $ pm_scope#implicit_parameters.;
597
598 /**
599 * This is a bitfield that indicates the parameters that are being used in
600 * this scope. It is a combination of the PM_SCOPE_PARAMETERS_* constants.
601 * There are three different kinds of parameters that can be used in a
602 * scope:
603 *
604 * - Ordinary parameters (e.g., def foo(bar); end)
605 * - Numbered parameters (e.g., def foo; _1; end)
606 * - The it parameter (e.g., def foo; it; end)
607 *
608 * If ordinary parameters are being used, then certain parameters can be
609 * forwarded to another method/structure. Those are indicated by four
610 * additional bits in the params field. For example, some combinations of:
611 *
612 * - def foo(*); end
613 * - def foo(**); end
614 * - def foo(&); end
615 * - def foo(...); end
616 */
617 pm_scope_parameters_tcxx . . $ pm_scope_parameters_t# parameterscxx . . $ pm_scope#parameters.;
618
619 /**
620 * The current state of constant shareability for this scope. This is
621 * changed by magic shareable_constant_value comments.
622 */
623 pm_shareable_constant_value_tcxx . . $ pm_shareable_constant_value_t# shareable_constantcxx . . $ pm_scope#shareable_constant.;
624
625 /**
626 * A boolean indicating whether or not this scope can see into its parent.
627 * If closed is true, then the scope cannot see into its parent.
628 */
629 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! closedcxx . . $ pm_scope#closed.;
630 } pm_scope_tcxx . . $ pm_scope_t#;
631
632 /**
633 * A struct that represents a stack of boolean values.
634 */
635 typedef uint32_tcxx . . $ uint32_t# pm_state_stack_tcxx . . $ pm_state_stack_t#;
636
637 /**
638 * This struct represents the overall parser. It contains a reference to the
639 * source file, as well as pointers that indicate where in the source it's
640 * currently parsing. It also contains the most recent and current token that
641 * it's considering.
642 */
643 struct pm_parsercxx . . $ pm_parser# {
644 /**
645 * The next node identifier that will be assigned. This is a unique
646 * identifier used to track nodes such that the syntax tree can be dropped
647 * but the node can be found through another parse.
648 */
649 uint32_tcxx . . $ uint32_t# node_idcxx . . $ pm_parser#node_id.;
650
651 /** The current state of the lexer. */
652 pm_lex_state_tcxx . . $ pm_lex_state_t# lex_statecxx . . $ pm_parser#lex_state.;
653
654 /** Tracks the current nesting of (), [], and {}. */
655 int enclosure_nestingcxx . . $ pm_parser#enclosure_nesting.;
656
657 /**
658 * Used to temporarily track the nesting of enclosures to determine if a {
659 * is the beginning of a lambda following the parameters of a lambda.
660 */
661 int lambda_enclosure_nestingcxx . . $ pm_parser#lambda_enclosure_nesting.;
662
663 /**
664 * Used to track the nesting of braces to ensure we get the correct value
665 * when we are interpolating blocks with braces.
666 */
667 int brace_nestingcxx . . $ pm_parser#brace_nesting.;
668
669 /**
670 * The stack used to determine if a do keyword belongs to the predicate of a
671 * while, until, or for loop.
672 */
673 pm_state_stack_tcxx . . $ pm_state_stack_t# do_loop_stackcxx . . $ pm_parser#do_loop_stack.;
674
675 /**
676 * The stack used to determine if a do keyword belongs to the beginning of a
677 * block.
678 */
679 pm_state_stack_tcxx . . $ pm_state_stack_t# accepts_block_stackcxx . . $ pm_parser#accepts_block_stack.;
680
681 /** A stack of lex modes. */
682 structcxx . . $ pm_parser#$anonymous_type_16# {
683 /** The current mode of the lexer. */
684 pm_lex_mode_tcxx . . $ pm_lex_mode_t# *currentcxx . . $ pm_parser#$anonymous_type_16#current.;
685
686 /** The stack of lexer modes. */
687 pm_lex_mode_tcxx . . $ pm_lex_mode_t# stackcxx . . $ pm_parser#$anonymous_type_16#stack.[PM_LEX_STACK_SIZEcxx . . $ `include/prism/parser.h:262:9`!];
688
689 /** The current index into the lexer mode stack. */
690 size_t indexcxx . . $ pm_parser#$anonymous_type_16#index.;
691 } lex_modescxx . . $ pm_parser#lex_modes.;
692
693 /** The pointer to the start of the source. */
694 const uint8_tcxx . . $ uint8_t# *startcxx . . $ pm_parser#start.;
695
696 /** The pointer to the end of the source. */
697 const uint8_tcxx . . $ uint8_t# *endcxx . . $ pm_parser#end.;
698
699 /** The previous token we were considering. */
700 pm_token_tcxx . . $ pm_token_t# previouscxx . . $ pm_parser#previous.;
701
702 /** The current token we're considering. */
703 pm_token_tcxx . . $ pm_token_t# currentcxx . . $ pm_parser#current.;
704
705 /**
706 * This is a special field set on the parser when we need the parser to jump
707 * to a specific location when lexing the next token, as opposed to just
708 * using the end of the previous token. Normally this is NULL.
709 */
710 const uint8_tcxx . . $ uint8_t# *next_startcxx . . $ pm_parser#next_start.;
711
712 /**
713 * This field indicates the end of a heredoc whose identifier was found on
714 * the current line. If another heredoc is found on the same line, then this
715 * will be moved forward to the end of that heredoc. If no heredocs are
716 * found on a line then this is NULL.
717 */
718 const uint8_tcxx . . $ uint8_t# *heredoc_endcxx . . $ pm_parser#heredoc_end.;
719
720 /** The list of comments that have been found while parsing. */
721 pm_list_tcxx . . $ pm_list_t# comment_listcxx . . $ pm_parser#comment_list.;
722
723 /** The list of magic comments that have been found while parsing. */
724 pm_list_tcxx . . $ pm_list_t# magic_comment_listcxx . . $ pm_parser#magic_comment_list.;
725
726 /**
727 * An optional location that represents the location of the __END__ marker
728 * and the rest of the content of the file. This content is loaded into the
729 * DATA constant when the file being parsed is the main file being executed.
730 */
731 pm_location_tcxx . . $ pm_location_t# data_loccxx . . $ pm_parser#data_loc.;
732
733 /** The list of warnings that have been found while parsing. */
734 pm_list_tcxx . . $ pm_list_t# warning_listcxx . . $ pm_parser#warning_list.;
735
736 /** The list of errors that have been found while parsing. */
737 pm_list_tcxx . . $ pm_list_t# error_listcxx . . $ pm_parser#error_list.;
738
739 /** The current local scope. */
740 pm_scope_tcxx . . $ pm_scope_t# *current_scopecxx . . $ pm_parser#current_scope.;
741
742 /** The current parsing context. */
743 pm_context_node_tcxx . . $ pm_context_node_t# *current_contextcxx . . $ pm_parser#current_context.;
744
745 /**
746 * The hash keys for the hash that is currently being parsed. This is not
747 * usually necessary because it can pass it down the various call chains,
748 * but in the event that you're parsing a hash that is being directly
749 * pushed into another hash with **, we need to share the hash keys so that
750 * we can warn for the nested hash as well.
751 */
752 pm_static_literals_tcxx . . $ pm_static_literals_t# *current_hash_keyscxx . . $ pm_parser#current_hash_keys.;
753
754 /**
755 * The encoding functions for the current file is attached to the parser as
756 * it's parsing so that it can change with a magic comment.
757 */
758 const pm_encoding_tcxx . . $ pm_encoding_t# *encodingcxx . . $ pm_parser#encoding.;
759
760 /**
761 * When the encoding that is being used to parse the source is changed by
762 * prism, we provide the ability here to call out to a user-defined
763 * function.
764 */
765 pm_encoding_changed_callback_tcxx . . $ pm_encoding_changed_callback_t# encoding_changed_callbackcxx . . $ pm_parser#encoding_changed_callback.;
766
767 /**
768 * This pointer indicates where a comment must start if it is to be
769 * considered an encoding comment.
770 */
771 const uint8_tcxx . . $ uint8_t# *encoding_comment_startcxx . . $ pm_parser#encoding_comment_start.;
772
773 /**
774 * This is an optional callback that can be attached to the parser that will
775 * be called whenever a new token is lexed by the parser.
776 */
777 pm_lex_callback_tcxx . . $ pm_lex_callback_t# *lex_callbackcxx . . $ pm_parser#lex_callback.;
778
779 /**
780 * This is the path of the file being parsed. We use the filepath when
781 * constructing SourceFileNodes.
782 */
783 pm_string_tcxx . . $ pm_string_t# filepathcxx . . $ pm_parser#filepath.;
784
785 /**
786 * This constant pool keeps all of the constants defined throughout the file
787 * so that we can reference them later.
788 */
789 pm_constant_pool_tcxx . . $ pm_constant_pool_t# constant_poolcxx . . $ pm_parser#constant_pool.;
790
791 /** This is the list of newline offsets in the source file. */
792 pm_newline_list_tcxx . . $ pm_newline_list_t# newline_listcxx . . $ pm_parser#newline_list.;
793
794 /**
795 * We want to add a flag to integer nodes that indicates their base. We only
796 * want to parse these once, but we don't have space on the token itself to
797 * communicate this information. So we store it here and pass it through
798 * when we find tokens that we need it for.
799 */
800 pm_node_flags_tcxx . . $ pm_node_flags_t# integer_basecxx . . $ pm_parser#integer_base.;
801
802 /**
803 * This string is used to pass information from the lexer to the parser. It
804 * is particularly necessary because of escape sequences.
805 */
806 pm_string_tcxx . . $ pm_string_t# current_stringcxx . . $ pm_parser#current_string.;
807
808 /**
809 * The line number at the start of the parse. This will be used to offset
810 * the line numbers of all of the locations.
811 */
812 int32_tcxx . . $ int32_t# start_linecxx . . $ pm_parser#start_line.;
813
814 /**
815 * When a string-like expression is being lexed, any byte or escape sequence
816 * that resolves to a value whose top bit is set (i.e., >= 0x80) will
817 * explicitly set the encoding to the same encoding as the source.
818 * Alternatively, if a unicode escape sequence is used (e.g., \\u{80}) that
819 * resolves to a value whose top bit is set, then the encoding will be
820 * explicitly set to UTF-8.
821 *
822 * The _next_ time this happens, if the encoding that is about to become the
823 * explicitly set encoding does not match the previously set explicit
824 * encoding, a mixed encoding error will be emitted.
825 *
826 * When the expression is finished being lexed, the explicit encoding
827 * controls the encoding of the expression. For the most part this means
828 * that the expression will either be encoded in the source encoding or
829 * UTF-8. This holds for all encodings except US-ASCII. If the source is
830 * US-ASCII and an explicit encoding was set that was _not_ UTF-8, then the
831 * expression will be encoded as ASCII-8BIT.
832 *
833 * Note that if the expression is a list, different elements within the same
834 * list can have different encodings, so this will get reset between each
835 * element. Furthermore all of this only applies to lists that support
836 * interpolation, because otherwise escapes that could change the encoding
837 * are ignored.
838 *
839 * At first glance, it may make more sense for this to live on the lexer
840 * mode, but we need it here to communicate back to the parser for character
841 * literals that do not push a new lexer mode.
842 */
843 const pm_encoding_tcxx . . $ pm_encoding_t# *explicit_encodingcxx . . $ pm_parser#explicit_encoding.;
844
845 /**
846 * When parsing block exits (e.g., break, next, redo), we need to validate
847 * that they are in correct contexts. For the most part we can do this by
848 * looking at our parent contexts. However, modifier while and until
849 * expressions can change that context to make block exits valid. In these
850 * cases, we need to keep track of the block exits and then validate them
851 * after the expression has been parsed.
852 *
853 * We use a pointer here because we don't want to keep a whole list attached
854 * since this will only be used in the context of begin/end expressions.
855 */
856 pm_node_list_tcxx . . $ pm_node_list_t# *current_block_exitscxx . . $ pm_parser#current_block_exits.;
857
858 /** The version of prism that we should use to parse. */
859 pm_options_version_tcxx . . $ pm_options_version_t# versioncxx . . $ pm_parser#version.;
860
861 /** The command line flags given from the options. */
862 uint8_tcxx . . $ uint8_t# command_linecxx . . $ pm_parser#command_line.;
863
864 /**
865 * Whether or not we have found a frozen_string_literal magic comment with
866 * a true or false value.
867 * May be:
868 * - PM_OPTIONS_FROZEN_STRING_LITERAL_DISABLED
869 * - PM_OPTIONS_FROZEN_STRING_LITERAL_ENABLED
870 * - PM_OPTIONS_FROZEN_STRING_LITERAL_UNSET
871 */
872 int8_tcxx . . $ int8_t# frozen_string_literalcxx . . $ pm_parser#frozen_string_literal.;
873
874 /**
875 * Whether or not we are parsing an eval string. This impacts whether or not
876 * we should evaluate if block exits/yields are valid.
877 */
878 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! parsing_evalcxx . . $ pm_parser#parsing_eval.;
879
880 /**
881 * Whether or not we are parsing a "partial" script, which is a script that
882 * will be evaluated in the context of another script, so we should not
883 * check jumps (next/break/etc.) for validity.
884 */
885 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! partial_scriptcxx . . $ pm_parser#partial_script.;
886
887 /** Whether or not we're at the beginning of a command. */
888 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! command_startcxx . . $ pm_parser#command_start.;
889
890 /** Whether or not we're currently recovering from a syntax error. */
891 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! recoveringcxx . . $ pm_parser#recovering.;
892
893 /**
894 * This is very specialized behavior for when you want to parse in a context
895 * that does not respect encoding comments. Its main use case is translating
896 * into the whitequark/parser AST which re-encodes source files in UTF-8
897 * before they are parsed and ignores encoding comments.
898 */
899 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! encoding_lockedcxx . . $ pm_parser#encoding_locked.;
900
901 /**
902 * Whether or not the encoding has been changed by a magic comment. We use
903 * this to provide a fast path for the lexer instead of going through the
904 * function pointer.
905 */
906 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! encoding_changedcxx . . $ pm_parser#encoding_changed.;
907
908 /**
909 * This flag indicates that we are currently parsing a pattern matching
910 * expression and impacts that calculation of newlines.
911 */
912 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! pattern_matching_newlinescxx . . $ pm_parser#pattern_matching_newlines.;
913
914 /** This flag indicates that we are currently parsing a keyword argument. */
915 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! in_keyword_argcxx . . $ pm_parser#in_keyword_arg.;
916
917 /**
918 * Whether or not the parser has seen a token that has semantic meaning
919 * (i.e., a token that is not a comment or whitespace).
920 */
921 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! semantic_token_seencxx . . $ pm_parser#semantic_token_seen.;
922
923 /**
924 * True if the current regular expression being lexed contains only ASCII
925 * characters.
926 */
927 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! current_regular_expression_ascii_onlycxx . . $ pm_parser#current_regular_expression_ascii_only.;
928
929 /**
930 * By default, Ruby always warns about mismatched indentation. This can be
931 * toggled with a magic comment.
932 */
933 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! warn_mismatched_indentationcxx . . $ pm_parser#warn_mismatched_indentation.;
934 };
935
936 #endif