[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Union Type Object problem
From: |
Hans Aberg |
Subject: |
Re: Union Type Object problem |
Date: |
Thu, 5 Aug 2004 18:39:54 +0200 |
At 13:37 +0200 2004/08/05, Enrico Oliosi wrote:
>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;
>}
This way, Bison will not clean up the *exp pointers; so will have to do it
explicitly in the actions and using the experimental %destructors option. I
posted in the Bison-Patches list a way to produce a C++ parser. One can the
replace your class Expression with one that maintains a pointer to this
class, and cleanup will take place via the C++ language class features
then. One cannot use the %unions feature this way, though as C/C++ unions
only accept POD.
Hans Aberg
- 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 <=
- Re: Union Type Object problem, Laurence Finston, 2004/08/05
- 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