Exception: RLTK::LexingError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rltk/lexer.rb

Overview

A LexingError exception is raised when an input stream contains a substring that isn’t matched by any of a lexer’s rules.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream_offset, line_number, line_offset, remainder) ⇒ LexingError

Returns a new instance of LexingError.

Parameters:

  • stream_offset (Integer)

    Offset from begnning of string.

  • line_number (Integer)

    Number of newlines encountered so far.

  • line_offset (Integer)

    Offset from beginning of line.

  • remainder (String)

    Rest of the string that couldn’t be lexed.



40
41
42
43
44
45
# File 'lib/rltk/lexer.rb', line 40

def initialize(stream_offset, line_number, line_offset, remainder)
	@stream_offset	= stream_offset
	@line_number	= line_number
	@line_offset	= line_offset
	@remainder	= remainder
end

Instance Attribute Details

#line_numberInteger (readonly)

Returns:

  • (Integer)


28
29
30
# File 'lib/rltk/lexer.rb', line 28

def line_number
  @line_number
end

#line_offsetInteger (readonly)

Returns:

  • (Integer)


31
32
33
# File 'lib/rltk/lexer.rb', line 31

def line_offset
  @line_offset
end

#remainderString (readonly)

Returns:

  • (String)


34
35
36
# File 'lib/rltk/lexer.rb', line 34

def remainder
  @remainder
end

#stream_offsetInteger (readonly)

Returns:

  • (Integer)


25
26
27
# File 'lib/rltk/lexer.rb', line 25

def stream_offset
  @stream_offset
end

Instance Method Details

#to_sString

Returns String representation of the error.

Returns:

  • (String)

    String representation of the error.



48
49
50
# File 'lib/rltk/lexer.rb', line 48

def to_s
	"#{super()}: #{@remainder}"
end