]> granicus.if.org Git - re2c/commitdiff
- Fixed issue with -ws/-wb
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sun, 7 May 2006 20:52:37 +0000 (20:52 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sun, 7 May 2006 20:52:37 +0000 (20:52 +0000)
- Added support for -wg

CHANGELOG
code.cc
test/cvsignore.wb.c

index a9e3d92aae9b88183974998725bf125518d72123..0c87388e4da784418914308a741d11ad7cc4fd03 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,6 @@
 Version 0.10.3 (????-??-??)
 ---------------------------
+- Fixed issue with -wb and -ws.
 - Added -g switch to support gcc's computed goto's.
 - Changed to use nested if's instead of "switch(yyaccept)" in -s mode.
 
diff --git a/code.cc b/code.cc
index 5ef1071f08244568ef3feecfead847f5a819b2e2..8c80ebe78f528408e33abae3769b86721dbcdc79 100644 (file)
--- a/code.cc
+++ b/code.cc
@@ -893,13 +893,45 @@ void Go::genBase(std::ostream &o, uint ind, const State *from, const State *next
 
 void Go::genGoto(std::ostream &o, uint ind, const State *from, const State *next, bool &readCh)
 {
-       if (gFlag && !wFlag && nSpans >= 16)
+       uint xSpans = nSpans;
+
+       if (wSpans == ~0u && wFlag)
        {
-               o << indent(ind++) << "{\n";
+               wSpans = 0;
+               xSpans = 1;
+               for (uint p = 0; p < nSpans; p++)
+               {
+                       if (span[p].ub > 0xFF)
+                       {
+                               wSpans++;
+                       }
+                       if (span[p].ub < 0x100)
+                       {
+                               xSpans++;
+                       }
+               }
+       }
+
+       if (gFlag && xSpans >= 16)
+       {
+               const char * sYych = readCh ? "(yych = *YYCURSOR)" : "yych";
+
+               readCh = false;
+               if (wFlag)
+               {
+                       o << indent(ind) << "if(" << sYych <<" & 0xFF00) {\n";
+                       genBase(o, ind+1, from, next, readCh, 1);
+                       o << indent(ind) << "} else {\n";
+                       sYych = "yych";
+               }
+               else
+               {
+                       o << indent(ind++) << "{\n";
+               }
                o << indent(ind++) << "static void *yytarget[256] = {\n";
                o << indent(ind);
                uint ch = 0;
-               for (uint i = 0; i < nSpans; ++i)
+               for (uint i = 0; i < xSpans && ch < 0x100u; ++i)
                {
                        for(; ch < span[i].ub; ++ch)
                        {
@@ -916,32 +948,12 @@ void Go::genGoto(std::ostream &o, uint ind, const State *from, const State *next
                        vUsedLabels.insert(span[i].to->label);
                }
                o << indent(--ind) << "};\n";
-               if (readCh)
-               {
-                       o << indent(ind) << "goto *yytarget[yych = *YYCURSOR];\n";
-                       o << "";
-               }
-               else
-               {
-                       o << indent(ind) << "goto *yytarget[yych];\n";
-               }
+               o << indent(ind) << "goto *yytarget[" << sYych << "];\n";
                o << indent(--ind) << "}\n";
                return;
        }
        else if (bFlag)
        {
-               if (wSpans == ~0u && wFlag)
-               {
-                       wSpans = 0;
-                       for (uint p = 0; p < nSpans; p++)
-                       {
-                               if (span[p].ub > 0xFF)
-                               {
-                                       wSpans++;
-                               }
-                       }
-               }
-
                for (uint i = 0; i < nSpans; ++i)
                {
                        State *to = span[i].to;
@@ -956,27 +968,17 @@ void Go::genGoto(std::ostream &o, uint ind, const State *from, const State *next
                                        Go go;
                                        go.span = new Span[nSpans];
                                        go.unmap(this, to);
+                                       sYych = readCh ? "(yych = *YYCURSOR)" : "yych";
+                                       readCh = false;
                                        if (wFlag)
                                        {
-                                               if (readCh)
-                                               {
-                                                       o << indent(ind) << "yych = *YYCURSOR;\n";
-                                                       readCh = false;
-                                               }
+                                               o << indent(ind) << "if(" << sYych << " & 0xFF00) {\n";
                                                sYych = "yych";
-                                               o << indent(ind) << "if(yyh & 0xFF00) {\n";
                                                genBase(o, ind+1, from, next, readCh, 1);
                                                o << indent(ind) << "} else ";
                                        }
-                                       else if (readCh)
-                                       {
-                                               sYych = "(yych = *YYCURSOR)";
-                                               readCh = false;
-                                               o << indent(ind);
-                                       }
                                        else
                                        {
-                                               sYych = "yych";
                                                o << indent(ind);
                                        }
                                        o << "if(yybm[" << b->i << "+" << sYych << "] & ";
index bc9822d51a31a14f28f186381645810e25d9e685..8034343ac3c43bdaf0a7c945400a5abc52ec6d54 100755 (executable)
@@ -138,7 +138,7 @@ yy17:
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
 yy18:
-               if(yyh & 0xFF00) {
+               if(yych & 0xFF00) {
                        goto yy17;
                } else if(yybm[0+yych] & 128) {
                        goto yy17;