help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: yytoknum and YYPRINT


From: Akim Demaille
Subject: Re: yytoknum and YYPRINT
Date: Mon, 18 Nov 2002 10:23:22 +0100
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu)

 Tim> Is yytoknum intended to be available to the user?

src/bison/doc % grep yytoknum bison.texinfo
src/bison/doc %

Nope.

 Tim> It's just that we had a function in most our .y files that
 Tim> returned a given token's name (for use in internal tracing etc).
 Tim> Using yytoknum and yytname for this worked quite nicely.

Can you show us the actual code?  Is it the feature that you need, or
really these two guys?

 Tim> But now yytoknum's visibility depends on YYPRINT being defined;
 Tim> this seems to make little sense to me, 

Nope, it does: that's the only place where we need this information.


src/bison/data % fgrep yytoknum c.m4 -C 10                                      
                                                   nostromo 10:22
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;
b4_location_if([  (void) yylocationp;
])dnl

  if (yytype < YYNTOKENS)
    {
      YYFPRINTF (yyout, "token %s (", yytname[[yytype]]);
# ifdef YYPRINT
      YYPRINT (yyout, yytoknum[[yytype]], *yyvaluep);
# endif
    }
  else
    YYFPRINTF (yyout, "nterm %s (", yytname[[yytype]]);

  switch (yytype)
    {
m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))dnl
      default:
        break;


 Tim> Also, the bison manual's example for a YYPRINT function displays
 Tim> values with leading spaces; given that YYPRINT's output is
 Tim> enclosed in parens, I don't think a leading space is very
 Tim> appropriate.

Correct, thanks!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]