bisonpp version 0.8.1

Bisonpp is a simple script that simplifies writing parsers using C++. Bisonpp calls bison, it has been tested with bison v.1.35. It does not work with bison-1.875.

To install on a system with a more recent (than 1.35) version of bison, one can

The command line is

bisonpp [--help] [--class class-name] [bison-option].. file

Bisonpp uses a slightly modified version of bison.simple, called bisonpp.simple. The main differences are that the definitions of the following ``global'' variables have been removed

int             yynerrs;
int             yychar;
YYSTYPE         yylval;
void    	yyerror(const char* msg);
and that the declaration of yyparse() now reads
int @CLASS@::yyparse()
where @CLASS@ will be replaced by the class-name argument of bisonpp.

All this implies that the user must include a declaration of a class class-name in the first section of the bison input file. Typically, this will be done by an include directive, like

#include parser.h
where parser.h might look like this (in the example, the class-name is ExpParser):

#include	"explexer.h"
#include	"" // used to be

class ExpParser {
	ExpLexer	_lexer;

	int		yynerrs;
	int		yychar;
	YYSTYPE		yylval;

	void	yyerror(const char* msg) { 
			// cerr << "yyerror: " << msg << endl; 
	int	yylex() { return _lexer.yylex(yylval); }

	ExpParser(istream& is): _lexer(&is) {}
	int	yyparse();



Here is complete example using flex and bisonpp to build a small program that evaluates the command line arguments as a simple arithmetic expression.