The startstate, first final and error state writing can be moved to FsmCodeGen.
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Mon, 12 Mar 2007 15:13:23 +0000 (15:13 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Mon, 12 Mar 2007 15:13:23 +0000 (15:13 +0000)
At this time entry points are written as well.

git-svn-id: http://svn.complang.org/ragel/trunk@137 052ea7fc-9027-0410-9066-f65837a77df0

rlgen-cd/fflatcodegen.cpp
rlgen-cd/fgotocodegen.cpp
rlgen-cd/flatcodegen.cpp
rlgen-cd/fsmcodegen.cpp
rlgen-cd/fsmcodegen.h
rlgen-cd/ftabcodegen.cpp
rlgen-cd/gotocodegen.cpp
rlgen-cd/ipgotocodegen.cpp
rlgen-cd/tabcodegen.cpp

index c629d59..813347f 100644 (file)
@@ -226,21 +226,7 @@ void FFlatCodeGen::writeData()
                "\n";
        }
 
-       out <<
-               "static const int " << START() << " = " << START_STATE_ID() << ";\n"
-               "\n";
-
-       if ( writeFirstFinal ) {
-               out <<
-                       "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
-                       "\n";
-       }
-
-       if ( writeErr ) {
-               out <<
-                       "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
-                       "\n";
-       }
+       STATE_IDS();
 }
 
 void FFlatCodeGen::writeExec()
index 9b08033..9c4f039 100644 (file)
@@ -152,22 +152,6 @@ unsigned int FGotoCodeGen::EOF_ACTION( RedStateAp *state )
 
 void FGotoCodeGen::writeData()
 {
-       out <<
-               "static const int " << START() << " = " << START_STATE_ID() << ";\n"
-               "\n";
-
-       if ( writeFirstFinal ) {
-               out <<
-                       "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
-                       "\n";
-       }
-
-       if ( writeErr ) {
-               out <<
-                       "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
-                       "\n";
-       }
-
        if ( redFsm->anyToStateActions() ) {
                OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActionLoc), TSA() );
                TO_STATE_ACTIONS();
@@ -188,6 +172,8 @@ void FGotoCodeGen::writeData()
                CLOSE_ARRAY() <<
                "\n";
        }
+
+       STATE_IDS();
 }
 
 void FGotoCodeGen::writeExec()
index 65d60f6..117f379 100644 (file)
@@ -572,21 +572,7 @@ void FlatCodeGen::writeData()
                "\n";
        }
 
-       out <<
-               "static const int " << START() << " = " << START_STATE_ID() << ";\n"
-               "\n";
-
-       if ( writeFirstFinal ) {
-               out <<
-                       "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
-                       "\n";
-       }
-
-       if ( writeErr ) {
-               out <<
-                       "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
-                       "\n";
-       }
+       STATE_IDS();
 }
 
 void FlatCodeGen::COND_TRANSLATE()
index 06407b4..190ef02 100644 (file)
@@ -510,13 +510,25 @@ string FsmCodeGen::WIDE_ALPH_TYPE()
        return ret;
 }
 
-void FsmCodeGen::ENTRY_POINTS()
+void FsmCodeGen::STATE_IDS()
 {
-       for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) {
-               STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << 
-                               " = " << entryPointIds[en.pos()] << ";\n";
-       }
+       STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n";
+
+       if ( writeFirstFinal )
+               STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n";
+
+       if ( writeErr )
+               STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n";
+
        out << "\n";
+
+       if ( entryPointNames.length() > 0 ) {
+               for ( EntryNameVect::Iter en = entryPointNames; en.lte(); en++ ) {
+                       STATIC_VAR( "int", DATA_PREFIX() + "en_" + *en ) << 
+                                       " = " << entryPointIds[en.pos()] << ";\n";
+               }
+               out << "\n";
+       }
 }
 
 void FsmCodeGen::writeExports()
index efb3d79..45f9dde 100644 (file)
@@ -150,7 +150,7 @@ protected:
        void GET_TOKEND( ostream &ret, InlineItem *item );
        void SUB_ACTION( ostream &ret, InlineItem *item, 
                        int targState, bool inFinish );
-       void ENTRY_POINTS();
+       void STATE_IDS();
 
        string ERROR_STATE();
        string FIRST_FINAL_STATE();
index 3cda8f4..1d65e71 100644 (file)
@@ -280,21 +280,7 @@ void FTabCodeGen::writeData()
                "\n";
        }
 
-       out <<
-               "static const int " << START() << " = " << START_STATE_ID() << ";\n"
-               "\n";
-
-       if ( writeFirstFinal ) {
-               out <<
-                       "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
-                       "\n";
-       }
-
-       if ( writeErr ) {
-               out <<
-                       "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
-                       "\n";
-       }
+       STATE_IDS();
 }
 
 void FTabCodeGen::writeExec()
index 28552e8..13be67d 100644 (file)
@@ -603,22 +603,6 @@ void GotoCodeGen::BREAK( ostream &ret, int targState )
 
 void GotoCodeGen::writeData()
 {
-       out <<
-               "static const int " << START() << " = " << START_STATE_ID() << ";\n"
-               "\n";
-
-       if ( writeFirstFinal ) {
-               out <<
-                       "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
-                       "\n";
-       }
-
-       if ( writeErr ) {
-               out <<
-                       "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
-                       "\n";
-       }
-
        if ( redFsm->anyActions() ) {
                OPEN_ARRAY( ARRAY_TYPE(redFsm->maxActArrItem), A() );
                ACTIONS_ARRAY();
@@ -646,6 +630,8 @@ void GotoCodeGen::writeData()
                CLOSE_ARRAY() <<
                "\n";
        }
+
+       STATE_IDS();
 }
 
 void GotoCodeGen::writeExec()
index 0cd19af..ed65be5 100644 (file)
@@ -334,21 +334,7 @@ void IpGotoCodeGen::setLabelsNeeded()
 
 void IpGotoCodeGen::writeData()
 {
-       out <<
-               "static const int " << START() << " = " << START_STATE_ID() << ";\n"
-               "\n";
-
-       if ( writeFirstFinal ) {
-               out <<
-                       "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
-                       "\n";
-       }
-
-       if ( writeErr ) {
-               out <<
-                       "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
-                       "\n";
-       }
+       STATE_IDS();
 }
 
 void IpGotoCodeGen::writeExec()
index bd4ce6f..22f0953 100644 (file)
@@ -785,20 +785,7 @@ void TabCodeGen::writeData()
                "\n";
        }
 
-       STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n"
-       "\n";
-
-       if ( writeFirstFinal ) {
-               STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n"
-               "\n";
-       }
-
-       if ( writeErr ) {
-               STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n"
-               "\n";
-       }
-
-       ENTRY_POINTS();
+       STATE_IDS();
 }
 
 void TabCodeGen::COND_TRANSLATE()