Yacc/Lex: multiple uses in the same program?
Jeffrey W Percival
jwp at larry.sal.wisc.edu
Sun Sep 17 06:36:29 AEST 1989
I am using Yacc and Lex to parse a special purpose "language", and am
in a bind. I wrote a yacc file with my grammar, and a lex program for
finding tokens. So far, so good.
Now, in one of my subroutines I need to pick apart a string, entirely
unrelated to the parsing that's going on. The string has a format
consisting of a name followed by an optional offset. The offset can be
of the form number/H for hex, number/O for octal, etc.
So I think to myself, a fledgling yacc/lex user, I can specify this as
a "mini" language, and use lex and yacc to pick it apart. I supplied
my own input() and unput() to feed yylex from my own private string
storage. I even remembered to put a "static" in front of the yyparse()
and yylex() definitions in my "mini" parser file, to avoid conflicts
with the "main" parser.
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?
--
Jeff Percival (jwp at larry.sal.wisc.edu)
More information about the Comp.unix.wizards
mailing list