From bb183cf5ee0a8e30d53b6a5fdffcdbdc53b3bee7 Mon Sep 17 00:00:00 2001 From: Andreas Buhr Date: Tue, 18 Nov 2025 09:49:49 +0100 Subject: [PATCH] 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. --- include/boost/parser/error_handling.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/boost/parser/error_handling.hpp b/include/boost/parser/error_handling.hpp index 3215c4c9..4843b498 100644 --- a/include/boost/parser/error_handling.hpp +++ b/include/boost/parser/error_handling.hpp @@ -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";