manpagez: man pages & more
info bison
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

8.4.3 The YYPRINT Macro

Before %printer support, semantic values could be displayed using the YYPRINT macro, which works only for terminal symbols and only with the ‘yacc.c’ skeleton.

Macro: YYPRINT (stream, token, value);

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 section Declarations for mfcalc):

%{
  static void print_token_value (FILE *, int, YYSTYPE);
  #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);
}

This document was generated on December 1, 2013 using texi2html 5.0.

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.