The code generators now exit immediately if the language is not correct. Write
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Tue, 13 Feb 2007 19:11:38 +0000 (19:11 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Tue, 13 Feb 2007 19:11:38 +0000 (19:11 +0000)
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

redfsm/gendata.cpp
rlgen-cd/main.cpp
rlgen-dot/gvdotgen.cpp
rlgen-dot/gvdotgen.h
rlgen-java/main.cpp
rlgen-ruby/main.cpp

index a5e90f3..fbf5256 100644 (file)
@@ -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 );
 
index fdb2fbe..4f87454 100644 (file)
@@ -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. */
index 85b0259..6b17e6d 100644 (file)
@@ -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() ) {
index 1a65293..356317a 100644 (file)
@@ -35,6 +35,7 @@ public:
        void writeDotFile( );
 
        virtual void finishRagelDef();
+       virtual void writeStatement( InputLoc &, int, char ** );
 
 private:
        /* Writing labels and actions. */
index c3c7cef..4aee365 100644 (file)
@@ -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. */
index a37b0b8..8031451 100644 (file)
@@ -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. */