yacc %token value #defines

Dave Decot decot at cwruecmp.UUCP
Sun Mar 11 22:13:16 AEST 1984


When using the new yacc with %union's, it is necessary to declare
the types of the yylval's of some tokens with

    %token <integer> TOKEN1 TOKEN2 'c' TOKEN4

declarations.  Yacc changes each one of the token names
in such a declaration into a #define:

    #define TOKEN1 257
    #define TOKEN2 258
    #define  c  99
    #define TOKEN4 259

It is convenient for me to declare 'c' as an integer, since I want it
to represent itself by default.  But the #define yacc generates for
the character ruins my code.  I don't want local variables named 99.

Is there any reason why a #define should be generated at all for literal
characters in %token declarations?

Dave Decot
decvax!cwruecmp!decot    (Decot.Case at rand-relay)



More information about the Comp.lang.c mailing list