Sha256: a987a977de296895e4a496d3ce954a120f2b6eecf0f9ef314df9c67cc4b8fc63

Contents?: true

Size: 675 Bytes

Versions: 13

Compression:

Stored size: 675 Bytes

Contents

module OrigenVerilog
  module Preprocessor
    class Writer < OrigenVerilog::Processor
      # Write the given ast to the given file
      def run(file, ast)
        File.open(file, 'w') do |file|
          @file = file
          process(ast)
        end
      end

      # Write the given ast to a string and returns it
      def to_s(ast)
        @file = ''
        process(ast)
        @file
      end

      def on_text_block(node)
        if f.is_a?(String)
          f << node.to_a[0]
        else
          f.write(node.to_a[0])
        end
      end
      alias_method :on_comment, :on_text_block

      private

      def f
        @file
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
origen_verilog-0.6.3 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.6.2 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.6.1 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.6.0 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.5.2 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.5.1 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.5.0 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.4.0 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.3.1 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.3.0 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.2.2 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.2.1 lib/origen_verilog/preprocessor/writer.rb
origen_verilog-0.2.0 lib/origen_verilog/preprocessor/writer.rb