Exception: Rubycc::CompileError

Inherits:
Error
  • Object
show all
Defined in:
lib/rubycc/compile_error.rb

Overview

A diagnostic raised for any user-facing compilation failure (lexing, parsing, ...). Carries enough source location information (N3) to render a gcc-style message with a caret pointing at the offending column.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, filename:, line:, column:, source_line:) ⇒ CompileError

description

the short error text, e.g. "expected ';'"

filename

the source file name for the message header

line

1-based line number

column

1-based column number

source_line

the full text of the offending source line (no newline)



19
20
21
22
23
24
25
26
# File 'lib/rubycc/compile_error.rb', line 19

def initialize(description, filename:, line:, column:, source_line:)
  @description = description
  @filename = filename
  @line = line
  @column = column
  @source_line = source_line
  super(build_message)
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



12
13
14
# File 'lib/rubycc/compile_error.rb', line 12

def column
  @column
end

#descriptionObject (readonly)

Returns the value of attribute description.



12
13
14
# File 'lib/rubycc/compile_error.rb', line 12

def description
  @description
end

#filenameObject (readonly)

Returns the value of attribute filename.



12
13
14
# File 'lib/rubycc/compile_error.rb', line 12

def filename
  @filename
end

#lineObject (readonly)

Returns the value of attribute line.



12
13
14
# File 'lib/rubycc/compile_error.rb', line 12

def line
  @line
end

#source_lineObject (readonly)

Returns the value of attribute source_line.



12
13
14
# File 'lib/rubycc/compile_error.rb', line 12

def source_line
  @source_line
end