car@access5.digex.net (Mr. Blue) wrote:> Problem:> 1. need to generate a lexer/parser from some grammar G> 2. The lexer/parser must be rigged so that they are part of a C++ class> that is called often with input from a *string*, not stdin.> 3. Class in (2) must be thread-safe.>> [Bison has a reentrant option which would probably do the trick. -John]

I am doing this, with Bison 1.24 and Flex 2.52. It works well.

Bison makes a standalone yyparse() using no statics.
Flex generates a C++ class called yyFlexLexer, that reads from
an istream (or an istrstream).
Some preprocesor defines turn the yyparse() into yyFlexLexer::yyparse(),
and the whole thing is wrapped up nicely.