I’m building a parser for an asset xchange format. And I’m including the %token-table directive in the bison file but, from the flex code I just can’t access the table or the constants associated with it. That is when trying to compile this code:
Frame|FrameTransformMatrix|Mesh|MeshNormals|MeshMaterialList|Material {
printf("A keyword: %s\n", yytext);
yylval.charptr_type = yytext;
int i;
for (i = 0; i < YYNTOKENS; i++)
{
if (yytname[i] != 0
&& yytname[i][0] == '"'
&& !strncmp(yytname[i] + 1, yytext, strlen(yytext))
&& yytname[i][strlen(yytext) + 1] == '"'
&& yytname[i][strlen(yytext) + 2] == 0)
return i;
}
}
gcc says both YYNTOKENS and yytname are undeclared. So was the token table finally deprecated and wiped or what’s the deal?
The Bison 2.6.2 manual says (on p82 in the PDF):
It looks like it is supposed to be there.
When I tried a trivial grammar, the table was present:
Notes: the table is static; if you are trying to access it from outside the file, that will not work.
There is an earlier stanza in the source:
This ensures that the token table is defined.