Class: Rley::Parser::ExpectationNotMet

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

Overview

Abstract class and subclass of ErrorReason. This specialization represents errors in which the input didn't match one of the expected token.

Direct Known Subclasses

PrematureInputEnd, UnexpectedToken

Instance Attribute Summary collapse

Attributes inherited from ErrorReason

#rank

Instance Method Summary collapse

Methods inherited from ErrorReason

#inspect, #message

Constructor Details

#initialize(aRank, lastToken, expectedTerminals) ⇒ ExpectationNotMet

Returns a new instance of ExpectationNotMet.

Raises:

  • (StandardError)


53
54
55
56
57
58
59
# File 'lib/rley/parser/error_reason.rb', line 53

def initialize(aRank, lastToken, expectedTerminals)
  super(aRank)
  raise StandardError, 'Internal error: nil token' if lastToken.nil?

  @last_token = lastToken.dup
  @expected_terminals = expectedTerminals.dup
end

Instance Attribute Details

#expected_terminalsObject (readonly)

The terminal symbols expected when error was occurred



51
52
53
# File 'lib/rley/parser/error_reason.rb', line 51

def expected_terminals
  @expected_terminals
end

#last_tokenObject (readonly)

The last input token read when error was detected



48
49
50
# File 'lib/rley/parser/error_reason.rb', line 48

def last_token
  @last_token
end