www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/16/23:05:03

From: Andrew Crabtree <andrewc AT typhoon DOT rose DOT hp DOT com>
Message-Id: <199704170249.AA052015350@typhoon.rose.hp.com>
Subject: Re: advice on bison required
To: grbhat AT unigoa DOT ernet DOT in (Gurunandan R. Bhat)
Date: Wed, 16 Apr 1997 19:49:09 PDT
Cc: djgpp AT delorie DOT com
In-Reply-To: <Pine.LNX.3.91.970416181229.1816A@aditya.unigoa.ernet.in>; from "Gurunandan R. Bhat" at Apr 16, 97 6:21 pm

> point, if it was there. of course, your suggestion now begs the question:
> do i need to explicitly declare: 
> 
> %token <dval> name
> ..
> ..
> %type <dval> expression
> 
> in the case that my union has a single type member, or is 
> understood by default? i will check it out soon

I think that for union declarations in C ( independent of Yacc ) 
any time you reference a variable of a union type without specifying
a particular union member it defaults to the first defined member type

so for

union foo_u {

double dval;
long int lval;

};
 
union foo_u bar;

bar = 5.6;

 and

bar.dval = 5.6;

 are treated the same way.  So, I think it will work for you without 
explicit declarations, but I would say its could practice to explicitly 
declare them if your default type isn't int.

Andrew









- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019