Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!crdgw1!steinmetz!oman!murren From: murren@oman.steinmetz (Brian Murren) Newsgroups: comp.lang.c++ Subject: Re: Using OO Languages for Compilers/Interpreters Keywords: YACC, Bison, parsers Message-ID: <13609@steinmetz.ge.com> Date: 13 Apr 89 19:21:27 GMT References: <16915@cup.portal.com> <3690007@wdl1.UUCP> <1706@iesd.dk> Sender: news@steinmetz.ge.com Reply-To: murren@oman.steinmetz.ge.com (Brian Murren) Organization: General Electric CRD, Schenectady, NY Lines: 34 In article <1706@iesd.dk> fischer@iesd.dk (Lars P. Fischer) writes: > >In article <3690007@wdl1.UUCP> rme@wdl1.UUCP (Richard M Emberson) writes: >> ...text deleted... (Try linking the output of two yacc grammers in the >> same program - the yacc/bison drivers don't allow multiple >> grammar tables). > > Lars Fischer replies: > * Make each parser a pure parser (*note Pure Decl::.) ... > > * In each grammar file, define `yyparse' as a macro ... A more primitive mechanism :-) than either of the above is to take the generated parser file (and associated header) and run them through the stream editor (sed). For example: yacc -d foo.y # or bison sed -e 's/yy/my_parser_/g' y.tab.h > myparser.h sed -e 's/yy/my_parser_/g' y.tab.c > myparser.c rm y.tab.h y.tab.c Applying a different filter for each parser will yield the desired result since each grammar table will exist in its own name space. I have an application where 5 different parsers peacefully coexist. Brian Murren GE Corporate Research and Development Center, Schenectady, NY Internet: murren@ge-crd.arpa OR murren@crd.ge.com UUCP: murren@oman.steinmetz.ge.com OR uunet!steinmetz!oman!murren -------------- All opinions expressed are strictly my own -----------------