Class: ASTTree
- Inherits:
-
Object
- Object
- ASTTree
- Defined in:
- lib/ast.rb
Overview
Note:
figure = node, data = leaf
Abstract Syntax Tree for ComeNg
Instance Method Summary collapse
- #add_node(node) ⇒ Object
- #build(figures) ⇒ Object
-
#initialize ⇒ ASTTree
constructor
A new instance of ASTTree.
- #pretty_print ⇒ Object
Constructor Details
#initialize ⇒ ASTTree
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_print ⇒ Object
25 26 27 28 29 |
# File 'lib/ast.rb', line 25 def pretty_print @nodes.each do |node| puts node end end |