# File lib/ruby-vpi/verilog_parser.rb, line 104 104: def verilog_to_ruby 105: content = self.dup 106: 107: # single-line comments 108: content.gsub! %r{//(.*)$}, '#\1' 109: 110: # multi-line comments 111: content.gsub! %r{/\*.*?\*/}m, "\n=begin\n\\0\n=end\n" 112: 113: # preprocessor directives 114: content.gsub! %r{`include}, '#\0' 115: 116: content.gsub! %r{`define\s+(\w+)\s+(.+)} do 117: "#{$1.to_ruby_const_name} = #{$2}" 118: end 119: 120: content.gsub! %r{`+}, '' 121: 122: # numbers 123: content.gsub! %r{\d*\'([dohb]\w+)}, '0\1' 124: 125: # ranges 126: content.gsub! %r{(\S)\s*:\s*(\S)}, '\1..\2' 127: 128: content 129: end