On 2022-06-17 10:26, slipbits wrote:
3.1.2 Prologue Alternatives, pg. 50
“and the new YYLTYPE definition before the Bison-generated YYSTYPE
and YYLTYPE definitions in both the parser implementation file and
the parser header file”.
This position causes, in this case, YYLTYPE to be doubly defined in the
same scope.
[ elided ]
Is this a bug?
There are ways in which both the header file and the parser source file
can independently provide a definition such that they don't clash:
/* paste freely wherever you want, however many times you want */
#ifndef FOO_DEFINED
struct foo { int x; };
#define FOO_DEFINED
#endif
The text refers to an example, and in that example this appears:
#define YYLTYPE YYLTYPE
typedef struct YYLTYPE
{ ...
in all likelihood, the Bison-generated skeleton code is checking for
the presence of the preprocessor symbol
You should try the example; if that doesn't work, then there is a bug.
I don't use YYLTYPE, but for YYSTYPE, Bison clearly generates
code like:
if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
Not sure about Java and other supported languages that don't have
preprocessing.