Class: Treetop::Compiler::DeclarationSequence

Inherits:
Runtime::SyntaxNode show all
Defined in:
lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/declaration_sequence.rb

Instance Attribute Summary

Attributes inherited from Runtime::SyntaxNode

#elements, #input, #interval, #parent

Instance Method Summary collapse

Methods inherited from Runtime::SyntaxNode

#empty?, #extension_modules, #initialize, #inspect, #nonterminal?, #terminal?, #text_value

Constructor Details

This class inherits a constructor from Treetop::Runtime::SyntaxNode

Instance Method Details

#compile(builder) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/declaration_sequence.rb', line 5

def compile(builder)
  unless rules.empty?
    builder.method_declaration("root") do
      builder << "@root || :#{rules.first.name}"
    end
    builder.newline
  end
  
  declarations.each do |declaration|
    declaration.compile(builder)
    builder.newline
  end
end

#rulesObject



19
20
21
# File 'lib/gems/treetop-1.2.4/lib/treetop/compiler/node_classes/declaration_sequence.rb', line 19

def rules
  declarations.select { |declaration| declaration.instance_of?(ParsingRule) }
end