Here's a hack to do what I want: #define YYDEBUG 1 #define YYFPRINTF yyfprintf
void yyfprintf
(FILE *hfile, // Ignore this
char *lpszFmt, // Format string
...) // Zero or more arguments
{
va_list vl;
int i1, i2, i3;
static char szTemp[256] = {'\0'};
char szTemp2[128];
va_start (vl, lpszFmt);
// Bison uses no more than three arguments.
// Note we must grab them separately this way
// as using va_arg in the argument list to
// wsprintf pushes the arguments in reverse
// order.
i1 = va_arg (vl, int);
i2 = va_arg (vl, int);
i3 = va_arg (vl, int);
wsprintf (szTemp2,
lpszFmt,
i1,
i2,
i3);
// Accumulate into local buffer because
// Bison calls this function multiple
// times for the same line, terminating
// the last call for the line with a LF.
lstrcat (szTemp, szTemp2);
// Check last character.
i1 = lstrlen (szTemp);
// If it's a LF, it's time to flush the buffer.
if (szTemp[i1 - 1] EQ '\n')
{
szTemp[i1 - 1] = '\0'; // Remove trailing LF
// because we're displaying
// in a GUI.
DbgMsg (szTemp); // Display in my debugger window.
szTemp[0] = '\0'; // Restart the buffer.
} // End IF/ELSE
va_end (vl);
} // End yyfprintf
On 10/26/2006 11:58 AM, Bob Smith wrote:
I must be missing something. I am already using yyerror () to capture error messages ("syntax error", "memory exhausted", etc.), but I want to capture debugging output as well. That output is, by default, sent directly to stderr by the YYFPRINTF #define.Also, I see no reference to a global yytext in the C output file (perhaps you meant ctxt?).Sorry, but I don't see how yyerror can be used to accomplish this. On 10/26/2006 2:50 AM, Ramaswamy R wrote:You should be able to use the function yyerror to capture the debugmessages. The function prototype would be like this in a re-entrant parser -int yyerror(void *ctxt, const char *msg) { if ( 0 == yytext[0] ) return fprintf(stderr, "\n%s.", msg); else return fprintf(stderr, "\n%s at '%s'.", msg, asntext); }I believe the ctxt would not be there in a non re-entrant version (globals being used if context information is required). You can use this function todo what you want with the message. Hope this helps.
-- _______________________________________________________________ Bob Smith - [EMAIL PROTECTED] - http://www.sudleyplace.com
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ [email protected] http://lists.gnu.org/mailman/listinfo/help-bison
