class YARP::ProgramNode

The top level node of any parse tree.

Attributes

locals[R]

attr_reader locals: Array

statements[R]

attr_reader statements: StatementsNode

Public Class Methods

new(locals, statements, location) click to toggle source

def initialize: (locals: Array, statements: StatementsNode, location: Location) -> void

# File yarp/node.rb, line 8624
def initialize(locals, statements, location)
  @locals = locals
  @statements = statements
  @location = location
end

Public Instance Methods

accept(visitor) click to toggle source

def accept: (visitor: Visitor) -> void

# File yarp/node.rb, line 8631
def accept(visitor)
  visitor.visit_program_node(self)
end
child_nodes() click to toggle source

def child_nodes: () -> Array[nil | Node]

# File yarp/node.rb, line 8636
def child_nodes
  [statements]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

def comment_targets: () -> Array[Node | Location]

# File yarp/node.rb, line 8641
def comment_targets
  [statements]
end
copy(**params) click to toggle source

def copy: (**params) -> ProgramNode

# File yarp/node.rb, line 8646
def copy(**params)
  ProgramNode.new(
    params.fetch(:locals) { locals },
    params.fetch(:statements) { statements },
    params.fetch(:location) { location },
  )
end
deconstruct()

def deconstruct: () -> Array[nil | Node]

Alias for: child_nodes
deconstruct_keys(keys) click to toggle source

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]

# File yarp/node.rb, line 8658
def deconstruct_keys(keys)
  { locals: locals, statements: statements, location: location }
end
inspect(inspector = NodeInspector.new) click to toggle source
# File yarp/node.rb, line 8662
def inspect(inspector = NodeInspector.new)
  inspector << inspector.header(self)
  inspector << "├── locals: #{locals.inspect}\n"
  inspector << "└── statements:\n"
  inspector << inspector.child_node(statements, "    ")
  inspector.to_str
end