Sha256: e8240b9384ab2fab3007d887787526f047eea0877556e71c129ac139b52ee2bc

Contents?: true

Size: 569 Bytes

Versions: 83

Compression:

Stored size: 569 Bytes

Contents

module Treetop
  module Compiler
    class DeclarationSequence < Runtime::SyntaxNode

      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
      
      def rules
        declarations.select { |declaration| declaration.instance_of?(ParsingRule) }
      end
    end
  end
end

Version data entries

83 entries across 83 versions & 13 rubygems

Version Path
treetop-1.2.3 lib/treetop/compiler/node_classes/declaration_sequence.rb
treetop-1.2.0 lib/treetop/compiler/node_classes/declaration_sequence.rb
treetop-1.2.2 lib/treetop/compiler/node_classes/declaration_sequence.rb