[Top][All Lists]

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

Re: union and stuff

From: Leah
Subject: Re: union and stuff
Date: Fri, 10 Oct 2003 08:40:09 -0600

On 09 Oct 2003 22:54:22 -0700
Paul Eggert <address@hidden> wrote:

> Leah <address@hidden> writes:
> > Is there a better way than placing...
> > 
> > #define union struct
> > 
> > ...in the user declarations, to allow more than one type of value to
> > be stored in a semantic value?
> Sure: leave the union alone, but have one of its members be the
> structure.

As an example:

   int num;
   char *str;

%token NUM
%token STR

%type <num> NUM num
%type <str> STR str


num: NUM
   | str   { $$ = $<num>1; }

str: STR   { $<num>$ = atoi($1); $$ = $1; }


Slightly contrived, maybe, but it shows the idea.  It's more convenient
to refer to 'str' as $$ and $<num>$ than it is to refer to it as $$.str
and $$.num, but with YYSTYPE being a union it isn't possible for a
semantic value to simultaneously be a <num> and a <str>.

> > Is the help-bison list not working anymore?
> Sorry, I don't read it.  What problem are you having with it?

It seems not to be receiving messages.  Also the archives don't list
September or October.


reply via email to

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