Class: Treetop::Compiler::InlineModule

Inherits:
Runtime::SyntaxNode show all
Includes:
InlineModuleMixin
Defined in:
lib/treetop/compiler/node_classes/inline_module.rb

Instance Attribute Summary

Attributes included from InlineModuleMixin

#module_name

Attributes inherited from Runtime::SyntaxNode

#input, #interval, #parent

Instance Method Summary collapse

Methods inherited from Runtime::SyntaxNode

#<=>, #dot_id, #elements, #empty?, #extension_modules, #initialize, #inspect, #nonterminal?, #terminal?, #text_value, #write_dot, #write_dot_file

Constructor Details

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

Instance Method Details

#compile(index, builder, rule) ⇒ Object


15
16
17
18
19
20
# File 'lib/treetop/compiler/node_classes/inline_module.rb', line 15

def compile(index, builder, rule)
  super
  builder.module_declaration(module_name) do
    builder << ruby_code.gsub(/\A\n/, '').rstrip
  end
end

#ruby_codeObject


22
23
24
# File 'lib/treetop/compiler/node_classes/inline_module.rb', line 22

def ruby_code
  elements[1].text_value
end