#include "avltree.h"
#include "fsmgraph.h"
#include "parsedata.h"
+#include "redfsm.h"
/* Forwards. */
struct TransAp;
}
};
-class XMLCodeGen
+struct GenBase
+{
+ GenBase( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser );
+
+ void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
+ void reduceActionTables();
+
+ char *fsmName;
+ ParseData *pd;
+ FsmAp *fsm;
+ XmlParser &xmlParser;
+
+ ActionTableMap actionTableMap;
+ int nextActionTableId;
+};
+
+class XMLCodeGen : protected GenBase
{
public:
XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm,
std::ostream &out, XmlParser &xmlParser );
+
void writeXML( );
- void makeBackend( );
private:
- void appendTrans( TransListVect &outList, Key lowKey, Key highKey, TransAp *trans );
void writeStateActions( StateAp *state );
void writeStateList();
void writeStateConditions( StateAp *state );
void writeActionList();
void writeActionTableList();
void reduceTrans( TransAp *trans );
- void reduceActionTables();
void writeTransList( StateAp *state );
void writeEofTrans( StateAp *state );
void writeTrans( Key lowKey, Key highKey, TransAp *defTrans );
void writeMachine();
void writeActionExec( InlineItem *item );
+ std::ostream &out;
+};
+
+class BackendGen : protected GenBase
+{
+public:
+ BackendGen( char *fsmName, ParseData *pd, FsmAp *fsm, XmlParser &xmlParser );
+ void makeBackend( );
+
+private:
void makeGenInlineList( GenInlineList *outList, InlineList *inList );
void makeKey( GenInlineList *outList, Key key );
void makeText( GenInlineList *outList, InlineItem *item );
- void makeGoto( GenInlineList *outList, InlineItem *item );
- void makeGotoExpr( GenInlineList *outList, InlineItem *item );
- void makeCall( GenInlineList *outList, InlineItem *item );
- void makeCallExpr( GenInlineList *outList, InlineItem *item );
- void makeNext( GenInlineList *outList, InlineItem *item );
- void makeNextExpr( GenInlineList *outList, InlineItem *item );
- void makeEntry( GenInlineList *outList, InlineItem *item );
void makeLmOnLast( GenInlineList *outList, InlineItem *item );
void makeLmOnNext( GenInlineList *outList, InlineItem *item );
void makeLmOnLagBehind( GenInlineList *outList, InlineItem *item );
void makeActionExec( GenInlineList *outList, InlineItem *item );
void makeLmSwitch( GenInlineList *outList, InlineItem *item );
-
- char *fsmName;
- ParseData *pd;
- FsmAp *fsm;
- std::ostream &out;
- XmlParser &xmlParser;
-
- ActionTableMap actionTableMap;
- int nextActionTableId;
+ void makeSetTokend( GenInlineList *outList, long offset );
+ void makeSetAct( GenInlineList *outList, long lmId );
+ void makeSubList( GenInlineList *outList, InlineList *inlineList,
+ GenInlineItem::Type type );
+ void makeTargetItem( GenInlineList *outList, long targetId, GenInlineItem::Type type );
+ void makeExecGetTokend( GenInlineList *outList );
+ void makeExports();
+ void makeMachine();
+ void makeActionList();
+ void makeAction( Action *action );
+ void makeActionTableList();
+ void makeConditions();
+ void makeEntryPoints();
+ bool makeNameInst( std::string &out, NameInst *nameInst );
+ void makeStateList();
+
+ void makeStateActions( StateAp *state );
+ void makeEofTrans( StateAp *state );
+ void makeStateConditions( StateAp *state );
+ void makeTransList( StateAp *state );
+ void makeTrans( Key lowKey, Key highKey, TransAp *trans );
};