added:
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 4 Jan 2009 21:23:15 +0000 (21:23 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 4 Jan 2009 21:23:15 +0000 (21:23 +0000)
    write start;
    write first_final;
    write error;

git-svn-id: http://svn.complang.org/ragel/trunk@660 052ea7fc-9027-0410-9066-f65837a77df0

12 files changed:
ragel.vim
ragel/cdcodegen.cpp
ragel/cdcodegen.h
ragel/cscodegen.cpp
ragel/cscodegen.h
ragel/gendata.cpp
ragel/gendata.h
ragel/javacodegen.cpp
ragel/javacodegen.h
ragel/rubycodegen.cpp
ragel/rubycodegen.h
test/runtests

index 0215882..58ae7a7 100644 (file)
--- a/ragel.vim
+++ b/ragel.vim
@@ -124,9 +124,9 @@ syntax cluster inlineItems contains=rlCodeCurly,ocComment,ocPreproc,ocLiteral,oc
 syntax region rlCodeCurly matchgroup=NONE start="{" end="}" contained contains=@inlineItems
 syntax region rlCodeSemi matchgroup=Type start="\<alphtype\>" start="\<getkey\>" start="\<access\>" start="\<variable\>" matchgroup=NONE end=";" contained contains=@inlineItems
 
-syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end=";" contained contains=rlWriteKeywords,rlWriteOptions
+syntax region rlWrite matchgroup=Type start="\<write\>" matchgroup=NONE end="[;)]" contained contains=rlWriteKeywords,rlWriteOptions
 
-syntax keyword rlWriteKeywords init data exec exports contained
+syntax keyword rlWriteKeywords init data exec exports start error first_final contained
 syntax keyword rlWriteOptions noerror nofinal noprefix noend nocs contained
 
 "
index 0a98469..afb1410 100644 (file)
@@ -776,6 +776,20 @@ void FsmCodeGen::STATE_IDS()
        }
 }
 
+void FsmCodeGen::writeStart()
+{
+       out << START_STATE_ID();
+}
+
+void FsmCodeGen::writeFirstFinal()
+{
+       out << FIRST_FINAL_STATE();
+}
+
+void FsmCodeGen::writeError()
+{
+       out << ERROR_STATE();
+}
 
 /*
  * Language specific, but style independent code generators functions.
index 467a309..6c4a92a 100644 (file)
@@ -66,6 +66,9 @@ public:
 
        virtual void finishRagelDef();
        virtual void writeInit();
+       virtual void writeStart();
+       virtual void writeFirstFinal();
+       virtual void writeError();
 
 protected:
        string FSM_NAME();
index 69c20bf..eddae7d 100644 (file)
@@ -735,6 +735,22 @@ void CSharpFsmCodeGen::STATE_IDS()
        }
 }
 
+
+void CSharpFsmCodeGen::writeStart()
+{
+       out << START_STATE_ID();
+}
+
+void CSharpFsmCodeGen::writeFirstFinal()
+{
+       out << FIRST_FINAL_STATE();
+}
+
+void CSharpFsmCodeGen::writeError()
+{
+       out << ERROR_STATE();
+}
+
 /*
  * C# Specific
  */
index 73f3cfe..fae7f4d 100644 (file)
@@ -66,6 +66,9 @@ public:
 
        virtual void finishRagelDef();
        virtual void writeInit();
+       virtual void writeStart();
+       virtual void writeFirstFinal();
+       virtual void writeError();
 
 protected:
        string FSM_NAME();
index 3cf1a35..e0189c6 100644 (file)
@@ -711,6 +711,11 @@ void CodeGenData::analyzeMachine()
        setValueLimits();
 }
 
+void CodeGenData::write_option_error( InputLoc &loc, char *arg )
+{
+       source_warning(loc) << "unrecognized write option \"" << arg << "\"" << endl;
+}
+
 void CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args )
 {
        /* FIXME: This should be moved to the virtual functions in the code
@@ -728,10 +733,8 @@ void CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args )
                                noPrefix = true;
                        else if ( strcmp( args[i], "nofinal" ) == 0 )
                                noFinal = true;
-                       else {
-                               source_warning(loc) << "unrecognized write option \"" << 
-                                               args[i] << "\"" << endl;
-                       }
+                       else
+                               write_option_error( loc, args[i] );
                }
                writeData();
        }
@@ -739,10 +742,8 @@ void CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args )
                for ( int i = 1; i < nargs; i++ ) {
                        if ( strcmp( args[i], "nocs" ) == 0 )
                                noCS = true;
-                       else {
-                               source_warning(loc) << "unrecognized write option \"" << 
-                                               args[i] << "\"" << endl;
-                       }
+                       else
+                               write_option_error( loc, args[i] );
                }
                writeInit();
        }
@@ -750,20 +751,31 @@ void CodeGenData::writeStatement( InputLoc &loc, int nargs, char **args )
                for ( int i = 1; i < nargs; i++ ) {
                        if ( strcmp( args[i], "noend" ) == 0 )
                                noEnd = true;
-                       else {
-                               source_warning(loc) << "unrecognized write option \"" << 
-                                               args[i] << "\"" << endl;
-                       }
+                       else
+                               write_option_error( loc, args[i] );
                }
                writeExec();
        }
        else if ( strcmp( args[0], "exports" ) == 0 ) {
-               for ( int i = 1; i < nargs; i++ ) {
-                       source_warning(loc) << "unrecognized write option \"" << 
-                                       args[i] << "\"" << endl;
-               }
+               for ( int i = 1; i < nargs; i++ )
+                       write_option_error( loc, args[i] );
                writeExports();
        }
+       else if ( strcmp( args[0], "start" ) == 0 ) {
+               for ( int i = 1; i < nargs; i++ )
+                       write_option_error( loc, args[i] );
+               writeStart();
+       }
+       else if ( strcmp( args[0], "first_final" ) == 0 ) {
+               for ( int i = 1; i < nargs; i++ )
+                       write_option_error( loc, args[i] );
+               writeFirstFinal();
+       }
+       else if ( strcmp( args[0], "error" ) == 0 ) {
+               for ( int i = 1; i < nargs; i++ )
+                       write_option_error( loc, args[i] );
+               writeError();
+       }
        else {
                /* EMIT An error here. */
                source_error(loc) << "unrecognized write command \"" << 
index 0439722..bc052d9 100644 (file)
@@ -87,6 +87,9 @@ struct CodeGenData
        virtual void writeInit() {};
        virtual void writeExec() {};
        virtual void writeExports() {};
+       virtual void writeStart() {};
+       virtual void writeFirstFinal() {};
+       virtual void writeError() {};
 
        /* This can also be overwridden to modify the processing of write
         * statements. */
@@ -195,6 +198,7 @@ struct CodeGenData
 
        ostream &source_warning( const InputLoc &loc );
        ostream &source_error( const InputLoc &loc );
+       void write_option_error( InputLoc &loc, char *arg );
 };
 
 #endif
index 1c3b09c..6936aa3 100644 (file)
@@ -895,6 +895,21 @@ void JavaTabCodeGen::writeExports()
        }
 }
 
+void JavaTabCodeGen::writeStart()
+{
+       out << START_STATE_ID();
+}
+
+void JavaTabCodeGen::writeFirstFinal()
+{
+       out << FIRST_FINAL_STATE();
+}
+
+void JavaTabCodeGen::writeError()
+{
+       out << ERROR_STATE();
+}
+
 void JavaTabCodeGen::writeData()
 {
        /* If there are any transtion functions then output the array. If there
index 555f192..21bf739 100644 (file)
@@ -78,6 +78,9 @@ struct JavaTabCodeGen : public CodeGenData
        virtual void writeData();
        virtual void writeInit();
        virtual void writeExports();
+       virtual void writeStart();
+       virtual void writeFirstFinal();
+       virtual void writeError();
        virtual void finishRagelDef();
 
        void NEXT( ostream &ret, int nextDest, bool inFinish );
index 6842fe6..f285c58 100644 (file)
@@ -898,6 +898,22 @@ void RubyCodeGen::writeExports()
        }
 }
 
+void RubyCodeGen::writeStart()
+{
+       out << START_STATE_ID();
+}
+
+void RubyCodeGen::writeFirstFinal()
+{
+       out << FIRST_FINAL_STATE();
+}
+
+void RubyCodeGen::writeError()
+{
+       out << ERROR_STATE();
+}
+
+
 /*
  * Local Variables:
  * mode: c++
index 1b62856..d671faa 100644 (file)
@@ -123,6 +123,9 @@ public:
 protected:
        virtual void writeExports();
        virtual void writeInit();
+       virtual void writeStart();
+       virtual void writeFirstFinal();
+       virtual void writeError();
 
        /* Determine if we should use indicies. */
        virtual void calcIndexSize();
index 7e0ca4a..5728105 100755 (executable)
@@ -51,7 +51,7 @@ shift $((OPTIND - 1));
 
 [ -z "$*" ] && set -- *.rl
 
-config=../common/config.h
+config=../ragel/config.h
 ragel=../ragel/ragel
 
 cxx_compiler=`sed '/^#define CXX/s/#define CXX *//p;d' $config`