two (or more) lex's/yacc's in one executable
leland at cs
leland at cs
Fri Dec 7 07:07:22 AEST 1990
I have an application that requires two discrete uses of both lex and
yacc. Since both lex and yacc have hardcoded names (all with the 'yy'
prefix) for a whole bunch of global symbols, there is an immediate
problem: somehow the two sets must be hidden from each other and
distinguished for any other code that accesses them.
I've tried this kludge: create a header file that re-#define's all the
names 'yyfoo' in lex/yacc set #1 to be named, say, set1yyfoo, and all
those in set #2 to be named set2yyfoo. This has worked for me in the
past, but won't in this particular instance because the generated
code includes calls to yyless() and yywrap(), which are in the LEX
library (-ll), the contents of which I cannot rename. So that doesn't
work.
I've also investigated GNU's replacements for these programs, flex and
bison. I haven't gotten to the bison documentation yet, but a
quick look at the flex man page implies that these programs still
have the hardcoded global symbol names. Flex eliminates the need
for the external library, however, so this may solve my problem. But
it's still a horrible kludge, and it would require that others to whom
I distribute the software maintain flex and/or bison. I'm looking
for something better.
I may be able to use some special loader options to 'hide' the yy*
symbols when compiling the object modules that contain them, but
the procedure for doing is not obvious nor it is standardized across
loader versions.
Has anybody listening gotten into this before? Can you offer any
suggestions? Thanks for whatever you may know.
It is difficult to accept that, considering how long these programs have
been around, none of the implementers ever thought to make these globals
static or to add a command-line option to rename them.
Leland Woodbury
--
ARPANET/INTERNET: leland at cs.columbia.edu
USENET: ...!columbia!cs.columbia.edu!leland
BITNET: leland%cs.columbia.edu at cuvmb
USMAIL: Columbia Univ., 457 CS, 500 W. 120 St., NYC 10027-6699
More information about the Comp.unix.questions
mailing list