Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!flood!tom From: tom@flood.com (Tom Chatt) Newsgroups: comp.unix.internals Subject: Re: two (or more) lex's/yacc's in one executable Message-ID: <1990Dec9.211732.1917@flood.com> Date: 9 Dec 90 21:17:32 GMT References: <1990Dec6.200753.12694@cs.columbia.edu> Sender: root@flood.com (Operator) Organization: The Flood Group, Inc. Lawndale, Ca. Lines: 41 I have an several occasions used more than one lex/yacc thing in one executable. I used a kludge that is similar in concept to yours, but perhaps a bit more reliable. Rather than creating a header file to redefine all of the yy_symbols to something else (which requires you to know all of the yy_symbols), I would run a "sed" on the generated code to do a global replace on the "yy" prefix. For example, to make two separate yaccs: yacc zzparse.y sed -e s/yy/zz/g y.tab.c > zzparse.c yacc xxparse.y sed -e s/yy/xx/g y.tab.c > xxparse.c If you are willing to follow some fairly reasonable naming conventions with regard to your lex and yacc source files, the above sort of filtering can be implemented in a couple of general ".y.o" and ".l.o" rules in your makefile. This solves the general case, rather than having to deal (e.g., create a header file) for each specific case, which is surely tedious. With regard to using calls out of the lex library (which are not available for you to rename -- not easily, anyway), I believe that most of the calls in the lex (and yacc) libraries provide "default action" routines which a user may want to customize. (This explains why the implementers did *not* make these routines static globals. It would have defeated the purpose.) For instance, the lex library even provides a "main()" routine, so that you could create a lex executable without having to provide your own "main()". Of course, providing your own "main()" is not precluded. Likewise for "yywrap()", and (if I remember right) everything else in there. It is possible (and not even hard) to create a lex source which does not need any of these default routines, by providing your own versions. Your own versions may perform the same default actions, but this gives you the opportunity to do your global rename on the prefixes. I can provide more specific info if you e-mail me (though I'm out of the office a lot recently and can't guarantee quick turnaround). Good luck. -- Tom Chatt \ Don't take offense, take action. Internet: tom@flood.com \ Speak up. When we remain silent, UUCP: ...!uunet!flood!tom / \ we oppress ourselves.