Path: utzoo!attcan!uunet!munnari!munmurra!jkjl From: jkjl@munmurra.mu.oz (John Lim) Newsgroups: comp.sys.mac.programmer Subject: using Bison and Flex with LSC Keywords: yacc and lex on the mac Message-ID: <1133@munmurra.mu.oz> Date: 24 May 89 04:40:27 GMT Organization: Comp Sci, Melbourne Uni, Australia Lines: 26 I'm been busy porting the some GNU C code to the mac. Here's a little hint if you use Bison and Flex with LSC like i do. Bison and Flex were compiled using MPW C which maps '\n' to carraige return, not linefeed. LSC maps '\n' to linefeed as in UNIX. But the symbol tables in both Bison and Flex expect '\n' defined in your .y and .l files to be carraige returns. It took me 4 stupid hours of debugging to realize this ( I dont own MPW C, just TML Pascal //). What this means when porting such code to LSC, use 1. The "b" flag for reading files (binary mode). 2. Change all instances of '\n' in the .c generated files to '\r' (and the .h files too !). 3. insert the line in the *.tab.c files: #define bcopy(x,y,z) BlockMove(x,y,z) 4. Rewrite alloca() or if you have lots of memory ... #define alloca(x) mlalloc((long) (x)) /* mem not freed */ Alternatively, rewrite the stdio project to make '\r' and '\n' equivalent B-). john lim