Next: Semantic Values of Tokens, Previous: Special Tokens, Up: The Lexical Analyzer Function yylex [Contents][Index]
If the grammar uses literal string tokens, there are two ways that
yylex can determine the token kind codes for them:
yylex can use these symbolic names like all others.
In this case, the use of the literal string tokens in the grammar file has
no effect on yylex.
This is the preferred approach.
yylex can search for the multicharacter token in the yytname
table. This method is discouraged: the primary purpose of string aliases is
forging good error messages, not describing the spelling of keywords. In
addition, looking for the token kind at runtime incurs a (small but
noticeable) cost.
The yytname table is generated only if you use the
%token-table declaration. See Bison Declaration Summary.