Class: Nodes

Inherits:
Struct
  • Object
show all
Defined in:
lib/toylang/ast/nodes.rb,
lib/toylang/interpreter/evaluation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nodesObject

Returns the value of attribute nodes

Returns:

  • (Object)

    the current value of nodes



3
4
5
# File 'lib/toylang/ast/nodes.rb', line 3

def nodes
  @nodes
end

Instance Method Details

#<<(node) ⇒ Object



4
5
6
7
# File 'lib/toylang/ast/nodes.rb', line 4

def <<(node)
  nodes << node
  self
end

#eval(context) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/toylang/interpreter/evaluation.rb', line 11

def eval(context)
  return_value = nil
  nodes.each do |node|
    return_value = node.eval(context)
  end
  return_value || Runtime['nil']
end