bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

duplicate members of YYSTYPE union in header file


From: Samuel Wrenn
Subject: duplicate members of YYSTYPE union in header file
Date: Tue, 4 Mar 2014 17:41:27 -0800

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]