# along with Ragel; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-INCS += -I../common -I../aapl
+INCS += -I../common -I../aapl -I../redfsm
DEFS +=
CFLAGS += -g -Wall
#include "vector.h"
#include "version.h"
#include "common.h"
+#include "xmlparse.h"
using std::istream;
using std::ostream;
void CodeGenData::initActionList( unsigned long length )
{
- allActions = new Action[length];
+ allActions = new GenAction[length];
for ( unsigned long a = 0; a < length; a++ )
actionList.append( allActions+a );
}
void CodeGenData::closeMachine()
{
- for ( ActionList::Iter a = actionList; a.lte(); a++ )
+ for ( GenActionList::Iter a = actionList; a.lte(); a++ )
resolveTargetStates( a->inlineList );
/* Note that even if we want a complete graph we do not give the error
* loop when in the error state. */
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- for ( StateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ )
+ for ( GenStateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ )
st->stateCondVect.append( sci );
}
}
void CodeGenData::initCondSpaceList( ulong length )
{
- allCondSpaces = new CondSpace[length];
+ allCondSpaces = new GenCondSpace[length];
for ( ulong c = 0; c < length; c++ )
condSpaceList.append( allCondSpaces + c );
}
void CodeGenData::newCondSpace( int cnum, int condSpaceId, Key baseKey )
{
- CondSpace *cond = allCondSpaces + cnum;
+ GenCondSpace *cond = allCondSpaces + cnum;
cond->condSpaceId = condSpaceId;
cond->baseKey = baseKey;
}
void CodeGenData::condSpaceItem( int cnum, long condActionId )
{
- CondSpace *cond = allCondSpaces + cnum;
+ GenCondSpace *cond = allCondSpaces + cnum;
cond->condSet.append( allActions + condActionId );
}
RedStateAp *curState = allStates + snum;
/* Create the new state condition. */
- StateCond *stateCond = new StateCond;
+ GenStateCond *stateCond = new GenStateCond;
stateCond->lowKey = lowKey;
stateCond->highKey = highKey;
/* Assign it a cond space. */
- CondSpace *condSpace = allCondSpaces + condNum;
+ GenCondSpace *condSpace = allCondSpaces + condNum;
stateCond->condSpace = condSpace;
curState->stateCondList.append( stateCond );
}
-CondSpace *CodeGenData::findCondSpace( Key lowKey, Key highKey )
+GenCondSpace *CodeGenData::findCondSpace( Key lowKey, Key highKey )
{
for ( CondSpaceList::Iter cs = condSpaceList; cs.lte(); cs++ ) {
Key csHighKey = cs->baseKey;
for ( RedTransList::Iter rtel = st->outSingle; rtel.lte(); rtel++ ) {
if ( rtel->value->action != 0 ) {
rtel->value->action->numTransRefs += 1;
- for ( ActionTable::Iter item = rtel->value->action->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = rtel->value->action->key; item.lte(); item++ )
item->value->numTransRefs += 1;
}
}
for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
if ( rtel->value->action != 0 ) {
rtel->value->action->numTransRefs += 1;
- for ( ActionTable::Iter item = rtel->value->action->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = rtel->value->action->key; item.lte(); item++ )
item->value->numTransRefs += 1;
}
}
/* Reference count default transition. */
if ( st->defTrans != 0 && st->defTrans->action != 0 ) {
st->defTrans->action->numTransRefs += 1;
- for ( ActionTable::Iter item = st->defTrans->action->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = st->defTrans->action->key; item.lte(); item++ )
item->value->numTransRefs += 1;
}
/* Reference count eof transitions. */
if ( st->eofTrans != 0 && st->eofTrans->action != 0 ) {
st->eofTrans->action->numTransRefs += 1;
- for ( ActionTable::Iter item = st->eofTrans->action->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = st->eofTrans->action->key; item.lte(); item++ )
item->value->numTransRefs += 1;
}
/* Reference count to state actions. */
if ( st->toStateAction != 0 ) {
st->toStateAction->numToStateRefs += 1;
- for ( ActionTable::Iter item = st->toStateAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = st->toStateAction->key; item.lte(); item++ )
item->value->numToStateRefs += 1;
}
/* Reference count from state actions. */
if ( st->fromStateAction != 0 ) {
st->fromStateAction->numFromStateRefs += 1;
- for ( ActionTable::Iter item = st->fromStateAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = st->fromStateAction->key; item.lte(); item++ )
item->value->numFromStateRefs += 1;
}
/* Reference count EOF actions. */
if ( st->eofAction != 0 ) {
st->eofAction->numEofRefs += 1;
- for ( ActionTable::Iter item = st->eofAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = st->eofAction->key; item.lte(); item++ )
item->value->numEofRefs += 1;
}
}
}
-void CodeGenData::analyzeAction( Action *act, GenInlineList *inlineList )
+void CodeGenData::analyzeAction( GenAction *act, GenInlineList *inlineList )
{
for ( GenInlineList::Iter item = *inlineList; item.lte(); item++ ) {
/* Only consider actions that are referenced. */
void CodeGenData::assignActionIds()
{
int nextActionId = 0;
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Only ever interested in referenced actions. */
if ( act->numRefs() > 0 )
act->actionId = nextActionId++;
/* Maximum values going into the action array. */
if ( at->key.length() > redFsm->maxActArrItem )
redFsm->maxActArrItem = at->key.length();
- for ( ActionTable::Iter item = at->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = at->key; item.lte(); item++ ) {
if ( item->value->actionId > redFsm->maxActArrItem )
redFsm->maxActArrItem = item->value->actionId;
}
findFinalActionRefs();
/* Check if there are any calls in action code. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Record the occurrence of various kinds of actions. */
if ( act->numToStateRefs > 0 )
redFsm->bAnyToStateActions = true;
/* Analyze reduced action lists. */
for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- for ( ActionTable::Iter act = redAct->key; act.lte(); act++ )
+ for ( GenActionTable::Iter act = redAct->key; act.lte(); act++ )
analyzeActionList( redAct, act->value->inlineList );
}
extern bool generateDot;
struct NameInst;
-typedef DList<Action> ActionList;
+typedef DList<GenAction> GenActionList;
typedef unsigned long ulong;
char *fsmName;
ostream &out;
RedFsmAp *redFsm;
- Action *allActions;
+ GenAction *allActions;
RedAction *allActionTables;
Condition *allConditions;
- CondSpace *allCondSpaces;
+ GenCondSpace *allCondSpaces;
RedStateAp *allStates;
NameInst **nameIndex;
int startState;
int errState;
- ActionList actionList;
+ GenActionList actionList;
ConditionList conditionList;
CondSpaceList condSpaceList;
GenInlineList *getKeyExpr;
void initStateCondList( int snum, ulong length );
void addStateCond( int snum, Key lowKey, Key highKey, long condNum );
- CondSpace *findCondSpace( Key lowKey, Key highKey );
+ GenCondSpace *findCondSpace( Key lowKey, Key highKey );
Condition *findCondition( Key key );
bool setAlphType( char *data );
/* Gather various info on the machine. */
void analyzeActionList( RedAction *redAct, GenInlineList *inlineList );
- void analyzeAction( Action *act, GenInlineList *inlineList );
+ void analyzeAction( GenAction *act, GenInlineList *inlineList );
void findFinalActionRefs();
void analyzeMachine();
/* KeyOps *keyOps = 0; */
-string Action::nameOrLoc()
+string GenAction::nameOrLoc()
{
if ( name != 0 )
return string(name);
st->condHighKey = st->stateCondList.tail->highKey;
unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey );
- st->condList = new CondSpace*[ span ];
- memset( st->condList, 0, sizeof(CondSpace*)*span );
+ st->condList = new GenCondSpace*[ span ];
+ memset( st->condList, 0, sizeof(GenCondSpace*)*span );
- for ( StateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ ) {
+ for ( GenStateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ ) {
unsigned long long base, trSpan;
base = keyOps->span( st->condLowKey, sci->lowKey )-1;
trSpan = keyOps->span( sci->lowKey, sci->highKey );
struct RedStateAp;
struct GenInlineList;
-struct Action;
+struct GenAction;
/* Location in an input file. */
struct GenInputLoc
struct GenInlineList : public DList<GenInlineItem> { };
/* Element in list of actions. Contains the string for the code to exectute. */
-struct Action
+struct GenAction
:
- public DListEl<Action>
+ public DListEl<GenAction>
{
- Action( )
+ GenAction( )
:
name(0),
inlineList(0),
struct RedStateAp;
struct StateAp;
-/* Transistion Action Element. */
-typedef SBstMapEl< int, Action* > ActionTableEl;
+/* Transistion GenAction Element. */
+typedef SBstMapEl< int, GenAction* > GenActionTableEl;
-/* Transition Action Table. */
-struct ActionTable
- : public SBstMap< int, Action*, CmpOrd<int> >
+/* Transition GenAction Table. */
+struct GenActionTable
+ : public SBstMap< int, GenAction*, CmpOrd<int> >
{
- void setAction( int ordering, Action *action );
- void setActions( int *orderings, Action **actions, int nActs );
- void setActions( const ActionTable &other );
+ void setAction( int ordering, GenAction *action );
+ void setActions( int *orderings, GenAction **actions, int nActs );
+ void setActions( const GenActionTable &other );
};
/* Compare of a whole action table element (key & value). */
-struct CmpActionTableEl
+struct CmpGenActionTableEl
{
- static int compare( const ActionTableEl &action1,
- const ActionTableEl &action2 )
+ static int compare( const GenActionTableEl &action1,
+ const GenActionTableEl &action2 )
{
if ( action1.key < action2.key )
return -1;
}
};
-/* Compare for ActionTable. */
-typedef CmpSTable< ActionTableEl, CmpActionTableEl > CmpActionTable;
+/* Compare for GenActionTable. */
+typedef CmpSTable< GenActionTableEl, CmpGenActionTableEl > CmpGenActionTable;
/* Set of states. */
typedef BstSet<RedStateAp*> RedStateSet;
bAnyBreakStmt(false)
{ }
- const ActionTable &getKey()
+ const GenActionTable &getKey()
{ return key; }
- ActionTable key;
+ GenActionTable key;
int actListId;
int location;
IntSet *eofRefs;
bool bAnyCurStateRef;
bool bAnyBreakStmt;
};
-typedef AvlTree<RedAction, ActionTable, CmpActionTable> ActionTableMap;
+typedef AvlTree<RedAction, GenActionTable, CmpGenActionTable> ActionTableMap;
/* Reduced transition. */
struct RedTransAp
typedef Vector<int> EntryIdVect;
typedef Vector<char*> EntryNameVect;
-typedef Vector< Action* > CondSet;
+typedef Vector< GenAction* > GenCondSet;
struct Condition
{
Key key;
Key baseKey;
- CondSet condSet;
+ GenCondSet condSet;
Condition *next, *prev;
};
typedef DList<Condition> ConditionList;
-struct CondSpace
+struct GenCondSpace
{
Key baseKey;
- CondSet condSet;
+ GenCondSet condSet;
int condSpaceId;
- CondSpace *next, *prev;
+ GenCondSpace *next, *prev;
};
-typedef DList<CondSpace> CondSpaceList;
+typedef DList<GenCondSpace> CondSpaceList;
-struct StateCond
+struct GenStateCond
{
Key lowKey;
Key highKey;
- CondSpace *condSpace;
+ GenCondSpace *condSpace;
- StateCond *prev, *next;
+ GenStateCond *prev, *next;
};
-typedef DList<StateCond> StateCondList;
-typedef Vector<StateCond*> StateCondVect;
+typedef DList<GenStateCond> GenStateCondList;
+typedef Vector<GenStateCond*> StateCondVect;
/* Reduced state. */
struct RedStateAp
/* For flat conditions. */
Key condLowKey, condHighKey;
- CondSpace **condList;
+ GenCondSpace **condList;
/* For flat keys. */
Key lowKey, highKey;
RedAction *eofAction;
RedTransAp *eofTrans;
int id;
- StateCondList stateCondList;
+ GenStateCondList stateCondList;
StateCondVect stateCondVect;
/* Pointers for the list of states. */
#include "vector.h"
#include "gendata.h"
+#include "buffer.h"
#include <iostream>
+using std::istream;
using std::ostream;
+#define XML_BUFSIZE 4096
+
struct AttrMarker
{
char *id;
int id;
};
-struct Token
-{
- XMLTag *tag;
- GenInputLoc loc;
-};
+struct Token;
struct GenInlineItem;
struct GenInlineList;
struct LmSwitchVect;
struct LmSwitchAction;
+struct XmlScanner
+{
+ XmlScanner( const char *fileName, istream &input );
+
+ int scan();
+ void adjustAttrPointers( int distance );
+ std::ostream &error();
+
+ const char *fileName;
+ istream &input;
+
+ /* Scanner State. */
+ int cs, act, have, curline, curcol;
+ char *ts, *te;
+ char *p, *pe;
+ int done;
+
+ /* Token data */
+ char *data;
+ int data_len;
+ int value;
+ AttrMkList attrMkList;
+ Buffer buffer;
+ char *tag_id_start;
+ int tag_id_len;
+ int token_col, token_line;
+
+ char buf[XML_BUFSIZE];
+};
+
+
struct XmlParser
{
%%{
long readOffsetPtr( char *td, char **end );
unsigned long readLength( char *td );
+struct Token
+{
+ XMLTag *tag;
+ GenInputLoc loc;
+};
+
CodeGenData *makeCodeGen( char *sourceFileName, char *fsmName,
ostream &out, bool wantComplete )
{
#include <string.h>
#include "vector.h"
#include "xmlparse.h"
-#include "buffer.h"
using std::istream;
using std::cout;
using std::cerr;
using std::endl;
-#define BUFSIZE 4096
-
%%{
machine XmlScanner;
write data;
static struct XMLTagHashPair *in_word_set (const char *str, unsigned int len);
};
-struct XmlScanner
+XmlScanner::XmlScanner( const char *fileName, istream &input ) :
+ fileName(fileName),
+ input(input),
+ curline(1),
+ curcol(1),
+ p(0), pe(0),
+ done(false),
+ data(0), data_len(0),
+ value(0)
{
- XmlScanner( const char *fileName, istream &input ) :
- fileName(fileName),
- input(input),
- curline(1),
- curcol(1),
- p(0), pe(0),
- done(false),
- data(0), data_len(0),
- value(0)
- {
- %%{
- machine XmlScanner;
- write init;
- }%%
- }
-
- int scan();
- void adjustAttrPointers( int distance );
- std::ostream &error();
-
- const char *fileName;
- istream &input;
-
- /* Scanner State. */
- int cs, act, have, curline, curcol;
- char *ts, *te;
- char *p, *pe;
- int done;
-
- /* Token data */
- char *data;
- int data_len;
- int value;
- AttrMkList attrMkList;
- Buffer buffer;
- char *tag_id_start;
- int tag_id_len;
- int token_col, token_line;
-
- char buf[BUFSIZE];
-};
-
+ %%{
+ machine XmlScanner;
+ write init;
+ }%%
+}
#define TK_NO_TOKEN (-1)
#define TK_ERR 1
}
p = buf + have;
- space = BUFSIZE - have;
+ space = XML_BUFSIZE - have;
if ( space == 0 ) {
/* We filled up the buffer trying to scan a token. */
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
out << "f" << redAct->actListId << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tgoto _again;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true, false );
out << "\tbreak;\n";
std::ostream &FlatCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &FlatCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &FlatCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &FlatCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break */
out <<
" switch ( _cond ) {\n";
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
+ GenCondSpace *condSpace = csi;
out << " case " << condSpace->condSpaceId + 1 << ": {\n";
out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "));\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(2) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
if ( totalActions++ % 8 == 7 )
out << "\n\t";
- for ( ActionTable::Iter item = act->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) {
out << item->value->actionId;
if ( ! (act.last() && item.last()) )
out << ", ";
return ret.str();
}
-void FsmCodeGen::ACTION( ostream &ret, Action *action, int targState,
+void FsmCodeGen::ACTION( ostream &ret, GenAction *action, int targState,
bool inFinish, bool csForced )
{
/* Write the preprocessor line info for going into the source file. */
ret << "}\n";
}
-void FsmCodeGen::CONDITION( ostream &ret, Action *condition )
+void FsmCodeGen::CONDITION( ostream &ret, GenAction *condition )
{
ret << "\n";
cdLineDirective( ret, sourceFileName, condition->loc.line );
struct RedFsmAp;
struct RedStateAp;
struct CodeGenData;
-struct Action;
+struct GenAction;
struct NameInst;
struct GenInlineItem;
struct GenInlineList;
string TABS( int level );
string KEY( Key key );
string LDIR_PATH( char *path );
- void ACTION( ostream &ret, Action *action, int targState,
+ void ACTION( ostream &ret, GenAction *action, int targState,
bool inFinish, bool csForced );
- void CONDITION( ostream &ret, Action *condition );
+ void CONDITION( ostream &ret, GenAction *condition );
string ALPH_TYPE();
string WIDE_ALPH_TYPE();
string ARRAY_TYPE( unsigned long maxVal );
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false, false );
out << "\tbreak;\n";
std::ostream &GotoCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &GotoCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &GotoCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &GotoCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. */
out << " goto _out;\n";
}
-void GotoCodeGen::COND_TRANSLATE( StateCond *stateCond, int level )
+void GotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level )
{
- CondSpace *condSpace = stateCond->condSpace;
+ GenCondSpace *condSpace = stateCond->condSpace;
out << TABS(level) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "));\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(level) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
{
/* Get the mid position, staying on the lower end of the range. */
int mid = (low + high) >> 1;
- StateCond **data = state->stateCondVect.data;
+ GenStateCond **data = state->stateCondVect.data;
/* Determine if we need to look higher or lower. */
bool anyLower = mid > low;
struct NameInst;
struct RedTransAp;
struct RedStateAp;
-struct StateCond;
+struct GenStateCond;
/*
* Goto driven fsm.
std::ostream &FROM_STATE_ACTIONS();
std::ostream &EOF_ACTIONS();
- void COND_TRANSLATE( StateCond *stateCond, int level );
+ void COND_TRANSLATE( GenStateCond *stateCond, int level );
void emitCondBSearch( RedStateAp *state, int level, int low, int high );
void STATE_CONDS( RedStateAp *state, bool genDefault );
out << " " << CS() << " = " << trans->targ->id << ";\n";
/* Write each action in the list. */
- for ( ActionTable::Iter item = trans->action->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = trans->action->key; item.lte(); item++ ) {
ACTION( out, item->value, trans->targ->id, false,
trans->action->anyNextStmt() );
}
if ( state->toStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->toStateAction->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = state->toStateAction->key; item.lte(); item++ ) {
ACTION( out, item->value, state->id, false,
state->toStateAction->anyNextStmt() );
}
if ( state->fromStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ ) {
ACTION( out, item->value, state->id, false,
state->fromStateAction->anyNextStmt() );
}
anyWritten = true;
/* Write each action in the eof action list. */
- for ( ActionTable::Iter item = act->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = act->key; item.lte(); item++ )
ACTION( out, item->value, STATE_ERR_STATE, true, false );
out << "\tbreak;\n";
}
* invoked on characters (ie, not from out action code). */
if ( trans->action != 0 ) {
/* Loop the actions. */
- for ( ActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
+ for ( GenActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
/* Get the action and walk it's tree. */
setLabelsNeeded( act->value->inlineList );
}
if ( state->toStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->toStateAction->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = state->toStateAction->key; item.lte(); item++ ) {
ACTION( out, item->value, state->id, false,
state->toStateAction->anyNextStmt() );
}
if ( state->fromStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ ) {
ACTION( out, item->value, state->id, false,
state->fromStateAction->anyNextStmt() );
}
out << " " << CS() << " = " << trans->targ->id << ";\n";
/* Write each action in the list. */
- for ( ActionTable::Iter item = trans->action->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = trans->action->key; item.lte(); item++ ) {
ACTION( out, item->value, trans->targ->id, false,
trans->action->anyNextStmt() );
}
if ( st->toStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
- for ( ActionTable::Iter item = st->toStateAction->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = st->toStateAction->key; item.lte(); item++ ) {
ACTION( out, item->value, st->id, false,
st->toStateAction->anyNextStmt() );
}
* invoked on characters (ie, not from out action code). */
if ( trans->action != 0 ) {
/* Loop the actions. */
- for ( ActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
+ for ( GenActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
/* Get the action and walk it's tree. */
setLabelsNeeded( fromState, act->value->inlineList );
}
std::ostream &TabCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &TabCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &TabCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &TabCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. */
int totalTrans = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Lower key. */
out << KEY( sc->lowKey ) << ", ";
if ( ++totalTrans % IALL == 0 )
int totalTrans = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Cond Space id. */
out << sc->condSpace->condSpaceId << ", ";
if ( ++totalTrans % IALL == 0 )
" + ((_mid - _keys)>>1)] ) {\n";
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
+ GenCondSpace *condSpace = csi;
out << " case " << condSpace->condSpaceId << ": {\n";
out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "));\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(2) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
out << "f" << redAct->actListId << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tgoto _again;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true );
out << "\tbreak;\n";
std::ostream &CSharpFlatCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &CSharpFlatCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &CSharpFlatCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &CSharpFlatCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break */
out <<
" switch ( _cond ) {\n";
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
+ GenCondSpace *condSpace = csi;
out << " case " << condSpace->condSpaceId + 1 << ": {\n";
out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "));\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(2) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
if ( totalActions++ % 8 == 7 )
out << "\n\t";
- for ( ActionTable::Iter item = act->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) {
out << item->value->actionId;
if ( ! (act.last() && item.last()) )
out << ", ";
return ret.str();
}
-void CSharpFsmCodeGen::ACTION( ostream &ret, Action *action, int targState, bool inFinish )
+void CSharpFsmCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish )
{
/* Write the preprocessor line info for going into the source file. */
csharpLineDirective( ret, sourceFileName, action->loc.line );
ret << "}\n";
}
-void CSharpFsmCodeGen::CONDITION( ostream &ret, Action *condition )
+void CSharpFsmCodeGen::CONDITION( ostream &ret, GenAction *condition )
{
ret << "\n";
csharpLineDirective( ret, sourceFileName, condition->loc.line );
struct RedFsmAp;
struct RedStateAp;
struct CodeGenData;
-struct Action;
+struct GenAction;
struct NameInst;
struct GenInlineItem;
struct GenInlineList;
string KEY( Key key );
string ALPHA_KEY( Key key );
string LDIR_PATH( char *path );
- void ACTION( ostream &ret, Action *action, int targState, bool inFinish );
- void CONDITION( ostream &ret, Action *condition );
+ void ACTION( ostream &ret, GenAction *action, int targState, bool inFinish );
+ void CONDITION( ostream &ret, GenAction *condition );
string ALPH_TYPE();
string WIDE_ALPH_TYPE();
string ARRAY_TYPE( unsigned long maxVal );
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true );
out << "\tbreak;\n";
out << "\tcase " << redAct->actListId+1 << ":\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
out << "\tbreak;\n";
std::ostream &CSharpGotoCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &CSharpGotoCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &CSharpGotoCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &CSharpGotoCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. */
out << " goto _out;\n";
}
-void CSharpGotoCodeGen::COND_TRANSLATE( StateCond *stateCond, int level )
+void CSharpGotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level )
{
- CondSpace *condSpace = stateCond->condSpace;
+ GenCondSpace *condSpace = stateCond->condSpace;
out << TABS(level) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "));\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(level) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
{
/* Get the mid position, staying on the lower end of the range. */
int mid = (low + high) >> 1;
- StateCond **data = state->stateCondVect.data;
+ GenStateCond **data = state->stateCondVect.data;
/* Determine if we need to look higher or lower. */
bool anyLower = mid > low;
struct NameInst;
struct RedTransAp;
struct RedStateAp;
-struct StateCond;
+struct GenStateCond;
/*
* Goto driven fsm.
std::ostream &FROM_STATE_ACTIONS();
std::ostream &EOF_ACTIONS();
- void COND_TRANSLATE( StateCond *stateCond, int level );
+ void COND_TRANSLATE( GenStateCond *stateCond, int level );
void emitCondBSearch( RedStateAp *state, int level, int low, int high );
void STATE_CONDS( RedStateAp *state, bool genDefault );
out << " " << CS() << " = " << trans->targ->id << ";\n";
/* Write each action in the list. */
- for ( ActionTable::Iter item = trans->action->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = trans->action->key; item.lte(); item++ )
ACTION( out, item->value, trans->targ->id, false );
/* If the action contains a next then we need to reload, otherwise
if ( state->toStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->toStateAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = state->toStateAction->key; item.lte(); item++ )
ACTION( out, item->value, state->id, false );
}
if ( state->fromStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ )
ACTION( out, item->value, state->id, false );
}
anyWritten = true;
/* Write each action in the eof action list. */
- for ( ActionTable::Iter item = act->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = act->key; item.lte(); item++ )
ACTION( out, item->value, STATE_ERR_STATE, true );
out << "\tbreak;\n";
}
* invoked on characters (ie, not from out action code). */
if ( trans->action != 0 ) {
/* Loop the actions. */
- for ( ActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
+ for ( GenActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
/* Get the action and walk it's tree. */
setLabelsNeeded( act->value->inlineList );
}
if ( state->toStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->toStateAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = state->toStateAction->key; item.lte(); item++ )
ACTION( out, item->value, state->id, false );
}
if ( state->fromStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
anyWritten = true;
- for ( ActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ )
ACTION( out, item->value, state->id, false );
}
out << " " << CS() << " = " << trans->targ->id << ";\n";
/* Write each action in the list. */
- for ( ActionTable::Iter item = trans->action->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = trans->action->key; item.lte(); item++ )
ACTION( out, item->value, trans->targ->id, false );
}
if ( st->toStateAction != 0 ) {
/* Remember that we wrote an action. Write every action in the list. */
- for ( ActionTable::Iter item = st->toStateAction->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = st->toStateAction->key; item.lte(); item++ )
ACTION( out, item->value, st->id, false );
genLineDirective( out );
}
* invoked on characters (ie, not from out action code). */
if ( trans->action != 0 ) {
/* Loop the actions. */
- for ( ActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
+ for ( GenActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
/* Get the action and walk it's tree. */
setLabelsNeeded( fromState, act->value->inlineList );
}
std::ostream &CSharpTabCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &CSharpTabCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &CSharpTabCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &CSharpTabCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. */
int totalTrans = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Lower key. */
out << ALPHA_KEY( sc->lowKey ) << ", ";
if ( ++totalTrans % IALL == 0 )
int totalTrans = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Cond Space id. */
out << sc->condSpace->condSpaceId << ", ";
if ( ++totalTrans % IALL == 0 )
" + ((_mid - _keys)>>1)] ) {\n";
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
+ GenCondSpace *condSpace = csi;
out << " case " << condSpace->condSpaceId << ": {\n";
out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "));\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(2) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
/* Loop the existing actions and write out what's there. */
for ( int a = 0; a < n; a++ ) {
- for ( ActionTable::Iter actIt = actions[a]->key.first(); actIt.lte(); actIt++ ) {
- Action *action = actIt->value;
+ for ( GenActionTable::Iter actIt = actions[a]->key.first(); actIt.lte(); actIt++ ) {
+ GenAction *action = actIt->value;
out << action->nameOrLoc();
if ( a < n-1 || !actIt.last() )
out << ", ";
{
/* The action. */
out << " / ";
- for ( ActionTable::Iter actIt = action->key.first(); actIt.lte(); actIt++ ) {
- Action *action = actIt->value;
+ for ( GenActionTable::Iter actIt = action->key.first(); actIt.lte(); actIt++ ) {
+ GenAction *action = actIt->value;
if ( action->name != 0 )
out << action->name;
else
std::ostream &GraphvizDotGen::ONCHAR( Key lowKey, Key highKey )
{
if ( lowKey > keyOps->maxKey ) {
- CondSpace *condSpace = findCondSpace( lowKey, highKey );
+ GenCondSpace *condSpace = findCondSpace( lowKey, highKey );
Key values = ( lowKey - condSpace->baseKey ) / keyOps->alphSize();
lowKey = keyOps->minKey +
}
out << "(";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
bool set = values & (1 << csi.pos());
if ( !set )
out << "!";
extern int numSplitPartitions;
-/* Print a summary of the options. */
-
/*
* Callbacks invoked by the XML data parser.
*/
;
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
+ GenCondSpace *condSpace = csi;
out << " case " << condSpace->condSpaceId << ": {\n";
out << TABS(2) << "_widec = " << KEY(condSpace->baseKey) <<
" + (" << GET_KEY() << " - " << KEY(keyOps->minKey) << ");\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(2) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
std::ostream &JavaTabCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &JavaTabCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &JavaTabCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &JavaTabCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. */
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Lower key. */
ARRAY_ITEM( KEY( sc->lowKey ), false );
ARRAY_ITEM( KEY( sc->highKey ), false );
{
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Cond Space id. */
ARRAY_ITEM( KEY( sc->condSpace->condSpaceId ), false );
}
/* Write out the length, which will never be the last character. */
ARRAY_ITEM( INT(act->key.length()), false );
- for ( ActionTable::Iter item = act->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = act->key; item.lte(); item++ )
ARRAY_ITEM( INT(item->value->actionId), (act.last() && item.last()) );
}
return out;
}
}
-void JavaTabCodeGen::ACTION( ostream &ret, Action *action, int targState, bool inFinish )
+void JavaTabCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish )
{
/* Write the preprocessor line info for going into the source file. */
javaLineDirective( ret, sourceFileName, action->loc.line );
ret << "}\n";
}
-void JavaTabCodeGen::CONDITION( ostream &ret, Action *condition )
+void JavaTabCodeGen::CONDITION( ostream &ret, GenAction *condition )
{
ret << "\n";
javaLineDirective( ret, sourceFileName, condition->loc.line );
string TABS( int level );
string KEY( Key key );
string INT( int i );
- void ACTION( ostream &ret, Action *action, int targState, bool inFinish );
- void CONDITION( ostream &ret, Action *condition );
+ void ACTION( ostream &ret, GenAction *action, int targState, bool inFinish );
+ void CONDITION( ostream &ret, GenAction *condition );
string ALPH_TYPE();
string WIDE_ALPH_TYPE();
string ARRAY_TYPE( unsigned long maxVal );
std::ostream &RbxGotoCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &RbxGotoCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &RbxGotoCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &RbxGotoCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. */
rbxGoto(out << " ", "_out") << "\n";
}
-void RbxGotoCodeGen::COND_TRANSLATE( StateCond *stateCond, int level )
+void RbxGotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level )
{
- CondSpace *condSpace = stateCond->condSpace;
+ GenCondSpace *condSpace = stateCond->condSpace;
out << TABS(level) << "_widec = " <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << ");\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(level) << "if ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
{
/* Get the mid position, staying on the lower end of the range. */
int mid = (low + high) >> 1;
- StateCond **data = state->stateCondVect.data;
+ GenStateCond **data = state->stateCondVect.data;
/* Determine if we need to look higher or lower. */
bool anyLower = mid > low;
int FROM_STATE_ACTION( RedStateAp *state );
int EOF_ACTION( RedStateAp *state );
- void COND_TRANSLATE( StateCond *stateCond, int level );
+ void COND_TRANSLATE( GenStateCond *stateCond, int level );
void emitCondBSearch( RedStateAp *state, int level, int low, int high );
void STATE_CONDS( RedStateAp *state, bool genDefault );
}
-void RubyCodeGen::ACTION( ostream &ret, Action *action, int targState, bool inFinish )
+void RubyCodeGen::ACTION( ostream &ret, GenAction *action, int targState, bool inFinish )
{
/* Write the preprocessor line info for going into the source file. */
rubyLineDirective( ret, sourceFileName, action->loc.line );
return ret.str();
}
-void RubyCodeGen::CONDITION( ostream &ret, Action *condition )
+void RubyCodeGen::CONDITION( ostream &ret, GenAction *condition )
{
ret << "\n";
rubyLineDirective( ret, sourceFileName, condition->loc.line );
/* Write out the length, which will never be the last character. */
ARRAY_ITEM( INT(act->key.length()), ++totalActions, false );
- for ( ActionTable::Iter item = act->key; item.lte(); item++ ) {
+ for ( GenActionTable::Iter item = act->key; item.lte(); item++ ) {
ARRAY_ITEM( INT(item->value->actionId), ++totalActions, (act.last() && item.last()) );
}
}
void INLINE_LIST(ostream &ret, GenInlineList *inlineList, int targState, bool inFinish);
string ACCESS();
- void ACTION( ostream &ret, Action *action, int targState, bool inFinish );
+ void ACTION( ostream &ret, GenAction *action, int targState, bool inFinish );
string GET_KEY();
string GET_WIDE_KEY();
string GET_WIDE_KEY( RedStateAp *state );
string KEY( Key key );
string TABS( int level );
string INT( int i );
- void CONDITION( ostream &ret, Action *condition );
+ void CONDITION( ostream &ret, GenAction *condition );
string ALPH_TYPE();
string WIDE_ALPH_TYPE();
string ARRAY_TYPE( unsigned long maxVal );
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
}
}
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
}
}
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true );
}
}
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
}
std::ostream &RubyFlatCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &RubyFlatCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &RubyFlatCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break */
std::ostream &RubyFlatCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break */
out <<
" case _cond \n";
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
+ GenCondSpace *condSpace = csi;
out << " when " << condSpace->condSpaceId + 1 << " then\n";
out << TABS(2) << "_widec = " << "(" <<
KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
" - " << KEY(keyOps->minKey) << "))\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
out << TABS(2) << "if ( ";
CONDITION( out, *csi );
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
}
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
}
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, true );
}
out << "\twhen " << redAct->actListId+1 << " then\n";
/* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
+ for ( GenActionTable::Iter item = redAct->key; item.lte(); item++ )
ACTION( out, item->value, 0, false );
}
" + ((_mid - _keys)>>1)]\n";
for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
+ GenCondSpace *condSpace = csi;
out << " when " << condSpace->condSpaceId << " then" ;
out << " _widec = " << KEY(condSpace->baseKey) <<
"+ (" << GET_KEY() << " - " << KEY(keyOps->minKey) << ")\n";
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
+ for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
out << " _widec += " << condValOffset << " if ( ";
CONDITION( out, *csi );
std::ostream &RubyTabCodeGen::FROM_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numFromStateRefs > 0 ) {
/* Write the case label, the action */
std::ostream &RubyTabCodeGen::TO_STATE_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numToStateRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &RubyTabCodeGen::EOF_ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numEofRefs > 0 ) {
/* Write the case label, the action and the case break. */
std::ostream &RubyTabCodeGen::ACTION_SWITCH()
{
/* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = actionList; act.lte(); act++ ) {
+ for ( GenActionList::Iter act = actionList; act.lte(); act++ ) {
/* Write out referenced actions. */
if ( act->numTransRefs > 0 ) {
/* Write the case label, the action and the case break. */
int totalTrans = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Lower key. */
ARRAY_ITEM( KEY( sc->lowKey ), ++totalTrans, false );
ARRAY_ITEM( KEY( sc->highKey ), ++totalTrans, false );
int totalTrans = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
/* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
+ for ( GenStateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
/* Cond Space id. */
ARRAY_ITEM( KEY( sc->condSpace->condSpaceId ), ++totalTrans, false );
}