[unix-wizards] Re: Linking two yacc (y.tab.o) files

Robert Steven Glickstein bobg+ at andrew.cmu.edu
Sun Mar 11 02:53:26 AEST 1990


Excerpts from netnews.alt.sources: 9-Mar-90 [unix-wizards] Re: Linking
.. Gregory N. Bond at bby.oz.a (2435)

> Here is a script I use for making yacc output files static, so you can
> link n of them in one binary.  I use it on the output of getdate.y to
> make a general gate-parsing library.  Tried only on SunOs 3.5 and 4.0.3.
> (It assumes the .y file contains a global routine that calls the
> yyparse routine).

> Usage: sed -f yaccstaticize.sed < y.tab.c > file.c

> [...]

> echo shar: Extracting \"'yaccstaticize.sed'\" \(93 characters\)
> sed "s/^X//" >'yaccstaticize.sed' <<'END_OF_FILE'
> Xs/^short yy/static &/
> Xs/^int[ 	]*yy/static &/
> Xs/^YY[LS]TYPE/static &/
> Xs/^yyparse()/static &/

Unfortunately, this is a highly non-portable approach whose success
depends on zillions of factors, such as whether your C compiler allows
static objects not to be forward-declared, and what the exact form of
your /usr/lib/yaccpar is.  I discovered the inadequacy of this approach
when I needed a tool to do the very same thing.

I have written a considerably more robust version of this, called
"yyhide".  Yyhide will not only make everything static, but it will
topographically sort the definitions of functions and variables within
the yacc output.

Yyhide is part of the Andrew distribution, which in turn is available in
the X11r4 distribution (under contrib/toolkits/andrew [yyhide itself
lives in contrib/toolkits/andrew/overhead/parsec]).

Please contact me if you have any questions.

______________
Bob Glickstein                | Internet: bobg at andrew.cmu.edu
Information Technology Center | Bitnet:   bobg%andrew at cmuccvma.bitnet
Carnegie Mellon University    | UUCP:     ...!harvard!andrew.cmu.edu!bobg
Pittsburgh, PA  15213-3890    |
(412) 268-6743                | Sinners can repent, but stupid is forever



More information about the Comp.unix.wizards mailing list