delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/28/11:25:36

From: "Campbell, Rolf [SKY:1U32:EXCH]" <cp1v45 AT americasm01 DOT nt DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bison help
Date: Mon, 28 Jun 1999 10:55:44 -0400
Organization: Nortel Networks
Lines: 30
Message-ID: <37778CEF.59A035CE@americasm01.nt.com>
References: <3775E3B1 DOT EC5991C AT hotmail DOT com> <3776932E DOT 7CBB5EEC AT unb DOT ca> <37770B2E DOT 7EBF4A1E AT hotmail DOT com>
NNTP-Posting-Host: bmerhc00.ca.nortel.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.6 [en] (X11; I; HP-UX B.10.20 9000/712)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Denis Lamarche wrote:

> ya, but then I would have to go:
>
> exp:  FUNC2 '(' exp ',' exp ')'  {$$ = func2($3,$5);}
> exp:  FUNC2 '(' exp ',' exp ',' exp ')'  {$$ = func2($3,$5,$7);}
> exp:  FUNC2 '(' exp ',' exp ',' exp ',' exp')'  {$$ =
> func2($3,$5,$7,$9);}
>
> and so on...isnt there a way I could do it for all possibilities?

    Oh, so you want to accept something like printf in C?

OK, that's tougher, but here's what comes to mind:

fcallBegin: FUNC '('  {$$.clear();  $$.add($1);}
| fcallBegin exp ','  {$$.add($2);}

fcall: fcallBegin ')'  {func($$);}

    Here, you would have to make some sort of list class (or the equivalent
in C), and it would hold the function name & all of the arguments passed to
it.  You would need to code a wrapper for the function you want to call that
accepts the list class and does the real call itself.

--
     -Rolf Campbell (39)3-6318



- Raw text -


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