From: thurston Date: Sat, 3 Feb 2007 00:06:44 +0000 (+0000) Subject: Updated version information in the both backend programs. Removed outputFormat X-Git-Tag: 2.0_alpha~420 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36362bf38197219cb705cc8de119736f5e266ee7;p=external%2Fragel.git Updated version information in the both backend programs. Removed outputFormat and codeStyle options from the java code generator. git-svn-id: http://svn.complang.org/ragel/trunk@66 052ea7fc-9027-0410-9066-f65837a77df0 --- diff --git a/rlcodegen/main.cpp b/rlcodegen/main.cpp index 8924389..b5e57bb 100644 --- a/rlcodegen/main.cpp +++ b/rlcodegen/main.cpp @@ -75,7 +75,7 @@ bool printPrintables = false; void usage() { cout << -"usage: rlcodegen [options] file\n" +"usage: " PROGNAME " [options] file\n" "general:\n" " -h, -H, -?, --help Print this usage and exit\n" " -v, --version Print version information and exit\n" @@ -98,8 +98,9 @@ void usage() /* Print version information. */ void version() { - cout << "Ragel Code Generator version " VERSION << " " PUBDATE << endl << - "Copyright (c) 2001-2006 by Adrian Thurston" << endl; + cout << "Ragel Code Generator for C, C++, Objective-C, D and Graphviz" << endl << + "Version " VERSION << ", " PUBDATE << endl << + "Copyright (c) 2001-2007 by Adrian Thurston" << endl; } /* Scans a string looking for the file extension. If there is a file diff --git a/rlgen-java/javacodegen.cpp b/rlgen-java/javacodegen.cpp index 8929784..86bea88 100644 --- a/rlgen-java/javacodegen.cpp +++ b/rlgen-java/javacodegen.cpp @@ -38,7 +38,6 @@ using std::endl; void genLineDirective( ostream &out ) { - assert( outputFormat == OutCode ); std::streambuf *sbuf = out.rdbuf(); output_filter *filter = static_cast(sbuf); lineDirective( out, filter->fileName, filter->line + 1 ); @@ -1478,23 +1477,13 @@ void JavaTabCodeGen::prepareMachine() /* Order the states. */ redFsm->depthFirstOrdering(); - if ( codeStyle == GenGoto || codeStyle == GenFGoto || - codeStyle == GenIpGoto || codeStyle == GenSplit ) - { - /* For goto driven machines we can keep the original depth - * first ordering because it's ok if the state ids are not - * sequential. Split the the ids by final state status. */ - redFsm->sortStateIdsByFinal(); - } - else { - /* For table driven machines the location of the state is used to - * identify it so the states must be sorted by their final ids. - * Though having a deterministic ordering is important, - * specifically preserving the depth first ordering is not because - * states are stored in tables. */ - redFsm->sortStatesByFinal(); - redFsm->sequentialStateIds(); - } + /* For table driven machines the location of the state is used to + * identify it so the states must be sorted by their final ids. + * Though having a deterministic ordering is important, + * specifically preserving the depth first ordering is not because + * states are stored in tables. */ + redFsm->sortStatesByFinal(); + redFsm->sequentialStateIds(); /* Find the first final state. This is the final state with the lowest * id. */ @@ -1504,21 +1493,12 @@ void JavaTabCodeGen::prepareMachine() redFsm->chooseDefaultSpan(); /* Maybe do flat expand, otherwise choose single. */ - if ( codeStyle == GenFlat || codeStyle == GenFFlat ) - redFsm->makeFlat(); - else - redFsm->chooseSingle(); + redFsm->chooseSingle(); /* If any errors have occured in the input file then don't write anything. */ if ( gblErrorCount > 0 ) return; - if ( codeStyle == GenSplit ) - redFsm->partitionFsm( numSplitPartitions ); - - if ( codeStyle == GenIpGoto || codeStyle == GenSplit ) - redFsm->setInTrans(); - /* Anlayze Machine will find the final action reference counts, among * other things. We will use these in reporting the usage * of fsm directives in action code. */ @@ -1530,64 +1510,61 @@ void JavaTabCodeGen::prepareMachine() void JavaTabCodeGen::finishRagelDef() { - assert( outputFormat == OutCode ); prepareMachine(); } void JavaTabCodeGen::writeStatement( InputLoc &loc, int nargs, char **args ) { - if ( outputFormat == OutCode ) { - /* Force a newline. */ - out << "\n"; - genLineDirective( out ); - - if ( strcmp( args[0], "data" ) == 0 ) { - for ( int i = 1; i < nargs; i++ ) { - if ( strcmp( args[i], "noerror" ) == 0 ) - writeErr = false; - else if ( strcmp( args[i], "noprefix" ) == 0 ) - dataPrefix = false; - else if ( strcmp( args[i], "nofinal" ) == 0 ) - writeFirstFinal = false; - else { - source_warning(loc) << "unrecognized write option \"" << - args[i] << "\"" << endl; - } - } - writeOutData(); - } - else if ( strcmp( args[0], "init" ) == 0 ) { - for ( int i = 1; i < nargs; i++ ) { + /* Force a newline. */ + out << "\n"; + genLineDirective( out ); + + if ( strcmp( args[0], "data" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + if ( strcmp( args[i], "noerror" ) == 0 ) + writeErr = false; + else if ( strcmp( args[i], "noprefix" ) == 0 ) + dataPrefix = false; + else if ( strcmp( args[i], "nofinal" ) == 0 ) + writeFirstFinal = false; + else { source_warning(loc) << "unrecognized write option \"" << args[i] << "\"" << endl; } - writeOutInit(); } - else if ( strcmp( args[0], "exec" ) == 0 ) { - for ( int i = 1; i < nargs; i++ ) { - if ( strcmp( args[i], "noend" ) == 0 ) - hasEnd = false; - else { - source_warning(loc) << "unrecognized write option \"" << - args[i] << "\"" << endl; - } - } - - /* Must set labels immediately before writing because we may depend - * on the noend write option. */ - setLabelsNeeded(); - writeOutExec(); + writeOutData(); + } + else if ( strcmp( args[0], "init" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + source_warning(loc) << "unrecognized write option \"" << + args[i] << "\"" << endl; } - else if ( strcmp( args[0], "eof" ) == 0 ) { - for ( int i = 1; i < nargs; i++ ) { + writeOutInit(); + } + else if ( strcmp( args[0], "exec" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + if ( strcmp( args[i], "noend" ) == 0 ) + hasEnd = false; + else { source_warning(loc) << "unrecognized write option \"" << args[i] << "\"" << endl; } - writeOutEOF(); } - else { - /* EMIT An error here. */ + + /* Must set labels immediately before writing because we may depend + * on the noend write option. */ + setLabelsNeeded(); + writeOutExec(); + } + else if ( strcmp( args[0], "eof" ) == 0 ) { + for ( int i = 1; i < nargs; i++ ) { + source_warning(loc) << "unrecognized write option \"" << + args[i] << "\"" << endl; } + writeOutEOF(); + } + else { + /* EMIT An error here. */ } } diff --git a/rlgen-java/main.cpp b/rlgen-java/main.cpp index 8cfcf33..82e4b73 100644 --- a/rlgen-java/main.cpp +++ b/rlgen-java/main.cpp @@ -43,10 +43,6 @@ using std::cout; using std::cerr; using std::endl; -/* Target language and output style. */ -OutputFormat outputFormat = OutCode; -CodeStyleEnum codeStyle = GenTables; - /* Io globals. */ istream *inStream = 0; ostream *outStream = 0; @@ -63,31 +59,20 @@ bool printPrintables = false; void usage() { cout << -"usage: rlcodegen-java [options] file\n" +"usage: " PROGNAME " [options] file\n" "general:\n" " -h, -H, -?, --help Print this usage and exit\n" " -v, --version Print version information and exit\n" " -o Write output to \n" -"output:\n" -" -V Generate a Graphviz dotfile instead of code\n" -" -p Print printable characters in Graphviz output\n" -"generated code style:\n" -" -T0 Table driven FSM (default)\n" -" -T1 Faster table driven FSM\n" -" -F0 Flat table driven FSM\n" -" -F1 Faster flat table-driven FSM\n" -" -G0 Goto-driven FSM\n" -" -G1 Faster goto-driven FSM\n" -" -G2 Really fast goto-driven FSM\n" -" -P N-Way Split really fast goto-driven FSM\n" ; } /* Print version information. */ void version() { - cout << "Ragel Code Generator version " VERSION << " " PUBDATE << endl << - "Copyright (c) 2001-2006 by Adrian Thurston" << endl; + cout << "Ragel Code Generator for Java" << endl << + "Version " VERSION << ", " PUBDATE << endl << + "Copyright (c) 2001-2007 by Adrian Thurston" << endl; } /* Scans a string looking for the file extension. If there is a file @@ -187,28 +172,17 @@ void escapeLineDirectivePath( std::ostream &out, char *path ) /* Invoked by the parser when the root element is opened. */ ostream *openOutput( char *inputFile, char *language ) { - if ( strcmp( language, "C" ) == 0 ) { - hostLangType = CCode; - hostLang = &hostLangC; - } - else if ( strcmp( language, "D" ) == 0 ) { - hostLangType = DCode; - hostLang = &hostLangD; - } - else if ( strcmp( language, "Java" ) == 0 ) { + if ( strcmp( language, "Java" ) == 0 ) { hostLangType = JavaCode; hostLang = &hostLangJava; } - - /* Eventually more types will be supported. */ - if ( hostLangType == JavaCode && codeStyle != GenTables ) { - error() << "java: only the table code style -T0 is " - "currently supported" << endl; + else { + error() << "this code genreator is for Java only" << endl; } /* If the output format is code and no output file name is given, then * make a default. */ - if ( outputFormat == OutCode && outputFileName == 0 ) { + if ( outputFileName == 0 ) { char *ext = findFileExtension( inputFile ); if ( ext != 0 && strcmp( ext, ".rh" ) == 0 ) outputFileName = fileNameFromStem( inputFile, ".h" ); @@ -283,56 +257,6 @@ int main(int argc, char **argv) } break; - /* Output formats. */ - case 'V': - outputFormat = OutGraphvizDot; - break; - - case 'p': - printPrintables = true; - break; - - /* Code style. */ - case 'T': - if ( pc.parameterArg[0] == '0' ) - codeStyle = GenTables; - else if ( pc.parameterArg[0] == '1' ) - codeStyle = GenFTables; - else { - error() << "-T" << pc.parameterArg[0] << - " is an invalid argument" << endl; - exit(1); - } - break; - case 'F': - if ( pc.parameterArg[0] == '0' ) - codeStyle = GenFlat; - else if ( pc.parameterArg[0] == '1' ) - codeStyle = GenFFlat; - else { - error() << "-F" << pc.parameterArg[0] << - " is an invalid argument" << endl; - exit(1); - } - break; - case 'G': - if ( pc.parameterArg[0] == '0' ) - codeStyle = GenGoto; - else if ( pc.parameterArg[0] == '1' ) - codeStyle = GenFGoto; - else if ( pc.parameterArg[0] == '2' ) - codeStyle = GenIpGoto; - else { - error() << "-G" << pc.parameterArg[0] << - " is an invalid argument" << endl; - exit(1); - } - break; - case 'P': - codeStyle = GenSplit; - numSplitPartitions = atoi( pc.parameterArg ); - break; - /* Version and help. */ case 'v': version(); @@ -395,8 +319,8 @@ int main(int argc, char **argv) if ( gblErrorCount > 0 ) exit(1); - bool wantComplete = outputFormat != OutGraphvizDot; - bool outputActive = outputFormat == OutCode; + bool wantComplete = true; + bool outputActive = true; /* Parse the input! */ xml_parse( *inStream, xmlInputFileName, outputActive, wantComplete ); diff --git a/rlgen-java/rlgen-java.h b/rlgen-java/rlgen-java.h index ed52e22..cfaf1f9 100644 --- a/rlgen-java/rlgen-java.h +++ b/rlgen-java/rlgen-java.h @@ -29,27 +29,7 @@ #include "vector.h" #include "config.h" -#define PROGNAME "rlcodegen" - -/* Target language. */ -enum OutputFormat -{ - OutCode, - OutGraphvizDot -}; - -/* Target output style. */ -enum CodeStyleEnum -{ - GenTables, - GenFTables, - GenFlat, - GenFFlat, - GenGoto, - GenFGoto, - GenIpGoto, - GenSplit -}; +#define PROGNAME "rlgen-java" /* Filter on the output stream that keeps track of the number of lines * output. */ @@ -64,19 +44,10 @@ public: char *fileName; int line; }; - -extern OutputFormat outputFormat; -extern CodeStyleEnum codeStyle; - -/* IO filenames and stream. */ -extern bool printPrintables; -extern bool graphvizDone; extern int gblErrorCount; extern char machineMain[]; -extern int numSplitPartitions; - std::ostream &error(); char *fileNameFromStem( char *stemFile, char *suffix );