Crate ruby_prism

Source
Expand description

§ruby-prism

Rustified version of Ruby’s prism parser.

Structs§

AliasGlobalVariableNode
Represents the use of the alias keyword to alias a global variable.
AliasMethodNode
Represents the use of the alias keyword to alias a method.
AlternationPatternNode
Represents an alternation pattern in pattern matching.
AndNode
Represents the use of the && operator or the and keyword.
ArgumentsNode
Represents a set of arguments to a method or a keyword.
ArrayNode
Represents an array literal. This can be a regular array using brackets or a special array using % like %w or %i.
ArrayPatternNode
Represents an array pattern in pattern matching.
AssocNode
Represents a hash key/value pair.
AssocSplatNode
Represents a splat in a hash literal.
BackReferenceReadNode
Represents reading a reference to a field in the previous match.
BeginNode
Represents a begin statement.
BlockArgumentNode
Represents a block argument using &.
BlockLocalVariableNode
Represents a block local variable.
BlockNode
Represents a block of ruby code.
BlockParameterNode
Represents a block parameter of a method, block, or lambda definition.
BlockParametersNode
Represents a block’s parameters declaration.
BreakNode
Represents the use of the break keyword.
CallAndWriteNode
Represents the use of the &&= operator on a call.
CallNode
Represents a method call, in all of the various forms that can take.
CallOperatorWriteNode
Represents the use of an assignment operator on a call.
CallOrWriteNode
Represents the use of the ||= operator on a call.
CallTargetNode
Represents assigning to a method call.
CapturePatternNode
Represents assigning to a local variable in pattern matching.
CaseMatchNode
Represents the use of a case statement for pattern matching.
CaseNode
Represents the use of a case statement.
ClassNode
Represents a class declaration involving the class keyword.
ClassVariableAndWriteNode
Represents the use of the &&= operator for assignment to a class variable.
ClassVariableOperatorWriteNode
Represents assigning to a class variable using an operator that isn’t =.
ClassVariableOrWriteNode
Represents the use of the ||= operator for assignment to a class variable.
ClassVariableReadNode
Represents referencing a class variable.
ClassVariableTargetNode
Represents writing to a class variable in a context that doesn’t have an explicit value.
ClassVariableWriteNode
Represents writing to a class variable.
Comment
A comment that was found during parsing.
Comments
A struct created by the comments method on ParseResult. It can be used to iterate over the comments in the parse result.
ConstantAndWriteNode
Represents the use of the &&= operator for assignment to a constant.
ConstantId
A handle for a constant ID.
ConstantList
A list of constants.
ConstantListIter
An iterator over the constants in a list.
ConstantOperatorWriteNode
Represents assigning to a constant using an operator that isn’t =.
ConstantOrWriteNode
Represents the use of the ||= operator for assignment to a constant.
ConstantPathAndWriteNode
Represents the use of the &&= operator for assignment to a constant path.
ConstantPathNode
Represents accessing a constant through a path of :: operators.
ConstantPathOperatorWriteNode
Represents assigning to a constant path using an operator that isn’t =.
ConstantPathOrWriteNode
Represents the use of the ||= operator for assignment to a constant path.
ConstantPathTargetNode
Represents writing to a constant path in a context that doesn’t have an explicit value.
ConstantPathWriteNode
Represents writing to a constant path.
ConstantReadNode
Represents referencing a constant.
ConstantTargetNode
Represents writing to a constant in a context that doesn’t have an explicit value.
ConstantWriteNode
Represents writing to a constant.
DefNode
Represents a method definition.
DefinedNode
Represents the use of the defined? keyword.
Diagnostic
A diagnostic message that came back from the parser.
Diagnostics
A struct created by the errors or warnings methods on ParseResult. It can be used to iterate over the diagnostics in the parse result.
ElseNode
Represents an else clause in a case, if, or unless statement.
EmbeddedStatementsNode
Represents an interpolated set of statements.
EmbeddedVariableNode
Represents an interpolated variable.
EnsureNode
Represents an ensure clause in a begin statement.
FalseNode
Represents the use of the literal false keyword.
FindPatternNode
Represents a find pattern in pattern matching.
FlipFlopNode
Represents the use of the .. or ... operators to create flip flops.
FloatNode
Represents a floating point number literal.
ForNode
Represents the use of the for keyword.
ForwardingArgumentsNode
Represents forwarding all arguments to this method to another method.
ForwardingParameterNode
Represents the use of the forwarding parameter in a method, block, or lambda declaration.
ForwardingSuperNode
Represents the use of the super keyword without parentheses or arguments.
GlobalVariableAndWriteNode
Represents the use of the &&= operator for assignment to a global variable.
GlobalVariableOperatorWriteNode
Represents assigning to a global variable using an operator that isn’t =.
GlobalVariableOrWriteNode
Represents the use of the ||= operator for assignment to a global variable.
GlobalVariableReadNode
Represents referencing a global variable.
GlobalVariableTargetNode
Represents writing to a global variable in a context that doesn’t have an explicit value.
GlobalVariableWriteNode
Represents writing to a global variable.
HashNode
Represents a hash literal.
HashPatternNode
Represents a hash pattern in pattern matching.
IfNode
Represents the use of the if keyword, either in the block form or the modifier form, or a ternary expression.
ImaginaryNode
Represents an imaginary number literal.
ImplicitNode
Represents a node that is implicitly being added to the tree but doesn’t correspond directly to a node in the source.
ImplicitRestNode
Represents using a trailing comma to indicate an implicit rest parameter.
InNode
Represents the use of the in keyword in a case statement.
IndexAndWriteNode
Represents the use of the &&= operator on a call to the [] method.
IndexOperatorWriteNode
Represents the use of an assignment operator on a call to [].
IndexOrWriteNode
Represents the use of the ||= operator on a call to [].
IndexTargetNode
Represents assigning to an index.
InstanceVariableAndWriteNode
Represents the use of the &&= operator for assignment to an instance variable.
InstanceVariableOperatorWriteNode
Represents assigning to an instance variable using an operator that isn’t =.
InstanceVariableOrWriteNode
Represents the use of the ||= operator for assignment to an instance variable.
InstanceVariableReadNode
Represents referencing an instance variable.
InstanceVariableTargetNode
Represents writing to an instance variable in a context that doesn’t have an explicit value.
InstanceVariableWriteNode
Represents writing to an instance variable.
Integer
A handle for an arbitarily-sized integer.
IntegerNode
Represents an integer number literal.
InterpolatedMatchLastLineNode
Represents a regular expression literal that contains interpolation that is being used in the predicate of a conditional to implicitly match against the last line read by an IO object.
InterpolatedRegularExpressionNode
Represents a regular expression literal that contains interpolation.
InterpolatedStringNode
Represents a string literal that contains interpolation.
InterpolatedSymbolNode
Represents a symbol literal that contains interpolation.
InterpolatedXStringNode
Represents an xstring literal that contains interpolation.
ItLocalVariableReadNode
Represents reading from the implicit it local variable.
ItParametersNode
Represents an implicit set of parameters through the use of the it keyword within a block or lambda.
KeywordHashNode
Represents a hash literal without opening and closing braces.
KeywordRestParameterNode
Represents a keyword rest parameter to a method, block, or lambda definition.
LambdaNode
Represents using a lambda literal (not the lambda method call).
LocalVariableAndWriteNode
Represents the use of the &&= operator for assignment to a local variable.
LocalVariableOperatorWriteNode
Represents assigning to a local variable using an operator that isn’t =.
LocalVariableOrWriteNode
Represents the use of the ||= operator for assignment to a local variable.
LocalVariableReadNode
Represents reading a local variable. Note that this requires that a local variable of the same name has already been written to in the same scope, otherwise it is parsed as a method call.
LocalVariableTargetNode
Represents writing to a local variable in a context that doesn’t have an explicit value.
LocalVariableWriteNode
Represents writing to a local variable.
Location
A range in the source file.
MagicComment
A magic comment that was found during parsing.
MagicComments
A struct created by the magic_comments method on ParseResult. It can be used to iterate over the magic comments in the parse result.
MatchLastLineNode
Represents a regular expression literal used in the predicate of a conditional to implicitly match against the last line read by an IO object.
MatchPredicateNode
Represents the use of the modifier in operator.
MatchRequiredNode
Represents the use of the => operator.
MatchWriteNode
Represents writing local variables using a regular expression match with named capture groups.
MissingNode
Represents a node that is missing from the source and results in a syntax error.
ModuleNode
Represents a module declaration involving the module keyword.
MultiTargetNode
Represents a multi-target expression.
MultiWriteNode
Represents a write to a multi-target expression.
NextNode
Represents the use of the next keyword.
NilNode
Represents the use of the nil keyword.
NoKeywordsParameterNode
Represents the use of **nil inside method arguments.
NodeList
A list of nodes.
NodeListIter
An iterator over the nodes in a list.
NumberedParametersNode
Represents an implicit set of parameters through the use of numbered parameters within a block or lambda.
NumberedReferenceReadNode
Represents reading a numbered reference to a capture in the previous match.
OptionalKeywordParameterNode
Represents an optional keyword parameter to a method, block, or lambda definition.
OptionalParameterNode
Represents an optional parameter to a method, block, or lambda definition.
OrNode
Represents the use of the || operator or the or keyword.
ParametersNode
Represents the list of parameters on a method, block, or lambda definition.
ParenthesesNode
Represents a parenthesized expression
ParseResult
The result of parsing a source string.
PinnedExpressionNode
Represents the use of the ^ operator for pinning an expression in a pattern matching expression.
PinnedVariableNode
Represents the use of the ^ operator for pinning a variable in a pattern matching expression.
PostExecutionNode
Represents the use of the END keyword.
PreExecutionNode
Represents the use of the BEGIN keyword.
ProgramNode
The top level node of any parse tree.
RangeNode
Represents the use of the .. or ... operators.
RationalNode
Represents a rational number literal.
RedoNode
Represents the use of the redo keyword.
RegularExpressionNode
Represents a regular expression literal with no interpolation.
RequiredKeywordParameterNode
Represents a required keyword parameter to a method, block, or lambda definition.
RequiredParameterNode
Represents a required parameter to a method, block, or lambda definition.
RescueModifierNode
Represents an expression modified with a rescue.
RescueNode
Represents a rescue statement.
RestParameterNode
Represents a rest parameter to a method, block, or lambda definition.
RetryNode
Represents the use of the retry keyword.
ReturnNode
Represents the use of the return keyword.
SelfNode
Represents the self keyword.
ShareableConstantNode
This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified.
SingletonClassNode
Represents a singleton class declaration involving the class keyword.
SourceEncodingNode
Represents the use of the __ENCODING__ keyword.
SourceFileNode
Represents the use of the __FILE__ keyword.
SourceLineNode
Represents the use of the __LINE__ keyword.
SplatNode
Represents the use of the splat operator.
StatementsNode
Represents a set of statements contained within some scope.
StringNode
Represents a string literal, a string contained within a %w list, or plain string content within an interpolated string.
SuperNode
Represents the use of the super keyword with parentheses or arguments.
SymbolNode
Represents a symbol literal or a symbol contained within a %i list.
TrueNode
Represents the use of the literal true keyword.
UndefNode
Represents the use of the undef keyword.
UnlessNode
Represents the use of the unless keyword, either in the block form or the modifier form.
UntilNode
Represents the use of the until keyword, either in the block form or the modifier form.
WhenNode
Represents the use of the when keyword within a case statement.
WhileNode
Represents the use of the while keyword, either in the block form or the modifier form.
XStringNode
Represents an xstring literal with no interpolation.
YieldNode
Represents the use of the yield keyword.

Enums§

Node
An enum representing the different kinds of nodes that can be parsed.

Traits§

Visit
A trait for visiting the AST.

Functions§

parse
Parses the given source string and returns a parse result.
visit_alias_global_variable_node
The default visitor implementation for a AliasGlobalVariableNode node.
visit_alias_method_node
The default visitor implementation for a AliasMethodNode node.
visit_alternation_pattern_node
The default visitor implementation for a AlternationPatternNode node.
visit_and_node
The default visitor implementation for a AndNode node.
visit_arguments_node
The default visitor implementation for a ArgumentsNode node.
visit_array_node
The default visitor implementation for a ArrayNode node.
visit_array_pattern_node
The default visitor implementation for a ArrayPatternNode node.
visit_assoc_node
The default visitor implementation for a AssocNode node.
visit_assoc_splat_node
The default visitor implementation for a AssocSplatNode node.
visit_back_reference_read_node
The default visitor implementation for a BackReferenceReadNode node.
visit_begin_node
The default visitor implementation for a BeginNode node.
visit_block_argument_node
The default visitor implementation for a BlockArgumentNode node.
visit_block_local_variable_node
The default visitor implementation for a BlockLocalVariableNode node.
visit_block_node
The default visitor implementation for a BlockNode node.
visit_block_parameter_node
The default visitor implementation for a BlockParameterNode node.
visit_block_parameters_node
The default visitor implementation for a BlockParametersNode node.
visit_break_node
The default visitor implementation for a BreakNode node.
visit_call_and_write_node
The default visitor implementation for a CallAndWriteNode node.
visit_call_node
The default visitor implementation for a CallNode node.
visit_call_operator_write_node
The default visitor implementation for a CallOperatorWriteNode node.
visit_call_or_write_node
The default visitor implementation for a CallOrWriteNode node.
visit_call_target_node
The default visitor implementation for a CallTargetNode node.
visit_capture_pattern_node
The default visitor implementation for a CapturePatternNode node.
visit_case_match_node
The default visitor implementation for a CaseMatchNode node.
visit_case_node
The default visitor implementation for a CaseNode node.
visit_class_node
The default visitor implementation for a ClassNode node.
visit_class_variable_and_write_node
The default visitor implementation for a ClassVariableAndWriteNode node.
visit_class_variable_operator_write_node
The default visitor implementation for a ClassVariableOperatorWriteNode node.
visit_class_variable_or_write_node
The default visitor implementation for a ClassVariableOrWriteNode node.
visit_class_variable_read_node
The default visitor implementation for a ClassVariableReadNode node.
visit_class_variable_target_node
The default visitor implementation for a ClassVariableTargetNode node.
visit_class_variable_write_node
The default visitor implementation for a ClassVariableWriteNode node.
visit_constant_and_write_node
The default visitor implementation for a ConstantAndWriteNode node.
visit_constant_operator_write_node
The default visitor implementation for a ConstantOperatorWriteNode node.
visit_constant_or_write_node
The default visitor implementation for a ConstantOrWriteNode node.
visit_constant_path_and_write_node
The default visitor implementation for a ConstantPathAndWriteNode node.
visit_constant_path_node
The default visitor implementation for a ConstantPathNode node.
visit_constant_path_operator_write_node
The default visitor implementation for a ConstantPathOperatorWriteNode node.
visit_constant_path_or_write_node
The default visitor implementation for a ConstantPathOrWriteNode node.
visit_constant_path_target_node
The default visitor implementation for a ConstantPathTargetNode node.
visit_constant_path_write_node
The default visitor implementation for a ConstantPathWriteNode node.
visit_constant_read_node
The default visitor implementation for a ConstantReadNode node.
visit_constant_target_node
The default visitor implementation for a ConstantTargetNode node.
visit_constant_write_node
The default visitor implementation for a ConstantWriteNode node.
visit_def_node
The default visitor implementation for a DefNode node.
visit_defined_node
The default visitor implementation for a DefinedNode node.
visit_else_node
The default visitor implementation for a ElseNode node.
visit_embedded_statements_node
The default visitor implementation for a EmbeddedStatementsNode node.
visit_embedded_variable_node
The default visitor implementation for a EmbeddedVariableNode node.
visit_ensure_node
The default visitor implementation for a EnsureNode node.
visit_false_node
The default visitor implementation for a FalseNode node.
visit_find_pattern_node
The default visitor implementation for a FindPatternNode node.
visit_flip_flop_node
The default visitor implementation for a FlipFlopNode node.
visit_float_node
The default visitor implementation for a FloatNode node.
visit_for_node
The default visitor implementation for a ForNode node.
visit_forwarding_arguments_node
The default visitor implementation for a ForwardingArgumentsNode node.
visit_forwarding_parameter_node
The default visitor implementation for a ForwardingParameterNode node.
visit_forwarding_super_node
The default visitor implementation for a ForwardingSuperNode node.
visit_global_variable_and_write_node
The default visitor implementation for a GlobalVariableAndWriteNode node.
visit_global_variable_operator_write_node
The default visitor implementation for a GlobalVariableOperatorWriteNode node.
visit_global_variable_or_write_node
The default visitor implementation for a GlobalVariableOrWriteNode node.
visit_global_variable_read_node
The default visitor implementation for a GlobalVariableReadNode node.
visit_global_variable_target_node
The default visitor implementation for a GlobalVariableTargetNode node.
visit_global_variable_write_node
The default visitor implementation for a GlobalVariableWriteNode node.
visit_hash_node
The default visitor implementation for a HashNode node.
visit_hash_pattern_node
The default visitor implementation for a HashPatternNode node.
visit_if_node
The default visitor implementation for a IfNode node.
visit_imaginary_node
The default visitor implementation for a ImaginaryNode node.
visit_implicit_node
The default visitor implementation for a ImplicitNode node.
visit_implicit_rest_node
The default visitor implementation for a ImplicitRestNode node.
visit_in_node
The default visitor implementation for a InNode node.
visit_index_and_write_node
The default visitor implementation for a IndexAndWriteNode node.
visit_index_operator_write_node
The default visitor implementation for a IndexOperatorWriteNode node.
visit_index_or_write_node
The default visitor implementation for a IndexOrWriteNode node.
visit_index_target_node
The default visitor implementation for a IndexTargetNode node.
visit_instance_variable_and_write_node
The default visitor implementation for a InstanceVariableAndWriteNode node.
visit_instance_variable_operator_write_node
The default visitor implementation for a InstanceVariableOperatorWriteNode node.
visit_instance_variable_or_write_node
The default visitor implementation for a InstanceVariableOrWriteNode node.
visit_instance_variable_read_node
The default visitor implementation for a InstanceVariableReadNode node.
visit_instance_variable_target_node
The default visitor implementation for a InstanceVariableTargetNode node.
visit_instance_variable_write_node
The default visitor implementation for a InstanceVariableWriteNode node.
visit_integer_node
The default visitor implementation for a IntegerNode node.
visit_interpolated_match_last_line_node
The default visitor implementation for a InterpolatedMatchLastLineNode node.
visit_interpolated_regular_expression_node
The default visitor implementation for a InterpolatedRegularExpressionNode node.
visit_interpolated_string_node
The default visitor implementation for a InterpolatedStringNode node.
visit_interpolated_symbol_node
The default visitor implementation for a InterpolatedSymbolNode node.
visit_interpolated_x_string_node
The default visitor implementation for a InterpolatedXStringNode node.
visit_it_local_variable_read_node
The default visitor implementation for a ItLocalVariableReadNode node.
visit_it_parameters_node
The default visitor implementation for a ItParametersNode node.
visit_keyword_hash_node
The default visitor implementation for a KeywordHashNode node.
visit_keyword_rest_parameter_node
The default visitor implementation for a KeywordRestParameterNode node.
visit_lambda_node
The default visitor implementation for a LambdaNode node.
visit_local_variable_and_write_node
The default visitor implementation for a LocalVariableAndWriteNode node.
visit_local_variable_operator_write_node
The default visitor implementation for a LocalVariableOperatorWriteNode node.
visit_local_variable_or_write_node
The default visitor implementation for a LocalVariableOrWriteNode node.
visit_local_variable_read_node
The default visitor implementation for a LocalVariableReadNode node.
visit_local_variable_target_node
The default visitor implementation for a LocalVariableTargetNode node.
visit_local_variable_write_node
The default visitor implementation for a LocalVariableWriteNode node.
visit_match_last_line_node
The default visitor implementation for a MatchLastLineNode node.
visit_match_predicate_node
The default visitor implementation for a MatchPredicateNode node.
visit_match_required_node
The default visitor implementation for a MatchRequiredNode node.
visit_match_write_node
The default visitor implementation for a MatchWriteNode node.
visit_missing_node
The default visitor implementation for a MissingNode node.
visit_module_node
The default visitor implementation for a ModuleNode node.
visit_multi_target_node
The default visitor implementation for a MultiTargetNode node.
visit_multi_write_node
The default visitor implementation for a MultiWriteNode node.
visit_next_node
The default visitor implementation for a NextNode node.
visit_nil_node
The default visitor implementation for a NilNode node.
visit_no_keywords_parameter_node
The default visitor implementation for a NoKeywordsParameterNode node.
visit_numbered_parameters_node
The default visitor implementation for a NumberedParametersNode node.
visit_numbered_reference_read_node
The default visitor implementation for a NumberedReferenceReadNode node.
visit_optional_keyword_parameter_node
The default visitor implementation for a OptionalKeywordParameterNode node.
visit_optional_parameter_node
The default visitor implementation for a OptionalParameterNode node.
visit_or_node
The default visitor implementation for a OrNode node.
visit_parameters_node
The default visitor implementation for a ParametersNode node.
visit_parentheses_node
The default visitor implementation for a ParenthesesNode node.
visit_pinned_expression_node
The default visitor implementation for a PinnedExpressionNode node.
visit_pinned_variable_node
The default visitor implementation for a PinnedVariableNode node.
visit_post_execution_node
The default visitor implementation for a PostExecutionNode node.
visit_pre_execution_node
The default visitor implementation for a PreExecutionNode node.
visit_program_node
The default visitor implementation for a ProgramNode node.
visit_range_node
The default visitor implementation for a RangeNode node.
visit_rational_node
The default visitor implementation for a RationalNode node.
visit_redo_node
The default visitor implementation for a RedoNode node.
visit_regular_expression_node
The default visitor implementation for a RegularExpressionNode node.
visit_required_keyword_parameter_node
The default visitor implementation for a RequiredKeywordParameterNode node.
visit_required_parameter_node
The default visitor implementation for a RequiredParameterNode node.
visit_rescue_modifier_node
The default visitor implementation for a RescueModifierNode node.
visit_rescue_node
The default visitor implementation for a RescueNode node.
visit_rest_parameter_node
The default visitor implementation for a RestParameterNode node.
visit_retry_node
The default visitor implementation for a RetryNode node.
visit_return_node
The default visitor implementation for a ReturnNode node.
visit_self_node
The default visitor implementation for a SelfNode node.
visit_shareable_constant_node
The default visitor implementation for a ShareableConstantNode node.
visit_singleton_class_node
The default visitor implementation for a SingletonClassNode node.
visit_source_encoding_node
The default visitor implementation for a SourceEncodingNode node.
visit_source_file_node
The default visitor implementation for a SourceFileNode node.
visit_source_line_node
The default visitor implementation for a SourceLineNode node.
visit_splat_node
The default visitor implementation for a SplatNode node.
visit_statements_node
The default visitor implementation for a StatementsNode node.
visit_string_node
The default visitor implementation for a StringNode node.
visit_super_node
The default visitor implementation for a SuperNode node.
visit_symbol_node
The default visitor implementation for a SymbolNode node.
visit_true_node
The default visitor implementation for a TrueNode node.
visit_undef_node
The default visitor implementation for a UndefNode node.
visit_unless_node
The default visitor implementation for a UnlessNode node.
visit_until_node
The default visitor implementation for a UntilNode node.
visit_when_node
The default visitor implementation for a WhenNode node.
visit_while_node
The default visitor implementation for a WhileNode node.
visit_x_string_node
The default visitor implementation for a XStringNode node.
visit_yield_node
The default visitor implementation for a YieldNode node.