Sha256: 6ece3c9c1221e799432de9b0c847ee9728277f4e70f13937d5ec18afe72020c9

Contents?: true

Size: 803 Bytes

Versions: 165

Compression:

Stored size: 803 Bytes

Contents

module Treetop
  module Compiler
    class Grammar < Runtime::SyntaxNode
      def compile
        builder = RubyBuilder.new
        
        builder.module_declaration "#{grammar_name.text_value}" do
          builder.in(indent_level) # account for initial indentation of grammar declaration
          builder << "include Treetop::Runtime"
          builder.newline
          declaration_sequence.compile(builder)
        end
        builder.newline
        builder.class_declaration "#{parser_name} < Treetop::Runtime::CompiledParser" do
          builder << "include #{grammar_name.text_value}"
        end
      end
      
      def indent_level
        input.column_of(interval.begin) - 1
      end
      
      def parser_name
        grammar_name.text_value + 'Parser'
      end
    end
 end 
end

Version data entries

165 entries across 135 versions & 14 rubygems

Version Path
depengine-0.0.17 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.16 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.16 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.15 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.15 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.14 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.14 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.13 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.13 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.12 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.12 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.11 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.11 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.10 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.10 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.9 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.9 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.8 etc/isolate/jruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.8 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb
depengine-0.0.7 etc/isolate/ruby-1.8/gems/treetop-1.4.8/lib/treetop/compiler/node_classes/grammar.rb