summaryrefslogtreecommitdiff
path: root/ragel/cdfflat.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ragel/cdfflat.cpp')
-rw-r--r--ragel/cdfflat.cpp62
1 files changed, 33 insertions, 29 deletions
diff --git a/ragel/cdfflat.cpp b/ragel/cdfflat.cpp
index 163e88c6..fe12ebe3 100644
--- a/ragel/cdfflat.cpp
+++ b/ragel/cdfflat.cpp
@@ -31,7 +31,7 @@ std::ostream &FFlatCodeGen::TO_STATE_ACTION( RedStateAp *state )
int act = 0;
if ( state->toStateAction != 0 )
act = state->toStateAction->actListId+1;
- out << act;
+ taTSA.VAL( act );
return out;
}
@@ -40,7 +40,7 @@ std::ostream &FFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state )
int act = 0;
if ( state->fromStateAction != 0 )
act = state->fromStateAction->actListId+1;
- out << act;
+ taFSA.VAL( act );
return out;
}
@@ -49,7 +49,7 @@ std::ostream &FFlatCodeGen::EOF_ACTION( RedStateAp *state )
int act = 0;
if ( state->eofAction != 0 )
act = state->eofAction->actListId+1;
- out << act;
+ taEA.VAL( act );
return out;
}
@@ -59,7 +59,7 @@ std::ostream &FFlatCodeGen::TRANS_ACTION( RedTransAp *trans )
int action = 0;
if ( trans->action != 0 )
action = trans->action->actListId+1;
- out << action;
+ taTA.VAL( action );
return out;
}
@@ -151,6 +151,8 @@ std::ostream &FFlatCodeGen::ACTION_SWITCH()
std::ostream &FFlatCodeGen::TRANS_ACTIONS()
{
+ taTA.OPEN( ARRAY_TYPE(redFsm->maxActListId) );
+
/* Transitions must be written ordered by their id. */
RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()];
for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ )
@@ -171,11 +173,17 @@ std::ostream &FFlatCodeGen::TRANS_ACTIONS()
}
out << "\n";
delete[] transPtrs;
+
+ taTA.CLOSE();
+ out << "\n";
+
return out;
}
std::ostream &FFlatCodeGen::TO_STATE_ACTIONS()
{
+ taTSA.OPEN( ARRAY_TYPE(redFsm->maxActionLoc) );
+
out << "\t";
int totalStateNum = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
@@ -188,11 +196,17 @@ std::ostream &FFlatCodeGen::TO_STATE_ACTIONS()
}
}
out << "\n";
+
+ taTSA.CLOSE();
+ out << "\n";
+
return out;
}
std::ostream &FFlatCodeGen::FROM_STATE_ACTIONS()
{
+ taFSA.OPEN( ARRAY_TYPE(redFsm->maxActionLoc) );
+
out << "\t";
int totalStateNum = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
@@ -205,11 +219,17 @@ std::ostream &FFlatCodeGen::FROM_STATE_ACTIONS()
}
}
out << "\n";
+
+ taFSA.CLOSE();
+ out << "\n";
+
return out;
}
std::ostream &FFlatCodeGen::EOF_ACTIONS()
{
+ taEA.OPEN( ARRAY_TYPE(redFsm->maxActListId) );
+
out << "\t";
int totalStateNum = 0;
for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
@@ -222,6 +242,10 @@ std::ostream &FFlatCodeGen::EOF_ACTIONS()
}
}
out << "\n";
+
+ taEA.CLOSE();
+ out << "\n";
+
return out;
}
@@ -245,40 +269,20 @@ void FFlatCodeGen::writeData()
TRANS_TARGS();
- if ( redFsm->anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), TA() );
+ if ( redFsm->anyActions() )
TRANS_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
- if ( redFsm->anyToStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
+ if ( redFsm->anyToStateActions() )
TO_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
- if ( redFsm->anyFromStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), FSA() );
+ if ( redFsm->anyFromStateActions() )
FROM_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
- if ( redFsm->anyEofActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActListId), EA() );
+ if ( redFsm->anyEofActions() )
EOF_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
- if ( redFsm->anyEofTrans() ) {
- OPEN_ARRAY( ARRAY_TYPE(redFsm->maxIndexOffset+1), ET() );
+ if ( redFsm->anyEofTrans() )
EOF_TRANS();
- CLOSE_ARRAY() <<
- "\n";
- }
STATE_IDS();
}