[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Finding out when a token is consumed
From: |
Hans Aberg |
Subject: |
Re: Finding out when a token is consumed |
Date: |
Tue, 13 May 2003 10:43:05 +0200 |
At 01:38 +0200 2003/05/13, Frank Heckenbach wrote:
>> >> It would be nice with a feature that tells whether the lookahead is
>>needed
>> >> or not, so one can implement sure context switches. While at tweaking the
>> >> skeleton files, there is a segment:
>> >>
>> >> 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.
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.
Hans Aberg
- Re: Finding out when a token is consumed, (continued)
- Message not available
- Re: Finding out when a token is consumed, Hans Aberg, 2003/05/09
- Re: Finding out when a token is consumed, Frank Heckenbach, 2003/05/09
- Re: Finding out when a token is consumed, Hans Aberg, 2003/05/10
- Re: Finding out when a token is consumed, Frank Heckenbach, 2003/05/10
- Re: Finding out when a token is consumed, Hans Aberg, 2003/05/10
- Re: Finding out when a token is consumed, Frank Heckenbach, 2003/05/10
- Re: Finding out when a token is consumed, Hans Aberg, 2003/05/11
- Re: Finding out when a token is consumed, Frank Heckenbach, 2003/05/11
- Re: Finding out when a token is consumed, Hans Aberg, 2003/05/12
- Re: Finding out when a token is consumed, Frank Heckenbach, 2003/05/12
- Re: Finding out when a token is consumed,
Hans Aberg <=
- Re: Finding out when a token is consumed, Frank Heckenbach, 2003/05/13
- Re: Finding out when a token is consumed, Hans Aberg, 2003/05/14
- Re: Finding out when a token is consumed, Frank Heckenbach, 2003/05/14
- Re: Finding out when a token is consumed, Hans Aberg, 2003/05/15
- include files in bison parser, Vitaliy Ziskin, 2003/05/10
- Re: include files in bison parser, Hans Aberg, 2003/05/10
Re: Finding out when a token is consumed, David Fletcher, 2003/05/09