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