24#define PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS PM_KEYWORD_HASH_NODE_FLAGS_STATIC_KEYS
34 PM_LEX_STATE_BIT_ENDARG,
35 PM_LEX_STATE_BIT_ENDFN,
37 PM_LEX_STATE_BIT_CMDARG,
39 PM_LEX_STATE_BIT_FNAME,
41 PM_LEX_STATE_BIT_CLASS,
42 PM_LEX_STATE_BIT_LABEL,
43 PM_LEX_STATE_BIT_LABELED,
44 PM_LEX_STATE_BIT_FITEM
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
75 PM_HEREDOC_QUOTE_NONE,
76 PM_HEREDOC_QUOTE_SINGLE =
'\'',
77 PM_HEREDOC_QUOTE_DOUBLE =
'"',
78 PM_HEREDOC_QUOTE_BACKTICK =
'`',
85 PM_HEREDOC_INDENT_NONE,
86 PM_HEREDOC_INDENT_DASH,
87 PM_HEREDOC_INDENT_TILDE,
254#define PM_LEX_STACK_SIZE 4
The abstract syntax tree.
uint16_t pm_node_flags_t
These are the flags embedded in the node struct.
pm_heredoc_indent_t
The type of indentation that a heredoc uses.
struct pm_context_node pm_context_node_t
This is a node in a linked list of contexts.
#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...
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.
pm_lex_state_t
This enum combines the various bits from the above enum into individual values that represent the var...
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.
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 ...
pm_context_t
While parsing, we keep track of a stack of contexts.
@ PM_CONTEXT_ELSIF
an elsif clause
@ PM_CONTEXT_ENSURE_DEF
an ensure statement within a method definition
@ PM_CONTEXT_ELSE
an else clause
@ PM_CONTEXT_FOR_INDEX
a for loop's index
@ PM_CONTEXT_CASE_WHEN
a case when statements
@ PM_CONTEXT_MODULE
a module declaration
@ PM_CONTEXT_DEF_PARAMS
a method definition's parameters
@ PM_CONTEXT_CASE_IN
a case in statements
@ PM_CONTEXT_SCLASS
a singleton class definition
@ PM_CONTEXT_UNLESS
an unless statement
@ PM_CONTEXT_POSTEXE
an END block
@ PM_CONTEXT_IF
an if statement
@ PM_CONTEXT_RESCUE_DEF
a rescue statement within a method definition
@ PM_CONTEXT_RESCUE
a rescue statement
@ PM_CONTEXT_LAMBDA_BRACES
a lambda expression with braces
@ PM_CONTEXT_PARENS
a parenthesized expression
@ PM_CONTEXT_BLOCK_BRACES
expressions in block arguments using braces
@ PM_CONTEXT_PREEXE
a BEGIN block
@ PM_CONTEXT_RESCUE_ELSE
a rescue else statement
@ PM_CONTEXT_UNTIL
an until statement
@ PM_CONTEXT_FOR
a for loop
@ PM_CONTEXT_PREDICATE
a predicate inside an if/elsif/unless statement
@ PM_CONTEXT_RESCUE_ELSE_DEF
a rescue else statement within a method definition
@ PM_CONTEXT_DEFAULT_PARAMS
a method definition's default parameter
@ PM_CONTEXT_CLASS
a class declaration
@ PM_CONTEXT_MAIN
the top level context
@ PM_CONTEXT_LAMBDA_DO_END
a lambda expression with do..end
@ PM_CONTEXT_BEGIN
a begin statement
@ PM_CONTEXT_ENSURE
an ensure statement
@ PM_CONTEXT_EMBEXPR
an interpolated expression
@ PM_CONTEXT_DEF
a method definition
@ PM_CONTEXT_BLOCK_KEYWORDS
expressions in block arguments using do..end
@ PM_CONTEXT_WHILE
a while statement
pm_comment_type_t
This is the type of a comment that we've found while parsing.
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.
A stack of boolean values.
uint32_t pm_state_stack_t
A struct that represents a stack of boolean values.
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.
The overall constant pool, which stores constants found while parsing.
This is a node in a linked list of contexts.
pm_context_t context
The context that this node represents.
struct pm_context_node * prev
A pointer to the previous context in the linked list.
This struct defines the functions necessary to implement the encoding interface so we can determine h...
When you are lexing through a file, the lexer needs all of the information that the parser additional...
void * data
This opaque pointer is used to provide whatever information the user deemed necessary to the callback...
When lexing Ruby source, the lexer has a small amount of state to tell which kind of token it is curr...
uint8_t terminator
This is the terminator of the list literal.
const uint8_t * ident_start
A pointer to the start of the heredoc identifier.
size_t nesting
This keeps track of the nesting level of the list.
bool interpolation
Whether or not interpolation is allowed in this list.
pm_heredoc_indent_t indent
The type of indentation that the heredoc uses.
uint8_t incrementor
When lexing a list, it takes into account balancing the terminator if the terminator is one of (),...
struct pm_lex_mode * prev
The previous lex state so that it knows how to pop.
pm_heredoc_quote_t quote
The type of quote that the heredoc uses.
@ 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...
@ PM_LEX_EMBVAR
This state is used when we're lexing a variable that is embedded directly inside of a string with the...
@ PM_LEX_REGEXP
This state is used when a regular expression has been begun and we are looking for the terminator.
@ PM_LEX_DEFAULT
This state is used when any given token is being lexed.
@ PM_LEX_HEREDOC
This state is used when you are inside the content of a heredoc.
@ PM_LEX_EMBEXPR
This state is used when we're lexing as normal but inside an embedded expression of a 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...
bool label_allowed
Whether or not at the end of the string we should allow a :, which would indicate this was a dynamic ...
union pm_lex_mode::@91 as
The data associated with this type of lex mode.
const uint8_t * next_start
This is the pointer to the character where lexing should resume once the heredoc has been completely ...
size_t ident_length
The length of the heredoc identifier.
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...
enum pm_lex_mode::@90 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.
This struct represents an abstract linked list that provides common functionality.
This represents the overall linked list.
This represents a range of bytes in the source string to which a node or token corresponds.
A list of offsets of newlines in a string.
This struct represents the overall parser.
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...
pm_lex_state_t lex_state
The current state of the lexer.
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 ...
bool pattern_matching_newlines
This flag indicates that we are currently parsing a pattern matching expression and impacts that calc...
const uint8_t * end
The pointer to the end of the source.
bool recovering
Whether or not we're currently recovering from a syntax error.
pm_node_flags_t integer_base
We want to add a flag to integer nodes that indicates their base.
pm_constant_pool_t constant_pool
This constant pool keeps all of the constants defined throughout the file so that we can reference th...
bool in_keyword_arg
This flag indicates that we are currently parsing a keyword argument.
bool suppress_warnings
Whether or not we should emit warnings.
pm_state_stack_t do_loop_stack
The stack used to determine if a do keyword belongs to the predicate of a while, until,...
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...
pm_string_t filepath_string
This is the path of the file being parsed.
pm_list_t magic_comment_list
The list of magic comments that have been found while parsing.
int lambda_enclosure_nesting
Used to temporarily track the nesting of enclosures to determine if a { is the beginning of a lambda ...
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...
pm_token_t previous
The previous token we were considering.
pm_string_t current_string
This string is used to pass information from the lexer to the parser.
bool encoding_changed
Whether or not the encoding has been changed by a magic comment.
pm_location_t data_loc
The optional location of the END keyword and its contents.
pm_context_node_t * current_context
The current parsing context.
pm_constant_id_t current_param_name
The current parameter name id on parsing its default value.
const uint8_t * start
The pointer to the start of the source.
pm_state_stack_t accepts_block_stack
The stack used to determine if a do keyword belongs to the beginning of a block.
int enclosure_nesting
Tracks the current nesting of (), [], and {}.
pm_list_t error_list
The list of errors that have been found while parsing.
const uint8_t * encoding_comment_start
This pointer indicates where a comment must start if it is to be considered an encoding comment.
pm_token_t current
The current token we're considering.
pm_lex_mode_t stack[PM_LEX_STACK_SIZE]
The stack of lexer modes.
pm_list_t warning_list
The list of warnings that have been found while parsing.
const uint8_t * heredoc_end
This field indicates the end of a heredoc whose identifier was found on the current line.
int brace_nesting
Used to track the nesting of braces to ensure we get the correct value when we are interpolating bloc...
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 ...
int32_t start_line
The line number at the start of the parse.
struct pm_parser::@96 lex_modes
A stack of lex modes.
pm_lex_mode_t * current
The current mode of the lexer.
pm_list_t comment_list
The list of comments that have been found while parsing.
size_t index
The current index into the lexer mode stack.
pm_scope_t * current_scope
The current local scope.
bool command_start
Whether or not we're at the beginning of a command.
bool frozen_string_literal
Whether or not we have found a frozen_string_literal magic comment with a true value.
pm_newline_list_t newline_list
This is the list of newline offsets in the source file.
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...
This struct represents a node in a linked list of scopes.
struct pm_scope * previous
A pointer to the previous scope in the linked list.
pm_constant_id_list_t locals
The IDs of the locals in the given scope.
bool explicit_params
A boolean indicating whether or not this scope has explicit parameters.
bool closed
A boolean indicating whether or not this scope can see into its parent.
uint8_t numbered_parameters
An integer indicating the number of numbered parameters on this scope.
A generic string type that can have various ownership semantics.
This struct represents a token in the Ruby source.