Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Newsgroups: comp.lang.c++ Subject: Multiple parsers in C++? Message-ID: <69907@brunix.UUCP> Date: 26 Mar 91 22:02:45 GMT Sender: news@brunix.UUCP Reply-To: sdm@cs.brown.edu (Scott Meyers) Organization: Brown University Department of Computer Science Lines: 27 I'm writing an application that needs to use multiple lexers and parsers. The ideal situation would be to use modified versions of lex and yacc so that each lexer/parser was in its own class. This is sort of done by bison++, but it currently generates code that won't compile under anything but g++ (it initializes data members inside the class declaration). In addition, there is no corresponding flex++, at least not that I know about, so you're still stuck with a single lexer unless you go in and change things by hand. I also know about lex++/yacc++ that come with the Sun compiler, but the (beta) versions that we have don't seem to generate classes, i.e., they're just lex and yacc that generate C++ instead of C (with no gain in flexibility). What I want to be able to do is have files lexer1.l and parser1.y run through a lex++/yacc++ yielding class parser1, which would have member functions yylex and yyparse, while the files lexer2.l and parser2.y would yield class parser2 with the same member function names. Furthermore, I want to be able to set up a makefile so the generation of these classes is automatic -- I don't want to tweak things later by hand. My source files are the .l and .y files, and I really would like to keep it that way. I hope I'm overlooking some obvious solution, and I'm hoping somebody will tell me what it is. Scott ------------------------------------------------------------------------------- What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."