module · Ruby 4.0
Prism::DSL
171 instance methods
The DSL module provides a set of methods that can be used to create prism nodes in a more concise manner. For example, instead of writing:
Example
source = Prism::Source.for("[1]") Prism::ArrayNode.new( source, 0, Prism::Location.new(source, 0, 3), 0, [ Prism::IntegerNode.new( source, 0, Prism::Location.new(source, 1, 1), Prism::IntegerBaseFlags::DECIMAL, 1 ) ], Prism::Location.new(source, 0, 1), Prism::Location.new(source, 2, 1) )
you could instead write:
Example
class Builder include Prism::DSL attr_reader :default_source def initialize @default_source = source("[1]") end def build array_node( location: location(start_offset: 0, length: 3), elements: [ integer_node( location: location(start_offset: 1, length: 1), flags: integer_base_flag(:decimal), value: 1 ) ], opening_loc: location(start_offset: 0, length: 1), closing_loc: location(start_offset: 2, length: 1) ) end end
This is mostly helpful in the context of generating trees programmatically.
Instance methods 171
#alias_global_variable_node
#alias_method_node
#alternation_pattern_node
#and_node
#arguments_node
#arguments_node_flag
#array_node
#array_node_flag
#array_pattern_node
#assoc_node
#assoc_splat_node
#back_reference_read_node
#begin_node
#block_argument_node
#block_local_variable_node
#block_node
#block_parameter_node
#block_parameters_node
#break_node
#call_and_write_node
#call_node
#call_node_flag
#call_operator_write_node
#call_or_write_node
#call_target_node
#capture_pattern_node
#case_match_node
#case_node
#class_node
#class_variable_and_write_node
#class_variable_operator_write_node
#class_variable_or_write_node
#class_variable_read_node
#class_variable_target_node
#class_variable_write_node
#constant_and_write_node
#constant_operator_write_node
#constant_or_write_node
#constant_path_and_write_node
#constant_path_node
#constant_path_operator_write_node
#constant_path_or_write_node
#constant_path_target_node
#constant_path_write_node
#constant_read_node
#constant_target_node
#constant_write_node
#default_location
#default_node
#default_source
#defined_node
#def_node
#else_node
#embedded_statements_node
#embedded_variable_node
#encoding_flag
#ensure_node
#false_node
#find_pattern_node
#flip_flop_node
#float_node
#for_node
#forwarding_arguments_node
#forwarding_parameter_node
#forwarding_super_node
#global_variable_and_write_node
#global_variable_operator_write_node
#global_variable_or_write_node
#global_variable_read_node
#global_variable_target_node
#global_variable_write_node
#hash_node
#hash_pattern_node
#if_node
#imaginary_node
#implicit_node
#implicit_rest_node
#index_and_write_node
#index_operator_write_node
#index_or_write_node
#index_target_node
#in_node
#instance_variable_and_write_node
#instance_variable_operator_write_node
#instance_variable_or_write_node
#instance_variable_read_node
#instance_variable_target_node
#instance_variable_write_node
#integer_base_flag
#integer_node
#interpolated_match_last_line_node
#interpolated_regular_expression_node
#interpolated_string_node
#interpolated_string_node_flag
#interpolated_symbol_node
#interpolated_x_string_node
#it_local_variable_read_node
#it_parameters_node
#keyword_hash_node
#keyword_hash_node_flag
#keyword_rest_parameter_node
#lambda_node
#local_variable_and_write_node
#local_variable_operator_write_node
#local_variable_or_write_node
#local_variable_read_node
#local_variable_target_node
#local_variable_write_node
#location
#loop_flag
#match_last_line_node
#match_predicate_node
#match_required_node
#match_write_node
#missing_node
#module_node
#multi_target_node
#multi_write_node
#next_node
#nil_node
#no_keywords_parameter_node
#numbered_parameters_node
#numbered_reference_read_node
#optional_keyword_parameter_node
#optional_parameter_node
#or_node
#parameter_flag
#parameters_node
#parentheses_node
#parentheses_node_flag
#pinned_expression_node
#pinned_variable_node
#post_execution_node
#pre_execution_node
#program_node
#range_flag
#range_node
#rational_node
#redo_node
#regular_expression_flag
#regular_expression_node
#required_keyword_parameter_node
#required_parameter_node
#rescue_modifier_node
#rescue_node
#rest_parameter_node
#retry_node
#return_node
#self_node
#shareable_constant_node
#shareable_constant_node_flag
#singleton_class_node
#source
#source_encoding_node
#source_file_node
#source_line_node
#splat_node
#statements_node
#string_flag
#string_node
#super_node
#symbol_flag
#symbol_node
#true_node
#undef_node
#unless_node
#until_node
#when_node
#while_node
#x_string_node
#yield_node