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 either. 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? _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison