]> granicus.if.org Git - re2c/commitdiff
Added tests for tags (nondeterminism, unsuccessfull minimization).
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 11 May 2016 12:27:07 +0000 (13:27 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 11 May 2016 12:27:07 +0000 (13:27 +0100)
20 files changed:
re2c/test/tags/minimization.i.c [new file with mode: 0644]
re2c/test/tags/minimization.i.re [new file with mode: 0644]
re2c/test/tags/nondet_alt1.--tags.c [new file with mode: 0644]
re2c/test/tags/nondet_alt1.--tags.re [new file with mode: 0644]
re2c/test/tags/nondet_alt2.--tags.c [new file with mode: 0644]
re2c/test/tags/nondet_alt2.--tags.re [new file with mode: 0644]
re2c/test/tags/nondet_cat1.--tags.c [new file with mode: 0644]
re2c/test/tags/nondet_cat1.--tags.re [new file with mode: 0644]
re2c/test/tags/nondet_cat2.c [new file with mode: 0644]
re2c/test/tags/nondet_cat2.re [new file with mode: 0644]
re2c/test/tags/nondet_cat3.i.c [new file with mode: 0644]
re2c/test/tags/nondet_cat3.i.re [new file with mode: 0644]
re2c/test/tags/nondet_cat4.--tags.c [new file with mode: 0644]
re2c/test/tags/nondet_cat4.--tags.re [new file with mode: 0644]
re2c/test/tags/nondeterministic1.i--tags.c [deleted file]
re2c/test/tags/nondeterministic1.i--tags.re [deleted file]
re2c/test/tags/nondeterministic1_trail.i--tags.c [deleted file]
re2c/test/tags/nondeterministic1_trail.i--tags.re [deleted file]
re2c/test/tags/nondeterministic1_trail.i.c [deleted file]
re2c/test/tags/nondeterministic1_trail.i.re [deleted file]

diff --git a/re2c/test/tags/minimization.i.c b/re2c/test/tags/minimization.i.c
new file mode 100644 (file)
index 0000000..83044b2
--- /dev/null
@@ -0,0 +1,66 @@
+/* Generated by re2c */
+// Rules are the same except for the tag in the 2nd case.
+// In the 1st case common tail "a" is deduplicated after DFA minimization.
+// In the 2nd case tag prevents minimization.
+
+
+{
+       YYCTYPE yych;
+       if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'b':
+       case 'c':       goto yy4;
+       default:        goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+yy3:
+       {}
+yy4:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy5;
+       default:        goto yy3;
+       }
+yy5:
+       ++YYCURSOR;
+       {}
+}
+
+
+
+{
+       YYCTYPE yych;
+       long yytag0p;
+       YYCTXMARKER = YYCURSOR;
+       if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'b':       goto yy11;
+       case 'c':       goto yy12;
+       default:        goto yy9;
+       }
+yy9:
+       ++YYCURSOR;
+yy10:
+       {}
+yy11:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':
+               yytag0p = (YYCURSOR - YYCTXMARKER);
+               goto yy13;
+       default:        goto yy10;
+       }
+yy12:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy13;
+       default:        goto yy10;
+       }
+yy13:
+       ++YYCURSOR;
+       { (YYCTXMARKER + yytag0p) }
+}
+
diff --git a/re2c/test/tags/minimization.i.re b/re2c/test/tags/minimization.i.re
new file mode 100644 (file)
index 0000000..949b0c4
--- /dev/null
@@ -0,0 +1,14 @@
+// Rules are the same except for the tag in the 2nd case.
+// In the 1st case common tail "a" is deduplicated after DFA minimization.
+// In the 2nd case tag prevents minimization.
+
+/*!re2c
+    "ba" | "ca" {}
+    * {}
+*/
+
+/*!re2c
+    re2c:flags:tags = 1;
+    "b" @p "a" | "ca" { @p }
+    * {}
+*/
diff --git a/re2c/test/tags/nondet_alt1.--tags.c b/re2c/test/tags/nondet_alt1.--tags.c
new file mode 100644 (file)
index 0000000..47a58dd
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
diff --git a/re2c/test/tags/nondet_alt1.--tags.re b/re2c/test/tags/nondet_alt1.--tags.re
new file mode 100644 (file)
index 0000000..b461e58
--- /dev/null
@@ -0,0 +1,4 @@
+/*!re2c
+    "a" @p | "a" { @p }
+    * {}
+*/
diff --git a/re2c/test/tags/nondet_alt2.--tags.c b/re2c/test/tags/nondet_alt2.--tags.c
new file mode 100644 (file)
index 0000000..47a58dd
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
diff --git a/re2c/test/tags/nondet_alt2.--tags.re b/re2c/test/tags/nondet_alt2.--tags.re
new file mode 100644 (file)
index 0000000..1d8d78a
--- /dev/null
@@ -0,0 +1,4 @@
+/*!re2c
+    @p "a" | "a" { @p }
+    * {}
+*/
diff --git a/re2c/test/tags/nondet_cat1.--tags.c b/re2c/test/tags/nondet_cat1.--tags.c
new file mode 100644 (file)
index 0000000..47a58dd
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: line 2: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
diff --git a/re2c/test/tags/nondet_cat1.--tags.re b/re2c/test/tags/nondet_cat1.--tags.re
new file mode 100644 (file)
index 0000000..1caed3a
--- /dev/null
@@ -0,0 +1,4 @@
+/*!re2c
+    "a"+ @p "a"+ { @p }
+    * {}
+*/
diff --git a/re2c/test/tags/nondet_cat2.c b/re2c/test/tags/nondet_cat2.c
new file mode 100644 (file)
index 0000000..d9137ba
--- /dev/null
@@ -0,0 +1,2 @@
+re2c: error: line 7: trailing context is nondeterministic [-Werror-nondeterministic-tags]
+re2c: warning: line 13: trailing context is nondeterministic [-Wnondeterministic-tags]
diff --git a/re2c/test/tags/nondet_cat2.re b/re2c/test/tags/nondet_cat2.re
new file mode 100644 (file)
index 0000000..8707367
--- /dev/null
@@ -0,0 +1,15 @@
+// The same rules, nondeterministic trailing context, with different configurations:
+//     1. tags:    error
+//     2. no tags: warning
+
+/*!re2c
+    re2c:flags:tags = 1;
+    "a"+ / "a"+ {}
+    * {}
+*/
+
+/*!re2c
+    re2c:flags:tags = 0;
+    "a"+ / "a"+ {}
+    * {}
+*/
diff --git a/re2c/test/tags/nondet_cat3.i.c b/re2c/test/tags/nondet_cat3.i.c
new file mode 100644 (file)
index 0000000..712f5af
--- /dev/null
@@ -0,0 +1,147 @@
+/* Generated by re2c */
+// The same rules, fixed length trailing context, with different configurations:
+//     1. default input API, no tags: no warning (no variable, static offset)
+//     2. default input API, tags:    no warning (no variable, static offset)
+//     3. generic input API, no tags: warning (need variable: lack API to to make use of fixed length)
+//     4. generic input API, tags:    no warning (no variable, static offset)
+
+
+{
+       YYCTYPE yych;
+       if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy4;
+       default:        goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+yy3:
+       {}
+yy4:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy5;
+       default:        goto yy3;
+       }
+yy5:
+       ++YYCURSOR;
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy5;
+       default:        goto yy7;
+       }
+yy7:
+       YYCURSOR -= 1;
+       {}
+}
+
+
+
+{
+       YYCTYPE yych;
+       YYCTXMARKER = YYCURSOR;
+       if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy12;
+       default:        goto yy10;
+       }
+yy10:
+       ++YYCURSOR;
+yy11:
+       {}
+yy12:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy13;
+       default:        goto yy11;
+       }
+yy13:
+       ++YYCURSOR;
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy13;
+       default:        goto yy15;
+       }
+yy15:
+       YYCURSOR -= 1;
+       {}
+}
+
+
+
+{
+       YYCTYPE yych;
+       if (YYLESSTHAN (2)) YYFILL(2);
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':       goto yy20;
+       default:        goto yy18;
+       }
+yy18:
+       YYSKIP ();
+yy19:
+       {}
+yy20:
+       YYSKIP ();
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':
+               YYBACKUPCTX ();
+               goto yy21;
+       default:        goto yy19;
+       }
+yy21:
+       YYSKIP ();
+       if (YYLESSTHAN (1)) YYFILL(1);
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':
+               YYBACKUPCTX ();
+               goto yy21;
+       default:        goto yy23;
+       }
+yy23:
+       YYRESTORECTX ();
+       {}
+}
+
+
+
+{
+       YYCTYPE yych;
+       YYBACKUPCTX ();
+       if (YYLESSTHAN (2)) YYFILL(2);
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':       goto yy28;
+       default:        goto yy26;
+       }
+yy26:
+       YYSKIP ();
+yy27:
+       {}
+yy28:
+       YYSKIP ();
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':       goto yy29;
+       default:        goto yy27;
+       }
+yy29:
+       YYSKIP ();
+       if (YYLESSTHAN (1)) YYFILL(1);
+       yych = YYPEEK ();
+       switch (yych) {
+       case 'a':       goto yy29;
+       default:        goto yy31;
+       }
+yy31:
+       YYRESTORECTX (YYDIST() - 1);
+       {}
+}
+
+re2c: warning: line 24: trailing context is nondeterministic [-Wnondeterministic-tags]
diff --git a/re2c/test/tags/nondet_cat3.i.re b/re2c/test/tags/nondet_cat3.i.re
new file mode 100644 (file)
index 0000000..784164a
--- /dev/null
@@ -0,0 +1,33 @@
+// The same rules, fixed length trailing context, with different configurations:
+//     1. default input API, no tags: no warning (no variable, static offset)
+//     2. default input API, tags:    no warning (no variable, static offset)
+//     3. generic input API, no tags: warning (need variable: lack API to to make use of fixed length)
+//     4. generic input API, tags:    no warning (no variable, static offset)
+
+/*!re2c
+    re2c:flags:input = default;
+    re2c:flags:tags = 0;
+    "a"+ / "a" {}
+    * {}
+*/
+
+/*!re2c
+    re2c:flags:input = default;
+    re2c:flags:tags = 1;
+    "a"+ / "a" {}
+    * {}
+*/
+
+/*!re2c
+    re2c:flags:input = custom;
+    re2c:flags:tags = 0;
+    "a"+ / "a" {}
+    * {}
+*/
+
+/*!re2c
+    re2c:flags:input = custom;
+    re2c:flags:tags = 1;
+    "a"+ / "a" {}
+    * {}
+*/
diff --git a/re2c/test/tags/nondet_cat4.--tags.c b/re2c/test/tags/nondet_cat4.--tags.c
new file mode 100644 (file)
index 0000000..3da022e
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: line 4: tag 'p' is nondeterministic [-Werror-nondeterministic-tags]
diff --git a/re2c/test/tags/nondet_cat4.--tags.re b/re2c/test/tags/nondet_cat4.--tags.re
new file mode 100644 (file)
index 0000000..a5fe981
--- /dev/null
@@ -0,0 +1,6 @@
+// Tag is nondeterministic: fixed length helps only in top-level
+
+/*!re2c
+    "a"+ @p "a" | "b" { @p }
+    * {}
+*/
diff --git a/re2c/test/tags/nondeterministic1.i--tags.c b/re2c/test/tags/nondeterministic1.i--tags.c
deleted file mode 100644 (file)
index 6647a34..0000000
+++ /dev/null
@@ -1 +0,0 @@
-re2c: error: line 13: tag 'p1' is nondeterministic [-Werror-nondeterministic-tags]
diff --git a/re2c/test/tags/nondeterministic1.i--tags.re b/re2c/test/tags/nondeterministic1.i--tags.re
deleted file mode 100644 (file)
index a88a744..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stddef.h>
-#include <stdio.h>
-
-static void lex(const char *YYCURSOR)
-{
-    const char *YYMARKER;
-    const char *YYCTXMARKER;
-    /*!re2c
-        re2c:define:YYCTYPE = char;
-        re2c:yyfill:enable = 0;
-
-        * { printf("error\n"); return; }
-        "a"+ @p1 "a"+ {
-            printf("'%.*s', '%.*s'\n",
-                @p1 - YYCTXMARKER, YYCTXMARKER,
-                YYCURSOR - @p1, @p1);
-                return;
-        }
-    */
-}
-
-int main(int argc, char **argv)
-{
-    for (int i = 1; i < argc; ++i) {
-        lex(argv[i]);
-    }
-    return 0;
-}
diff --git a/re2c/test/tags/nondeterministic1_trail.i--tags.c b/re2c/test/tags/nondeterministic1_trail.i--tags.c
deleted file mode 100644 (file)
index 4844e83..0000000
+++ /dev/null
@@ -1 +0,0 @@
-re2c: error: line 13: trailing context is nondeterministic [-Werror-nondeterministic-tags]
diff --git a/re2c/test/tags/nondeterministic1_trail.i--tags.re b/re2c/test/tags/nondeterministic1_trail.i--tags.re
deleted file mode 100644 (file)
index 5f1b962..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stddef.h>
-#include <stdio.h>
-
-static void lex(const char *YYCURSOR)
-{
-    const char *YYMARKER;
-    const char *YYCTXMARKER;
-    /*!re2c
-        re2c:define:YYCTYPE = char;
-        re2c:yyfill:enable = 0;
-
-        * { printf("error\n"); return; }
-        "" @p0 "a"+ / "a"+ {
-            printf("'%.*s', '%s'\n",
-                YYCURSOR - @p0, @p0,
-                YYCURSOR);
-                return;
-        }
-    */
-}
-
-int main(int argc, char **argv)
-{
-    for (int i = 1; i < argc; ++i) {
-        lex(argv[i]);
-    }
-    return 0;
-}
diff --git a/re2c/test/tags/nondeterministic1_trail.i.c b/re2c/test/tags/nondeterministic1_trail.i.c
deleted file mode 100644 (file)
index 7dbebbc..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Generated by re2c */
-#include <stddef.h>
-#include <stdio.h>
-
-static void lex(const char *YYCURSOR)
-{
-    const char *YYCTXMARKER;
-    const char *token = YYCURSOR;
-    
-{
-       char yych;
-       yych = *YYCURSOR;
-       switch (yych) {
-       case 'a':       goto yy4;
-       default:        goto yy2;
-       }
-yy2:
-       ++YYCURSOR;
-yy3:
-       { printf("error\n"); return; }
-yy4:
-       yych = *++YYCURSOR;
-       switch (yych) {
-       case 'a':
-               YYCTXMARKER = YYCURSOR;
-               goto yy5;
-       default:        goto yy3;
-       }
-yy5:
-       ++YYCURSOR;
-       yych = *YYCURSOR;
-       switch (yych) {
-       case 'a':
-               YYCTXMARKER = YYCURSOR;
-               goto yy5;
-       default:        goto yy7;
-       }
-yy7:
-       YYCURSOR = YYCTXMARKER;
-       {
-            printf("'%.*s', '%s'\n",
-                YYCURSOR - token, token,
-                YYCURSOR);
-                return;
-        }
-}
-
-}
-
-int main(int argc, char **argv)
-{
-    for (int i = 1; i < argc; ++i) {
-        lex(argv[i]);
-    }
-    return 0;
-}
-re2c: warning: line 13: trailing context is nondeterministic [-Wnondeterministic-tags]
diff --git a/re2c/test/tags/nondeterministic1_trail.i.re b/re2c/test/tags/nondeterministic1_trail.i.re
deleted file mode 100644 (file)
index 32db9cb..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stddef.h>
-#include <stdio.h>
-
-static void lex(const char *YYCURSOR)
-{
-    const char *YYCTXMARKER;
-    const char *token = YYCURSOR;
-    /*!re2c
-        re2c:define:YYCTYPE = char;
-        re2c:yyfill:enable = 0;
-
-        * { printf("error\n"); return; }
-        "a"+ / "a"+ {
-            printf("'%.*s', '%s'\n",
-                YYCURSOR - token, token,
-                YYCURSOR);
-                return;
-        }
-    */
-}
-
-int main(int argc, char **argv)
-{
-    for (int i = 1; i < argc; ++i) {
-        lex(argv[i]);
-    }
-    return 0;
-}