From b0ca11ee1272201dc4a3abce999706b52b151b4a Mon Sep 17 00:00:00 2001 From: thurston Date: Sat, 21 Mar 2009 15:10:35 +0000 Subject: [PATCH] Removed wantComplete and outputActive from InputData. The wantComplete var is used in CodeGenData and can be set when the code generator is allocated. It doesn't need to be passed in from the main routine. The outputActive var is not used. git-svn-id: http://svn.complang.org/ragel/trunk@750 052ea7fc-9027-0410-9066-f65837a77df0 --- ragel/gendata.cpp | 42 ++++++++++++++++++------------------------ ragel/gendata.h | 3 +++ ragel/inputdata.h | 6 +----- ragel/main.cpp | 18 ++++++------------ ragel/parsedata.cpp | 3 +-- ragel/rlparse.kl | 4 ---- ragel/xmlparse.kh | 3 --- 7 files changed, 29 insertions(+), 50 deletions(-) diff --git a/ragel/gendata.cpp b/ragel/gendata.cpp index 8801ef0..cbe98d8 100644 --- a/ragel/gendata.cpp +++ b/ragel/gendata.cpp @@ -67,21 +67,23 @@ using std::cerr; using std::endl; /* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *dotMakeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) +CodeGenData *dotMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *codeGen = new GraphvizDotGen(out); codeGen->sourceFileName = sourceFileName; codeGen->fsmName = fsmName; - codeGen->wantComplete = wantComplete; + + /* For normal code generation we want a transition on every character so we never + * end up in an undefined state. For graphviz this just clutters the + * drawing so we turn it off. */ + codeGen->wantComplete = false; return codeGen; } /* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *cdMakeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) +CodeGenData *cdMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *codeGen = 0; switch ( hostLang->lang ) { @@ -148,27 +150,23 @@ CodeGenData *cdMakeCodeGen( const char *sourceFileName, const char *fsmName, codeGen->sourceFileName = sourceFileName; codeGen->fsmName = fsmName; - codeGen->wantComplete = wantComplete; return codeGen; } /* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *javaMakeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) +CodeGenData *javaMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *codeGen = new JavaTabCodeGen(out); codeGen->sourceFileName = sourceFileName; codeGen->fsmName = fsmName; - codeGen->wantComplete = wantComplete; return codeGen; } /* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *rubyMakeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) +CodeGenData *rubyMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *codeGen = 0; switch ( codeStyle ) { @@ -202,14 +200,12 @@ CodeGenData *rubyMakeCodeGen( const char *sourceFileName, const char *fsmName, } codeGen->sourceFileName = sourceFileName; codeGen->fsmName = fsmName; - codeGen->wantComplete = wantComplete; return codeGen; } /* Invoked by the parser when a ragel definition is opened. */ -CodeGenData *csharpMakeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) +CodeGenData *csharpMakeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *codeGen = 0; @@ -242,28 +238,26 @@ CodeGenData *csharpMakeCodeGen( const char *sourceFileName, const char *fsmName, codeGen->sourceFileName = sourceFileName; codeGen->fsmName = fsmName; - codeGen->wantComplete = wantComplete; return codeGen; } -CodeGenData *makeCodeGen( const char *sourceFileName, const char *fsmName, - ostream &out, bool wantComplete ) +CodeGenData *makeCodeGen( const char *sourceFileName, const char *fsmName, ostream &out ) { CodeGenData *cgd = 0; if ( generateDot ) - cgd = dotMakeCodeGen( sourceFileName, fsmName, out, wantComplete ); + cgd = dotMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangC ) - cgd = cdMakeCodeGen( sourceFileName, fsmName, out, wantComplete ); + cgd = cdMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangD ) - cgd = cdMakeCodeGen( sourceFileName, fsmName, out, wantComplete ); + cgd = cdMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangJava ) - cgd = javaMakeCodeGen( sourceFileName, fsmName, out, wantComplete ); + cgd = javaMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangRuby ) - cgd = rubyMakeCodeGen( sourceFileName, fsmName, out, wantComplete ); + cgd = rubyMakeCodeGen( sourceFileName, fsmName, out ); else if ( hostLang == &hostLangCSharp ) - cgd = csharpMakeCodeGen( sourceFileName, fsmName, out, wantComplete ); + cgd = csharpMakeCodeGen( sourceFileName, fsmName, out ); return cgd; } @@ -322,7 +316,7 @@ CodeGenData::CodeGenData( ostream &out ) tokstartExpr(0), tokendExpr(0), dataExpr(0), - wantComplete(0), + wantComplete(true), hasLongestMatch(false), noEnd(false), noPrefix(false), diff --git a/ragel/gendata.h b/ragel/gendata.h index a0ec5b6..3cdd407 100644 --- a/ragel/gendata.h +++ b/ragel/gendata.h @@ -180,4 +180,7 @@ struct CodeGenData void write_option_error( InputLoc &loc, char *arg ); }; +CodeGenData *makeCodeGen( const char *sourceFileName, + const char *fsmName, ostream &out ); + #endif diff --git a/ragel/inputdata.h b/ragel/inputdata.h index 8ccabeb..e41b8f0 100644 --- a/ragel/inputdata.h +++ b/ragel/inputdata.h @@ -28,19 +28,15 @@ struct Parser; struct InputData { - InputData( const char *inputFileName, bool outputActive, bool wantComplete ) : + InputData( const char *inputFileName ) : inputFileName(inputFileName), outStream(0), - outputActive(outputActive), - wantComplete(wantComplete), dotGenParser(0) {} /* The name of the root section, this does not change during an include. */ const char *inputFileName; ostream *outStream; - bool outputActive; - bool wantComplete; Parser *dotGenParser; void writeOutput(); diff --git a/ragel/main.cpp b/ragel/main.cpp index 2e7d989..91e279a 100644 --- a/ragel/main.cpp +++ b/ragel/main.cpp @@ -54,7 +54,6 @@ #include "vector.h" #include "version.h" #include "common.h" -#include "xmlparse.h" #include "inputdata.h" using std::istream; @@ -100,6 +99,10 @@ ostream *outStream = 0; output_filter *outFilter = 0; const char *outputFileName = 0; +ParserDict parserDict; +ParserList parserList; +InputItemList inputItems; + /* Print a summary of the options. */ void usage() { @@ -445,15 +448,14 @@ void processArgs( int argc, const char **argv, const char *&inputFileName ) void process( const char *inputFileName ) { - bool wantComplete = true; - bool outputActive = true; - /* Open the input file for reading. */ assert( inputFileName != 0 ); ifstream *inFile = new ifstream( inputFileName ); if ( ! inFile->is_open() ) error() << "could not open " << inputFileName << " for reading" << endp; + InputData inputData( inputFileName ); + /* Used for just a few things. */ std::ostringstream hostData; @@ -471,13 +473,6 @@ void process( const char *inputFileName ) if ( gblErrorCount > 0 ) exit(1); - if ( generateDot ) { - wantComplete = false; - outputActive = false; - } - - InputData inputData( inputFileName, outputActive, wantComplete ); - /* Now send EOF to all parsers. */ inputData.terminateAllParsers(); @@ -593,7 +588,6 @@ int main( int argc, const char **argv ) { const char *inputFileName = 0; processArgs( argc, argv, inputFileName ); - /* If -M or -S are given and we're not generating a dot file then invoke * the frontend. These options are not useful with code generators. */ diff --git a/ragel/parsedata.cpp b/ragel/parsedata.cpp index 6ff3e75..73dcc33 100644 --- a/ragel/parsedata.cpp +++ b/ragel/parsedata.cpp @@ -1433,8 +1433,7 @@ void ParseData::generateReduced( InputData &inputData ) { beginProcessing(); - cgd = makeCodeGen( inputData.inputFileName, sectionName, - *inputData.outStream, inputData.wantComplete ); + cgd = makeCodeGen( inputData.inputFileName, sectionName, *inputData.outStream ); /* Make the generator. */ BackendGen backendGen( sectionName, this, sectionGraph, cgd ); diff --git a/ragel/rlparse.kl b/ragel/rlparse.kl index eb7f12d..79e816a 100644 --- a/ragel/rlparse.kl +++ b/ragel/rlparse.kl @@ -29,10 +29,6 @@ using std::cout; using std::cerr; using std::endl; -ParserDict parserDict; -ParserList parserList; -InputItemList inputItems; - %%{ parser Parser; diff --git a/ragel/xmlparse.kh b/ragel/xmlparse.kh index 1534cbe..47b2758 100644 --- a/ragel/xmlparse.kh +++ b/ragel/xmlparse.kh @@ -206,7 +206,4 @@ int xml_parse( std::istream &input, const char *fileName, bool outputActive, bool wantComplete, XmlScanner &scanner, XmlParser &parser ); -CodeGenData *makeCodeGen( const char *sourceFileName, - const char *fsmName, ostream &out, bool wantComplete ); - #endif -- 2.7.4