Method: FuPeg::Parser#fail!

Defined in:
lib/fupeg/parser.rb

#fail!(pat: nil, skip: 2) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/fupeg/parser.rb', line 41

def fail!(*, pat: nil, skip: 2)
  if debug || !@failed || bytepos > @failed.bytepos
    stack = caller_locations(skip)
    stack.delete_if do |loc|
      path = loc.path
      if path == __FILE__
        true
      elsif path.start_with?(__dir__)
        loc.label =~ /\b(backtrack|each|block)\b/
      end
    end
    @failed = Fail.new(stack, bytepos, pat)
    report_failed($stderr) if debug
  end
  nil
end