Sha256: 769e8fd7eb613b7989d9d18174e82142cbf7e64706fae68e854e529b4c01239b

Contents?: true

Size: 927 Bytes

Versions: 8

Compression:

Stored size: 927 Bytes

Contents

module OrigenVerilog
  module Preprocessor
    # Concatenates all text_block nodes
    class Concatenator < OrigenVerilog::Processor
      def run(node)
        @text_block = nil
        nodes = process_all(node.children)
        nodes << @text_block if @text_block
        node.updated(nil, nodes)
      end

      def on_text_block(node)
        if @text_block
          @text_block = @text_block.updated(:text_block, [@text_block.to_a[0] + node.to_a[0]])
        else
          @text_block = node
        end
        nil
      end
      alias_method :on_comment, :on_text_block

      def on_file(node)
        node = Concatenator.new.run(node)
        if @text_block
          tb = @text_block
          @text_block = nil
          inline [tb, node]
        else
          node
        end
      end

      def handler_missing(node)
        fail "No handler defined for node type: #{node.type}"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
origen_verilog-0.6.3 lib/origen_verilog/preprocessor/contatenator.rb
origen_verilog-0.6.2 lib/origen_verilog/preprocessor/contatenator.rb
origen_verilog-0.6.1 lib/origen_verilog/preprocessor/contatenator.rb
origen_verilog-0.6.0 lib/origen_verilog/preprocessor/contatenator.rb
origen_verilog-0.5.2 lib/origen_verilog/preprocessor/contatenator.rb
origen_verilog-0.5.1 lib/origen_verilog/preprocessor/contatenator.rb
origen_verilog-0.5.0 lib/origen_verilog/preprocessor/contatenator.rb
origen_verilog-0.4.0 lib/origen_verilog/preprocessor/contatenator.rb