\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}
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]) );
}
}
-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.
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
*/
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 ||
virtual void finishRagelDef();
virtual void writeInit();
- virtual void writeExports();
protected:
string FSM_NAME();
virtual string UINT();
virtual string PTR_CONST();
virtual string CTRL_FLOW();
+
+ virtual void writeExports();
};
class DCodeGen : virtual public FsmCodeGen
virtual string UINT();
virtual string PTR_CONST();
virtual string CTRL_FLOW();
+
+ virtual void writeExports();
};
#endif /* _FSMCODEGEN_H */