0

I'm learning Bison in generating c++ parser.

Since %token-table is obsolescent, is there any alternatives to get the name from token integer value in c++ parser?

linrongbin
  • 2,967
  • 6
  • 31
  • 59

1 Answers1

1

You can use yysymbol_name(), described in the manual section on syntax error reporting.

The C++ API apparently has a similar method on the parser context object, called symbol_name. (See this future question for more information about C++.)

rici
  • 234,347
  • 28
  • 237
  • 341
  • Hi, since I'm using Bison to generate a c++ parser, I didn't find any API named `yysymbol_name()`. Does it support c++ ? – linrongbin Aug 25 '20 at 07:37
  • @linrongbin: you shouldn't tag with two language tags unless you are prepared to accept an answer in either language. I would be very surprised if the C++ API doesn't have that feature but since I hardly ever use the C++ API, I don't know what it is. – rici Aug 25 '20 at 07:48
  • Otoh, it didn't take long to find by looking through the manual. You should try that :-) – rici Aug 25 '20 at 07:54