YAwn: Fix off-by-one error in error message
@@ -53,8 +53,9 @@ string ErrorListener::visualizeError (Location const & location, string const &
errorLine = prefix + errorLine + "\n" + prefix + string (location.begin.column - 1, ' ');
// We assume that an error does not span more than one line
start = location.begin.column;
- end = location.end.column;
- for (size_t current = start; current <= end; current++)
+ end = location.end.column - 1;
+ errorLine += "^"; // Show at least one caret, even if the token is 0 characters long
+ for (size_t current = start; current < end; current++)
{
errorLine += "^";
}
