From e6fdf5f7e20c93bf3989aa7677a0edc6c846255f Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 14 Jun 2020 17:03:40 +0200 Subject: [PATCH] Make PPerror message more verbose: give hint to buggy line segment --- src/frontend/parse-bison.y | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/frontend/parse-bison.y b/src/frontend/parse-bison.y index bc3b55af9..8afc37129 100644 --- a/src/frontend/parse-bison.y +++ b/src/frontend/parse-bison.y @@ -27,6 +27,8 @@ while (0) static void PPerror (YYLTYPE *locp, char **line, struct pnode **retval, char const *); + + static char *keepline; %} %name-prefix "PP" @@ -96,6 +98,7 @@ { $$.num = 0.0; yylloc.start = yylloc.stop = NULL; + keepline = *line; }; %% @@ -170,6 +173,8 @@ PPerror (YYLTYPE *locp, char **line, struct pnode **retval, char const *s) NG_IGNORE(locp); NG_IGNORE(line); NG_IGNORE(retval); - - fprintf (stderr, "%s: %s\n", __func__, s); + char *tmpstr = strstr(keepline, *line); + size_t len = strlen(keepline); + fprintf (stderr, "%s: %s in line segment\n %s\nnear\n %*s\n", + __func__, s, keepline, len, strstr(keepline, *line)); }