From: helly Date: Sun, 6 May 2007 19:54:36 +0000 (+0000) Subject: - Synch order of condition enum with condition jump table and internalusage X-Git-Tag: 0.13.6~144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5eb58a6ae5e7c7999e4aa6dfc3a7c0d44c48f488;p=re2c - Synch order of condition enum with condition jump table and internalusage --- diff --git a/re2c/bootstrap/scanner.cc b/re2c/bootstrap/scanner.cc index 20c6d45a..2173e805 100644 --- a/re2c/bootstrap/scanner.cc +++ b/re2c/bootstrap/scanner.cc @@ -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 diff --git a/re2c/code.cc b/re2c/code.cc index 307622b6..46f6ca3a 100644 --- a/re2c/code.cc +++ b/re2c/code.cc @@ -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"; } diff --git a/re2c/test/condition_05.cgitcondition_05.cgit.h.h b/re2c/test/condition_05.cgitcondition_05.cgit.h.h index 74bc7ef9..439fa96e 100755 --- a/re2c/test/condition_05.cgitcondition_05.cgit.h.h +++ b/re2c/test/condition_05.cgitcondition_05.cgit.h.h @@ -1,6 +1,6 @@ /* Generated by re2c */ enum YYCONDTYPE { - yyccomment, yycnormal, + yyccomment, }; diff --git a/re2c/test/condition_05.cgtcondition_05.cgt.h.h b/re2c/test/condition_05.cgtcondition_05.cgt.h.h index 29a8d28b..dbd252f4 100755 --- a/re2c/test/condition_05.cgtcondition_05.cgt.h.h +++ b/re2c/test/condition_05.cgtcondition_05.cgt.h.h @@ -2,6 +2,6 @@ #line 3 "condition_05.cgt.h" enum YYCONDTYPE { - yyccomment, yycnormal, + yyccomment, }; diff --git a/re2c/test/condition_06.cs.c b/re2c/test/condition_06.cs.c index 81b20862..a160013d 100755 --- a/re2c/test/condition_06.cs.c +++ b/re2c/test/condition_06.cs.c @@ -56,8 +56,8 @@ void fputl(const char *s, size_t len, FILE *stream) #line 57 "" enum YYCONDTYPE { - EStateComment, EStateNormal, + EStateComment, EStateSkiptoeol, EStateString, }; diff --git a/re2c/test/condition_08.cbi.c b/re2c/test/condition_08.cbi.c index e2ab76a6..75e698b7 100755 --- a/re2c/test/condition_08.cbi.c +++ b/re2c/test/condition_08.cbi.c @@ -7,8 +7,8 @@ enum ScanContition { - EStateComment, EStateNormal, + EStateComment, EStateSkiptoeol, EStateString, }; diff --git a/re2c/test/condition_08.cbif.c b/re2c/test/condition_08.cbif.c index c546c452..ccaae1a2 100755 --- a/re2c/test/condition_08.cbif.c +++ b/re2c/test/condition_08.cbif.c @@ -7,8 +7,8 @@ enum ScanContition { - EStateComment, EStateNormal, + EStateComment, EStateSkiptoeol, EStateString, }; diff --git a/re2c/test/condition_09.cbif.c b/re2c/test/condition_09.cbif.c index 62295f23..4167be8a 100755 --- a/re2c/test/condition_09.cbif.c +++ b/re2c/test/condition_09.cbif.c @@ -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); diff --git a/re2c/test/condition_09.cbif.re b/re2c/test/condition_09.cbif.re index 60cbc7da..7bd5bce3 100755 --- a/re2c/test/condition_09.cbif.re +++ b/re2c/test/condition_09.cbif.re @@ -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 + "/*" => 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); diff --git a/re2c/test/condition_09.cgif.c b/re2c/test/condition_09.cgif.c index 625dbd36..6e7a878e 100755 --- a/re2c/test/condition_09.cgif.c +++ b/re2c/test/condition_09.cgif.c @@ -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); diff --git a/re2c/test/condition_09.cgif.re b/re2c/test/condition_09.cgif.re index 60cbc7da..7bd5bce3 100755 --- a/re2c/test/condition_09.cgif.re +++ b/re2c/test/condition_09.cgif.re @@ -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 + "/*" => 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);