[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
yy_reduce_print: debug ouput cannot be redirected to a file.
From: |
Sébastien Fricker |
Subject: |
yy_reduce_print: debug ouput cannot be redirected to a file. |
Date: |
Fri, 16 Feb 2007 10:44:52 +0100 |
User-agent: |
Mutt/1.5.9i |
Hi,
here is a small issue in the debug output,
Regards,
Sébastien Fricker
The code of yy_reduce_print is:
static void
yy_reduce_print (yyvsp, yylsp, yyrule)
YYSTYPE *yyvsp;
YYLTYPE *yylsp;
int yyrule;
{
int yynrhs = yyr2[yyrule];
int yyi;
unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
fprintf (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) );
fprintf (stderr, "\n");
}
}
If the use decides to reimplement YYFPRINTF to print the debug output
into a log file (ex: #define YYFPRINTF(F,X...) fprintf(logfile,X)) then
this code is not working.
The solution would be to produce the following code (which is nothing
else than replacinf fprintf through YYFPRINTF):
static void
yy_reduce_print (yyvsp, yylsp, yyrule)
YYSTYPE *yyvsp;
YYLTYPE *yylsp;
int yyrule;
{
int yynrhs = yyr2[yyrule];
int yyi;
unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) );
YYFPRINTF (stderr, "\n");
}
}
--
Sébastien Fricker
signature.asc
Description: Digital signature
- yy_reduce_print: debug ouput cannot be redirected to a file.,
Sébastien Fricker <=