Exception: Cucumber::Parser::SyntaxError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/cucumber/parser/treetop_ext.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser, file, line_offset) ⇒ SyntaxError

Returns a new instance of SyntaxError.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cucumber/parser/treetop_ext.rb', line 29

def initialize(parser, file, line_offset)
  tf = parser.terminal_failures
  expected = tf.size == 1 ? tf[0].expected_string.inspect : "one of #{tf.map{|f| f.expected_string.inspect}.uniq*', '}"
  after = parser.input[parser.index...parser.failure_index]
  found = parser.input[parser.failure_index..parser.failure_index]
  
  line = parser.failure_line + line_offset
  message = "#{file}:#{line}:#{parser.failure_column}: " +
    "Parse error, expected #{expected}. After #{after.inspect}. Found: #{found.inspect}"
  super(message)
end