]> granicus.if.org Git - re2c/commitdiff
Added tests for bug #121 "trailing contexts are fundamentally broken".
authorUlya Trofimovich <skvadrik@gmail.com>
Tue, 10 May 2016 14:17:51 +0000 (15:17 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Tue, 10 May 2016 14:17:51 +0000 (15:17 +0100)
14 files changed:
re2c/test/tags/bug121_fix.i--input(custom).c [new file with mode: 0644]
re2c/test/tags/bug121_fix.i--input(custom).re [new file with mode: 0644]
re2c/test/tags/bug121_fix.i.c [new file with mode: 0644]
re2c/test/tags/bug121_fix.i.re [new file with mode: 0644]
re2c/test/tags/bug121_var_multiple.i--input(custom).c [new file with mode: 0644]
re2c/test/tags/bug121_var_multiple.i--input(custom).re [new file with mode: 0644]
re2c/test/tags/bug121_var_multiple.i.c [new file with mode: 0644]
re2c/test/tags/bug121_var_multiple.i.re [new file with mode: 0644]
re2c/test/tags/bug121_var_single.i--input(custom).c [moved from re2c/test/tags/overlap.i--input(custom).c with 76% similarity]
re2c/test/tags/bug121_var_single.i--input(custom).re [new file with mode: 0644]
re2c/test/tags/bug121_var_single.i.c [moved from re2c/test/tags/overlap.i.c with 77% similarity]
re2c/test/tags/bug121_var_single.i.re [new file with mode: 0644]
re2c/test/tags/overlap.i--input(custom).re [deleted file]
re2c/test/tags/overlap.i.re [deleted file]

diff --git a/re2c/test/tags/bug121_fix.i--input(custom).c b/re2c/test/tags/bug121_fix.i--input(custom).c
new file mode 100644 (file)
index 0000000..fd31bb1
--- /dev/null
@@ -0,0 +1,58 @@
+/* Generated by re2c */
+// overlapping trailing contexts of fixed length:
+// because of generic API we cannot take advantage of
+// fixed length and have to use multiple tags, which
+// further are deduplicated and we end up with single
+// tag
+
+
+{
+       YYCTYPE yych;
+       if (YYLESSTHAN (4)) YYFILL(4);
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':       goto yy4;
+       default:        goto yy2;
+       }
+yy2:
+       YYSKIP ();
+yy3:
+       { d }
+yy4:
+       YYSKIP ();
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'b':
+               YYBACKUPCTX ();
+               goto yy5;
+       default:        goto yy3;
+       }
+yy5:
+       YYSKIP ();
+       YYBACKUP ();
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'b':       goto yy7;
+       default:        goto yy6;
+       }
+yy6:
+       YYRESTORECTX ();
+       { 1 }
+yy7:
+       YYSKIP ();
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'c':
+               YYBACKUPCTX ();
+               goto yy9;
+       default:        goto yy8;
+       }
+yy8:
+       YYRESTORE ();
+       goto yy6;
+yy9:
+       YYSKIP ();
+       YYRESTORECTX ();
+       { 0 }
+}
+
diff --git a/re2c/test/tags/bug121_fix.i--input(custom).re b/re2c/test/tags/bug121_fix.i--input(custom).re
new file mode 100644 (file)
index 0000000..822349e
--- /dev/null
@@ -0,0 +1,11 @@
+// overlapping trailing contexts of fixed length:
+// because of generic API we cannot take advantage of
+// fixed length and have to use multiple tags, which
+// further are deduplicated and we end up with single
+// tag
+
+/*!re2c
+    "abb" / "c" { 0 }
+    "a"   / "b" { 1 }
+    *           { d }
+*/
diff --git a/re2c/test/tags/bug121_fix.i.c b/re2c/test/tags/bug121_fix.i.c
new file mode 100644 (file)
index 0000000..13f3d33
--- /dev/null
@@ -0,0 +1,47 @@
+/* Generated by re2c */
+// overlapping trailing contexts of fixed length:
+// we don't need any tags at all
+
+
+{
+       YYCTYPE yych;
+       if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy4;
+       default:        goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+yy3:
+       { d }
+yy4:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'b':       goto yy5;
+       default:        goto yy3;
+       }
+yy5:
+       yych = *(YYMARKER = ++YYCURSOR);
+       switch (yych) {
+       case 'b':       goto yy7;
+       default:        goto yy6;
+       }
+yy6:
+       YYCURSOR -= 1;
+       { 1 }
+yy7:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'c':       goto yy9;
+       default:        goto yy8;
+       }
+yy8:
+       YYCURSOR = YYMARKER;
+       goto yy6;
+yy9:
+       ++YYCURSOR;
+       YYCURSOR -= 1;
+       { 0 }
+}
+
diff --git a/re2c/test/tags/bug121_fix.i.re b/re2c/test/tags/bug121_fix.i.re
new file mode 100644 (file)
index 0000000..1d455e4
--- /dev/null
@@ -0,0 +1,8 @@
+// overlapping trailing contexts of fixed length:
+// we don't need any tags at all
+
+/*!re2c
+    "abb" / "c" { 0 }
+    "a"   / "b" { 1 }
+    *           { d }
+*/
diff --git a/re2c/test/tags/bug121_var_multiple.i--input(custom).c b/re2c/test/tags/bug121_var_multiple.i--input(custom).c
new file mode 100644 (file)
index 0000000..2189a3b
--- /dev/null
@@ -0,0 +1,71 @@
+/* Generated by re2c */
+// overlapping trailing contexts of variable length:
+// we need multiple tags and we cannot deduplicate them
+
+
+{
+       YYCTYPE yych;
+       long yytag0;
+       long yytag1;
+       YYBACKUPCTX ();
+       if (YYLESSTHAN (4)) YYFILL(4);
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':       goto yy4;
+       default:        goto yy2;
+       }
+yy2:
+       YYSKIP ();
+       { d }
+yy4:
+       YYSKIP ();
+       yytag1 = YYDIST();
+       switch ((yych = YYPEEK ())) {
+       case 'b':       goto yy6;
+       default:        goto yy5;
+       }
+yy5:
+       YYRESTORECTX (yytag1);
+       { 1 }
+yy6:
+       YYSKIP ();
+       YYBACKUP ();
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'c':
+               yytag0 = YYDIST();
+               goto yy9;
+       default:        goto yy8;
+       }
+yy7:
+       YYSKIP ();
+       if (YYLESSTHAN (1)) YYFILL(1);
+       yych = YYPEEK ();
+yy8:
+       switch (yych) {
+       case 'b':       goto yy7;
+       default:        goto yy5;
+       }
+yy9:
+       YYSKIP ();
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'c':       goto yy11;
+       default:        goto yy10;
+       }
+yy10:
+       YYRESTORE ();
+       goto yy5;
+yy11:
+       YYSKIP ();
+       if (YYLESSTHAN (1)) YYFILL(1);
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'c':       goto yy11;
+       default:        goto yy13;
+       }
+yy13:
+       YYRESTORECTX (yytag0);
+       { 0 }
+}
+
diff --git a/re2c/test/tags/bug121_var_multiple.i--input(custom).re b/re2c/test/tags/bug121_var_multiple.i--input(custom).re
new file mode 100644 (file)
index 0000000..b661c89
--- /dev/null
@@ -0,0 +1,8 @@
+// overlapping trailing contexts of variable length:
+// we need multiple tags and we cannot deduplicate them
+
+/*!re2c
+    "ab" / "c"{2,} { 0 }
+    "a"  / "b"*    { 1 }
+    *              { d }
+*/
diff --git a/re2c/test/tags/bug121_var_multiple.i.c b/re2c/test/tags/bug121_var_multiple.i.c
new file mode 100644 (file)
index 0000000..74903c1
--- /dev/null
@@ -0,0 +1,68 @@
+/* Generated by re2c */
+// overlapping trailing contexts of variable length:
+// we need multiple tags and we cannot deduplicate them
+
+
+{
+       YYCTYPE yych;
+       long yytag0;
+       long yytag1;
+       YYCTXMARKER = YYCURSOR;
+       if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy4;
+       default:        goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+       { d }
+yy4:
+       ++YYCURSOR;
+       yytag1 = (YYCURSOR - YYCTXMARKER);
+       switch ((yych = *YYCURSOR)) {
+       case 'b':       goto yy6;
+       default:        goto yy5;
+       }
+yy5:
+       YYCURSOR = YYCTXMARKER + yytag1;
+       { 1 }
+yy6:
+       yych = *(YYMARKER = ++YYCURSOR);
+       switch (yych) {
+       case 'c':
+               yytag0 = (YYCURSOR - YYCTXMARKER);
+               goto yy9;
+       default:        goto yy8;
+       }
+yy7:
+       ++YYCURSOR;
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+yy8:
+       switch (yych) {
+       case 'b':       goto yy7;
+       default:        goto yy5;
+       }
+yy9:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'c':       goto yy11;
+       default:        goto yy10;
+       }
+yy10:
+       YYCURSOR = YYMARKER;
+       goto yy5;
+yy11:
+       ++YYCURSOR;
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'c':       goto yy11;
+       default:        goto yy13;
+       }
+yy13:
+       YYCURSOR = YYCTXMARKER + yytag0;
+       { 0 }
+}
+
diff --git a/re2c/test/tags/bug121_var_multiple.i.re b/re2c/test/tags/bug121_var_multiple.i.re
new file mode 100644 (file)
index 0000000..b661c89
--- /dev/null
@@ -0,0 +1,8 @@
+// overlapping trailing contexts of variable length:
+// we need multiple tags and we cannot deduplicate them
+
+/*!re2c
+    "ab" / "c"{2,} { 0 }
+    "a"  / "b"*    { 1 }
+    *              { d }
+*/
similarity index 76%
rename from re2c/test/tags/overlap.i--input(custom).c
rename to re2c/test/tags/bug121_var_single.i--input(custom).c
index bb596524983b7b6322913bb3f1280fa7ce502f3b..fbcb38aac3f7d0fcfb9b4badb7a7fd22b2db540f 100644 (file)
@@ -1,4 +1,9 @@
 /* Generated by re2c */
+// overlapping trailing contexts of variable length:
+// in principle, we need multiple tags here, but in this
+// particular case all tags can be implemented using sinle
+// variable (due to tag deduplication)
+
 
 {
        YYCTYPE yych;
@@ -10,7 +15,7 @@
        }
 yy2:
        YYSKIP ();
-       {}
+       { d }
 yy4:
        YYSKIP ();
        YYBACKUPCTX ();
@@ -20,7 +25,7 @@ yy4:
        }
 yy5:
        YYRESTORECTX ();
-       {}
+       { 1 }
 yy6:
        YYSKIP ();
        switch ((yych = YYPEEK ())) {
@@ -34,7 +39,7 @@ yy6:
        }
 yy7:
        YYRESTORECTX ();
-       {}
+       { 0 }
 yy8:
        YYSKIP ();
        if (YYLESSTHAN (1)) YYFILL(1);
diff --git a/re2c/test/tags/bug121_var_single.i--input(custom).re b/re2c/test/tags/bug121_var_single.i--input(custom).re
new file mode 100644 (file)
index 0000000..065a337
--- /dev/null
@@ -0,0 +1,10 @@
+// overlapping trailing contexts of variable length:
+// in principle, we need multiple tags here, but in this
+// particular case all tags can be implemented using sinle
+// variable (due to tag deduplication)
+
+/*!re2c
+    "ab" / "c"* { 0 }
+    "a"  / "b"* { 1 }
+    *           { d }
+*/
similarity index 77%
rename from re2c/test/tags/overlap.i.c
rename to re2c/test/tags/bug121_var_single.i.c
index 8ae0b14685246add205e02d867455b335472d32e..a9619bf91a44c25f0d6ee9fc293bc2155843a87c 100644 (file)
@@ -1,4 +1,9 @@
 /* Generated by re2c */
+// overlapping trailing contexts of variable length:
+// in principle, we need multiple tags here, but in this
+// particular case all tags can be implemented using sinle
+// variable (due to tag deduplication)
+
 
 {
        YYCTYPE yych;
@@ -10,7 +15,7 @@
        }
 yy2:
        ++YYCURSOR;
-       {}
+       { d }
 yy4:
        ++YYCURSOR;
        YYCTXMARKER = YYCURSOR;
@@ -20,7 +25,7 @@ yy4:
        }
 yy5:
        YYCURSOR = YYCTXMARKER;
-       {}
+       { 1 }
 yy6:
        ++YYCURSOR;
        switch ((yych = *YYCURSOR)) {
@@ -34,7 +39,7 @@ yy6:
        }
 yy7:
        YYCURSOR = YYCTXMARKER;
-       {}
+       { 0 }
 yy8:
        ++YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
diff --git a/re2c/test/tags/bug121_var_single.i.re b/re2c/test/tags/bug121_var_single.i.re
new file mode 100644 (file)
index 0000000..065a337
--- /dev/null
@@ -0,0 +1,10 @@
+// overlapping trailing contexts of variable length:
+// in principle, we need multiple tags here, but in this
+// particular case all tags can be implemented using sinle
+// variable (due to tag deduplication)
+
+/*!re2c
+    "ab" / "c"* { 0 }
+    "a"  / "b"* { 1 }
+    *           { d }
+*/
diff --git a/re2c/test/tags/overlap.i--input(custom).re b/re2c/test/tags/overlap.i--input(custom).re
deleted file mode 100644 (file)
index 986fac7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/*!re2c
-    "ab" / "c"* {}
-    "a"  / "b"* {}
-    *           {}
-*/
diff --git a/re2c/test/tags/overlap.i.re b/re2c/test/tags/overlap.i.re
deleted file mode 100644 (file)
index 986fac7..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-/*!re2c
-    "ab" / "c"* {}
-    "a"  / "b"* {}
-    *           {}
-*/