Class: ASTTree

Inherits:
Object
  • Object
show all
Defined in:
lib/ast.rb

Overview

Note:

figure = node, data = leaf

Abstract Syntax Tree for ComeNg

Instance Method Summary collapse

Constructor Details

#initializeASTTree

Returns a new instance of ASTTree.



10
11
12
13
# File 'lib/ast.rb', line 10

def initialize
  @root = 'SITAC'
  @nodes = []
end

Instance Method Details

#add_node(node) ⇒ Object



15
16
17
# File 'lib/ast.rb', line 15

def add_node(node)
  @nodes << node
end

#build(figures) ⇒ Object



19
20
21
22
23
# File 'lib/ast.rb', line 19

def build(figures)
  figures.each do |figure|
    add_node(ASTNode.new(figure))
  end
end

#pretty_printObject



25
26
27
28
29
# File 'lib/ast.rb', line 25

def pretty_print
  @nodes.each do |node|
    puts node
  end
end