"eof" is no longer a write command.
[external/ragel.git] / ragel / fsmgraph.h
index b2ded15..ba9d011 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
+ *  Copyright 2001-2007 Adrian Thurston <thurston@complang.org>
  */
 
 /*  This file is part of Ragel.
@@ -25,6 +25,7 @@
 #include "config.h"
 #include <assert.h>
 #include <iostream>
+#include <string>
 #include "common.h"
 #include "vector.h"
 #include "bstset.h"
 //#define LOG_CONDS
 
 /* Flags that control merging. */
-#define SB_GRAPH1     0x01
-#define SB_GRAPH2     0x02
-#define SB_BOTH       0x03
-#define SB_ISFINAL    0x04
-#define SB_ISMARKED   0x08
-#define SB_ONLIST     0x10
+#define STB_GRAPH1     0x01
+#define STB_GRAPH2     0x02
+#define STB_BOTH       0x03
+#define STB_ISFINAL    0x04
+#define STB_ISMARKED   0x08
+#define STB_ONLIST     0x10
 
 using std::ostream;
 
@@ -96,7 +97,7 @@ struct Action
 {
 public:
 
-       Action( const InputLoc &loc, char *name, InlineList *inlineList, int condId )
+       Action( const InputLoc &loc, const char *name, InlineList *inlineList, int condId )
        :
                loc(loc),
                name(name),
@@ -114,11 +115,11 @@ public:
        }
 
        /* Key for action dictionary. */
-       char *getKey() const { return name; }
+       const char *getKey() const { return name; }
 
        /* Data collected during parse. */
        InputLoc loc;
-       char *name;
+       const char *name;
        InlineList *inlineList;
        int actionId;
 
@@ -379,10 +380,8 @@ struct TransAp
                highKey(other.highKey),
                fromState(0), toState(0),
                actionTable(other.actionTable),
-               priorTable(other.priorTable)
-       {
-               assert( lmActionTable.length() == 0 && other.lmActionTable.length() == 0 );
-       }
+               priorTable(other.priorTable),
+               lmActionTable(other.lmActionTable) {}
 
        Key lowKey, highKey;
        StateAp *fromState;
@@ -641,16 +640,28 @@ struct Removal
 
 struct CondData
 {
-       CondData() : nextCondKey(0) {}
+       CondData() : lastCondKey(0) {}
 
        /* Condition info. */
-       Key nextCondKey;
+       Key lastCondKey;
 
        CondSpaceMap condSpaceMap;
 };
 
 extern CondData *condData;
 
+struct FsmConstructFail
+{
+       enum Reason
+       {
+               CondNoKeySpace
+       };
+
+       FsmConstructFail( Reason reason ) 
+               : reason(reason) {}
+       Reason reason;
+};
+
 /* State class that implements actions and priorities. */
 struct StateAp 
 {
@@ -659,7 +670,7 @@ struct StateAp
        ~StateAp();
 
        /* Is the state final? */
-       bool isFinState() { return stateBits & SB_ISFINAL; }
+       bool isFinState() { return stateBits & STB_ISFINAL; }
 
        /* Out transition list and the pointer for the default out trans. */
        TransList outList;
@@ -667,6 +678,10 @@ struct StateAp
        /* In transition Lists. */
        TransInList inList;
 
+       /* Set only during scanner construction when actions are added. NFA to DFA
+        * code can ignore this. */
+       StateAp *eofTarget;
+
        /* Entry points into the state. */
        EntryIdSet entryIds;
 
@@ -1117,7 +1132,9 @@ struct FsmAp
        void leaveFsmPrior( int ordering, PriorDesc *prior );
 
        /* Action setting support. */
+       void transferOutActions( StateAp *state );
        void transferErrorActions( StateAp *state, int transferPoint );
+       void setErrorActions( StateAp *state, const ActionTable &other );
        void setErrorAction( StateAp *state, int ordering, Action *action );
 
        /* Fill all spaces in a transition list with an error transition. */