From: thurston Date: Tue, 13 Feb 2007 19:11:38 +0000 (+0000) Subject: The code generators now exit immediately if the language is not correct. Write X-Git-Tag: 2.0_alpha~379 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=129ab1879557cd6dfcd3c77a6c3faa94368a35c3;p=external%2Fragel.git The code generators now exit immediately if the language is not correct. Write statements are no longer interpreted in rlgen-dot. Since they have no meaning in this generator, it is best to ignore them. git-svn-id: http://svn.complang.org/ragel/trunk@107 052ea7fc-9027-0410-9066-f65837a77df0 --- diff --git a/redfsm/gendata.cpp b/redfsm/gendata.cpp index a5e90f3..fbf5256 100644 --- a/redfsm/gendata.cpp +++ b/redfsm/gendata.cpp @@ -639,7 +639,10 @@ void CodeGenData::analyzeMachine() void CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args ) { - /* Force a newline. */ + /* FIXME: This should be moved to the virtual functions in the code + * generators. + * + * Force a newline. */ out << "\n"; genLineDirective( out ); diff --git a/rlgen-cd/main.cpp b/rlgen-cd/main.cpp index fdb2fbe..4f87454 100644 --- a/rlgen-cd/main.cpp +++ b/rlgen-cd/main.cpp @@ -113,8 +113,10 @@ ostream &error() /* Invoked by the parser when the root element is opened. */ ostream *openOutput( char *inputFile ) { - if ( hostLangType != CCode && hostLangType != DCode ) + if ( hostLangType != CCode && hostLangType != DCode ) { error() << "this code generator is for C and D only" << endl; + exit(1); + } /* If the output format is code and no output file name is given, then * make a default. */ diff --git a/rlgen-dot/gvdotgen.cpp b/rlgen-dot/gvdotgen.cpp index 85b0259..6b17e6d 100644 --- a/rlgen-dot/gvdotgen.cpp +++ b/rlgen-dot/gvdotgen.cpp @@ -33,6 +33,11 @@ void genLineDirective( ostream &out ) { } +/* Override this so that write statement processing is ignored */ +void GraphvizDotGen::writeStatement( InputLoc &, int, char ** ) +{ +} + std::ostream &GraphvizDotGen::KEY( Key key ) { if ( displayPrintables && key.isPrintable() ) { diff --git a/rlgen-dot/gvdotgen.h b/rlgen-dot/gvdotgen.h index 1a65293..356317a 100644 --- a/rlgen-dot/gvdotgen.h +++ b/rlgen-dot/gvdotgen.h @@ -35,6 +35,7 @@ public: void writeDotFile( ); virtual void finishRagelDef(); + virtual void writeStatement( InputLoc &, int, char ** ); private: /* Writing labels and actions. */ diff --git a/rlgen-java/main.cpp b/rlgen-java/main.cpp index c3c7cef..4aee365 100644 --- a/rlgen-java/main.cpp +++ b/rlgen-java/main.cpp @@ -92,8 +92,10 @@ ostream &error() /* Invoked by the parser when the root element is opened. */ ostream *openOutput( char *inputFile ) { - if ( hostLangType != JavaCode ) + if ( hostLangType != JavaCode ) { error() << "this code generator is for Java only" << endl; + exit(1); + } /* If the output format is code and no output file name is given, then * make a default. */ diff --git a/rlgen-ruby/main.cpp b/rlgen-ruby/main.cpp index a37b0b8..8031451 100644 --- a/rlgen-ruby/main.cpp +++ b/rlgen-ruby/main.cpp @@ -92,8 +92,10 @@ ostream &error() /* Invoked by the parser when the root element is opened. */ ostream *openOutput( char *inputFile ) { - if ( hostLangType != RubyCode ) + if ( hostLangType != RubyCode ) { error() << "this code generator is for Ruby only" << endl; + exit(1); + } /* If the output format is code and no output file name is given, then * make a default. */