Exception: Yarr::InputParser::ParseError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/yarr/input_parser.rb

Overview

Error raised when parsing fails

Instance Method Summary collapse

Constructor Details

#initialize(parslet_error) ⇒ ParseError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This class should be only instantiated from within the Yarr::InputParser


79
80
81
# File 'lib/yarr/input_parser.rb', line 79

def initialize(parslet_error)
  @parslet_error = parslet_error
end

Instance Method Details

#report(message) ⇒ String

Reports the parse error occurred


86
87
88
89
90
91
# File 'lib/yarr/input_parser.rb', line 86

def report(message)
  cause = @parslet_error.parse_failure_cause
  position = cause.pos.charpos
  puts cause.ascii_tree if Yarr.config.development?
  "parser error at position #{position} around `#{message[position]}'"
end