Class
A compiler is a visitor that returns the value of each node as it visits. This is as opposed to a visitor which will only walk the tree. This can be useful when you are trying to compile a tree into a different format.
For example, to build a representation of the tree as s-expressions, you could write:
class SExpressions < Prism::Compiler def visit_arguments_node(node) = [:arguments, super] def visit_call_node(node) = [:call, super] def visit_integer_node(node) = [:integer] def visit_program_node(node) = [:program, super] end Prism.parse("1 + 2").value.accept(SExpressions.new) # => [:program, [[[:call, [[:integer], [:arguments, [[:integer]]]]]]]]
Instance Methods
lib/prism/compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/compiler.rb, line 29
def visit(node)
node&.accept(self)
end
Visit an individual node.
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/compiler.rb, line 34
def visit_all(nodes)
nodes.map { |node| node&.accept(self) }
end
Visit a list of nodes.
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/compiler.rb, line 39
def visit_child_nodes(node)
node.compact_child_nodes.map { |node| node.accept(self) }
end
Visit the child nodes of the given node.
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes
lib/prism/compiler.rb
View on GitHub
An alias for visit_child_nodes