jorgnsn@QUCIS.QUEENSU.CA (John Jorgensen) (02/14/89)
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