Previous: Mfcalc Traces, Up: Tracing [Contents][Index]
YYPRINT
MacroThe %printer
directive was introduced in Bison 1.50 (November 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 kind, 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 section 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, yytoken_kind_t kind, YYSTYPE value) { if (kind == VAR) fprintf (file, "%s", value.tptr->name); else if (kind == NUM) fprintf (file, "%d", value.val); }
See section Enabling Debug Traces for mfcalc
, for the proper use of %printer
.