www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/07/01:40:00

Message-ID: <3781BA61.A5028CFA@hotmail.com>
From: Denis Lamarche <brainwav AT hotmail DOT com>
Organization: @Home Network
X-Mailer: Mozilla 4.5 [en]C-AtHome0405 (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: bison variable access
References: <199907020051 DOT UAA06732 AT indy DOT delorie DOT com> <377C404E DOT 36E22B7 AT hotmail DOT com> <378182F5 DOT AF4797B3 AT unb DOT ca>
Lines: 43
Date: Tue, 06 Jul 1999 05:19:47 GMT
NNTP-Posting-Host: 24.112.228.171
X-Complaints-To: abuse AT home DOT net
X-Trace: news2.rdc1.on.home.com 931238387 24.112.228.171 (Mon, 05 Jul 1999 22:19:47 PDT)
NNTP-Posting-Date: Mon, 05 Jul 1999 22:19:47 PDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Yes!..that is what I meant.  Ive done that with the functions, but when
I try to do it with the variables, my compiler (DJGPP for dos) keeps
telling me that I cannot assign the pointer of my variable to a pointer
because it is not constant.  

struct vars
{
char *vname;
double *var;
};

struct vars variables[]
= {
  *drive,
  *room,
  *picture,
  *house
  };

and this does not work.



Endlisnis wrote:
> 
>     Are you saying you have a variable declared in your bison code like:
> int status;
> 
>     And when you parse the input file and find a line reading something like:
> status = 12
> you want to assign 12 to the status variable inside the parser?
> 
>     If so, there is no trivial way to do it, the easiest way I can think of is
> to make an array of structs containing strings and int pointers.  Each time you
> find a VAR = exp, compare the string version of VAR to every entry in your array
> of structs, when you find the right struct, make an assinment to the pointer,
> and make sure to initialize the pointer to point to the correct variable.
> 
> --
>      (\/) Endlisnis (\/)
>           s257m AT unb DOT ca
>           Endlisnis AT HotMail DOT com
>           ICQ: 32959047

- Raw text -


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