sdm@cs.brown.edu (Scott Meyers) (03/30/91)
I received a number of replies regarding my request for information on generating multiple lexers and parsers to run in a single application. It seems that a number of people have run up against this problem, but there doesn't seem to be a simple solution to it, i.e., there isn't any widely available software that generates the code more or less automatically. In theory, what should work is combining the OMA lexer-generator from Oregon State University with the bison++ parser generator from Stanford. OMA is said to generate C++ class definitions containing lexers, and one person wrote to say it worked well for him. However, I couldn't get it to compile here. According to the README file, the current OMA is "a very primitive pre-release version." OMA is ftp-able from cs.orst.edu in the directory pub/budd/oma. Bison++ generates C++ class definitions from yacc-like input files, and it seems to work just fine, thanks to some very speedy fixes by Larry Augustin, to whom I am greatly indebted. Bison++ is ftp-able from wilbur.stanford.edu in the pub directory. A couple of people mentioned modifications they'd made to byacc. I don't have access to byacc, so I don't know anything about it, and since I'm happy with bison++, I didn't look into byacc very much. In conjunction with byacc, flex was also usually mentioned, but our version of flex (2.3.6) doesn't generate classes, or at least the documentation doesn't say anything about it generating classes (I didn't actually try it). Flex will, however, generate code that can be compiled with a C++ compiler. Our beta versions of Sun's lex++ and yacc++ are similar to our version of flex in that they generate C++ code, but they don't generate classes: you're still stuck with a single yylex and a single yyparse. Finally, I received word of a commercial product called Yacc++, as follows: We have a commercial product called Yacc++, which can generate multiple lexers and parsers. It generates lexer and parser "objects" in standard C. They are objects in the sense that the lexer/parser generator implements (multiple) inheritance of grammars and the resulting lexer and parser objects support dynamic binding and polymorphism--lexers and parsers can be configured to communicate in any pairings at runtime. Chris Clark Compiler Resources, Inc. voice: (508) 435-5016 3 Proctor Street fax: (508) 435-4847 Hopkinton, MA 01748 What I'm currently doing is using lex++ and bison++, and hoping that I can eventually get OMA to work. In the meantime, I'm writing my lexers/parsers separately and testing them in different programs. With any luck, by the time I am confident that they work correctly, either OMA will work or I'll have come up with some other brilliant solution to the lexing problem. By the way, I also found the need to perform a fair amount of makefile magic to get things to build automatically, but that's not too surprising considering that I'm combining software from AT&T (C++ compiler), Gnu (bison++), and Sun (lex++ beta). Scott ------------------------------------------------------------------------------- What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."