Class: Rley::Parser::ErrorReason

Inherits:
Object
  • Object
show all
Defined in:
lib/rley/parser/error_reason.rb

Overview

Abstract class. An instance represents an explanation describing the likely cause of a parse error detected by Rley.

Direct Known Subclasses

ExpectationNotMet, NoInput

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aPosition) ⇒ ErrorReason

Returns a new instance of ErrorReason.



13
14
15
# File 'lib/rley/parser/error_reason.rb', line 13

def initialize(aPosition)
  @position = aPosition
end

Instance Attribute Details

#positionObject (readonly)

The position of the offending input token



8
9
10
# File 'lib/rley/parser/error_reason.rb', line 8

def position
  @position
end

#productionObject (readonly)

The failing production



11
12
13
# File 'lib/rley/parser/error_reason.rb', line 11

def production
  @production
end

Instance Method Details

#inspectObject

Return this reason's class name and message



23
24
25
# File 'lib/rley/parser/error_reason.rb', line 23

def inspect
  "#{self.class.name}: #{message}"
end

#messageObject

Returns the result of invoking reason.to_s.



18
19
20
# File 'lib/rley/parser/error_reason.rb', line 18

def message()
  return self.to_s
end