String literals in %token, where are they stored?
Maury Markowitz <[email protected]> Mon, 19 May 2025 19:08:49 -0400
| Newsgroups | gmane.comp.parsers.bison.general |
|---|---|
| Message-ID | <[email protected]> |
I was going through some old emails looking for another topic when I = came across a post by Christian Schoenebeck: > That even seems to work in combination with type specifiers and string=20= > literals: >=20 > %token <sval> ONE "one" > %token <ival> TWO "two" > %token <dval> THREE "three" I had skipped over this bit, but now I think I need to understand it. First, consider these definitions in .y: %token FOR %token TO "->" %token STROP 1000 "step" Reading the "Token Kind Names" doc, and tables.h, I am not clear where = these bits end up. I assume the first item, "FOR", "TO" and "STROP", end up in yytname, and = that in this case we might expect to see something like 280, 281 and = 1000 in yytoknum. Is that correct? If so, where are the string literals stored? Is there a collection I can = iterate? Or is there some way I can get to them through yytname or = yytoknum? If there is an easy way to iterate over these literals, it seems it = could fix a very thorny problem I've been thinking about for some time.