]> granicus.if.org Git - re2c/commitdiff
- Synch order of condition enum with condition jump table and internalusage
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sun, 6 May 2007 19:54:36 +0000 (19:54 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sun, 6 May 2007 19:54:36 +0000 (19:54 +0000)
re2c/bootstrap/scanner.cc
re2c/code.cc
re2c/test/condition_05.cgitcondition_05.cgit.h.h
re2c/test/condition_05.cgtcondition_05.cgt.h.h
re2c/test/condition_06.cs.c
re2c/test/condition_08.cbi.c
re2c/test/condition_08.cbif.c
re2c/test/condition_09.cbif.c
re2c/test/condition_09.cbif.re
re2c/test/condition_09.cgif.c
re2c/test/condition_09.cgif.re

index 20c6d45af72a34886f2b604d7d3fd823f6115fe9..2173e8053f3f374fd015823b0fcd6eac1dc38f68 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.0.dev on Sat May  5 19:12:48 2007 */
+/* Generated by re2c 0.13.0.dev on Sun May  6 21:32:27 2007 */
 #line 1 "scanner.re"
 /* $Id$ */
 #include <stdlib.h>
index 307622b6d15720d6907d69c73cda47e0b0facb49..46f6ca3a5537763246faa5342d3d4b6fbc34221e 100644 (file)
@@ -1852,10 +1852,19 @@ void genTypes(std::string& o, uint ind, const RegExpMap& specMap)
        o.clear();
 
        o += indent(ind++) + "enum " + mapCodeName["YYCONDTYPE"] + " {\n";
-       for(RegExpMap::const_iterator it = specMap.begin(); it != specMap.end(); ++it)
+
+       RegExpIndices  vCondList(specMap.size());
+
+       for(RegExpMap::const_iterator itSpecMap = specMap.begin(); itSpecMap != specMap.end(); ++itSpecMap)
+       {
+               vCondList[itSpecMap->second.first] = itSpecMap->first;
+       }
+
+       for(RegExpIndices::const_iterator itCondType = vCondList.begin(); itCondType != vCondList.end(); ++itCondType)
        {
-               o += indent(ind) + condEnumPrefix + it->first + ",\n";
+               o += indent(ind) + condEnumPrefix + *itCondType + ",\n";
        }
+
        o += indent(--ind) + "};\n";
 }
 
index 74bc7ef94b27266c560caa642462dfeb18e6d099..439fa96e7bf8990f967996dd16f37883da0cf893 100755 (executable)
@@ -1,6 +1,6 @@
 /* Generated by re2c */
 
 enum YYCONDTYPE {
-       yyccomment,
        yycnormal,
+       yyccomment,
 };
index 29a8d28bcfdfdfa0bb2a4542673a5e7305bb9f0a..dbd252f45d02bb1b2ed31acd5f36fb50020697eb 100755 (executable)
@@ -2,6 +2,6 @@
 #line 3 "condition_05.cgt.h"
 
 enum YYCONDTYPE {
-       yyccomment,
        yycnormal,
+       yyccomment,
 };
index 81b20862f801cc607c021ec61f13d43d246e3d1e..a160013d1ea71770220840bc708b10588718f766 100755 (executable)
@@ -56,8 +56,8 @@ void fputl(const char *s, size_t len, FILE *stream)
 #line 57 "<stdout>"
 
 enum YYCONDTYPE {
-       EStateComment,
        EStateNormal,
+       EStateComment,
        EStateSkiptoeol,
        EStateString,
 };
index e2ab76a674f8caf558c707a2f26d816bfda93055..75e698b7bae99e559292e478928ccd2f426aa6a3 100755 (executable)
@@ -7,8 +7,8 @@
 
 
 enum ScanContition {
-       EStateComment,
        EStateNormal,
+       EStateComment,
        EStateSkiptoeol,
        EStateString,
 };
index c546c452716a197d7cd7dad548a7cd088bd8a5aa..ccaae1a2b0a694d514224c58ece30b983a1fce57 100755 (executable)
@@ -7,8 +7,8 @@
 
 
 enum ScanContition {
-       EStateComment,
        EStateNormal,
+       EStateComment,
        EStateSkiptoeol,
        EStateString,
 };
index 62295f23535b925fa47d63f1638d3c91862e06f6..4167be8af8509b2ee7a8b7b3e9801ae0ce9a97c8 100755 (executable)
@@ -7,8 +7,8 @@
 
 
 enum ScanContition {
-       EStateComment,
        EStateNormal,
+       EStateComment,
        EStateSkiptoeol,
        EStateString,
 };
@@ -60,6 +60,8 @@ size_t init(Scanner *s)
 {
        s->cur = s->tok = s->lim = s->buffer;
        s->eof = 0;
+       s->cond = EStateNormal;
+       s->state = -1;
 
        return fill(s, 0);
 }
@@ -74,19 +76,21 @@ void fputl(const char *s, size_t len, FILE *stream)
 
 void scan(Scanner *s)
 {
+       s->tok = s->cur;
+
+       switch(s->state) {
+       default: goto yy0;
+       case 0: goto yyFillLabel0;
+       case 1: goto yyFillLabel1;
+       case 2: goto yyFillLabel2;
+       case 3: goto yyFillLabel3;
+       }
        for(;;)
        {
                s->tok = s->cur;
 
                {
 
-                       switch(s->state) {
-                       default: goto yy0;
-                       case 0: goto yyFillLabel0;
-                       case 1: goto yyFillLabel1;
-                       case 2: goto yyFillLabel2;
-                       case 3: goto yyFillLabel3;
-                       }
 yy0:
                        if (s->cond < 2) {
                                if (s->cond < 1) {
@@ -194,7 +198,7 @@ yy22:
                        }
 yy24:
                        ++s->cur;
-                       s->cond = EStateNormal;
+                       s->cond = EStateComment;
                        {
                                goto yyc_Comment;
                        }
@@ -364,7 +368,6 @@ yy69:
 int main(int argc, char **argv)
 {
        Scanner in;
-       char c;
 
        if (argc != 2)
        {
@@ -384,8 +387,6 @@ int main(int argc, char **argv)
                return 1;
        }
 
-       in.cond = EStateNormal;
-
        if (init(&in) > 0)
        {
                scan(&in);
index 60cbc7da003d14a40c58cbd54aefa1bf44e1913f..7bd5bce3b01d519030c3afd6d0cacdd2cd76ccc2 100755 (executable)
@@ -52,6 +52,8 @@ size_t init(Scanner *s)
 {
        s->cur = s->tok = s->lim = s->buffer;
        s->eof = 0;
+       s->cond = EStateNormal;
+       s->state = -1;
 
        return fill(s, 0);
 }
@@ -66,6 +68,14 @@ void fputl(const char *s, size_t len, FILE *stream)
 
 void scan(Scanner *s)
 {
+       s->tok = s->cur;
+/*!re2c
+re2c:define:YYGETSTATE       = "s->state";
+re2c:define:YYGETSTATE:naked = 1;
+re2c:define:YYCONDTYPE       = ScanContition;
+re2c:indent:top              = 1;
+*/
+/*!getstate:re2c */
        for(;;)
        {
                s->tok = s->cur;
@@ -80,13 +90,10 @@ re2c:define:YYFILL:naked     = 1;
 re2c:define:YYFILL           = "if(fill(s, #) == ~0) break;";
 re2c:define:YYSETSTATE@state = #;
 re2c:define:YYSETSTATE       = "s->state = #;";
-re2c:define:YYGETSTATE       = "s->state";
-re2c:define:YYGETSTATE:naked = 1;
 re2c:define:YYSETCONDITION       = "s->cond = #;";
 re2c:define:YYSETCONDITION@cond  = #;
 re2c:define:YYGETCONDITION       = s->cond;
 re2c:define:YYGETCONDITION:naked = 1;
-re2c:define:YYCONDTYPE       = ScanContition;
 re2c:variable:yych           = s->yych;
 re2c:yych:emit               = 0;
 re2c:indent:top              = 2;
@@ -137,7 +144,7 @@ re2c:condenumprefix          = EState;
                                fputc('~', stdout);
                                continue;
                        }
-<Normal>       "/*" => Normal
+<Normal>       "/*" => Comment
                        {
                                goto yyc_Comment;
                        }
@@ -206,7 +213,6 @@ re2c:condenumprefix          = EState;
 int main(int argc, char **argv)
 {
        Scanner in;
-       char c;
 
        if (argc != 2)
        {
@@ -226,8 +232,6 @@ int main(int argc, char **argv)
                return 1;
        }
 
-       in.cond = EStateNormal;
-
        if (init(&in) > 0)
        {
                scan(&in);
index 625dbd3663b03fd2c0445b19606bacb2f60f62c3..6e7a878edd2f5aa42e4a394b279c0d4c8621e34f 100755 (executable)
@@ -7,8 +7,8 @@
 
 
 enum ScanContition {
-       EStateComment,
        EStateNormal,
+       EStateComment,
        EStateSkiptoeol,
        EStateString,
 };
@@ -60,6 +60,8 @@ size_t init(Scanner *s)
 {
        s->cur = s->tok = s->lim = s->buffer;
        s->eof = 0;
+       s->cond = EStateNormal;
+       s->state = -1;
 
        return fill(s, 0);
 }
@@ -74,6 +76,15 @@ void fputl(const char *s, size_t len, FILE *stream)
 
 void scan(Scanner *s)
 {
+       s->tok = s->cur;
+
+       switch(s->state) {
+       default: goto yy0;
+       case 0: goto yyFillLabel0;
+       case 1: goto yyFillLabel1;
+       case 2: goto yyFillLabel2;
+       case 3: goto yyFillLabel3;
+       }
        for(;;)
        {
                s->tok = s->cur;
@@ -86,13 +97,6 @@ void scan(Scanner *s)
                                &&yyc_Skiptoeol,
                                &&yyc_String,
                        };
-                       switch(s->state) {
-                       default: goto yy0;
-                       case 0: goto yyFillLabel0;
-                       case 1: goto yyFillLabel1;
-                       case 2: goto yyFillLabel2;
-                       case 3: goto yyFillLabel3;
-                       }
 yy0:
                        goto *yyctable[s->cond];
 /* *********************************** */
@@ -214,7 +218,7 @@ yy22:
                        }
 yy24:
                        ++s->cur;
-                       s->cond = EStateNormal;
+                       s->cond = EStateComment;
                        {
                                goto yyc_Comment;
                        }
@@ -409,7 +413,6 @@ yy69:
 int main(int argc, char **argv)
 {
        Scanner in;
-       char c;
 
        if (argc != 2)
        {
@@ -429,8 +432,6 @@ int main(int argc, char **argv)
                return 1;
        }
 
-       in.cond = EStateNormal;
-
        if (init(&in) > 0)
        {
                scan(&in);
index 60cbc7da003d14a40c58cbd54aefa1bf44e1913f..7bd5bce3b01d519030c3afd6d0cacdd2cd76ccc2 100755 (executable)
@@ -52,6 +52,8 @@ size_t init(Scanner *s)
 {
        s->cur = s->tok = s->lim = s->buffer;
        s->eof = 0;
+       s->cond = EStateNormal;
+       s->state = -1;
 
        return fill(s, 0);
 }
@@ -66,6 +68,14 @@ void fputl(const char *s, size_t len, FILE *stream)
 
 void scan(Scanner *s)
 {
+       s->tok = s->cur;
+/*!re2c
+re2c:define:YYGETSTATE       = "s->state";
+re2c:define:YYGETSTATE:naked = 1;
+re2c:define:YYCONDTYPE       = ScanContition;
+re2c:indent:top              = 1;
+*/
+/*!getstate:re2c */
        for(;;)
        {
                s->tok = s->cur;
@@ -80,13 +90,10 @@ re2c:define:YYFILL:naked     = 1;
 re2c:define:YYFILL           = "if(fill(s, #) == ~0) break;";
 re2c:define:YYSETSTATE@state = #;
 re2c:define:YYSETSTATE       = "s->state = #;";
-re2c:define:YYGETSTATE       = "s->state";
-re2c:define:YYGETSTATE:naked = 1;
 re2c:define:YYSETCONDITION       = "s->cond = #;";
 re2c:define:YYSETCONDITION@cond  = #;
 re2c:define:YYGETCONDITION       = s->cond;
 re2c:define:YYGETCONDITION:naked = 1;
-re2c:define:YYCONDTYPE       = ScanContition;
 re2c:variable:yych           = s->yych;
 re2c:yych:emit               = 0;
 re2c:indent:top              = 2;
@@ -137,7 +144,7 @@ re2c:condenumprefix          = EState;
                                fputc('~', stdout);
                                continue;
                        }
-<Normal>       "/*" => Normal
+<Normal>       "/*" => Comment
                        {
                                goto yyc_Comment;
                        }
@@ -206,7 +213,6 @@ re2c:condenumprefix          = EState;
 int main(int argc, char **argv)
 {
        Scanner in;
-       char c;
 
        if (argc != 2)
        {
@@ -226,8 +232,6 @@ int main(int argc, char **argv)
                return 1;
        }
 
-       in.cond = EStateNormal;
-
        if (init(&in) > 0)
        {
                scan(&in);