2
0
mirror of https://github.com/boostorg/parser.git synced 2026-01-19 04:22:13 +00:00

Improve error visualization.

If the parsed string contains tab characters on the failing line,
the underlining in the error message pointed to the wrong position.

This patch adds as many tab characters to the underlining as
there are in the parsed line. So the underlining points to the
correct position.
This commit is contained in:
Andreas Buhr
2025-11-18 09:49:49 +01:00
committed by Zach Laine
parent 885595f7bd
commit bb183cf5ee

View File

@@ -90,6 +90,9 @@ namespace boost { namespace parser {
os << ":\n";
std::string underlining(std::distance(position.line_start, it), ' ');
std::transform(position.line_start, it,
underlining.begin(),
[](auto c) { return c == '\t' ? '\t' : ' ';});
detail::trace_input(os, position.line_start, it, false, 1u << 31);
if (it == last) {
os << '\n' << underlining << "^\n";