Skip to content

Commit

Permalink
cfg-grammar.y: add location reporting to bison debug
Browse files Browse the repository at this point in the history
Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
  • Loading branch information
bazsi committed Jun 3, 2024
1 parent 422dbfb commit 7fe6df7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/cfg-grammar.y
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,40 @@

#define YYMAXDEPTH 20000

static int
main_location_print (FILE *yyo, YYLTYPE const * const yylocp)
{
int res = 0;
int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
const char *last_slash = yylocp->name ? strrchr(yylocp->name, '/') : NULL;

if (last_slash)
fprintf(yyo, "%s:", last_slash + 1);
else
fprintf(yyo, "%s:", yylocp->name);
if (0 <= yylocp->first_line)
{
res += fprintf(yyo, "%d", yylocp->first_line);
if (0 <= yylocp->first_column)
res += fprintf(yyo, ".%d", yylocp->first_column);
}
if (0 <= yylocp->last_line)
{
if (yylocp->first_line < yylocp->last_line)
{
res += fprintf(yyo, "-%d", yylocp->last_line);
if (0 <= end_col)
res += fprintf(yyo, ".%d", end_col);
}
else if (0 <= end_col && yylocp->first_column < end_col)
res += fprintf(yyo, "-%d", end_col);
}
return res;
}

#undef YYLOCATION_PRINT
#define YYLOCATION_PRINT(File, Loc) main_location_print(File, Loc)


}

Expand Down

0 comments on commit 7fe6df7

Please sign in to comment.