[net.unix-wizards] YYSTYPE problems with YACC

dyer (02/14/83)

I am having a small problem with YACC on 4.1BSD.  I am trying to use the
%union construct to redefine the type of YACC's value stack.  %union produces
a C statement of the form:
typedef union { ... } YYSTYPE;

All well and good.  However, the "y.tab.c" file which YACC generates
has a preprocessor line:
#ifndef YYSTYPE
#define YYSTYPE int
#endif
The problem, of course, is that the preprocessor does not "know" about
typedef's.  Thus, all my objects declared as YYSTYPE turn into int's,
and PCC barfs.  I can get around this by replacing the %union construct with:
%{
union unionname { ... };
#define YYSTYPE union unionname
%}
But, it bothers me.  It seems like the designers decided to go with typedefs
but didn't follow through completely.  Or am I doing something wrong?
YACC gurus, please comment.  Thanks.

/Steve Dyer	decvax!wivax!dyer	sdyer@bbn-unix