Ruby 4.1.0dev (2026-03-06 revision 9aca729140424bbf465c11ab8ab53e5cc6602c01)
parser.h
Go to the documentation of this file.
1
6#ifndef PRISM_PARSER_H
7#define PRISM_PARSER_H
8
9#include "prism/defines.h"
10#include "prism/ast.h"
11#include "prism/encoding.h"
12#include "prism/options.h"
14#include "prism/util/pm_arena.h"
16#include "prism/util/pm_list.h"
19
20#include <stdbool.h>
21
27typedef enum {
28 PM_LEX_STATE_BIT_BEG,
29 PM_LEX_STATE_BIT_END,
30 PM_LEX_STATE_BIT_ENDARG,
31 PM_LEX_STATE_BIT_ENDFN,
32 PM_LEX_STATE_BIT_ARG,
33 PM_LEX_STATE_BIT_CMDARG,
34 PM_LEX_STATE_BIT_MID,
35 PM_LEX_STATE_BIT_FNAME,
36 PM_LEX_STATE_BIT_DOT,
37 PM_LEX_STATE_BIT_CLASS,
38 PM_LEX_STATE_BIT_LABEL,
39 PM_LEX_STATE_BIT_LABELED,
40 PM_LEX_STATE_BIT_FITEM
42
47typedef enum {
48 PM_LEX_STATE_NONE = 0,
49 PM_LEX_STATE_BEG = (1 << PM_LEX_STATE_BIT_BEG),
50 PM_LEX_STATE_END = (1 << PM_LEX_STATE_BIT_END),
51 PM_LEX_STATE_ENDARG = (1 << PM_LEX_STATE_BIT_ENDARG),
52 PM_LEX_STATE_ENDFN = (1 << PM_LEX_STATE_BIT_ENDFN),
53 PM_LEX_STATE_ARG = (1 << PM_LEX_STATE_BIT_ARG),
54 PM_LEX_STATE_CMDARG = (1 << PM_LEX_STATE_BIT_CMDARG),
55 PM_LEX_STATE_MID = (1 << PM_LEX_STATE_BIT_MID),
56 PM_LEX_STATE_FNAME = (1 << PM_LEX_STATE_BIT_FNAME),
57 PM_LEX_STATE_DOT = (1 << PM_LEX_STATE_BIT_DOT),
58 PM_LEX_STATE_CLASS = (1 << PM_LEX_STATE_BIT_CLASS),
59 PM_LEX_STATE_LABEL = (1 << PM_LEX_STATE_BIT_LABEL),
60 PM_LEX_STATE_LABELED = (1 << PM_LEX_STATE_BIT_LABELED),
61 PM_LEX_STATE_FITEM = (1 << PM_LEX_STATE_BIT_FITEM),
62 PM_LEX_STATE_BEG_ANY = PM_LEX_STATE_BEG | PM_LEX_STATE_MID | PM_LEX_STATE_CLASS,
63 PM_LEX_STATE_ARG_ANY = PM_LEX_STATE_ARG | PM_LEX_STATE_CMDARG,
64 PM_LEX_STATE_END_ANY = PM_LEX_STATE_END | PM_LEX_STATE_ENDARG | PM_LEX_STATE_ENDFN
66
70typedef enum {
71 PM_HEREDOC_QUOTE_NONE,
72 PM_HEREDOC_QUOTE_SINGLE = '\'',
73 PM_HEREDOC_QUOTE_DOUBLE = '"',
74 PM_HEREDOC_QUOTE_BACKTICK = '`',
76
80typedef enum {
81 PM_HEREDOC_INDENT_NONE,
82 PM_HEREDOC_INDENT_DASH,
83 PM_HEREDOC_INDENT_TILDE,
85
102
110typedef struct pm_lex_mode {
112 enum {
115
121
127
130
136
142
149
151 union {
152 struct {
154 size_t nesting;
155
158
163 uint8_t incrementor;
164
166 uint8_t terminator;
167
172 uint8_t breakpoints[11];
173 } list;
174
175 struct {
179 size_t nesting;
180
185 uint8_t incrementor;
186
188 uint8_t terminator;
189
194 uint8_t breakpoints[7];
195 } regexp;
196
197 struct {
199 size_t nesting;
200
202 bool interpolation;
203
210
215 uint8_t incrementor;
216
221 uint8_t terminator;
222
227 uint8_t breakpoints[7];
228 } string;
229
230 struct {
235
240 const uint8_t *next_start;
241
248
251 } heredoc;
252 } as;
253
257
263#define PM_LEX_STACK_SIZE 4
264
268typedef struct pm_parser pm_parser_t;
269
275typedef enum {
278
281
284
287
290
293
296
299
302
305
308
311
314
317
320
323
326
329
332
335
338
341
344
347
350
353
356
359
362
365
368
371
374
377
380
383
386
389
392
395
398
401
404
407
410
413
416
419
422
425
428
431
434
437
441
450
452typedef enum {
453 PM_COMMENT_INLINE,
454 PM_COMMENT_EMBDOC
456
472
489
495
504typedef struct {
510 void *data;
511
516 void (*callback)(void *data, pm_parser_t *parser, pm_token_t *token);
518
521static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_NONE = 0x0;
522static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_LITERAL = PM_SHAREABLE_CONSTANT_NODE_FLAGS_LITERAL;
523static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_EVERYTHING = PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_EVERYTHING;
524static const pm_shareable_constant_value_t PM_SCOPE_SHAREABLE_CONSTANT_EXPERIMENTAL_COPY = PM_SHAREABLE_CONSTANT_NODE_FLAGS_EXPERIMENTAL_COPY;
525
530typedef struct {
533
536
538 uint32_t index;
539
541 uint32_t reads;
542
544 uint32_t hash;
545} pm_local_t;
546
552typedef struct pm_locals {
554 uint32_t size;
555
557 uint32_t capacity;
558
562
564typedef uint8_t pm_scope_parameters_t;
565static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NONE = 0x0;
566static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_POSITIONALS = 0x1;
567static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_KEYWORDS = 0x2;
568static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_BLOCK = 0x4;
569static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_FORWARDING_ALL = 0x8;
570static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_IMPLICIT_DISALLOWED = 0x10;
571static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NUMBERED_INNER = 0x20;
572static const pm_scope_parameters_t PM_SCOPE_PARAMETERS_NUMBERED_FOUND = 0x40;
573
626
630typedef uint32_t pm_state_stack_t;
631
638struct pm_parser {
641
647 uint32_t node_id;
648
651
654
660
666
672
678
680 struct {
683
686
688 size_t index;
690
692 const uint8_t *start;
693
695 const uint8_t *end;
696
699
702
708 const uint8_t *next_start;
709
716 const uint8_t *heredoc_end;
717
720
723
730
733
736
739
742
751
757
764
770
776
782
788
791
798 pm_node_flags_t integer_base;
799
805
810 int32_t start_line;
811
842
855
858
861
871
877
884
887
890
898
905
911
914
920
926
932};
933
934#endif
The options that can be passed to parsing.
pm_options_version_t
The version of Ruby syntax that we should be parsing with.
Definition options.h:84
struct pm_locals pm_locals_t
This is a set of local variables in a certain lexical context (method, class, module,...
pm_heredoc_indent_t
The type of indentation that a heredoc uses.
Definition parser.h:80
struct pm_context_node pm_context_node_t
This is a node in a linked list of contexts.
uint32_t pm_state_stack_t
A struct that represents a stack of boolean values.
Definition parser.h:630
#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:263
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...
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
This enum provides various bits that represent different kinds of states that the lexer can track.
Definition parser.h:27
pm_lex_state_t
This enum combines the various bits from the above enum into individual values that represent the var...
Definition parser.h:47
struct pm_scope pm_scope_t
This struct represents a node in a linked list of scopes.
pm_heredoc_quote_t
The type of quote that a heredoc uses.
Definition parser.h:70
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:494
pm_context_t
While parsing, we keep track of a stack of contexts.
Definition parser.h:275
@ PM_CONTEXT_CLASS_RESCUE
a rescue statement within a class statement
Definition parser.h:325
@ PM_CONTEXT_ELSIF
an elsif clause
Definition parser.h:352
@ PM_CONTEXT_DEF_RESCUE
a rescue statement within a method definition
Definition parser.h:337
@ PM_CONTEXT_ELSE
an else clause
Definition parser.h:349
@ PM_CONTEXT_FOR_INDEX
a for loop's index
Definition parser.h:361
@ PM_CONTEXT_CASE_WHEN
a case when statements
Definition parser.h:310
@ PM_CONTEXT_BLOCK_RESCUE
a rescue statement within a do..end block
Definition parser.h:307
@ PM_CONTEXT_MODULE
a module declaration
Definition parser.h:388
@ PM_CONTEXT_DEF_PARAMS
a method definition's parameters
Definition parser.h:340
@ PM_CONTEXT_CASE_IN
a case in statements
Definition parser.h:313
@ PM_CONTEXT_BLOCK_ELSE
a rescue else statement within a do..end block
Definition parser.h:301
@ PM_CONTEXT_LOOP_PREDICATE
the predicate clause of a loop statement
Definition parser.h:382
@ PM_CONTEXT_SCLASS
a singleton class definition
Definition parser.h:418
@ PM_CONTEXT_UNLESS
an unless statement
Definition parser.h:433
@ PM_CONTEXT_POSTEXE
an END block
Definition parser.h:406
@ PM_CONTEXT_IF
an if statement
Definition parser.h:364
@ PM_CONTEXT_MULTI_TARGET
a multiple target expression
Definition parser.h:400
@ PM_CONTEXT_LAMBDA_RESCUE
a rescue statement within a lambda expression
Definition parser.h:379
@ PM_CONTEXT_BEGIN_ELSE
a rescue else statement with an explicit begin
Definition parser.h:286
@ PM_CONTEXT_NONE
a null context, used for returning a value from a function
Definition parser.h:277
@ PM_CONTEXT_CLASS_ELSE
a rescue else statement within a class statement
Definition parser.h:322
@ PM_CONTEXT_LAMBDA_ENSURE
an ensure statement within a lambda expression
Definition parser.h:373
@ PM_CONTEXT_BLOCK_ENSURE
an ensure statement within a do..end block
Definition parser.h:298
@ PM_CONTEXT_CLASS_ENSURE
an ensure statement within a class statement
Definition parser.h:319
@ PM_CONTEXT_LAMBDA_BRACES
a lambda expression with braces
Definition parser.h:367
@ PM_CONTEXT_MODULE_ELSE
a rescue else statement within a module statement
Definition parser.h:394
@ PM_CONTEXT_PARENS
a parenthesized expression
Definition parser.h:403
@ PM_CONTEXT_BLOCK_BRACES
expressions in block arguments using braces
Definition parser.h:292
@ PM_CONTEXT_BLOCK_PARAMETERS
expressions in block parameters foo do |...| end
Definition parser.h:304
@ PM_CONTEXT_DEF_ENSURE
an ensure statement within a method definition
Definition parser.h:331
@ PM_CONTEXT_SCLASS_RESCUE
a rescue statement with a singleton class
Definition parser.h:427
@ PM_CONTEXT_PREEXE
a BEGIN block
Definition parser.h:412
@ PM_CONTEXT_DEFINED
a defined? expression
Definition parser.h:343
@ PM_CONTEXT_MODULE_ENSURE
an ensure statement within a module statement
Definition parser.h:391
@ PM_CONTEXT_BEGIN_RESCUE
a rescue statement with an explicit begin
Definition parser.h:289
@ PM_CONTEXT_UNTIL
an until statement
Definition parser.h:436
@ PM_CONTEXT_DEF_ELSE
a rescue else statement within a method definition
Definition parser.h:334
@ PM_CONTEXT_FOR
a for loop
Definition parser.h:358
@ PM_CONTEXT_PREDICATE
a predicate inside an if/elsif/unless statement
Definition parser.h:409
@ PM_CONTEXT_BEGIN_ENSURE
an ensure statement with an explicit begin
Definition parser.h:283
@ PM_CONTEXT_SCLASS_ENSURE
an ensure statement with a singleton class
Definition parser.h:421
@ PM_CONTEXT_DEFAULT_PARAMS
a method definition's default parameter
Definition parser.h:346
@ PM_CONTEXT_LAMBDA_ELSE
a rescue else statement within a lambda expression
Definition parser.h:376
@ PM_CONTEXT_CLASS
a class declaration
Definition parser.h:316
@ PM_CONTEXT_MAIN
the top level context
Definition parser.h:385
@ PM_CONTEXT_LAMBDA_DO_END
a lambda expression with do..end
Definition parser.h:370
@ PM_CONTEXT_BEGIN
a begin statement
Definition parser.h:280
@ PM_CONTEXT_RESCUE_MODIFIER
a modifier rescue clause
Definition parser.h:415
@ PM_CONTEXT_EMBEXPR
an interpolated expression
Definition parser.h:355
@ PM_CONTEXT_TERNARY
a ternary expression
Definition parser.h:430
@ PM_CONTEXT_DEF
a method definition
Definition parser.h:328
@ PM_CONTEXT_SCLASS_ELSE
a rescue else statement with a singleton class
Definition parser.h:424
@ PM_CONTEXT_MODULE_RESCUE
a rescue statement within a module statement
Definition parser.h:397
@ PM_CONTEXT_BLOCK_KEYWORDS
expressions in block arguments using do..end
Definition parser.h:295
@ PM_CONTEXT_WHILE
a while statement
Definition parser.h:439
uint8_t pm_scope_parameters_t
The flags about scope parameters that can be set.
Definition parser.h:564
uint8_t pm_shareable_constant_value_t
The type of shareable constant value that can be set.
Definition parser.h:520
pm_comment_type_t
This is the type of a comment that we've found while parsing.
Definition parser.h:452
A bump allocator for the prism parser.
A data structure that stores a set of strings.
uint32_t pm_constant_id_t
A constant id is a unique identifier for a constant in the constant pool.
A list of byte offsets of newlines in a string.
An abstract linked list.
A generic string type that can have various ownership semantics.
Macro definitions used throughout the prism library.
The encoding interface and implementations used by the parser.
A set of static literal nodes that can be checked for duplicates.
C99 shim for <stdbool.h>
A bump allocator.
Definition pm_arena.h:39
This is a node in the linked list of comments that we've found while parsing.
Definition parser.h:462
pm_list_node_t node
The embedded base node.
Definition parser.h:464
pm_comment_type_t type
The type of comment that we've found.
Definition parser.h:470
pm_location_t location
The location of the comment in the source.
Definition parser.h:467
The overall constant pool, which stores constants found while parsing.
This is a node in a linked list of contexts.
Definition parser.h:443
pm_context_t context
The context that this node represents.
Definition parser.h:445
struct pm_context_node * prev
A pointer to the previous context in the linked list.
Definition parser.h:448
This struct defines the functions necessary to implement the encoding interface so we can determine h...
Definition encoding.h:23
All of the information necessary to store to lexing a heredoc.
Definition parser.h:89
size_t ident_length
The length of the heredoc identifier.
Definition parser.h:94
pm_heredoc_quote_t quote
The type of quote that the heredoc uses.
Definition parser.h:97
pm_heredoc_indent_t indent
The type of indentation that the heredoc uses.
Definition parser.h:100
const uint8_t * ident_start
A pointer to the start of the heredoc identifier.
Definition parser.h:91
When you are lexing through a file, the lexer needs all of the information that the parser additional...
Definition parser.h:504
void * data
This opaque pointer is used to provide whatever information the user deemed necessary to the callback...
Definition parser.h:510
When lexing Ruby source, the lexer has a small amount of state to tell which kind of token it is curr...
Definition parser.h:110
uint8_t terminator
This is the terminator of the list literal.
Definition parser.h:166
size_t nesting
This keeps track of the nesting level of the list.
Definition parser.h:154
bool interpolation
Whether or not interpolation is allowed in this list.
Definition parser.h:157
uint8_t incrementor
When lexing a list, it takes into account balancing the terminator if the terminator is one of (),...
Definition parser.h:163
enum pm_lex_mode::@98 mode
The type of this lex mode.
uint8_t breakpoints[11]
This is the character set that should be used to delimit the tokens within the list.
Definition parser.h:172
pm_heredoc_lex_mode_t base
All of the data necessary to lex a heredoc.
Definition parser.h:234
bool line_continuation
True if the previous token ended with a line continuation.
Definition parser.h:250
struct pm_lex_mode * prev
The previous lex state so that it knows how to pop.
Definition parser.h:255
@ 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:135
@ 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:126
@ PM_LEX_REGEXP
This state is used when a regular expression has been begun and we are looking for the terminator.
Definition parser.h:141
@ PM_LEX_DEFAULT
This state is used when any given token is being lexed.
Definition parser.h:114
@ PM_LEX_HEREDOC
This state is used when you are inside the content of a heredoc.
Definition parser.h:129
@ PM_LEX_EMBEXPR
This state is used when we're lexing as normal but inside an embedded expression of a string.
Definition parser.h:120
@ 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:147
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:209
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:240
union pm_lex_mode::@99 as
The data associated with this type of lex mode.
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:247
A list of offsets of the start of lines in a string.
This struct represents an abstract linked list that provides common functionality.
Definition pm_list.h:46
This represents the overall linked list.
Definition pm_list.h:55
This tracks an individual local variable in a certain lexical context, as well as the number of times...
Definition parser.h:530
pm_constant_id_t name
The name of the local variable.
Definition parser.h:532
pm_location_t location
The location of the local variable in the source.
Definition parser.h:535
uint32_t hash
The hash of the local variable.
Definition parser.h:544
uint32_t index
The index of the local variable in the local table.
Definition parser.h:538
uint32_t reads
The number of times the local variable is read.
Definition parser.h:541
This is a set of local variables in a certain lexical context (method, class, module,...
Definition parser.h:552
pm_local_t * locals
The nullable allocated memory for the local variables in the set.
Definition parser.h:560
uint32_t capacity
The capacity of the local variables set.
Definition parser.h:557
uint32_t size
The number of local variables in the set.
Definition parser.h:554
This struct represents a slice in the source code, defined by an offset and a length.
Definition ast.h:540
This is a node in the linked list of magic comments that we've found while parsing.
Definition parser.h:479
pm_list_node_t node
The embedded base node.
Definition parser.h:481
pm_location_t value
The value of the magic comment.
Definition parser.h:487
pm_location_t key
The key of the magic comment.
Definition parser.h:484
A list of nodes in the source, most often used for lists of children.
Definition ast.h:553
This struct represents the overall parser.
Definition parser.h:638
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:841
pm_lex_state_t lex_state
The current state of the lexer.
Definition parser.h:650
uint8_t command_line
The command line flags given from the options.
Definition parser.h:860
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:756
bool partial_script
Whether or not we are parsing a "partial" script, which is a script that will be evaluated in the con...
Definition parser.h:883
bool pattern_matching_newlines
This flag indicates that we are currently parsing a pattern matching expression and impacts that calc...
Definition parser.h:910
const uint8_t * end
The pointer to the end of the source.
Definition parser.h:695
bool recovering
Whether or not we're currently recovering from a syntax error.
Definition parser.h:889
pm_node_flags_t integer_base
We want to add a flag to integer nodes that indicates their base.
Definition parser.h:798
bool warn_mismatched_indentation
By default, Ruby always warns about mismatched indentation.
Definition parser.h:931
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:787
bool in_keyword_arg
This flag indicates that we are currently parsing a keyword argument.
Definition parser.h:913
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:671
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:708
pm_static_literals_t * current_hash_keys
The hash keys for the hash that is currently being parsed.
Definition parser.h:750
pm_list_t magic_comment_list
The list of magic comments that have been found while parsing.
Definition parser.h:722
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:659
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:775
pm_options_version_t version
The version of prism that we should use to parse.
Definition parser.h:857
pm_token_t previous
The previous token we were considering.
Definition parser.h:698
pm_string_t current_string
This string is used to pass information from the lexer to the parser.
Definition parser.h:804
bool parsing_eval
Whether or not we are parsing an eval string.
Definition parser.h:876
bool current_regular_expression_ascii_only
True if the current regular expression being lexed contains only ASCII characters.
Definition parser.h:925
bool encoding_changed
Whether or not the encoding has been changed by a magic comment.
Definition parser.h:904
pm_location_t data_loc
An optional location that represents the location of the END marker and the rest of the content of th...
Definition parser.h:729
pm_context_node_t * current_context
The current parsing context.
Definition parser.h:741
const uint8_t * start
The pointer to the start of the source.
Definition parser.h:692
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:677
int enclosure_nesting
Tracks the current nesting of (), [], and {}.
Definition parser.h:653
pm_line_offset_list_t line_offsets
This is the list of line offsets in the source file.
Definition parser.h:790
pm_list_t error_list
The list of errors that have been found while parsing.
Definition parser.h:735
int8_t frozen_string_literal
Whether or not we have found a frozen_string_literal magic comment with a true or false value.
Definition parser.h:870
pm_node_list_t * current_block_exits
When parsing block exits (e.g., break, next, redo), we need to validate that they are in correct cont...
Definition parser.h:854
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:769
pm_token_t current
The current token we're considering.
Definition parser.h:701
pm_lex_mode_t stack[PM_LEX_STACK_SIZE]
The stack of lexer modes.
Definition parser.h:685
pm_list_t warning_list
The list of warnings that have been found while parsing.
Definition parser.h:732
const uint8_t * heredoc_end
This field indicates the end of a heredoc whose identifier was found on the current line.
Definition parser.h:716
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:665
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:763
struct pm_parser::@104 lex_modes
A stack of lex modes.
int32_t start_line
The line number at the start of the parse.
Definition parser.h:810
bool encoding_locked
This is very specialized behavior for when you want to parse in a context that does not respect encod...
Definition parser.h:897
pm_lex_mode_t * current
The current mode of the lexer.
Definition parser.h:682
pm_arena_t * arena
The arena used for all AST-lifetime allocations.
Definition parser.h:640
pm_list_t comment_list
The list of comments that have been found while parsing.
Definition parser.h:719
size_t index
The current index into the lexer mode stack.
Definition parser.h:688
pm_string_t filepath
This is the path of the file being parsed.
Definition parser.h:781
pm_scope_t * current_scope
The current local scope.
Definition parser.h:738
bool command_start
Whether or not we're at the beginning of a command.
Definition parser.h:886
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:919
uint32_t node_id
The next node identifier that will be assigned.
Definition parser.h:647
This struct represents a node in a linked list of scopes.
Definition parser.h:578
struct pm_scope * previous
A pointer to the previous scope in the linked list.
Definition parser.h:580
pm_node_list_t implicit_parameters
This is a list of the implicit parameters contained within the block.
Definition parser.h:591
pm_shareable_constant_value_t shareable_constant
The current state of constant shareability for this scope.
Definition parser.h:618
pm_locals_t locals
The IDs of the locals in the given scope.
Definition parser.h:583
pm_scope_parameters_t parameters
This is a bitfield that indicates the parameters that are being used in this scope.
Definition parser.h:612
bool closed
A boolean indicating whether or not this scope can see into its parent.
Definition parser.h:624
Certain sets of nodes (hash keys and when clauses) check for duplicate nodes to alert the user of pot...
A generic string type that can have various ownership semantics.
Definition pm_string.h:33
This struct represents a token in the Ruby source.
Definition ast.h:521