Bison C++ Push-Skeleton - UML class-diagram
The push-parser interface has five abstract methods and one enumeration. The enumeration describes the parser state and will be returned by parseToken(...).
The values are:
  • Unkown describes an internal state
  • Accept describes a paser state == accept;
  • Abort describes a paser state == abort;
  • Wait means that the parser needs a new token
The new data type SematicType is a typedef of yystype. The new data type LocationType is a definition of yy::Location. The methods setDebug(...) and debug() are self-explanatory. The methode parseToken(int token,SemanticType yylvlal,LocationType yylloc) is a call from the lexer to send the next token to the PushParser.
The methods accept() and error() are callback methods for the backend.
If the parser has reached the accept state, then the accept() methode will be called from doAccept(). (see UML Sequence-Diagram-Accept)
If the parser has reached the error state, the error() methode will be called from doErrlab1() or doAbort(). (see UML Sequence-Diagram-Error)
When using multiple parsers where one is dependant on another, it is helpful to notify the parser of the state of the other.

ScalcPushParser and MfcalcPushParser are generated by bison with the push-skeleton and the grammar file. The five interface methods will be overloaded. YYACCEPT(),YYABORT(), YYERROR() and yyerrok() are called in the semantic action like the macro YYACCEPT, YYABORT, YYERROR and yyerror in the yacc-skeleton. yyerror(...) is like yyerror(...) in the yacc-skeleton. The methode debugPrint(...) is called by debugOutput(...) and writes out debugging information. The methods yyerror(...) and debugPrint(...) are abstract and must be overloaded. These two methods are abstract so that the push-skeleton is independent from iostream or other output librarys. The user decides which output library will be used. It is not possible to generate an object from this class because the constructor is protected. To use the push-parser, derive a class from this class and overload the abstract methods.

MyScalcPushParser and MyMfcalcPushParser are user-generated by deriving from the bison generated class. You can analyse the parser state by looking at the return value from parseToken(...) or by overloading the error() and accept() methods.
Now you decide which output library will be used by overloading yyerror(...) and debugPrint(...).