Parent

Class/Module Index [+]

Quicksearch

Treetop::Compiler::RubyBuilder

Attributes

address_space[R]
level[R]
ruby[R]

Public Class Methods

new() click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 9
def initialize
  @level = 0
  @address_space = LexicalAddressSpace.new
  @ruby = ""
end

Public Instance Methods

<<(ruby_line) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 15
def <<(ruby_line)              
  return if ruby_line.blank?
  ruby << ruby_line.tabto(level) << "\n"
end
accumulate(left, right) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 60
def accumulate(left, right)
  self << "#{left} << #{right}"
end
assign(left, right) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 48
def assign(left, right)
  if left.instance_of? Array
    self << "#{left.join(', ')} = #{right.join(', ')}"
  else
    self << "#{left} = #{right}"
  end
end
break() click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 86
def break
  self << 'break'
end
class_declaration(name, &block) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 30
def class_declaration(name, &block)
  self << "class #{name}"
  indented(&block)
  self << "end"
end
else_(&block) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 74
def else_(&block)
  self << 'else'
  indented(&block)
  self << 'end'
end
extend(var, module_name) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 56
def extend(var, module_name)
  self << "#{var}.extend(#{module_name})"
end
if_(condition, &block) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 69
def if_(condition, &block)
  if__(condition, &block)
  self << 'end'
end
if__(condition, &block) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 64
def if__(condition, &block)
  self << "if #{condition}"
  indented(&block)
end
in(depth = 2) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 90
def in(depth = 2)
  @level += depth
  self
end
indented(depth = 2) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 24
def indented(depth = 2)
  self.in(depth)
  yield
  self.out(depth)
end
loop(&block) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 80
def loop(&block)
  self << 'loop do'
  indented(&block)
  self << 'end'
end
method_declaration(name, &block) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 42
def method_declaration(name, &block)
  self << "def #{name}"
  indented(&block)
  self << "end"
end
module_declaration(name, &block) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 36
def module_declaration(name, &block)
  self << "module #{name}"
  indented(&block)
  self << "end"
end
newline() click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 20
def newline
  ruby << "\n"
end
next_address() click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 100
def next_address
  address_space.next_address
end
out(depth = 2) click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 95
def out(depth = 2)
  @level -= depth
  self
end
reset_addresses() click to toggle source
# File lib/treetop/compiler/ruby_builder.rb, line 104
def reset_addresses
  address_space.reset_addresses
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.