Sha256: 47776f47ce239acfba028f33de1e09dcb1659b47214e83d3bdf45597b109e080

Contents?: true

Size: 933 Bytes

Versions: 8

Compression:

Stored size: 933 Bytes

Contents

module OrigenVerilog
  module Preprocessor
    # Invokes the Verilog parser on all text_block nodes, transforming the
    # given pre-processor output AST into a Verilog AST
    class VerilogParser < OrigenVerilog::Processor
      def run(node, options = {})
        @nodes = []
        @file = options[:file]
        @options = options
        process_all(node.children)
        Verilog::Node.new(:verilog_source, @nodes, file: @file)
      end

      def on_text_block(node)
        node = Verilog::Parser.parse(node.to_a[0], @options.merge(file: @file))
        @nodes += node.children
        nil
      end

      def on_file(node)
        file, *nodes = *node
        node = VerilogParser.new.run(node.updated(nil, nodes), @options.merge(file: file))
        @nodes += node.children
        nil
      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/verilog_parser.rb
origen_verilog-0.6.2 lib/origen_verilog/preprocessor/verilog_parser.rb
origen_verilog-0.6.1 lib/origen_verilog/preprocessor/verilog_parser.rb
origen_verilog-0.6.0 lib/origen_verilog/preprocessor/verilog_parser.rb
origen_verilog-0.5.2 lib/origen_verilog/preprocessor/verilog_parser.rb
origen_verilog-0.5.1 lib/origen_verilog/preprocessor/verilog_parser.rb
origen_verilog-0.5.0 lib/origen_verilog/preprocessor/verilog_parser.rb
origen_verilog-0.4.0 lib/origen_verilog/preprocessor/verilog_parser.rb