.TH BISON++ 1 "3/3/93" "GNU and RDT" "COMMANDS" .SH "NAME" bison++ \- generate a parser in c or c++\. .SH "SYNOPSIS" \fBbison++\fP [\fB\-dltvyVu\fP] [\fB\-b\fP \fIfile\-prefix\fP] [\fB\-p\fP \fIname\-prefix\fP] [\fB\-o\fP \fIoutfile\fP] [\fB\-h\fP \fIheaderfile\fP] [\fB\-S\fP \fIskeleton\fP] [\fB\-H\fP \fIheader\-skeleton\fP] [\fB\-\-debug\fP] [\fB\-\-defines\fP] [\fB\-\-fixed\-output\-files\fP] [\fB\-\-no\-lines\fP] [\fB\-\-verbose\fP] [\fB\-\-version\fP] [\fB\-\-yacc\fP] [\fB\-\-usage\fP] [\fB\-\-help\fP] [\fB\-\-file\-prefix=\fP\fIprefix\fP] [\fB\-\-name\-prefix=\fP\fIprefix\fP] [\fB\-\-skeleton=\fP\fIskeletonfile\fP] [\fB\-\-headerskeleton=\fP\fIheaderskeletonfile\fP] [\fB\-\-output=\fP\fIoutfile\fP] [\fB\-\-header\-name=\fP\fIheader\fP] \fIgrammar\-file\fP .SH "DESCRIPTION" Generate a parser\. Based on \fBbison\fP version 1\.19\. See \fBbison\fP(1) for details of main functionality\. Only changes are reported here\. .PP You now generate a C++ class if you are compiling with a C++ compiler\. The generated header is far more rich than before, and is made from a skeleton\-header\. The code skeleton is also richer, and the generated code is less important compared to the skeletons\. It permit you to modify much things only by changing the two skeletons\. .PP In plain C, the \fBbison++\fP is compatible with standard \fBbison\fP\. .SH "OPTIONS" .\"bloc1[ .IP "\\fB\\-\\-name\\-prefix=\\fP\\fIprefix\\fP" .IP "\\fB\\-p\\fP \\fIprefix\\fP" Set prefix of names of yylex,yyerror\. keeped for compatibility, but you should prefer \fB%define LEX \fP\fInewname\fP, and similar\. .IP "\\fB\\-\\-skeleton=\\fP\\fIskeleton\\fP" .IP "\\fB\\-S\\fP \\fIskeleton\\fP" Set filename of code skeleton\. Default is \fBbison\.cc\fP\. .IP "\\fB\\-\\-headerskeleton=\\fP\\fIheader\\-skeleton\\fP" .IP "\\fB\\-H\\fP \\fIheader\\-skeleton\\fP" Set filename of header skeleton\. Default is \fBbison\.h\fP\. .IP "\\fB\\-\\-header\\-name=\\fP\\fIheader\\fP" .IP "\\fB\\-h\\fP \\fIheader\\fP" Set filename of header skeleton\. Default is \fBy\.tab\.h\fP, or \fIprefix\fP\.h if option \fB\-b\fP is used or \fIc_basename\fP\.h if \fB\-o\fP is used\. \fB\.c\fP, \fB\.cc\fP, \fB\.C\fP, \fB\.cpp\fP, \fB\.cxx\fP options for output files are replaced by \fB\.h\fP for header name\. .\"bloc1] .SH "DECLARATIONS" These are new declarations to put in the declaration section : .\"bloc1[ .IP "\\fB%name\\fP \\fIparser_name\\fP" Declare the name of this parser\. User for C++ class name, and to render many names unique\. default is \fBparse\fP\. Must be given before \fB%union\fP and \fB%define\fP, or never\. .IP "\\fB%define\\fP \\fIdefine_name\\fP \\fIcontent\\.\\.\\.\\fP" Declare a macro symbol in header and code\. The name of the symbol is \fBYY_\fP'\fIparser_name\fP'\fB_\fP'\fIdefine_name\fP'\. The content if given after, as with #define\. Newline can be escaped as with #define\. Many symbols are proposed for customisation\. .IP "\\fB%union\\fP" as with bison generate a union for semantic type\. The difference is that the union is named \fByy_\fP'\fIparser_name\fP'\fB_stype\fP\. .IP "\\fB%pure_parser\\fP" As with bison in C\. In C++ generate a parser where yylval, and yylloc (if needed) are passed as parameter to yylex, and where some instance variable are local to yyparse (like yydebug\.\.\.)\. Not very useful, since you can create multiple instances for reentering another parser\. .IP "\\fB%header{\\fP" Like \fB%{\fP, but include this text both in the header, and in the code\. End with \fB%}\fP\. When put in declaration section, the text is added before the definitions\. It can be put in the last section so that the text is added after all definition in the header, and in the last section at the current position in the code\. .\"bloc1] .PP Note that the order of these declaration is important, since they are translated into preprocessor sympols, typedef or code depending on their type\. For example use \fB%name\fP before any \fB%define\fP, since the name is needed to compose the name of the define symbols\. Order of \fB%header\fP and \fB%union\fP is important, since type may be undefined\. .SH "DECLARATION DEFINE SYMBOLS" These are the symbols you can define with \fB%define\fP in declaration section, or that are already defined\. Remind that they are replaced by a preprocessor \fB#define YY_\fP'\fIparser_name\fP'\fB_\fP'\fIname\fP\. .\"bloc1[ .IP "\\fBBISON\\fP" defined to \fB1\fP in the code\. used for conditional code\. Don't redefine it\. .IP "\\fBh_included\\fP" defined in the code, and in the header\. used for include anti\-reload\. Don't redefine it\. .IP "\\fBCOMPATIBILITY\\fP" Indicate if obsoleted defines are to be used and produced\. If defined to 0, indicate no compatibility needed, else if defined to non\-0, generate it\. If it is undefined, default is to be compatible if classes are not used\. .IP "\\fBUSE_GOTO\\fP" Indicates (if defined as 1) that \fBgoto\fP are to be used (for backward compatibility) in the parser function\. By default \fBgoto\fP are replaced with a \fBswitch\fP construction, to avoid problems with some compiler that don't support \fBgoto\fP and destructor in the same function block\. If \fBCOMPATIBILITY\fP is 1, and \fBUSE_GOTO\fP is not defined, then \fBUSE_GOTO\fP is defined to 1, to be compatible with older bison\. .IP "\\fBUSE_CONST_TOKEN\\fP" Indicate (if defined as 1) that \fBstatic const int\fP are to be used in C++, for token IDs\. By default an enum is used to define the token IDs instead of const\. .IP "\\fBENUM_TOKEN\\fP" When \fBenum\fP are used instead of \fBstatic const int\fP for token IDs, this symbol define the name of the enum type\. Defined to \fByy_\fP'\fIparser_name\fP'\fB_enum_token\fP by default\. .IP "\\fBPURE\\fP" Indicate that \fB%pure_parser\fP is asked\.\.\. Don't redefine it\. .IP "\\fBLSP_NEEDED\\fP" if defined indicate that @ construct is used, so \fBLLOC\fP stack is needed\. Can be defined to force use of location stack\. .IP "\\fBDEBUG\\fP" if defined to non\-0 activate debugging code\. See\fB YYDEBUG\fP in bison\. .IP "\\fBERROR_VERBOSE\\fP" if defined activate dump parser stack when error append\. .IP "\\fBSTYPE\\fP" the type of the semantic value of token\. defined by \fB%union\fP\. default is \fBint\fP\. See \fBYYSTYPE\fP in bison\. Don't redefine it, if you use a \fB%union\fP\. .IP "\\fBLTYPE\\fP" The token location type\. If needed default is \fByyltype\fP\. See \fBYYLTYPE\fP in bison\. default \fByyltype\fP is a typedef and struct defined as in old bison\. .IP "\\fBLLOC\\fP" The token location variable name\. If needed, default is \fByylloc\fP\. See \fByylloc\fP in bison\. .IP "\\fBLVAL\\fP" The token semantic value variable name\. Default \fByylval\fP\. See \fByylval\fP in bison\. .IP "\\fBCHAR\\fP" The lookahead token value variable name\. Default \fByychar\fP\. See \fByychar\fP in bison\. .IP "\\fBLEX\\fP" The scanner function name\. Default \fByylex\fP\. See \fByylex\fP in bison\. .IP "\\fBPARSE\\fP" The parser function name\. Default \fByyparse\fP\. See \fByyparse\fP in bison\. .IP "\\fBPARSE_PARAM\\fP" The parser function parameters declaration\. Default \fBvoid\fP in C++ or ANSIC, nothing if old C\. In ANSIC and C++ contain the prototype\. In old\-C comtaim just the list of parameters name\. Don't allows default value\. .IP "\\fBPARSE_PARAM_DEF\\fP" The parser function parameters definition, for old style C\. Default nothing\. For example to use an \fBint\fP parameter called \fBx\fP, PARSE_PARAM is \fBx\fP, and PARSE_PARAM_DEF is \fBint x;\fP\. In ANSIC or C++ it is unuseful and ignored\. .IP "\\fBERROR\\fP" The error function name\. Default \fByyerror\fP\. See \fByyerror\fP in bison\. .IP "\\fBNERRS\\fP" The error count name\. Default \fByynerrs\fP\. See \fByynerrs\fP in bison\. .IP "\\fBDEBUG_FLAG\\fP" The runtime debug flag\. Default \fByydebug\fP\. See \fByydebug\fP in bison\. .\"bloc1] .PP These are only used if class is generated\. .\"bloc1[ .IP "\\fBCLASS\\fP" The class name\. default is the parser name\. .IP "\\fBINHERIT\\fP" The inheritance list\. Don't forget the \fB:\fP before, if not empty list\. .IP "\\fBMEMBERS\\fP" List of members to add to the class definition, before ending it\. .IP "\\fBLEX_BODY\\fP" The scanner member function boby\. May be defined to \fB=0\fP for pure function, or to an inline body\. .IP "\\fBERROR_BODY\\fP" The error member function boby\. May be defined to \fB=0\fP for pure function, or to an inline body\. .IP "\\fBCONSTRUCTOR_PARAM\\fP" List of parameters of the constructor\. Dont allows default value\. .IP "\\fBCONSTRUCTOR_INIT\\fP" List of initialisation befor constructor call\. If not empty dont't forget the \fB:\fP before list of initialisation\. .IP "\\fBCONSTRUCTOR_CODE\\fP" Code added after internal initialisation in constructor\. .\"bloc1] .SH "OBSOLETED PREPROCESSOR SYMBOLS" if you use new features, the folowing symbols should not be used, though they are proposed\. The symbol \fBCOMPATIBILITY\fP control their disponibility\. Incoherence may arise if they are defined simultaneously with the new symbol\. .\"bloc1[ .IP "\\fBYYLTYPE\\fP" prefer \fB%define LTYPE\fP\. .IP "\\fBYYSTYPE\\fP" prefer \fB%define STYPE\fP\. .IP "\\fBYYDEBUG\\fP" prefer \fB%define DEBUG\fP\. .IP "\\fBYYERROR_VERBOSE\\fP" prefer \fB%define ERROR_VERBOSE\fP\. .IP "\\fBYYLSP_NEEDED\\fP" prefer \fB%define LSP_NEEDED\fP\. .IP "\\fByystype\\fP" Now a preprocessor symbol instead of a typedef\. prefer \fByy_\fP'\fIparser_name\fP'\fB_stype\fP\. .\"bloc1] .SH "CONSERVED PREPROCESSOR SYMBOLS" These symbols are kept, and cannot be defined elsewhere, since they control private parameters of the generated parser, or are actually unused\. You can \fB#define\fP them to the value you need, or indirectly to the name of a \fB%define\fP generated symbol if you want to be clean\. .\"bloc1[ .IP "\\fBYYINITDEPTH\\fP" initial stack depth\. .IP "\\fBYYMAXDEPTH\\fP" stack overflow limit depth\. .IP "\\fByyoverflow\\fP" instead of expand with alloca, realloc manualy or raise error\. .\"bloc1] .SH "OTHER ADDED PREPROCESSOR SYMBOLS" .\"bloc1[ .IP "\\fBYY_USE_CLASS\\fP" indicate that class will be produced\. Default if C++\. .\"bloc1] .SH "C++ CLASS GENERATED" To simplify the notation, we note \fB%SYMBOLNAME\fP the preprocessor symbol generated with a \fB%define\fP of this name\. In fact see the use of \fB%define\fP for it's real name\. .PP Note that there is sometime symbols that differ from only an underscore \fB_\fP, like \fByywrap\fP and \fByy_wrap\fP\. They are much different\. In this case \fByy_wrap()\fP is a virtual member function, and \fByywrap()\fP is a macro\. .SS "General Class declaration" class %CLASS %INHERIT .PP { .PP public: .PP #if %USE_CONST_TOKEN != 0 .PP static const TOKEN_NEXT; .PP static const AND_SO_ON; .PP // \.\.\. .PP #else .PP enum %ENUM_TOKEN { %NULL_TOKEN .\"bloc1[ .IP ,TOKEN_FIRST=256 .IP ,TOKEN_NEXT=257 .IP ,AND_SO_ON=258 .\"bloc1] .PP } ; .PP // \.\.\. .PP #endif .PP public: .PP int %PARSE (%PARSE_PARAM); .PP virtual void %ERROR(char *msg) %ERROR_BODY; .PP #ifdef %PURE .\"bloc1[ .IP // if %PURE , we must pass the value and (eventually) the location explicitely .IP #ifdef %LSP_NEEDED .IP // if and only if %LSP_NEEDED , we must pass the location explicitely .IP virtual int %LEX (%STYPE *%LVAL,%LTYPE *%LLOC) %LEX_BODY; .IP #else .IP virtual int %LEX (%STYPE *%LVAL) %LEX_BODY; .IP #endif .\"bloc1] .PP #else .\"bloc1[ .IP // if not %PURE , we must declare member to store the value and (eventually) the location explicitely .IP // if not %PURE ,%NERRS and %CHAR are not local variable to %PARSE, so must be member .IP virtual int %LEX() %LEX_BODY; .IP %STYPE %LVAL; .IP #ifdef %LSP_NEEDED .IP %LTYPE %LLOC; .IP #endif .IP int %NERRS; .IP int %CHAR; .\"bloc1] .PP #endif .PP #if %DEBUG != 0 .PP int %DEBUG_FLAG; /* nonzero means print parse trace */ .PP #endif .PP public: .PP %CLASS(%CONSTRUCTOR_PARAM); .PP public: .PP %MEMBERS .PP }; .PP // here are defined the token constants .PP // for example: .PP #if %USE_CONST_TOKEN != 0 .\"bloc1[ .IP const %CLASS::TOKEN_FIRST=1; .IP \.\.\. .\"bloc1] .PP #endif .PP // here is the construcor .PP %CLASS::%CLASS(%CONSTRUCTOR_PARAM) %CONSTRUCTOR_INIT .PP { .PP #if %DEBUG != 0 .PP %DEBUG_FLAG=0; .PP #endif .PP %CONSTRUCTOR_CODE; .PP }; .SS "Default Class declaration" // Here is the default declaration made in the header when you %define nothing .PP // typical yyltype .PP typedef struct yyltype .PP { .PP int timestamp; .PP int first_line; .PP int first_column; .PP int last_line; .PP int last_column; .PP char *text; .PP } yyltype; .PP // class definition .PP class parser .PP { .PP public: .PP enum yy_parser_enum_token { YY_parser_NULL_TOKEN .\"bloc1[ .IP ,TOKEN_FIRST=256 .IP ,TOKEN_NEXT=257 .IP ,AND_SO_ON=258 .\"bloc1] .PP } ; .PP // \.\.\. .PP public: .PP int yyparse (yyparse_PARAM); .PP virtual void yyerror(char *msg) ; .PP #ifdef YY_parser_PURE .\"bloc1[ .IP #ifdef YY_parser_LSP_NEEDED .IP virtual int yylex (int *yylval,yyltype *yylloc) ; .IP #else .IP virtual int yylex (int *yylval) ; .IP #endif .\"bloc1] .PP #else .\"bloc1[ .IP virtual int yylex() %LEX_BODY; .IP int yylval; .IP #ifdef YY_parser_LSP_NEEDED .IP yyltype yylloc; .IP #endif .IP int yynerrs; .IP int yychar; .\"bloc1] .PP #endif .PP #if YY_parser_DEBUG != 0 .PP int yydebug; .PP #endif .PP public: .PP parser(); .PP public: .PP }; .PP // here is the constructor code .PP parser::parser() .PP { .PP #if YY_parser_DEBUG != 0 .PP yydebug=0; .PP #endif .PP }; .SH "USAGE" Should replace \fBbison\fP, because it generate a far more customisable parser, still beeing compatible\. .PP You should always use the header facility\. .PP Use it with \fBflex++\fP (same author)\. .SH "EXEMPLES" This man page has been produced through a parser made in C++ with this version of \fBbison\fP and our version of \fBflex++\fP (same author)\. .SH "FILES" .\"bloc1[ .IP "\\fBbison\\.cc\\fP" main skeleton\. .IP "\\fBbison\\.h\\fP" header skeleton\. .IP "\\fBbison\\.hairy\\fP" old main skeleton for semantic parser\. Not adapted to this version\. Kept for future works\. .\"bloc1] .SH "ENVIRONNEMENT" .SH "DIAGNOSTICS" .SH "SEE ALSO" \fBbison\fP(1), \fBbison\.info\fP (use texinfo), \fBflex++\fP(1)\. .SH "DOCUMENTATION" .SH "BUGS" Tell us more ! .PP The \fB%semantic_parser\fP is no more supported\. If you want to use it, adapt the skeletons, and maybe \fBbison++\fP generator itself\. The reason is that it seems unused, unuseful, not documented, and too complex for us to support\. tell us if you use, need, or understand it\. .PP Header is not included in the parser code\. Change made in the generated header are not used in the parser code, even if you include it volontarily, since it is guarded against re\-include\. So don't modify it\. .PP For the same reasons, if you modify the header skeleton, or the code skeleton, report the changes in the other skeleton if applicable\. If not done, incoherent declarations may lead to unpredictable result\. .PP Use of defines for \fBYYLTYPE\fP, \fBYYSTYPE\fP, \fBYYDEBUG\fP is supported for backward compatibility in C, but should not be used with new features, as \fB%defines\fP or C++ classes\. You can define them, and use them as with old \fBbison\fP in C only\. .PP Parameters are richer than before, and nothing is removed\. POSIX compliance can be enforced by not using extensions\. If you want to forbide them, there is a good job ! .SH "FUTUR WORKS" tell us ! .PP Support semantic parser\. Is it really used ? .PP POSIX compliance\. is'nt it good now ? .PP Use lex and yacc (flex/bison) to generate the scanner/parser\. It would be comfortable for futur works, though very complicated\. Who feel it good ? .PP \fBiostream\fP : this is a great demand\. this work will be done as soon as possible\. The virtual members permit such work still easily\. .SH "INSTALLATION" With this install the executable is named bison++\. rename it bison if you want, because it could replace \fBbison\fP\. .SH "TESTS" .SH "AUTHORS" Alain Coe\*:tmeur (coetmeur@icdc\.fr), R&D department (RDT) , Informatique\-CDC, France\. .SH "RESTRICTIONS" The words 'author', and 'us' mean the author and colleages, not GNU\. We don't have contacted GNU about this, nowaday\. If you're in GNU, we are ready to propose it to you, and you may tell us what you think about\. .PP Based on GNU version 1\.21 of bison\. Modified by the author\.