Hiding Yacc vars

Robert Steven Glickstein bobg+ at andrew.cmu.edu
Wed Jun 14 07:24:20 AEST 1989


I'm sure some of you have encountered this problem before.  Both Yacc
and Lex make all of their identifiers external, when in fact they should
be static.  This becomes a major problem when you have large software
projects in which zillions of libraries are linked together, any two of
which might define yyparse, yytext, yylength, etc., leading to a name
conflict.  The kludgy solution that we've been using at the ITC has been
to run lex.yy.c and y.tab.c through sed, changing all instances of "yy"
to "fooyy".  The right solution (short of hacking Yacc and Lex
themselves) is to run the output files through a postprocessor to make
all the "yy"-something declarations static.  This postprocessor would
optionally preserve the external-ness of yylex and yyparse, but it would
be able to rename them to something the programmer specified.  (I call
this an option because another behavior would be to leave yylex and
yyparse static, and provide interface routines in the files foo.l and
bar.y to get at the parser and tokenizer.)

Anyway, does such a postprocessor exist?  If not, I plan to write one;
how much interest do you folks have in seeing it written?

Gratefully,
  Bob Glickstein
    Information Technology Center
    Carnegie Mellon University
    Pittsburgh, PA



More information about the Comp.unix.questions mailing list