Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!gatech!mcnc!duke!juliet!khera From: khera@juliet.cs.duke.edu (Vick Khera) Newsgroups: comp.unix.wizards Subject: Re: Yacc/Lex: multiple uses in the same program? Message-ID: <15626@duke.cs.duke.edu> Date: 19 Sep 89 14:51:32 GMT References: <727@larry.sal.wisc.edu> <8106@goofy.megatest.UUCP> Sender: news@duke.cs.duke.edu Reply-To: khera@cs.duke.edu (Vick Khera) Organization: Duke University CS Dept.; Durham, NC Lines: 30 In article <8106@goofy.megatest.UUCP> djones@megatest.UUCP (Dave Jones) writes: >From article <727@larry.sal.wisc.edu>, by jwp@larry.sal.wisc.edu (Jeffrey W Percival): >> But when I link my main program, I run into trouble with ld(1) finding >> multiple definitions of many lex variables. >> How can I do what I want? >Several ways. (In order from probably best to probably worst...) > 1. In your makefile, use the -D option to cc to define the offending > symbols as something else. For example, > 2. Run an awk or sed script over the y.tab.c file, changing the > names mechanically. That also should go into the makefile. >Number 3 would be the "right" way if there were a standard, powerful >object-file editor universally available: Edit the symbol-table in >the object file. another alternative is to use a newer program. flex is a faster lex that also happens to produce scanners that declare all variables as static. it also has quite a few options that are quite useful. there are a few minor differences between flex and lex, but they are easily overcome. as for yacc, the GNU project has a version called bison. it generates parsers with mostly static declarations. i am not sure if the ones that are not static need to be that way. there is also a newly released parser generator that is having an identity crisis: is it called "zoo" still? i have no experience with this one, though. vick. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ARPA: khera@cs.duke.edu Department of Computer Science CSNET: khera@duke Duke University UUCP: {mcnc,decvax}!duke!khera Durham, NC 27706