[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Union Type Object problem
From: |
Laurence Finston |
Subject: |
Re: Union Type Object problem |
Date: |
Thu, 05 Aug 2004 23:59:10 +0200 |
User-agent: |
IMHO/0.98.3+G (Webmail for Roxen) |
Unions can't contain objects with constructors.
This has come up recently, so if you look in the archives you can find
references to Stroustrup and the standard, if you're interested.
Laurence
-------------------
> 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
>
- Union Type Object problem, Enrico Oliosi, 2004/08/05
- AW: Union Type Object problem, Olav Groehn, 2004/08/05
- Re: Union Type Object problem, Hans Aberg, 2004/08/05
- Re: Union Type Object problem,
Laurence Finston <=
- Re: Union Type Object problem, Laurence Finston, 2004/08/05
- Re: Union Type Object problem, Hans Aberg, 2004/08/06
- Re: Union Type Object problem, Laurence Finston, 2004/08/07
- Message not available
- Re: Union Type Object problem, Hans Aberg, 2004/08/09
- Re: Union Type Object problem, Laurence Finston, 2004/08/08
- Re: Union Type Object problem, Hans Aberg, 2004/08/09
- Re: Union Type Object problem, Laurence Finston, 2004/08/09
- Message not available
- Re: Union Type Object problem, Hans Aberg, 2004/08/10
- Re: Union Type Object problem, Laurence Finston, 2004/08/10
- Message not available
- Re: Union Type Object problem, Hans Aberg, 2004/08/11