Exception: Inform::UnexpectedToken

Inherits:
StandardError
  • Object
show all
Defined in:
lib/runtime/grammar_parser.rb

Overview

The UnexpectedToken error class

Constant Summary collapse

UnknownString =
'unknown'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected, found) ⇒ UnexpectedToken

Returns a new instance of UnexpectedToken.



242
243
244
245
246
247
248
# File 'lib/runtime/grammar_parser.rb', line 242

def initialize(expected, found)
  super()
  @expected = expected
  @found = found
  @file = UnknownString
  @line = UnknownString
end

Instance Attribute Details

#file=(value) ⇒ Object (writeonly)

Sets the attribute file

Parameters:

  • value

    the value to set the attribute file to.



240
241
242
# File 'lib/runtime/grammar_parser.rb', line 240

def file=(value)
  @file = value
end

#line=(value) ⇒ Object (writeonly)

Sets the attribute line

Parameters:

  • value

    the value to set the attribute line to.



240
241
242
# File 'lib/runtime/grammar_parser.rb', line 240

def line=(value)
  @line = value
end

Instance Method Details

#to_sObject



250
251
252
# File 'lib/runtime/grammar_parser.rb', line 250

def to_s
  "(#{@file}):#{@line}: token error, unexpected '#{@found}', expecting '#{@expected}'"
end