help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

&union and overlapping declarations


From: Davide Rizzo
Subject: &union and overlapping declarations
Date: Mon, 20 Jan 2003 15:55:40 +0100

I'm using Bison 1.24 together with Flex 2.5
I would like to define two different semantic types for my tokens and rules, so I specified the following:
%union {
   char* str;
   int integer;
}
%token <str>        IDENTIFIER WEEK HOUR DAY MONTH YEAR
%token <integer>    DAY_OF_WEEK MONTH_NAME DIGIT
%type  <integer>    input phrase note date_specification date date_stmt date_interval
%type  <integer>    time time_stmt time_specification time_interval
...etc...
in the declaration section. After having assigned each token and rule a semantic type, I arranged Flex to return the right values, eg:
[[:alpha:]]+        {
                      yylval = yytext;
                      return(IDENTIFIER);
                    } 
[0-9]+              {
                      yylval = atoi(yytext);
                      return(DIGIT);
                    }
Bison and Flex correctly generate the whole, but when I try to compile the code (using Dev-C++ 4.9 gcc compiler) I get some strange errors:
  1. a "conflicting types for `typedef union YYSTYPE YYSTYPE' " error in the header file filename_tab.h generated by Bison where there is the definition
    typedef union {
       char* str;
       int integer;
    } YYSTYPE;
    equivalent to the %union specification
  2. a "previous declaration as `typedef union YYSTYPE YYSTYPE' " error in the declaration section of Bison source file
    %union {
       char* str;
       int integer;
    }
  3. a "conflicting types for `union YYSTYPE yylval' " error in the header file filename_tab.h generated by Bison where there is the definition
    extern YYSTYPE yylval;
  4. a "previous declaration as `union YYSTYPE yylval' " error in bison.simple file at line 117
    YYSTYPE yylval;   /*  the semantic value of the  */
I guess there's something wrong with type definition/redefinition, but I cannot understand what I must change. Can you help me?
Thanks so much in advance, regards
Davide Rizzo
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]