Broke dependency on facets and trying to coexist with Rails.
[treetop.git] / lib / treetop / compiler / node_classes / inline_module.rb
blobd77f4b641955df90745644c7c212ecea08686d5b
1 module Treetop
2   module Compiler
3     module InlineModuleMixin
4       attr_reader :module_name
5       
6       def compile(index, rule, builder)
7         @module_name = "#{rule.name.treetop_camelize}#{index}"
8       end
9     end
10     
11     class InlineModule < Runtime::SyntaxNode
13       include InlineModuleMixin
14       
15       def compile(index, rule, builder)
16         super
17         builder.module_declaration(module_name) do
18           builder << ruby_code.gsub(/\A\n/, '').rstrip
19         end
20       end
21       
22       def ruby_code
23         elements[1].text_value
24       end
25     end
26   end
27 end