62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/fupeg/parser.rb', line 62
def report_failed(out)
pos = position(bytepos: @failed.bytepos)
out << if @failed.pattern
"Failed #{failed.pattern.inspect} at #{pos.lineno}:#{pos.colno}"
else
"Failed at #{pos.lineno}:#{pos.colno}"
end
if @file
out << " of #{@file}"
end
out << ":\n"
out << pos.line.chomp + "\n"
curpos = pos.line[...pos.colno].gsub("\t", " " * 8).size
curpos = 1 if curpos == 0 && @failed.bytepos == @str.bytesize
out << (" " * (curpos - 1) + "^\n")
out << "Call stack:\n"
@failed.stack.each do |loc|
out << "#{loc.path}:#{loc.lineno} in #{loc.label}\n"
end
out
end
|