🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2286

bison not quite compatible with yacc: YYSTYPE can't be typedefed

#2286
From: John Jorgensen
Date: Mon, 13 Feb 1989 17:05
38 lines
2363 bytes
First, I apologize for sending a bison report to bug-gcc, but I don't 
have an address for bison bugs.  I can't find a version number in my
bison but the date on the manual is 12 October, 1988.  

Stephen Johnson's paper on yacc says that as an alternative to
using %union to declare the types of your semantic values, you
can put a typedef of YYSTYPE into the declarations section of
your input file (page 22 of the paper in the USENIX edition of
4.2 BSD UNIX Programmer's Manual, Supplementary Documents).  This
won't work in bison.  In the *.tab.c that bison produces, if
YYSTYPE is not already defined as a macro, it is defined as int.
A typedef of YYSTYPE will be masked by the macro definition of
YYSTYPE to int.  Trying to compile the resulting *.tab.c file
will likely result in all sorts of errors about referring to the
members of a variable that isn't a struct or union.

I have an example grammar if you'd like me to send it, but this
problem seemed straightforward enough that I thought I wouldn't
send it unless you ask.  It's likely that someone else has 
already informed you about this problem, anyway.

I'm not sure that this is a bug.  The bison documentation is
quite clear about setting YYSTYPE as a macro, not a typedef.  It
probably would have been better programming practice to use
%union than a typedef.  BUT, the manual says ``all
properly-written Yacc grammars ought to work with Bison with no
change''; yacc handles this grammer, but bison doesn't.  I think
there should at least be a warning about typedef-ing YYSTYPE,
since it is a practise explicitly suggested in the yacc paper.
If there already is a warning somewhere that I missed, I
apologize.

Anyway, thanks a lot for making bison available.  It is able to
handle grammars that have made our yacc dump core (that's an 
incompatibility I welcome :-) ).

John Jorgensen
jorgnsn@qucis.queensu.ca
Technical Details
Message-ID: <8902131705.AA15695@qucis.queensu.ca>
Path: arc1-ca.pugleaf.net!utzoo!telly!lethe!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!QUCIS.QUEENSU.CA!jorgnsn

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!lethe!dptcdc!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!QUCIS.QUEENSU.CA!jorgnsn
From: jorgnsn@QUCIS.QUEENSU.CA (John Jorgensen)
Newsgroups: gnu.gcc.bug
Subject: bison not quite compatible with yacc: YYSTYPE can't be typedefed
Message-ID: <8902131705.AA15695@qucis.queensu.ca>
Date: 13 Feb 89 17:05:54 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 38