Yacc/Lex: multiple uses in the same program?

Vick Khera khera at juliet.cs.duke.edu
Wed Sep 20 00:51:32 AEST 1989


In article <8106 at goofy.megatest.UUCP> djones at megatest.UUCP (Dave Jones) writes:
>From article <727 at larry.sal.wisc.edu>, by jwp at 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 at cs.duke.edu		Department of Computer Science
CSNET:	khera at duke			Duke University
UUCP:	{mcnc,decvax}!duke!khera	Durham, NC 27706



More information about the Comp.unix.wizards mailing list