[Top][All Lists]

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

C code generation bug in bison 1.29

From: tstevenson
Subject: C code generation bug in bison 1.29
Date: Tue, 2 Oct 2001 13:39:23 -0600

I found a bug where the generated C code from Bison adds a slash to a comment,
causing the C compiler to fail.

I am using GNU Bison 1.29

I am running both on DG/UX version 4.20 (update 7) and Sun Solaris version 8.
The bug appears on both platforms.

The following Bison grammar:


%union {
     char *string;            /*a comment*/
     int cmd;

%token <string> QSTRING, STRING, EOT


          {printf("hello world"); }
          {printf("syntax error"}


generates the following code when converting the %union operation to the
corresponding C typedef:
 (I show only the snippet that is bad)

#line 4 "yacc.y"
typedef union {
     char *string;            //*a comment*/
     int cmd;
#include <stdio.h>

Please note the '//' on the comment.  I realize that most modern C compilers
allow a // as a comment, however, not all do,
and this is an invalid C construct.

I've attached the complete source grammar file and the output from Bison.
I generate the code running Bison without any command line arguments.

thank you.  Bison is a great tool.

Todd Stevenson

(See attached file: yacc.y)(See attached file: yacc.tab.c)

Attachment: yacc.y
Description: Binary data

Attachment: yacc.tab.c
Description: Binary data

reply via email to

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