Exception: Layo::UnexpectedTokenError
- Inherits:
-
SyntaxError
- Object
- RuntimeError
- SyntaxError
- Layo::UnexpectedTokenError
- Defined in:
- lib/layo/unexpected_token_error.rb
Instance Attribute Summary
Attributes inherited from SyntaxError
Instance Method Summary collapse
-
#initialize(token) ⇒ UnexpectedTokenError
constructor
A new instance of UnexpectedTokenError.
- #token2str(token) ⇒ Object
Methods inherited from SyntaxError
Constructor Details
#initialize(token) ⇒ UnexpectedTokenError
Returns a new instance of UnexpectedTokenError.
3 4 5 |
# File 'lib/layo/unexpected_token_error.rb', line 3 def initialize(token) super(token[:line], token[:pos], "Unexpected token #{token2str(token)}") end |
Instance Method Details
#token2str(token) ⇒ Object
7 8 9 10 11 |
# File 'lib/layo/unexpected_token_error.rb', line 7 def token2str(token) result = "'#{token[:type].to_s}'" result << " (#{token[:data].to_s})" if token.has_key?(:data) result end |