[comp.sys.mac.programmer] Bison / Yacc and Think C: missing bcopy and alloca

stan@dnlunx.pttrnl.nl (Burgt S.P.v.d.) (05/22/91)

Hi,

I am trying to port a yacc/c program to the mac. Doing this I ran into
the following: After creating the parser from the yacc file with a PD
yacc (bison) on the mac, Think C seems to be missing the following 
functions or macro's:

    undefined: alloca (lotosy.tab.c)
    undefined: bcopy (lotosy.tab.c)

Is there someone who could give me the obvious answer?

	Thanks in advance

	Stan

-- 
   S.P. van de Burgt                       PTT Research, Neher Labs
                                           PO Box 421, Leidschendam
   E-mail: SP_vdBurgt@pttrnl.nl            the Netherlands

stan@dnlunx.pttrnl.nl (Stan van de Burgt) (05/28/91)

I wrote:

>I am trying to port a yacc/c program to the mac. Doing this I ran into
>the following: After creating the parser from the yacc file with a PD
>yacc (bison) on the mac, Think C seems to be missing the following 
>functions or macro's:
>    undefined: alloca (lotosy.tab.c)
>    undefined: bcopy (lotosy.tab.c)
>Is there someone who could give me the obvious answer?


Here's a summary of the answers I got upto now:

1) "The sources of bcopy and alloca are in the bison package.
   Just add the source to the project."
   Right. I was only using the application and the skeletons.

2) "#define bcopy(src,dest,len) memcpy(dest,src,len)
    #define alloca malloc
   to make for something that works but has a memory leak."
   also works.

3) Found this myself after looking carefully at the C program bison 
   generates: 

   The bcopy and alloca functions are only called in an
   emergency, only in case of a parser stack overflow. In this case
   a message is printed and the stack is temporally extended with
   alloca. If the programmer provides his own macro the piece of code
   with the two function calls is skipped. So I added:

   #define yyoverflow(msg,b,c,d,e,f,g,h) { yyerror(msg); exit(2); }

   This seems to work fine!

I like to thank:
    ruurd@ooc.uva.nl
    pas@kepler.unh.edu
    d88-jwa@nada.kth.se
    neeri@iis.ethz.CH
    rcbalc@urc.tue.nl

    for their help.

					Stan

-- 
   S.P. van de Burgt                       PTT Research, Neher Labs
                                           PO Box 421, Leidschendam
   E-mail: SP_vdBurgt@pttrnl.nl            the Netherlands