Class: Treetop::Compiler::RubyBuilder

### Home Classes Methods

### In Files

- lib/treetop/compiler/ruby_builder.rb

### Parent

Object

### Methods

- ::new
- #<<
- #accumulate
- #assign
- #break
- #class_declaration
- #else_
- #extend
- #if_
- #if__
- #in
- #indented
- #loop
- #method_declaration
- #module_declaration
- #newline
- #next_address
- #out
- #reset_addresses

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Treetop
- Treetop::Compiler
- Treetop::Compiler::AndPredicate
- Treetop::Compiler::AnythingSymbol
- Treetop::Compiler::AtomicExpression
- Treetop::Compiler::CharacterClass
- Treetop::Compiler::Choice
- Treetop::Compiler::DeclarationSequence
- Treetop::Compiler::Grammar
- Treetop::Compiler::GrammarCompiler
- Treetop::Compiler::InlineModule
- Treetop::Compiler::InlineModuleMixin
- Treetop::Compiler::LexicalAddressSpace
- Treetop::Compiler::Metagrammar
- Treetop::Compiler::Metagrammar::BracketExpression0
- Treetop::Compiler::Metagrammar::CharacterClass0
- Treetop::Compiler::Metagrammar::CharacterClass1
- Treetop::Compiler::Metagrammar::CharacterClass2
- Treetop::Compiler::Metagrammar::CharacterClass3
- Treetop::Compiler::Metagrammar::CharacterClass4
- Treetop::Compiler::Metagrammar::Choice0
- Treetop::Compiler::Metagrammar::Choice1
- Treetop::Compiler::Metagrammar::Choice2
- Treetop::Compiler::Metagrammar::CommentToEol0
- Treetop::Compiler::Metagrammar::CommentToEol1
- Treetop::Compiler::Metagrammar::DeclarationSequence0
- Treetop::Compiler::Metagrammar::DeclarationSequence1
- Treetop::Compiler::Metagrammar::DeclarationSequence2
- Treetop::Compiler::Metagrammar::DeclarationSequence3
- Treetop::Compiler::Metagrammar::DoubleQuotedString0
- Treetop::Compiler::Metagrammar::DoubleQuotedString1
- Treetop::Compiler::Metagrammar::Grammar0
- Treetop::Compiler::Metagrammar::Grammar1
- Treetop::Compiler::Metagrammar::GrammarName0
- Treetop::Compiler::Metagrammar::IncludeDeclaration0
- Treetop::Compiler::Metagrammar::IncludeDeclaration1
- Treetop::Compiler::Metagrammar::InlineModule0
- Treetop::Compiler::Metagrammar::InlineModule1
- Treetop::Compiler::Metagrammar::KeywordInsideGrammar0
- Treetop::Compiler::Metagrammar::LabeledExpressionSequenceBody0
- Treetop::Compiler::Metagrammar::LabeledSequencePrimary0
- Treetop::Compiler::Metagrammar::LabeledSequencePrimary1
- Treetop::Compiler::Metagrammar::ModuleDeclaration0
- Treetop::Compiler::Metagrammar::ModuleDeclaration1
- Treetop::Compiler::Metagrammar::ModuleDeclaration2
- Treetop::Compiler::Metagrammar::ModuleDeclaration3
- Treetop::Compiler::Metagrammar::ModuleDeclaration4
- Treetop::Compiler::Metagrammar::ModuleDeclaration5
- Treetop::Compiler::Metagrammar::NamedLabel0
- Treetop::Compiler::Metagrammar::NamedLabel1
- Treetop::Compiler::Metagrammar::NamedLabel2
- Treetop::Compiler::Metagrammar::NodeClassDeclarations0
- Treetop::Compiler::Metagrammar::NodeClassDeclarations1
- Treetop::Compiler::Metagrammar::NodeClassExpression0
- Treetop::Compiler::Metagrammar::NodeClassExpression1
- Treetop::Compiler::Metagrammar::NodeClassExpression2
- Treetop::Compiler::Metagrammar::NodeClassExpression3
- Treetop::Compiler::Metagrammar::NonSpaceChar0
- Treetop::Compiler::Metagrammar::Nonterminal0
- Treetop::Compiler::Metagrammar::Nonterminal1
- Treetop::Compiler::Metagrammar::NullLabel0
- Treetop::Compiler::Metagrammar::OccurrenceRange0
- Treetop::Compiler::Metagrammar::ParenthesizedExpression0
- Treetop::Compiler::Metagrammar::ParenthesizedExpression1
- Treetop::Compiler::Metagrammar::ParsingRule0
- Treetop::Compiler::Metagrammar::ParsingRule1
- Treetop::Compiler::Metagrammar::PredicateBlock0
- Treetop::Compiler::Metagrammar::Primary0
- Treetop::Compiler::Metagrammar::Primary1
- Treetop::Compiler::Metagrammar::Primary2
- Treetop::Compiler::Metagrammar::Primary3
- Treetop::Compiler::Metagrammar::Primary4
- Treetop::Compiler::Metagrammar::Primary5
- Treetop::Compiler::Metagrammar::Primary6
- Treetop::Compiler::Metagrammar::Primary7
- Treetop::Compiler::Metagrammar::QuotedString0
- Treetop::Compiler::Metagrammar::RequireStatement0
- Treetop::Compiler::Metagrammar::Sequence0
- Treetop::Compiler::Metagrammar::Sequence1
- Treetop::Compiler::Metagrammar::SequencePrimary0
- Treetop::Compiler::Metagrammar::SequencePrimary1
- Treetop::Compiler::Metagrammar::SequencePrimary2
- Treetop::Compiler::Metagrammar::SequencePrimary3
- Treetop::Compiler::Metagrammar::SequencePrimary4
- Treetop::Compiler::Metagrammar::SequencePrimary5
- Treetop::Compiler::Metagrammar::SingleQuotedString0
- Treetop::Compiler::Metagrammar::SingleQuotedString1
- Treetop::Compiler::Metagrammar::TrailingInlineModule0
- Treetop::Compiler::Metagrammar::TrailingInlineModule1
- Treetop::Compiler::Metagrammar::TrailingInlineModule2
- Treetop::Compiler::Metagrammar::TreetopFile0
- Treetop::Compiler::Metagrammar::TreetopFile1
- Treetop::Compiler::Metagrammar::TreetopFile2
- Treetop::Compiler::Metagrammar::UnlabeledSequencePrimary0
- Treetop::Compiler::Metagrammar::UnlabeledSequencePrimary1
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody0
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody1
- Treetop::Compiler::Metagrammar::VariableLengthSequenceBody2
- Treetop::Compiler::MetagrammarParser
- Treetop::Compiler::Nonterminal
- Treetop::Compiler::NotPredicate
- Treetop::Compiler::OccurrenceRange
- Treetop::Compiler::OneOrMore
- Treetop::Compiler::Optional
- Treetop::Compiler::ParenthesizedExpression
- Treetop::Compiler::ParsingExpression
- Treetop::Compiler::ParsingRule
- Treetop::Compiler::Predicate
- Treetop::Compiler::PredicateBlock
- Treetop::Compiler::Repetition
- Treetop::Compiler::RubyBuilder
- Treetop::Compiler::Sequence
- Treetop::Compiler::SequenceElementAccessorModule
- Treetop::Compiler::Terminal
- Treetop::Compiler::TransientPrefix
- Treetop::Compiler::TreetopFile
- Treetop::Compiler::ZeroOrMore
- Treetop::Polyglot
- Treetop::Runtime
- Treetop::Runtime::CompiledParser
- Treetop::Runtime::SyntaxNode
- Treetop::Runtime::TerminalParseFailure
- Treetop::Runtime::TerminalSyntaxNode
- IntervalSkipList
- IntervalSkipList::HeadNode
- IntervalSkipList::Node
- Object
- String

No matching classes.

# 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.