Previous: Mfcalc Traces, Up: Tracing [Contents][Index]
YYPRINT MacroThe %printer directive was introduced in Bison 1.50 (Novembre 2002).
Before then, YYPRINT provided a similar feature, but only for
terminal symbols and only with the yacc.c skeleton.
Deprecated, will be removed eventually.
If you define YYPRINT, it should take three arguments. The parser
will pass a standard I/O stream, the numeric code for the token type, and
the token value (from yylval).
For yacc.c only. Obsoleted by %printer.
Here is an example of YYPRINT suitable for the multi-function
calculator (see Declarations for mfcalc):
%{
static void print_token_value (FILE *file, int type, YYSTYPE value);
#define YYPRINT(File, Type, Value) \
print_token_value (File, Type, Value)
%}
… %% … %% …
static void
print_token_value (FILE *file, int type, YYSTYPE value)
{
if (type == VAR)
fprintf (file, "%s", value.tptr->name);
else if (type == NUM)
fprintf (file, "%d", value.val);
}
See Enabling Debug Traces for mfcalc, for the
proper use of %printer.