Ruby: prism/parser.h Source File

Ruby 3.3.5p100 (2024-09-03 revision ef084cc8f4958c1b6e4ead99136631bef6d8ddba)

parser.h
Go to the documentation of this file.
1
6#ifndef PRISM_PARSER_H
7#define PRISM_PARSER_H
8
9#include "prism/ast.h"
10#include "prism/defines.h"
11#include "prism/encoding.h"
12#include "prism/util/pm_constant_pool.h"
13#include "prism/util/pm_list.h"
14#include "prism/util/pm_newline_list.h"
15#include "prism/util/pm_state_stack.h"
16#include "prism/util/pm_string.h"
17
18#include <stdbool.h>
19
20// TODO: remove this by renaming the original flag
24#define PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS PM_KEYWORD_HASH_NODE_FLAGS_STATIC_KEYS
25
31 typedef enum {
32 PM_LEX_STATE_BIT_BEG,
33 PM_LEX_STATE_BIT_END,
34 PM_LEX_STATE_BIT_ENDARG,
35 PM_LEX_STATE_BIT_ENDFN,
36 PM_LEX_STATE_BIT_ARG,
37 PM_LEX_STATE_BIT_CMDARG,
38 PM_LEX_STATE_BIT_MID,
39 PM_LEX_STATE_BIT_FNAME,
40 PM_LEX_STATE_BIT_DOT,
41 PM_LEX_STATE_BIT_CLASS,
42 PM_LEX_STATE_BIT_LABEL,
43 PM_LEX_STATE_BIT_LABELED,
44 PM_LEX_STATE_BIT_FITEM
45} pm_lex_state_bit_t;
46
51 typedef enum {
52 PM_LEX_STATE_NONE = 0,
53 PM_LEX_STATE_BEG = (1 << PM_LEX_STATE_BIT_BEG),
54 PM_LEX_STATE_END = (1 << PM_LEX_STATE_BIT_END),
55 PM_LEX_STATE_ENDARG = (1 << PM_LEX_STATE_BIT_ENDARG),
56 PM_LEX_STATE_ENDFN = (1 << PM_LEX_STATE_BIT_ENDFN),
57 PM_LEX_STATE_ARG = (1 << PM_LEX_STATE_BIT_ARG),
58 PM_LEX_STATE_CMDARG = (1 << PM_LEX_STATE_BIT_CMDARG),
59 PM_LEX_STATE_MID = (1 << PM_LEX_STATE_BIT_MID),
60 PM_LEX_STATE_FNAME = (1 << PM_LEX_STATE_BIT_FNAME),
61 PM_LEX_STATE_DOT = (1 << PM_LEX_STATE_BIT_DOT),
62 PM_LEX_STATE_CLASS = (1 << PM_LEX_STATE_BIT_CLASS),
63 PM_LEX_STATE_LABEL = (1 << PM_LEX_STATE_BIT_LABEL),
64 PM_LEX_STATE_LABELED = (1 << PM_LEX_STATE_BIT_LABELED),
65 PM_LEX_STATE_FITEM = (1 << PM_LEX_STATE_BIT_FITEM),
66 PM_LEX_STATE_BEG_ANY = PM_LEX_STATE_BEG | PM_LEX_STATE_MID | PM_LEX_STATE_CLASS,
67 PM_LEX_STATE_ARG_ANY = PM_LEX_STATE_ARG | PM_LEX_STATE_CMDARG,
68 PM_LEX_STATE_END_ANY = PM_LEX_STATE_END | PM_LEX_STATE_ENDARG | PM_LEX_STATE_ENDFN
69} pm_lex_state_t;
70
74 typedef enum {
75 PM_HEREDOC_QUOTE_NONE,
76 PM_HEREDOC_QUOTE_SINGLE = '\'',
77 PM_HEREDOC_QUOTE_DOUBLE = '"',
78 PM_HEREDOC_QUOTE_BACKTICK = '`',
79} pm_heredoc_quote_t;
80
84 typedef enum {
85 PM_HEREDOC_INDENT_NONE,
86 PM_HEREDOC_INDENT_DASH,
87 PM_HEREDOC_INDENT_TILDE,
88} pm_heredoc_indent_t;
89
97 typedef struct pm_lex_mode {
99 enum {
101 PM_LEX_DEFAULT,
102
107 PM_LEX_EMBEXPR,
108
113 PM_LEX_EMBVAR,
114
116 PM_LEX_HEREDOC,
117
122 PM_LEX_LIST,
123
128 PM_LEX_REGEXP,
129
134 PM_LEX_STRING
135 } mode;
136
138 union {
139 struct {
141 size_t nesting;
142
144 bool interpolation;
145
150 uint8_t incrementor;
151
153 uint8_t terminator;
154
159 uint8_t breakpoints[11];
160 } list;
161
162 struct {
166 size_t nesting;
167
172 uint8_t incrementor;
173
175 uint8_t terminator;
176
181 uint8_t breakpoints[6];
182 } regexp;
183
184 struct {
186 size_t nesting;
187
189 bool interpolation;
190
196 bool label_allowed;
197
202 uint8_t incrementor;
203
208 uint8_t terminator;
209
214 uint8_t breakpoints[6];
215 } string;
216
217 struct {
219 const uint8_t *ident_start;
220
222 size_t ident_length;
223
225 pm_heredoc_quote_t quote;
226
228 pm_heredoc_indent_t indent;
229
234 const uint8_t *next_start;
235
241 size_t common_whitespace;
242 } heredoc;
243 } as;
244
246 struct pm_lex_mode *prev;
247} pm_lex_mode_t;
248
254#define PM_LEX_STACK_SIZE 4
255
259 typedef struct pm_parser pm_parser_t;
260
266 typedef enum {
268 PM_CONTEXT_BEGIN,
269
271 PM_CONTEXT_BLOCK_BRACES,
272
274 PM_CONTEXT_BLOCK_KEYWORDS,
275
277 PM_CONTEXT_CASE_WHEN,
278
280 PM_CONTEXT_CASE_IN,
281
283 PM_CONTEXT_CLASS,
284
286 PM_CONTEXT_DEF,
287
289 PM_CONTEXT_DEF_PARAMS,
290
292 PM_CONTEXT_DEFAULT_PARAMS,
293
295 PM_CONTEXT_ELSE,
296
298 PM_CONTEXT_ELSIF,
299
301 PM_CONTEXT_EMBEXPR,
302
304 PM_CONTEXT_ENSURE,
305
307 PM_CONTEXT_ENSURE_DEF,
308
310 PM_CONTEXT_FOR,
311
313 PM_CONTEXT_FOR_INDEX,
314
316 PM_CONTEXT_IF,
317
319 PM_CONTEXT_LAMBDA_BRACES,
320
322 PM_CONTEXT_LAMBDA_DO_END,
323
325 PM_CONTEXT_MAIN,
326
328 PM_CONTEXT_MODULE,
329
331 PM_CONTEXT_PARENS,
332
334 PM_CONTEXT_POSTEXE,
335
337 PM_CONTEXT_PREDICATE,
338
340 PM_CONTEXT_PREEXE,
341
343 PM_CONTEXT_RESCUE_ELSE,
344
346 PM_CONTEXT_RESCUE_ELSE_DEF,
347
349 PM_CONTEXT_RESCUE,
350
352 PM_CONTEXT_RESCUE_DEF,
353
355 PM_CONTEXT_SCLASS,
356
358 PM_CONTEXT_UNLESS,
359
361 PM_CONTEXT_UNTIL,
362
364 PM_CONTEXT_WHILE,
365} pm_context_t;
366
368 typedef struct pm_context_node {
370 pm_context_t context;
371
373 struct pm_context_node *prev;
374} pm_context_node_t;
375
377 typedef enum {
378 PM_COMMENT_INLINE,
379 PM_COMMENT_EMBDOC
380} pm_comment_type_t;
381
387 typedef struct pm_comment {
389 pm_list_node_t node;
390
392 pm_location_t location;
393
395 pm_comment_type_t type;
396} pm_comment_t;
397
404 typedef struct {
406 pm_list_node_t node;
407
409 const uint8_t *key_start;
410
412 const uint8_t *value_start;
413
415 uint32_t key_length;
416
418 uint32_t value_length;
419} pm_magic_comment_t;
420
425 typedef void (*pm_encoding_changed_callback_t)(pm_parser_t *parser);
426
435 typedef struct {
441 void *data;
442
447 void (*callback)(void *data, pm_parser_t *parser, pm_token_t *token);
448} pm_lex_callback_t;
449
454 typedef struct pm_scope {
456 pm_constant_id_list_t locals;
457
459 struct pm_scope *previous;
460
465 bool closed;
466
472 bool explicit_params;
473
480 uint8_t numbered_parameters;
481} pm_scope_t;
482
489 struct pm_parser {
491 pm_lex_state_t lex_state;
492
494 int enclosure_nesting;
495
500 int lambda_enclosure_nesting;
501
506 int brace_nesting;
507
512 pm_state_stack_t do_loop_stack;
513
518 pm_state_stack_t accepts_block_stack;
519
521 struct {
523 pm_lex_mode_t *current;
524
526 pm_lex_mode_t stack[PM_LEX_STACK_SIZE];
527
529 size_t index;
530 } lex_modes;
531
533 const uint8_t *start;
534
536 const uint8_t *end;
537
539 pm_token_t previous;
540
542 pm_token_t current;
543
549 const uint8_t *next_start;
550
557 const uint8_t *heredoc_end;
558
560 pm_list_t comment_list;
561
563 pm_list_t magic_comment_list;
564
566 pm_location_t data_loc;
567
569 pm_list_t warning_list;
570
572 pm_list_t error_list;
573
575 pm_scope_t *current_scope;
576
578 pm_context_node_t *current_context;
579
584 const pm_encoding_t *encoding;
585
591 pm_encoding_changed_callback_t encoding_changed_callback;
592
597 const uint8_t *encoding_comment_start;
598
603 pm_lex_callback_t *lex_callback;
604
609 pm_string_t filepath_string;
610
615 pm_constant_pool_t constant_pool;
616
618 pm_newline_list_t newline_list;
619
626 pm_node_flags_t integer_base;
627
632 pm_string_t current_string;
633
638 int32_t start_line;
639
669 const pm_encoding_t *explicit_encoding;
670
672 bool command_start;
673
675 bool recovering;
676
682 bool encoding_changed;
683
688 bool pattern_matching_newlines;
689
691 bool in_keyword_arg;
692
694 pm_constant_id_t current_param_name;
695
700 bool semantic_token_seen;
701
706 bool frozen_string_literal;
707
713 bool suppress_warnings;
714};
715
716#endif
ast.h
The abstract syntax tree.
pm_node_flags_t
uint16_t pm_node_flags_t
These are the flags embedded in the node struct.
Definition ast.h:1029
pm_heredoc_indent_t
pm_heredoc_indent_t
The type of indentation that a heredoc uses.
Definition parser.h:84
pm_context_node_t
struct pm_context_node pm_context_node_t
This is a node in a linked list of contexts.
PM_LEX_STACK_SIZE
#define PM_LEX_STACK_SIZE
We pre-allocate a certain number of lex states in order to avoid having to call malloc too many times...
Definition parser.h:254
pm_lex_mode_t
struct pm_lex_mode pm_lex_mode_t
When lexing Ruby source, the lexer has a small amount of state to tell which kind of token it is curr...
pm_comment_t
struct pm_comment pm_comment_t
This is a node in the linked list of comments that we've found while parsing.
pm_lex_state_bit_t
pm_lex_state_bit_t
This enum provides various bits that represent different kinds of states that the lexer can track.
Definition parser.h:31
pm_lex_state_t
pm_lex_state_t
This enum combines the various bits from the above enum into individual values that represent the var...
Definition parser.h:51
pm_scope_t
struct pm_scope pm_scope_t
This struct represents a node in a linked list of scopes.
pm_heredoc_quote_t
pm_heredoc_quote_t
The type of quote that a heredoc uses.
Definition parser.h:74
pm_encoding_changed_callback_t
void(* pm_encoding_changed_callback_t)(pm_parser_t *parser)
When the encoding that is being used to parse the source is changed by prism, we provide the ability ...
Definition parser.h:425
pm_context_t
pm_context_t
While parsing, we keep track of a stack of contexts.
Definition parser.h:266
PM_CONTEXT_ELSIF
@ PM_CONTEXT_ELSIF
an elsif clause
Definition parser.h:298
PM_CONTEXT_ENSURE_DEF
@ PM_CONTEXT_ENSURE_DEF
an ensure statement within a method definition
Definition parser.h:307
PM_CONTEXT_ELSE
@ PM_CONTEXT_ELSE
an else clause
Definition parser.h:295
PM_CONTEXT_FOR_INDEX
@ PM_CONTEXT_FOR_INDEX
a for loop's index
Definition parser.h:313
PM_CONTEXT_CASE_WHEN
@ PM_CONTEXT_CASE_WHEN
a case when statements
Definition parser.h:277
PM_CONTEXT_MODULE
@ PM_CONTEXT_MODULE
a module declaration
Definition parser.h:328
PM_CONTEXT_DEF_PARAMS
@ PM_CONTEXT_DEF_PARAMS
a method definition's parameters
Definition parser.h:289
PM_CONTEXT_CASE_IN
@ PM_CONTEXT_CASE_IN
a case in statements
Definition parser.h:280
PM_CONTEXT_SCLASS
@ PM_CONTEXT_SCLASS
a singleton class definition
Definition parser.h:355
PM_CONTEXT_UNLESS
@ PM_CONTEXT_UNLESS
an unless statement
Definition parser.h:358
PM_CONTEXT_POSTEXE
@ PM_CONTEXT_POSTEXE
an END block
Definition parser.h:334
PM_CONTEXT_IF
@ PM_CONTEXT_IF
an if statement
Definition parser.h:316
PM_CONTEXT_RESCUE_DEF
@ PM_CONTEXT_RESCUE_DEF
a rescue statement within a method definition
Definition parser.h:352
PM_CONTEXT_RESCUE
@ PM_CONTEXT_RESCUE
a rescue statement
Definition parser.h:349
PM_CONTEXT_LAMBDA_BRACES
@ PM_CONTEXT_LAMBDA_BRACES
a lambda expression with braces
Definition parser.h:319
PM_CONTEXT_PARENS
@ PM_CONTEXT_PARENS
a parenthesized expression
Definition parser.h:331
PM_CONTEXT_BLOCK_BRACES
@ PM_CONTEXT_BLOCK_BRACES
expressions in block arguments using braces
Definition parser.h:271
PM_CONTEXT_PREEXE
@ PM_CONTEXT_PREEXE
a BEGIN block
Definition parser.h:340
PM_CONTEXT_RESCUE_ELSE
@ PM_CONTEXT_RESCUE_ELSE
a rescue else statement
Definition parser.h:343
PM_CONTEXT_UNTIL
@ PM_CONTEXT_UNTIL
an until statement
Definition parser.h:361
PM_CONTEXT_FOR
@ PM_CONTEXT_FOR
a for loop
Definition parser.h:310
PM_CONTEXT_PREDICATE
@ PM_CONTEXT_PREDICATE
a predicate inside an if/elsif/unless statement
Definition parser.h:337
PM_CONTEXT_RESCUE_ELSE_DEF
@ PM_CONTEXT_RESCUE_ELSE_DEF
a rescue else statement within a method definition
Definition parser.h:346
PM_CONTEXT_DEFAULT_PARAMS
@ PM_CONTEXT_DEFAULT_PARAMS
a method definition's default parameter
Definition parser.h:292
PM_CONTEXT_CLASS
@ PM_CONTEXT_CLASS
a class declaration
Definition parser.h:283
PM_CONTEXT_MAIN
@ PM_CONTEXT_MAIN
the top level context
Definition parser.h:325
PM_CONTEXT_LAMBDA_DO_END
@ PM_CONTEXT_LAMBDA_DO_END
a lambda expression with do..end
Definition parser.h:322
PM_CONTEXT_BEGIN
@ PM_CONTEXT_BEGIN
a begin statement
Definition parser.h:268
PM_CONTEXT_ENSURE
@ PM_CONTEXT_ENSURE
an ensure statement
Definition parser.h:304
PM_CONTEXT_EMBEXPR
@ PM_CONTEXT_EMBEXPR
an interpolated expression
Definition parser.h:301
PM_CONTEXT_DEF
@ PM_CONTEXT_DEF
a method definition
Definition parser.h:286
PM_CONTEXT_BLOCK_KEYWORDS
@ PM_CONTEXT_BLOCK_KEYWORDS
expressions in block arguments using do..end
Definition parser.h:274
PM_CONTEXT_WHILE
@ PM_CONTEXT_WHILE
a while statement
Definition parser.h:364
pm_comment_type_t
pm_comment_type_t
This is the type of a comment that we've found while parsing.
Definition parser.h:377
pm_constant_pool.h
A data structure that stores a set of strings.
pm_constant_id_t
uint32_t pm_constant_id_t
A constant id is a unique identifier for a constant in the constant pool.
Definition pm_constant_pool.h:24
pm_list.h
An abstract linked list.
pm_newline_list.h
A list of byte offsets of newlines in a string.
pm_state_stack.h
A stack of boolean values.
pm_state_stack_t
uint32_t pm_state_stack_t
A struct that represents a stack of boolean values.
Definition pm_state_stack.h:17
pm_string.h
A generic string type that can have various ownership semantics.
defines.h
Macro definitions used throughout the prism library.
encoding.h
The encoding interface and implementations used by the parser.
stdbool.h
C99 shim for <stdbool.h>
pm_comment
This is a node in the linked list of comments that we've found while parsing.
Definition parser.h:387
pm_comment::node
pm_list_node_t node
The embedded base node.
Definition parser.h:389
pm_comment::type
pm_comment_type_t type
The type of comment that we've found.
Definition parser.h:395
pm_comment::location
pm_location_t location
The location of the comment in the source.
Definition parser.h:392
pm_constant_id_list_t
A list of constant IDs.
Definition pm_constant_pool.h:29
pm_constant_pool_t
The overall constant pool, which stores constants found while parsing.
Definition pm_constant_pool.h:118
pm_context_node
This is a node in a linked list of contexts.
Definition parser.h:368
pm_context_node::context
pm_context_t context
The context that this node represents.
Definition parser.h:370
pm_context_node::prev
struct pm_context_node * prev
A pointer to the previous context in the linked list.
Definition parser.h:373
pm_encoding_t
This struct defines the functions necessary to implement the encoding interface so we can determine h...
Definition encoding.h:23
pm_lex_callback_t
When you are lexing through a file, the lexer needs all of the information that the parser additional...
Definition parser.h:435
pm_lex_callback_t::data
void * data
This opaque pointer is used to provide whatever information the user deemed necessary to the callback...
Definition parser.h:441
pm_lex_mode
When lexing Ruby source, the lexer has a small amount of state to tell which kind of token it is curr...
Definition parser.h:97
pm_lex_mode::terminator
uint8_t terminator
This is the terminator of the list literal.
Definition parser.h:153
pm_lex_mode::ident_start
const uint8_t * ident_start
A pointer to the start of the heredoc identifier.
Definition parser.h:219
pm_lex_mode::nesting
size_t nesting
This keeps track of the nesting level of the list.
Definition parser.h:141
pm_lex_mode::interpolation
bool interpolation
Whether or not interpolation is allowed in this list.
Definition parser.h:144
pm_lex_mode::indent
pm_heredoc_indent_t indent
The type of indentation that the heredoc uses.
Definition parser.h:228
pm_lex_mode::incrementor
uint8_t incrementor
When lexing a list, it takes into account balancing the terminator if the terminator is one of (),...
Definition parser.h:150
pm_lex_mode::prev
struct pm_lex_mode * prev
The previous lex state so that it knows how to pop.
Definition parser.h:246
pm_lex_mode::quote
pm_heredoc_quote_t quote
The type of quote that the heredoc uses.
Definition parser.h:225
pm_lex_mode::PM_LEX_LIST
@ PM_LEX_LIST
This state is used when we are lexing a list of tokens, as in a w word list literal or a i symbol lis...
Definition parser.h:122
pm_lex_mode::PM_LEX_EMBVAR
@ PM_LEX_EMBVAR
This state is used when we're lexing a variable that is embedded directly inside of a string with the...
Definition parser.h:113
pm_lex_mode::PM_LEX_REGEXP
@ PM_LEX_REGEXP
This state is used when a regular expression has been begun and we are looking for the terminator.
Definition parser.h:128
pm_lex_mode::PM_LEX_DEFAULT
@ PM_LEX_DEFAULT
This state is used when any given token is being lexed.
Definition parser.h:101
pm_lex_mode::PM_LEX_HEREDOC
@ PM_LEX_HEREDOC
This state is used when you are inside the content of a heredoc.
Definition parser.h:116
pm_lex_mode::PM_LEX_EMBEXPR
@ PM_LEX_EMBEXPR
This state is used when we're lexing as normal but inside an embedded expression of a string.
Definition parser.h:107
pm_lex_mode::PM_LEX_STRING
@ PM_LEX_STRING
This state is used when we are lexing a string or a string-like token, as in string content with eith...
Definition parser.h:134
pm_lex_mode::label_allowed
bool label_allowed
Whether or not at the end of the string we should allow a :, which would indicate this was a dynamic ...
Definition parser.h:196
pm_lex_mode::as
union pm_lex_mode::@91 as
The data associated with this type of lex mode.
pm_lex_mode::next_start
const uint8_t * next_start
This is the pointer to the character where lexing should resume once the heredoc has been completely ...
Definition parser.h:234
pm_lex_mode::ident_length
size_t ident_length
The length of the heredoc identifier.
Definition parser.h:222
pm_lex_mode::common_whitespace
size_t common_whitespace
This is used to track the amount of common whitespace on each line so that we know how much to dedent...
Definition parser.h:241
pm_lex_mode::mode
enum pm_lex_mode::@90 mode
The type of this lex mode.
pm_lex_mode::breakpoints
uint8_t breakpoints[11]
This is the character set that should be used to delimit the tokens within the list.
Definition parser.h:159
pm_list_node
This struct represents an abstract linked list that provides common functionality.
Definition pm_list.h:46
pm_list_t
This represents the overall linked list.
Definition pm_list.h:55
pm_location_t
This represents a range of bytes in the source string to which a node or token corresponds.
Definition ast.h:543
pm_magic_comment_t
This is a node in the linked list of magic comments that we've found while parsing.
Definition parser.h:404
pm_magic_comment_t::key_length
uint32_t key_length
The length of the key in the source.
Definition parser.h:415
pm_magic_comment_t::node
pm_list_node_t node
The embedded base node.
Definition parser.h:406
pm_magic_comment_t::key_start
const uint8_t * key_start
A pointer to the start of the key in the source.
Definition parser.h:409
pm_magic_comment_t::value_start
const uint8_t * value_start
A pointer to the start of the value in the source.
Definition parser.h:412
pm_magic_comment_t::value_length
uint32_t value_length
The length of the value in the source.
Definition parser.h:418
pm_newline_list_t
A list of offsets of newlines in a string.
Definition pm_newline_list.h:28
pm_parser
This struct represents the overall parser.
Definition parser.h:489
pm_parser::explicit_encoding
const pm_encoding_t * explicit_encoding
When a string-like expression is being lexed, any byte or escape sequence that resolves to a value wh...
Definition parser.h:669
pm_parser::lex_state
pm_lex_state_t lex_state
The current state of the lexer.
Definition parser.h:491
pm_parser::encoding
const pm_encoding_t * encoding
The encoding functions for the current file is attached to the parser as it's parsing so that it can ...
Definition parser.h:584
pm_parser::pattern_matching_newlines
bool pattern_matching_newlines
This flag indicates that we are currently parsing a pattern matching expression and impacts that calc...
Definition parser.h:688
pm_parser::end
const uint8_t * end
The pointer to the end of the source.
Definition parser.h:536
pm_parser::recovering
bool recovering
Whether or not we're currently recovering from a syntax error.
Definition parser.h:675
pm_parser::integer_base
pm_node_flags_t integer_base
We want to add a flag to integer nodes that indicates their base.
Definition parser.h:626
pm_parser::constant_pool
pm_constant_pool_t constant_pool
This constant pool keeps all of the constants defined throughout the file so that we can reference th...
Definition parser.h:615
pm_parser::in_keyword_arg
bool in_keyword_arg
This flag indicates that we are currently parsing a keyword argument.
Definition parser.h:691
pm_parser::suppress_warnings
bool suppress_warnings
Whether or not we should emit warnings.
Definition parser.h:713
pm_parser::do_loop_stack
pm_state_stack_t do_loop_stack
The stack used to determine if a do keyword belongs to the predicate of a while, until,...
Definition parser.h:512
pm_parser::next_start
const uint8_t * next_start
This is a special field set on the parser when we need the parser to jump to a specific location when...
Definition parser.h:549
pm_parser::filepath_string
pm_string_t filepath_string
This is the path of the file being parsed.
Definition parser.h:609
pm_parser::magic_comment_list
pm_list_t magic_comment_list
The list of magic comments that have been found while parsing.
Definition parser.h:563
pm_parser::lambda_enclosure_nesting
int lambda_enclosure_nesting
Used to temporarily track the nesting of enclosures to determine if a { is the beginning of a lambda ...
Definition parser.h:500
pm_parser::lex_callback
pm_lex_callback_t * lex_callback
This is an optional callback that can be attached to the parser that will be called whenever a new to...
Definition parser.h:603
pm_parser::previous
pm_token_t previous
The previous token we were considering.
Definition parser.h:539
pm_parser::current_string
pm_string_t current_string
This string is used to pass information from the lexer to the parser.
Definition parser.h:632
pm_parser::encoding_changed
bool encoding_changed
Whether or not the encoding has been changed by a magic comment.
Definition parser.h:682
pm_parser::data_loc
pm_location_t data_loc
The optional location of the END keyword and its contents.
Definition parser.h:566
pm_parser::current_context
pm_context_node_t * current_context
The current parsing context.
Definition parser.h:578
pm_parser::current_param_name
pm_constant_id_t current_param_name
The current parameter name id on parsing its default value.
Definition parser.h:694
pm_parser::start
const uint8_t * start
The pointer to the start of the source.
Definition parser.h:533
pm_parser::accepts_block_stack
pm_state_stack_t accepts_block_stack
The stack used to determine if a do keyword belongs to the beginning of a block.
Definition parser.h:518
pm_parser::enclosure_nesting
int enclosure_nesting
Tracks the current nesting of (), [], and {}.
Definition parser.h:494
pm_parser::error_list
pm_list_t error_list
The list of errors that have been found while parsing.
Definition parser.h:572
pm_parser::encoding_comment_start
const uint8_t * encoding_comment_start
This pointer indicates where a comment must start if it is to be considered an encoding comment.
Definition parser.h:597
pm_parser::current
pm_token_t current
The current token we're considering.
Definition parser.h:542
pm_parser::stack
pm_lex_mode_t stack[PM_LEX_STACK_SIZE]
The stack of lexer modes.
Definition parser.h:526
pm_parser::warning_list
pm_list_t warning_list
The list of warnings that have been found while parsing.
Definition parser.h:569
pm_parser::heredoc_end
const uint8_t * heredoc_end
This field indicates the end of a heredoc whose identifier was found on the current line.
Definition parser.h:557
pm_parser::brace_nesting
int brace_nesting
Used to track the nesting of braces to ensure we get the correct value when we are interpolating bloc...
Definition parser.h:506
pm_parser::encoding_changed_callback
pm_encoding_changed_callback_t encoding_changed_callback
When the encoding that is being used to parse the source is changed by prism, we provide the ability ...
Definition parser.h:591
pm_parser::start_line
int32_t start_line
The line number at the start of the parse.
Definition parser.h:638
pm_parser::lex_modes
struct pm_parser::@96 lex_modes
A stack of lex modes.
pm_parser::current
pm_lex_mode_t * current
The current mode of the lexer.
Definition parser.h:523
pm_parser::comment_list
pm_list_t comment_list
The list of comments that have been found while parsing.
Definition parser.h:560
pm_parser::index
size_t index
The current index into the lexer mode stack.
Definition parser.h:529
pm_parser::current_scope
pm_scope_t * current_scope
The current local scope.
Definition parser.h:575
pm_parser::command_start
bool command_start
Whether or not we're at the beginning of a command.
Definition parser.h:672
pm_parser::frozen_string_literal
bool frozen_string_literal
Whether or not we have found a frozen_string_literal magic comment with a true value.
Definition parser.h:706
pm_parser::newline_list
pm_newline_list_t newline_list
This is the list of newline offsets in the source file.
Definition parser.h:618
pm_parser::semantic_token_seen
bool semantic_token_seen
Whether or not the parser has seen a token that has semantic meaning (i.e., a token that is not a com...
Definition parser.h:700
pm_scope
This struct represents a node in a linked list of scopes.
Definition parser.h:454
pm_scope::previous
struct pm_scope * previous
A pointer to the previous scope in the linked list.
Definition parser.h:459
pm_scope::locals
pm_constant_id_list_t locals
The IDs of the locals in the given scope.
Definition parser.h:456
pm_scope::explicit_params
bool explicit_params
A boolean indicating whether or not this scope has explicit parameters.
Definition parser.h:472
pm_scope::closed
bool closed
A boolean indicating whether or not this scope can see into its parent.
Definition parser.h:465
pm_scope::numbered_parameters
uint8_t numbered_parameters
An integer indicating the number of numbered parameters on this scope.
Definition parser.h:480
pm_string_t
A generic string type that can have various ownership semantics.
Definition pm_string.h:30
pm_token_t
This struct represents a token in the Ruby source.
Definition ast.h:528