[Top][All Lists]

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

Re: [bug-bison] Bug in string-valued terminals

From: Joel E. Denny
Subject: Re: [bug-bison] Bug in string-valued terminals
Date: Wed, 29 Dec 2010 20:31:15 -0500 (EST)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

Hi Tom,

I've added help-bison.  Maybe someone there will know more.

On Wed, 29 Dec 2010, Tom Roberts wrote:

> Ok. I decided to not use yytoknum[], as it is undocumented and also requires a
> funky "#define YYPRINT". Here is the code I am using inside yylex():

>                 for(int i=0; i<YYNTOKENS; ++i) {
>                         if(yytname[i][0] != '"') continue;
>                         string name(yytname[i]+1);
>                         name.erase(name.size()-1,1);
>                         for(int j=YYMAXUTOK; j>0; --j) {
>                                 if(yytranslate[j] == i) {
>                                         keyword[name] = j;
>                                         break;

Isn't your inner loop sufficient?  The body could just translate and index 
into yytname.

In any case, YYMAXUTOK and yytranslate are not documented for users 

Again, it would be great if someone could recall how %token-table and the 
yytname table it generates were originally intended to be used.  The 
trouble is that yytname indices are internal token numbers, but there 
seems to be no mechanism that is documented for the Bison user to 
translate internal token numbers to user token numbers (which are the 
token numbers returned by yylex).  How then is yytname useful?

reply via email to

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