Re: yytname woes

Hans Ã…berg <[email protected]> Mon, 13 Nov 2023 19:14:55 +0100
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
> On Nov 12, 2023, at 18:18, James K. Lowden <[email protected]> =
wrote:
>=20
> On Mon, 13 Nov 2023 10:52:02 +0100
> Hans =C3=85berg <[email protected]> wrote:
>=20
>>> Let's start, shall we, with "is it a bug"? =20
>>=20
>> The parser knows how to translate token numbers into names for error
>> messages, but there is no API for that as far as I know.
>=20
> I disagree.  Bison might know how to do that, but "the parser" does
> not.

Read the generated parser code: Error message strings are generated by =
translating token numbers into symbol names, first into the =
symbol-number mentioned.

>  Bison is a parser-generator.  I'm writing "the parser" using
> Bison. I implemented yyerror(). I'm producing the error message using
> the only vehicle I've found, yytname.  It's insufficient to the
> purpose.

It generates an error message string, which one is expected to use. Not =
the internal tables directly.