From: thurston Date: Mon, 1 Sep 2008 23:31:52 +0000 (+0000) Subject: Now supplying the XmlParser to writeMachines. X-Git-Tag: 2.0_alpha~110 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b56b3456c109e2c836a4e6ace69cca9186eec4cb;p=external%2Fragel.git Now supplying the XmlParser to writeMachines. git-svn-id: http://svn.complang.org/ragel/trunk@468 052ea7fc-9027-0410-9066-f65837a77df0 --- diff --git a/ragel/main.cpp b/ragel/main.cpp index 5261ff1..1e7ccc0 100644 --- a/ragel/main.cpp +++ b/ragel/main.cpp @@ -443,10 +443,13 @@ void processArgs( int argc, const char **argv, const char *&inputFileName ) void process( const char *inputFileName, const char *intermed ) { + const char *xmlFileName = intermed; + bool wantComplete = true; + bool outputActive = true; + /* Open the input file for reading. */ assert( inputFileName != 0 ); ifstream *inFile = new ifstream( inputFileName ); - istream *inStream = inFile; if ( ! inFile->is_open() ) error() << "could not open " << inputFileName << " for reading" << endp; @@ -456,7 +459,7 @@ void process( const char *inputFileName, const char *intermed ) if ( machineSpec == 0 && machineName == 0 ) hostData << ""; - Scanner scanner( inputFileName, *inStream, hostData, 0, 0, 0, false ); + Scanner scanner( inputFileName, *inFile, hostData, 0, 0, 0, false ); scanner.do_scan(); /* Finished, final check for errors.. */ @@ -476,29 +479,13 @@ void process( const char *inputFileName, const char *intermed ) if ( gblErrorCount > 0 ) exit(1); - ostream *outputFile = new ofstream( intermed ); + /* Open the XML file for writing. */ + ostream *xmlOutFile = new ofstream( xmlFileName ); - /* Write the machines, then the surrounding code. */ - writeMachines( *outputFile, hostData.str(), inputFileName ); - - /* Close the input and the intermediate file. */ - delete outputFile; - delete inFile; - - /* Bail on above error. */ - if ( gblErrorCount > 0 ) - exit(1); - - const char *xmlInputFileName = intermed; - - bool wantComplete = true; - bool outputActive = true; - - /* Open the input file for reading. */ - inFile = new ifstream( xmlInputFileName ); - inStream = inFile; - if ( ! inFile->is_open() ) - error() << "could not open " << xmlInputFileName << " for reading" << endl; + /* Open the XML file for reading. */ + ifstream *xmlInFile = new ifstream( xmlFileName ); + if ( ! xmlInFile->is_open() ) + error() << "could not open " << xmlFileName << " for reading" << endl; /* Bail on above error. */ if ( gblErrorCount > 0 ) @@ -510,11 +497,22 @@ void process( const char *inputFileName, const char *intermed ) outputActive = false; } - XmlScanner xmlScanner( xmlInputFileName, *inStream ); - XmlParser xmlParser( xmlInputFileName, outputActive, wantComplete ); + XmlScanner xmlScanner( xmlFileName, *xmlInFile ); + XmlParser xmlParser( xmlFileName, outputActive, wantComplete ); xmlParser.init(); - xml_parse( *inStream, xmlInputFileName, + /* Write the machines, then the surrounding code. */ + writeMachines( *xmlOutFile, hostData.str(), inputFileName, xmlParser ); + + /* Close the input and the intermediate file. */ + delete xmlOutFile; + delete inFile; + + /* Bail on above error. */ + if ( gblErrorCount > 0 ) + exit(1); + + xml_parse( *xmlInFile, xmlFileName, outputActive, wantComplete, xmlScanner, xmlParser ); diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp index 8d862cd..73f52c6 100644 --- a/ragel/parsedata.cpp +++ b/ragel/parsedata.cpp @@ -1470,7 +1470,8 @@ void writeLanguage( std::ostream &out ) } -void writeMachines( std::ostream &out, std::string hostData, const char *inputFileName ) +void writeMachines( std::ostream &out, std::string hostData, + const char *inputFileName, XmlParser &xmlParser ) { if ( machineSpec == 0 && machineName == 0 ) { /* No machine spec or machine name given. Generate everything. */ diff --git a/ragel/ragel.h b/ragel/ragel.h index 125ceb7..cf5951b 100644 --- a/ragel/ragel.h +++ b/ragel/ragel.h @@ -80,8 +80,11 @@ std::ostream &error(); std::ostream &error( const InputLoc &loc ); std::ostream &warning( const InputLoc &loc ); +struct XmlParser; + void terminateAllParsers( ); -void writeMachines( std::ostream &out, std::string hostData, const char *inputFileName ); +void writeMachines( std::ostream &out, std::string hostData, + const char *inputFileName, XmlParser &xmlParser ); void xmlEscapeHost( std::ostream &out, char *data, long len ); typedef Vector ArgsVector;