[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to set friendly name for "$end"?
From: |
Szabolcs Horvát |
Subject: |
How to set friendly name for "$end"? |
Date: |
Fri, 6 May 2022 11:12:49 +0200 |
Hello,
Error messages issued by Bison-generated parsers sometimes mention the
special token "$end", which is confusing to end users. Normal tokens
can be given a friendly names using
%token MYTOKEN "my token"
Is it possible to set a friendly name for $end as well?
Recent versions of Bison format $end as "end of file". I am looking
for a solution that works in older versions as well. Version 3.5 is a
must, versions 3.0 and 2.3 (which ships with macOS) are highly
preferable.
One solution that has been proposed to me (see
https://stackoverflow.com/q/72130611/695132) is to use
%token END 0 "end of file"
This does indeed work in all versions, including 2.3. But it is
unclear to me if it is safe. Is it guaranteed that $end corresponds to
0?
Thanks for any hints in advance,
Szabolcs
- How to set friendly name for "$end"?,
Szabolcs Horvát <=