Updated the manual section on instantiation to reflect the 5.19 features.
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Wed, 14 Mar 2007 19:58:14 +0000 (19:58 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Wed, 14 Mar 2007 19:58:14 +0000 (19:58 +0000)
Exports in D cannot use defines like C. Static const ints are used instead.
Removed a left-over debug output statement from rlscan.rl.

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

doc/ragel-guide.tex
ragel/rlscan.rl
rlgen-cd/fsmcodegen.cpp
rlgen-cd/fsmcodegen.h

index 61e2a0b..2d7c755 100644 (file)
@@ -560,11 +560,15 @@ expression.
 \end{verbatim}
 \verbspace
 
-The machine instantiation statement generates a set of states representing an expression and
-associates a name with the entry point. Each instantiation generates a distinct
-set of states.  At a very minimum the \verb|main| machine must be instantiated.
-Other machines may be instantiated and control passed to them by use of
-\verb|fcall|, \verb|fgoto| or \verb|fnext| statements.
+The machine instantiation statement generates a set of states representing an
+expression. Each instantiation generates a distinct set of states.  The entry
+point is written in the generated code using the instantiation name.  If the
+\verb|main| machine is instantiated, then a start state is also generated and
+assigned to the \verb|cs| variable by the \verb|write init| command.  From
+outside the execution loop, control may be passed to any machine by assigning
+the entry point to the \verb|cs| variable.  From inside the execution loop,
+control may be passed to any machine instantiation using \verb|fcall|,
+\verb|fgoto| or \verb|fnext| statements.
 
 \section{Lexical Analysis of a Ragel Block}
 \label{lexing}
index 7f69ea0..70e97fd 100644 (file)
@@ -136,7 +136,6 @@ void Scanner::flushImport()
        if ( tok_tokstart == 0 )
                cur_token = 0;
        else {
-               cerr << "BLOCK BREAK" << endl;
                cur_token = pe - tok_tokstart;
                int ts_offset = tok_tokstart - token_data;
                memmove( token_data, token_data+ts_offset, cur_token*sizeof(token_data[0]) );
index 3e277f4..0d711d3 100644 (file)
@@ -534,17 +534,6 @@ void FsmCodeGen::STATE_IDS()
        }
 }
 
-void FsmCodeGen::writeExports()
-{
-       if ( exportList.length() > 0 ) {
-               for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
-                       out << "#define " << DATA_PREFIX() << "ex_" << ex->name << " " << 
-                                       KEY(ex->key) << "\n";
-               }
-               out << "\n";
-       }
-}
-
 
 /*
  * Language specific, but style independent code generators functions.
@@ -607,6 +596,17 @@ string CCodeGen::CTRL_FLOW()
        return "";
 }
 
+void CCodeGen::writeExports()
+{
+       if ( exportList.length() > 0 ) {
+               for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
+                       out << "#define " << DATA_PREFIX() << "ex_" << ex->name << " " << 
+                                       KEY(ex->key) << "\n";
+               }
+               out << "\n";
+       }
+}
+
 /*
  * D Specific
  */
@@ -670,6 +670,21 @@ string DCodeGen::CTRL_FLOW()
        return "if (true) ";
 }
 
+void DCodeGen::writeExports()
+{
+       if ( exportList.length() > 0 ) {
+               for ( ExportList::Iter ex = exportList; ex.lte(); ex++ ) {
+                       out << "static const " << ALPH_TYPE() << " " << DATA_PREFIX() << 
+                                       "ex_" << ex->name << " = " << KEY(ex->key) << ";\n";
+               }
+               out << "\n";
+       }
+}
+
+/*
+ * End D-specific code.
+ */
+
 void FsmCodeGen::finishRagelDef()
 {
        if ( codeStyle == GenGoto || codeStyle == GenFGoto || 
index 45f9dde..628f9a9 100644 (file)
@@ -66,7 +66,6 @@ public:
 
        virtual void finishRagelDef();
        virtual void writeInit();
-       virtual void writeExports();
 
 protected:
        string FSM_NAME();
@@ -192,6 +191,8 @@ public:
        virtual string UINT();
        virtual string PTR_CONST();
        virtual string CTRL_FLOW();
+
+       virtual void writeExports();
 };
 
 class DCodeGen : virtual public FsmCodeGen
@@ -210,6 +211,8 @@ public:
        virtual string UINT();
        virtual string PTR_CONST();
        virtual string CTRL_FLOW();
+
+       virtual void writeExports();
 };
 
 #endif /* _FSMCODEGEN_H */