Hello,
I may have found a bug in Bison 3.0.2. These are the steps to reproduce:
1. Use "%define api.value.type union" in a grammar definition.
2. Define one or more tokens or types.
3. Run bison with "-d" to produce a header file
The header file should then include a definition of union YYSTYPE
containing duplicates of each token and type defined in the grammar.
Example input:
%{
int yylex (void);
void yyerror (char const *);
%}
%define api.value.type union
%token <double> NUM
%%
input:
%empty
| NUM
;
%%
int
yylex (void)
{
return 0;
}
void
yyerror (char const *s)
{
fprintf (stderr, "%s\n", s);
}
int
main (int argc, char const* argv[])
{
return yyparse ();
}
Relevant excerpt from header:
union YYSTYPE
{
#line 59 "bison_bug_dup.tab.h" /* yacc.c:1915 */
/* NUM */
double NUM;
/* NUM */
double NUM;
};
If this really is a bug, can I take a shot at fixing it? I've always wanted
to contribute to open source.
Best,
Sam