Class: Rley::Parser::UnexpectedToken
- Inherits:
-
ExpectationNotMet
- Object
- ErrorReason
- ExpectationNotMet
- Rley::Parser::UnexpectedToken
- Defined in:
- lib/rley/parser/error_reason.rb
Overview
This parse error occurs when the current token from the input is unexpected according to the grammar rules.
Instance Attribute Summary
Attributes inherited from ExpectationNotMet
#expected_terminals, #last_token
Attributes inherited from ErrorReason
Instance Method Summary collapse
-
#to_s ⇒ Object
Returns the reason's message.
Methods inherited from ExpectationNotMet
Methods inherited from ErrorReason
#initialize, #inspect, #message
Constructor Details
This class inherits a constructor from Rley::Parser::ExpectationNotMet
Instance Method Details
#to_s ⇒ Object
Returns the reason's message.
86 87 88 89 90 91 92 93 |
# File 'lib/rley/parser/error_reason.rb', line 86 def to_s err_msg = +"Syntax error at or near token #{position} " err_msg << ">>>#{last_token.lexeme}<<<\n" err_msg << expectations err_msg << ", found a '#{last_token.terminal}' instead." return err_msg end |