help-bison
[Top][All Lists]
Advanced

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

member [...] with constructor not allowed in union


From: Alexey Promokhov
Subject: member [...] with constructor not allowed in union
Date: Thu, 27 Jun 2002 12:59:32 +0400
User-agent: Gnus/5.090005 (Oort Gnus v0.05) XEmacs/21.5 (bamboo, i686-pc-linux)

Hi!

g++ give me the following message when compiling parser generated by
bison:

parse.y:24: member `class tkm {anonymous union}::kmval' with constructor not 
allowed in union

I have looked in mailing list archive, and found discussion of this
problem in March 2002. I writing in C language many years, but my
knowledges in C++ are weak. So, can I do something to use constructions
like this?

/* C header */
class tkm {
  struct {
    int i;
    int j;
  } km;
 public:
  tkm();
  tkm(int);
  tkm(int,int);
};

/* Bison grammar */
%token <intval> NUM
%type <kmval> km
%union {
  int intval;
  tkm kmval;
}
%%
km: NUM {$$=tkm($1);}
 | NUM ',' NUM {$$=tkm($1,$3);}
;


Problem persists in versions 1.29, 1.35 and 1.49b.
Currently I see one way: declare kmval as tkm*. But this way is ugly.

I don't realizing a serious project, I just want to know more about C++
and parser generators (and also to make something useful). So, maybe ugly
way is a right way? ;-)

-- 
Alexey Promokhov <ayp#ayp.msk.ru>




reply via email to

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