The version number is now included in the intermediate file. A error is emitted
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 29 Apr 2007 16:20:28 +0000 (16:20 +0000)
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>
Sun, 29 Apr 2007 16:20:28 +0000 (16:20 +0000)
if there is a mismatch.

Added an item and removed an item from the TODO.

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

TODO
ragel/parsedata.cpp
redfsm/xmlparse.kl

diff --git a/TODO b/TODO
index 958438a..32e57c1 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,7 @@
-Ragel 6.0 Features
-==================
+Ragel 6.0 Changes
+=================
+
+Remove old action embedding and condition setting syntax.
 
 Expressions of the form: ( expr1 <: expr2 . expr3 ) sometimes don't behave as
 expected. If expr2 contains the empty string then it's possible for the machine
@@ -43,8 +45,6 @@ Should be possible to include scanner definitions in another scanner.
 
 Need a "write entry name;" feature.
 
-Should be possible to embed the negative sense of a condition.
-
 Possibly bring back the old semantics of > in a new operator, or allow it to be
 defined somehow.
 
index 2852134..b4d8ab2 100644 (file)
@@ -31,6 +31,7 @@
 #include "parsetree.h"
 #include "mergesort.h"
 #include "xmlcodegen.h"
+#include "version.h"
 
 using namespace std;
 
@@ -1480,7 +1481,7 @@ void writeMachines( std::ostream &out, std::string hostData, char *inputFileName
                }
 
                if ( gblErrorCount == 0 ) {
-                       out << "<ragel filename=\"" << inputFileName << "\"";
+                       out << "<ragel version=\"" VERSION "\" filename=\"" << inputFileName << "\"";
                        writeLanguage( out );
                        out << ">\n";
                        for ( ParserDict::Iter parser = parserDict; parser.lte(); parser++ ) {
index 5846f3b..c7e990a 100644 (file)
@@ -22,6 +22,7 @@
 #include "xmlparse.h"
 #include "common.h"
 #include "gendata.h"
+#include "version.h"
 #include <iostream>
 #include <stdlib.h>
 
@@ -54,40 +55,46 @@ tag_ragel: tag_ragel_head ragel_def_list host_or_write_list '/' TAG_ragel;
 
 tag_ragel_head: TAG_ragel
        final {
+               /* Check version used to generated the intermediate file. */
+               Attribute *versionAttr = $1->tag->findAttr( "version" );
+               if ( versionAttr == 0 )
+                       error($1->loc) << "tag <ragel> requires a version attribute" << endp;
+               if ( strcmp( versionAttr->value, VERSION ) != 0 )
+                       error($1->loc) << "version mismatch between frontend and backend" << endp;
+
+               /* Check for file name attribute. */
                Attribute *fileNameAttr = $1->tag->findAttr( "filename" );
                if ( fileNameAttr == 0 )
                        error($1->loc) << "tag <ragel> requires a filename attribute" << endp;
-               else {
-                       sourceFileName = fileNameAttr->value;
+               sourceFileName = fileNameAttr->value;
 
-                       Attribute *langAttr = $1->tag->findAttr( "lang" );
-                       if ( langAttr == 0 )
-                               error($1->loc) << "tag <ragel> requires a lang attribute" << endp;
-                       else {
-                               if ( strcmp( langAttr->value, "C" ) == 0 ) {
-                                       hostLangType = CCode;
-                                       hostLang = &hostLangC;
-                               }
-                               else if ( strcmp( langAttr->value, "D" ) == 0 ) {
-                                       hostLangType = DCode;
-                                       hostLang = &hostLangD;
-                               }
-                               else if ( strcmp( langAttr->value, "Java" ) == 0 ) {
-                                       hostLangType = JavaCode;
-                                       hostLang = &hostLangJava;
-                               }
-                               else if ( strcmp( langAttr->value, "Ruby" ) == 0 ) {
-                                       hostLangType = RubyCode;
-                                       hostLang = &hostLangRuby;
-                               }
-                               else {
-                                       error($1->loc) << "expecting lang attribute to be "
-                                                       "one of C, D, Java or Ruby" << endp;
-                               }
+               /* Check for language attribute. */
+               Attribute *langAttr = $1->tag->findAttr( "lang" );
+               if ( langAttr == 0 )
+                       error($1->loc) << "tag <ragel> requires a lang attribute" << endp;
 
-                               outStream = openOutput( sourceFileName );
-                       }
+               if ( strcmp( langAttr->value, "C" ) == 0 ) {
+                       hostLangType = CCode;
+                       hostLang = &hostLangC;
+               }
+               else if ( strcmp( langAttr->value, "D" ) == 0 ) {
+                       hostLangType = DCode;
+                       hostLang = &hostLangD;
+               }
+               else if ( strcmp( langAttr->value, "Java" ) == 0 ) {
+                       hostLangType = JavaCode;
+                       hostLang = &hostLangJava;
+               }
+               else if ( strcmp( langAttr->value, "Ruby" ) == 0 ) {
+                       hostLangType = RubyCode;
+                       hostLang = &hostLangRuby;
                }
+               else {
+                       error($1->loc) << "expecting lang attribute to be "
+                                       "one of C, D, Java or Ruby" << endp;
+               }
+
+               outStream = openOutput( sourceFileName );
        };
 
 ragel_def_list: ragel_def_list ragel_def;