Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!zaphod.mps.ohio-state.edu!think.com!snorkelwacker!spdcc!esegue!compilers-sender From: sja@sirius.hut.fi (Sakari Jalovaara) Newsgroups: comp.compilers Subject: Re: Two pass compiler using YACC? Keywords: C, yacc Message-ID: <1990Aug25.170408.29508@santra.uucp> Date: 26 Aug 90 00:03:44 GMT References: <9008242036.AA10670@virgil.tfic.bc.ca> Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: sja@sirius.hut.fi (Sakari Jalovaara) Organization: Helsinki University of Technology Lines: 30 Approved: compilers@esegue.segue.boston.ma.us In-Reply-To: tbr@virgil.tfic.bc.ca's message of 24 Aug 90 20:36:19 GMT >>The problems come during link-time, for ld, obviously, complains about >>multiple defined symbols (such as yylval and yyparse). [solution with a sed script] How about an include file, say, yyrename.h (warning - untested code ahead): #define yyGLUE1(x,y) x ## y #define yyGLUE(x,y) yyGLUE1 (x, y) /* There may be an * easier way... */ #define yyparse yyGLUE (yyparsername,_yyparse) #define yylex yyGLUE (yyparsername,_yylex) #define yychar yyGLUE (yyparsername,_yychar) ...etc... and in parse.y: %{ #define yyparsername my_parser #include "yyrename.h" my_parser_yylex () { ...lexer goes here... } %} ++sja [No question, there are arbitrarily ugly ways to make this work. -John] -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.