I'm trying to use flex
and bison
in my project to generate a parser code for a file structure. Main programming language is C++ and project is on an OO design mainly running in parallel.
I heard that flex
and bison
generated parsers are C codes and they're not reenterant. Googling, I found flex++
and bisonc++
. Unfortunately there is no simple tutorial to get started. Most examples are based on bison/flex
. Some people somehow integrated bison/flex
parsers in their C++ code. They supposed to be "tricky"...
Documentation of flex++
and bisonc++
doesn't help me and. Tutorials and examples, they all get input from stdin and print some messages on stdout.
I need these features in my parser:
- Parser should be a C++ class, defined in normal manner (a header and a cpp file)
- Parser receives data from either an
std::string
orstd::stringstream
or a null-terminatedchar*
.
I feel so confused. Should I use flex++/bisonc++
or flex/bison
? And how to do that, satisfying above conditions?