Exception: VerilogTools::ParseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/HDLRuby/verilog_parser.rb

Overview

The class describing parse errors.

Instance Method Summary collapse

Constructor Details

#initialize(msg, line, lpos, cpos, filename) ⇒ ParseError

Create a new parse error with message +msg+, faulty line text +line_text+, line number +lpos+, column +cpos+, and possibly file name +filename+.



99
100
101
102
103
104
105
106
# File 'lib/HDLRuby/verilog_parser.rb', line 99

def initialize(msg,line,lpos,cpos,filename)
  @msg  = msg.to_s
  @line = line.to_s.gsub(/\t/," ")
  @lpos = lpos.to_i
  @cpos = cpos.to_i
  @filename = filename.to_s if filename
  super(self.make_message)
end

Instance Method Details

#make_messageObject

Generate the error message. NOTE: if you want to translate the error message, please redefine the function.



111
112
113
114
115
116
117
118
119
# File 'lib/HDLRuby/verilog_parser.rb', line 111

def make_message
  if @filename then
    head = "Parse error in file '#{@filename}' "
  else
    head = "Parse error "
  end
  return head + "line #{@lpos}: " + @msg + ".\n" + "#{@line}\n" +
    ("-" * (@cpos)) + "^"
end