Class: SyntaxTree::Bf::Root

Inherits:
Node
  • Object
show all
Defined in:
lib/syntax_tree/bf/nodes.rb

Overview

The root node of the syntax tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#format, #pretty_print

Constructor Details

#initialize(nodes:, location:) ⇒ Root

Returns a new instance of Root.



19
20
21
22
# File 'lib/syntax_tree/bf/nodes.rb', line 19

def initialize(nodes:, location:)
  @nodes = nodes
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



17
18
19
# File 'lib/syntax_tree/bf/nodes.rb', line 17

def location
  @location
end

#nodesObject (readonly)

Returns the value of attribute nodes.



17
18
19
# File 'lib/syntax_tree/bf/nodes.rb', line 17

def nodes
  @nodes
end

Instance Method Details

#accept(visitor) ⇒ Object



24
25
26
# File 'lib/syntax_tree/bf/nodes.rb', line 24

def accept(visitor)
  visitor.visit_root(self)
end

#child_nodesObject Also known as: deconstruct



28
29
30
# File 'lib/syntax_tree/bf/nodes.rb', line 28

def child_nodes
  nodes
end

#deconstruct_keys(keys) ⇒ Object



34
35
36
# File 'lib/syntax_tree/bf/nodes.rb', line 34

def deconstruct_keys(keys)
  { nodes: nodes, location: location }
end