Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uakari.primate.wisc.edu!larry!jwp From: jwp@larry.sal.wisc.edu (Jeffrey W Percival) Newsgroups: comp.unix.wizards Subject: Yacc/Lex: multiple uses in the same program? Keywords: yacc lex yyparse yylex local/global variables Message-ID: <727@larry.sal.wisc.edu> Date: 16 Sep 89 20:36:29 GMT Organization: Space Astronomy Lab, Madison WI Lines: 22 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@larry.sal.wisc.edu)