Flex++ Bisonc++ parser

Viewed 7017

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:

  1. Parser should be a C++ class, defined in normal manner (a header and a cpp file)
  2. Parser receives data from either an std::string or std::stringstream or a null-terminated char*.

I feel so confused. Should I use flex++/bisonc++ or flex/bison? And how to do that, satisfying above conditions?

3 Answers

The LRSTAR product (LR(k) parser and DFA lexer generator) is C++ based. Runs on Widowns and has six Visual Studio projects. The code also compiles with "gcc" and other compilers. There are classes for lexer and parser, symbol-table, AST. Complete source code is available. It gets good reviews. I should know. I am the author.

Related