Class: Riml::Compiler::Visitor

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

Overview

Base abstract visitor

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Visitor

Returns a new instance of Visitor.



27
28
29
# File 'lib/compiler.rb', line 27

def initialize(options={})
  @propagate_up_tree = options[:propagate_up_tree]
end

Instance Attribute Details

#propagate_up_tree=(value) ⇒ Object

Sets the attribute propagate_up_tree

Parameters:

  • value

    the value to set the attribute propagate_up_tree to.



25
26
27
# File 'lib/compiler.rb', line 25

def propagate_up_tree=(value)
  @propagate_up_tree = value
end

Instance Method Details

#visit(node) ⇒ Object



31
32
33
34
35
# File 'lib/compiler.rb', line 31

def visit(node)
  output = compile(node)
  output << "\n" if node.force_newline and output[-1] != "\n"
  propagate_up_tree(node, output)
end