The action of the <ragel_def> tag was made into a direct function call.
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Tue, 7 Oct 2008 22:01:55 +0000 (22:01 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Tue, 7 Oct 2008 22:01:55 +0000 (22:01 +0000)
git-svn-id: http://svn.complang.org/ragel/trunk@486 052ea7fc-9027-0410-9066-f65837a77df0

ragel/parsedata.cpp
ragel/parsedata.h
ragel/xmlcodegen.cpp
ragel/xmlcodegen.h
redfsm/redfsm.cpp
redfsm/xmlparse.kh
redfsm/xmlparse.kl

index 24e133c..8a37481 100644 (file)
@@ -1427,12 +1427,12 @@ void ParseData::prepareMachineGenTBWrapped( GraphDictEl *graphDictEl )
        sectionGraph->setStateNumbers( 0 );
 }
 
-void ParseData::generateXML( ostream &out )
+void ParseData::generateXML( ostream &out, XmlParser &xmlParser )
 {
        beginProcessing();
 
        /* Make the generator. */
-       XMLCodeGen codeGen( sectionName, this, sectionGraph, out );
+       XMLCodeGen codeGen( sectionName, this, sectionGraph, out, xmlParser );
 
        /* Write out with it. */
        codeGen.writeXML();
@@ -1469,11 +1469,11 @@ void writeMachines( std::ostream &out, std::string hostData,
                }
 
                if ( gblErrorCount == 0 ) {
-                       xmlParser.ragel( inputFileName );
+                       xmlParser.open_ragel( inputFileName );
                        for ( ParserDict::Iter parser = parserDict; parser.lte(); parser++ ) {
                                ParseData *pd = parser->value->pd;
                                if ( pd->instanceList.length() > 0 )
-                                       pd->generateXML( out );
+                                       pd->generateXML( out, xmlParser );
                        }
                        out << hostData;
                }
@@ -1507,8 +1507,8 @@ void writeMachines( std::ostream &out, std::string hostData,
                        /* Section/Machine to emit was found. Prepare and emit it. */
                        parseData->prepareMachineGen( graphDictEl );
                        if ( gblErrorCount == 0 ) {
-                               xmlParser.ragel( inputFileName );
-                               parseData->generateXML( out );
+                               xmlParser.open_ragel( inputFileName );
+                               parseData->generateXML( out, xmlParser );
                                out << hostData;
                        }
                }
index c62508f..bea22f0 100644 (file)
@@ -215,7 +215,7 @@ struct ParseData
 
        void prepareMachineGen( GraphDictEl *graphDictEl );
        void prepareMachineGenTBWrapped( GraphDictEl *graphDictEl );
-       void generateXML( ostream &out );
+       void generateXML( ostream &out, XmlParser &xmlParser );
        FsmAp *sectionGraph;
        bool generatingSectionSubset;
 
index 8cbe738..1f6a3d0 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "ragel.h"
 #include "xmlcodegen.h"
+#include "xmlparse.h"
 #include "parsedata.h"
 #include "fsmgraph.h"
 #include <string.h>
 using namespace std;
 
 XMLCodeGen::XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm, 
-               std::ostream &out )
+               std::ostream &out, XmlParser &xmlParser )
 :
        fsmName(fsmName),
        pd(pd),
        fsm(fsm),
        out(out),
+       xmlParser(xmlParser),
        nextActionTableId(0)
 {
 }
@@ -641,7 +643,8 @@ void XMLCodeGen::writeExports()
 void XMLCodeGen::writeXML()
 {
        /* Open the definition. */
-       out << "<ragel_def name=\"" << fsmName << "\">\n";
+       xmlParser.open_ragel_def( fsmName );
+       out << "<ragel_def>\n";
 
        /* Alphabet type. */
        out << "  <alphtype>" << keyOps->alphType->internalName << "</alphtype>\n";
index 719161e..0809e80 100644 (file)
@@ -79,7 +79,8 @@ struct NextRedTrans
 class XMLCodeGen
 {
 public:
-       XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm, std::ostream &out );
+       XMLCodeGen( char *fsmName, ParseData *pd, FsmAp *fsm, 
+                       std::ostream &out, XmlParser &xmlParser );
        void writeXML( );
 
 private:
@@ -123,6 +124,8 @@ private:
        ParseData *pd;
        FsmAp *fsm;
        std::ostream &out;
+       XmlParser &xmlParser;
+
        ActionTableMap actionTableMap;
        int nextActionTableId;
 };
index 2182648..9a58752 100644 (file)
@@ -27,8 +27,6 @@
 
 using std::ostringstream;
 
-/* KeyOps *keyOps = 0; */
-
 string GenAction::nameOrLoc()
 {
        if ( name != 0 )
index ed10bc8..143bcdb 100644 (file)
@@ -165,7 +165,8 @@ struct XmlParser
        int token( int tokenId, int col, int line );
        int token( XMLTag *tag, int col, int line );
 
-       void ragel( const char *fileName );
+       void open_ragel( const char *fileName );
+       void open_ragel_def( char *fsmName );
 
        /* Report an error encountered by the parser. */
        ostream &warning( const GenInputLoc &loc );
index 5aadffc..8f0b7af 100644 (file)
@@ -84,7 +84,7 @@ void genLineDirective( ostream &out )
        lineDirective( out, filter->fileName, filter->line + 1 );
 }
 
-void XmlParser::ragel( const char *fileName )
+void XmlParser::open_ragel( const char *fileName )
 {
        /* Check for file name attribute. */
        sourceFileName = fileName;
@@ -115,6 +115,18 @@ void XmlParser::ragel( const char *fileName )
                assert( false );
        }
 }
+
+void XmlParser::open_ragel_def( char *fsmName )
+{
+       CodeGenMapEl *mapEl = codeGenMap.find( fsmName );
+       if ( mapEl != 0 )
+               cgd = mapEl->value;
+       else {
+               cgd = makeCodeGen( sourceFileName, fsmName, *outStream, wantComplete );
+               codeGenMap.insert( fsmName, cgd );
+       }
+}
+
 %%{
 
 parser XmlParser;
@@ -149,7 +161,7 @@ tag_host:
        };
 
 ragel_def: 
-       tag_ragel_def_head ragel_def_item_list '/' TAG_ragel_def
+       TAG_ragel_def ragel_def_item_list '/' TAG_ragel_def
        final {
                /* Do this before distributing transitions out to singles and defaults
                 * makes life easier. */
@@ -164,29 +176,6 @@ ragel_def:
                cgd->finishRagelDef();
        };
 
-tag_ragel_def_head: TAG_ragel_def 
-       final {
-               char *fsmName = 0;
-               Attribute *nameAttr = $1->tag->findAttr( "name" );
-               if ( nameAttr != 0 ) {
-                       fsmName = nameAttr->value;
-
-                       CodeGenMapEl *mapEl = codeGenMap.find( fsmName );
-                       if ( mapEl != 0 )
-                               cgd = mapEl->value;
-                       else {
-                               cgd = makeCodeGen( sourceFileName, fsmName, *outStream, wantComplete );
-                               codeGenMap.insert( fsmName, cgd );
-                       }
-               }
-               else {
-                       cgd = makeCodeGen( sourceFileName, fsmName, 
-                                       *outStream, wantComplete );
-               }
-
-               ::keyOps = &cgd->thisKeyOps;
-       };
-
 ragel_def_item_list: ragel_def_item_list ragel_def_item;
 ragel_def_item_list: ;