lee@utexas-11.arpa (03/22/83)
From: William L. Lee III <lee@utexas-11.arpa> As far as I know, there isn't a good mechanism to override the define of YYSTYPE. One solution is what you suggest, i.e. #define YYSTYPE union unionname or something along those lines. The preprocessor doesn't know about typedefs so the obvious solution doesn't work. You could do something like this though- #define YYSTYPE YYSTYPE1 typedef union unionname YYSTYPE1; A little messy but it works. Another solution that almost works is to use the -R flag on the preprocessor to allow for recursive macros. Then you can say #define YYSTYPE YYSTYPE The problem here is that you get a macro recursion overflow. A solution here is to add a flag to the preprocessor (-Y) that stops recursion if the token is defined as itself. Some versions of the C preprocessor allow this type of construct. If anyone knows of cleaner ways to deal with redefining YYSTYPE to be a typedef, I'd like to know. -------
wartik (04/08/83)
The YYSTYPE mechanism works fine. However, you have to read the yacc manual very carefully to figure it out. Read page 22 very slowly! The key statement is the second sentence of the last paragraph on the page: you MUST use "%type" statements. If you do that, yacc removes the three lines it uses to define YYSTYPE, and replaces them with an appropriate union declaration. If you don't then even if you have used the "%union" construct yacc insists on leaving YYSTYPE as an integer by default. -- Steve Wartik decvax!trw-unix!trwspp!wartik