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();
}
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;
}
/* 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;
}
}
void prepareMachineGen( GraphDictEl *graphDictEl );
void prepareMachineGenTBWrapped( GraphDictEl *graphDictEl );
- void generateXML( ostream &out );
+ void generateXML( ostream &out, XmlParser &xmlParser );
FsmAp *sectionGraph;
bool generatingSectionSubset;
#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)
{
}
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";
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:
ParseData *pd;
FsmAp *fsm;
std::ostream &out;
+ XmlParser &xmlParser;
+
ActionTableMap actionTableMap;
int nextActionTableId;
};
using std::ostringstream;
-/* KeyOps *keyOps = 0; */
-
string GenAction::nameOrLoc()
{
if ( name != 0 )
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 );
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;
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;
};
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. */
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: ;