help-bison
[Top][All Lists]
Advanced

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

Re: Finding out when a token is consumed


From: Frank Heckenbach
Subject: Re: Finding out when a token is consumed
Date: Wed, 14 May 2003 00:50:51 +0200

Hans Aberg wrote:

> >> >> yybackup:
> >> >>
> >> >>   // Try to make a decision without lookahead:
> >> >>   n_ = pact_[state_];
> >> >>   if (n_ == pact_ninf_)
> >> >>     goto yydefault;
> >> >>
> >> >>   // Read a lookahead token.
> >> >>   if (lookahead_ == empty_) {
> >> >>     YYCDEBUG << "Reading a token: ";
> >> >>     lex_();
> >> >>   }
> ...
> >I don't know exactly where you copied that from (I didn't find
> >`lookahead_ == empty_' in the source of 1.875 or 20030320), but both
> >src/parse-gram.c and data/yacc.c contain:
> >
> >  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
> >  if (yychar == YYEMPTY)
> >    {
> >      YYDPRINTF ((stderr, "Reading a token: "));
> >      yychar = YYLEX;
> >    }
> >
> >which is exactly what I've been saying all the time ...
> 
> The segment is from my C++ skeleton file, which then uses C++ names, clearly.
> 
> Therefore, one has to look for a more general way to describe the feature
> one wants, and then let it be translated via the M4 approach into the
> various skeleton files.

Well, I'm not really familiar with alternative skeletons or with the
difference between C and C++ names, so I guess I'm out of it here. I
feel that it should be quite possible to get this information in a
general way (with the exception for GLR and maybe similar parsers),
but for the details I don't know anough of bison's internals.

> That is why I reluctant to just jump into speculations before having tried
> it out in actual programming. The discussions here helped though to raise
> the topic; I have had need for controlling the lookahead in context
> switches in the past.
> 
> If you now have a good example how to use it, you might try it out
> practically, and then report your findings back here.

Only the example code in my original mail (which seems to work, but
hasn't been used in practice).

Frank

-- 
Frank Heckenbach, address@hidden
http://fjf.gnu.de/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)




reply via email to

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