help-bison
[Top][All Lists]
Advanced

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

AW: Union Type Object problem


From: Olav Groehn
Subject: AW: Union Type Object problem
Date: Thu, 5 Aug 2004 13:45:23 +0200

Hi Enrico,

Looks to me like a missing include of class-definition in your generated
source file 

Kind regards
Olav

-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Im Auftrag
von Enrico Oliosi
Gesendet: Donnerstag, 5. August 2004 13:38
An: address@hidden
Betreff: Union Type Object problem

Hi,
I have to do a parser in Bison and I need to use in %union{} construct some
type Object.
I have this example-class Expression:

class Expression {
public:
   virtual ~Expression () {}
   //  It's necessary because we need to clone objects without
   // knowing the exact type.
   virtual Expression *clone () = 0;
   // The value represented by the expression
   virtual int value () = 0;
};

this is a very simple class, but when I define the Bison Type in union
construct in this way:

%union{
   Expression *exp;
   int num;
}

the compiler give me this error:

>> error: syntax error before `*' token

I compile this file Bison like this:
bash> bison -d parser.y 
bash> flex     parser.lex
bash> g++  -DCPLUSPLUS parser.tab.c lex.yy.c -lfl -o parser

Thanks a lot.
Enrico


_______________________________________________
address@hidden http://lists.gnu.org/mailman/listinfo/help-bison






reply via email to

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