Hi Akim, Ok, thanks for the feedback! I haven't found any better either so I implemented it and it seems to work but need to test it thoroughfully. Fortunately, as the mapping is generated as well, it's not tedious at all:)
Best regards, r0ller -------- Eredeti levél -------- Feladó: Akim Demaille < [email protected] (Link -> mailto:[email protected]) > Dátum: 2018 december 17 06:28:28 Tárgy: Re: mapping token identifier to value Címzett: r0ller < [email protected] (Link -> mailto:[email protected]) > Hi! > Le 14 déc. 2018 à 14:21, r0ller <[email protected]> a écrit : > > Hi Akim, > > I'm trying to get rid of numbering tokens and let bison do that but it seems > to be more difficult than I thought. Although, I managed to come up with an > idea as I'm anyway generating the bison source I could generate a map like: > > std::map<std::string, unsigned int> symbol2token={<!-- --> > { "t_Con", yy::parser::token::t_Con }, > ... > }; > > and could then get the values simply by: > > symbol2token.find("t_Con")->second; > > However, still wanted to ask if there's any better solution maybe one that I > overlooked and is provided by bison itself;) I personally would go for this solution. I agree it is tedious, but that's anyway what happens in a typically scanner in Lex. And that's probably something you already do somewhere, but with your own token numbers assigned by hand, so it's probably not very different. _______________________________________________ [email protected] https://lists.gnu.org/mailman/listinfo/help-bison
