]> granicus.if.org Git - re2c/commitdiff
Now checking for tag priority violation respects injective mappings.
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 8 Dec 2016 17:34:12 +0000 (17:34 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 8 Dec 2016 17:34:12 +0000 (17:34 +0000)
re2c/src/ir/dfa/find_state.cc
re2c/test/tags/mapping1.i--tags--dfa-mapping(injective).c [new file with mode: 0644]
re2c/test/tags/mapping1.i--tags--dfa-mapping(injective).re [new file with mode: 0644]
re2c/test/tags/mapping1.i--tags.c [new file with mode: 0644]
re2c/test/tags/mapping1.i--tags.re [new file with mode: 0644]
re2c/test/tags/mapping2.i--tags--dfa-mapping(injective).c [new file with mode: 0644]
re2c/test/tags/mapping2.i--tags--dfa-mapping(injective).re [new file with mode: 0644]
re2c/test/tags/mapping2.i--tags.c [new file with mode: 0644]
re2c/test/tags/mapping2.i--tags.re [new file with mode: 0644]

index 466790de0660e2f28a5e7c6c293d81f0b66b2d0e..9de2f6b3b5fa8a57ed8dac3008732a62da0e476a 100644 (file)
@@ -112,7 +112,7 @@ void mapping_t::init(tagver_t v)
  * X-component; all tags are merged together. However, priorities
  * should be checked individually for each tag. Since mapping is
  * automatically sorted by X, it suffices to ensure that Y
- * subsequence for the given tag is monotonically increasing.
+ * subsequence for the given tag is monotonically non-decreasing.
  */
 
 static bool compatible_kernels(const kernel_t *x, const kernel_t *y)
@@ -163,7 +163,7 @@ bool mapping_t::operator()(const kernel_t *k1, const kernel_t *k2)
                const size_t t = x2t[x];
 
                if (y == TAGVER_ZERO) continue;
-               if (y <= pred[t]) return false;
+               if (y < pred[t]) return false;
                pred[t] = y;
        }
        return true;
diff --git a/re2c/test/tags/mapping1.i--tags--dfa-mapping(injective).c b/re2c/test/tags/mapping1.i--tags--dfa-mapping(injective).c
new file mode 100644 (file)
index 0000000..0f25610
--- /dev/null
@@ -0,0 +1,62 @@
+/* Generated by re2c */
+
+{
+       YYCTYPE yych;
+       if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+       yych = *(YYMARKER = YYCURSOR);
+       switch (yych) {
+       case 'a':
+               yyt2 = YYCURSOR;
+               goto yy5;
+       case 'b':       goto yy3;
+       default:
+               yyt1 = YYCURSOR;
+               goto yy3;
+       }
+yy2:
+       {}
+yy3:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':
+               yyt2 = NULL;
+               goto yy8;
+       case 'b':       goto yy4;
+       default:
+               yyt2 = NULL;
+               goto yy7;
+       }
+yy4:
+       YYCURSOR = YYMARKER;
+       goto yy2;
+yy5:
+       ++YYCURSOR;
+       switch ((yych = *YYCURSOR)) {
+       case 'a':       goto yy9;
+       default:        goto yy6;
+       }
+yy6:
+       p = yyt2;
+       {}
+yy7:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy9;
+       default:        goto yy4;
+       }
+yy8:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy9;
+       default:
+               yyt2 = yyt1;
+               goto yy6;
+       }
+yy9:
+       ++YYCURSOR;
+       yych = *YYCURSOR;
+       goto yy6;
+}
+
+re2c: warning: line 4: rule matches empty string [-Wmatch-empty-string]
+re2c: warning: line 3: tag 'p' is non-deterministic and induces 2 parallel instances [-Wnondeterministic-tags]
diff --git a/re2c/test/tags/mapping1.i--tags--dfa-mapping(injective).re b/re2c/test/tags/mapping1.i--tags--dfa-mapping(injective).re
new file mode 100644 (file)
index 0000000..d7934be
--- /dev/null
@@ -0,0 +1,6 @@
+/*!re2c
+
+([^a] | @p) [^b]? "a" {}
+"" {}
+
+*/
diff --git a/re2c/test/tags/mapping1.i--tags.c b/re2c/test/tags/mapping1.i--tags.c
new file mode 100644 (file)
index 0000000..d11efaf
--- /dev/null
@@ -0,0 +1,73 @@
+/* Generated by re2c */
+
+{
+       YYCTYPE yych;
+       if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
+       yych = *(YYMARKER = YYCURSOR);
+       switch (yych) {
+       case 'a':
+               yyt2 = YYCURSOR;
+               goto yy5;
+       case 'b':       goto yy7;
+       default:
+               yyt1 = YYCURSOR;
+               goto yy3;
+       }
+yy2:
+       {}
+yy3:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':
+               yyt2 = NULL;
+               goto yy9;
+       case 'b':       goto yy4;
+       default:
+               yyt2 = NULL;
+               goto yy8;
+       }
+yy4:
+       YYCURSOR = YYMARKER;
+       goto yy2;
+yy5:
+       ++YYCURSOR;
+       switch ((yych = *YYCURSOR)) {
+       case 'a':       goto yy10;
+       default:        goto yy6;
+       }
+yy6:
+       p = yyt2;
+       {}
+yy7:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':
+               yyt2 = NULL;
+               goto yy5;
+       case 'b':       goto yy4;
+       default:
+               yyt2 = NULL;
+               goto yy8;
+       }
+yy8:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy10;
+       default:        goto yy4;
+       }
+yy9:
+       yych = *++YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy10;
+       default:
+               yyt2 = yyt1;
+               goto yy6;
+       }
+yy10:
+       ++YYCURSOR;
+       yych = *YYCURSOR;
+       goto yy6;
+}
+
+re2c: warning: line 4: rule matches empty string [-Wmatch-empty-string]
+re2c: warning: line 3: tag 'p' is non-deterministic and induces 2 parallel instances [-Wnondeterministic-tags]
diff --git a/re2c/test/tags/mapping1.i--tags.re b/re2c/test/tags/mapping1.i--tags.re
new file mode 100644 (file)
index 0000000..d7934be
--- /dev/null
@@ -0,0 +1,6 @@
+/*!re2c
+
+([^a] | @p) [^b]? "a" {}
+"" {}
+
+*/
diff --git a/re2c/test/tags/mapping2.i--tags--dfa-mapping(injective).c b/re2c/test/tags/mapping2.i--tags--dfa-mapping(injective).c
new file mode 100644 (file)
index 0000000..6d8f777
--- /dev/null
@@ -0,0 +1,38 @@
+/* Generated by re2c */
+
+{
+       YYCTYPE yych;
+       if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'b':       goto yy5;
+       default:
+               yyt1 = YYCURSOR;
+               goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'b':       goto yy4;
+       default:        goto yy2;
+       }
+yy4:
+       p = yyt1;
+       {}
+yy5:
+       ++YYCURSOR;
+       switch ((yych = *YYCURSOR)) {
+       case 'a':       goto yy2;
+       case 'b':
+               yyt1 = NULL;
+               goto yy4;
+       default:
+               yyt1 = NULL;
+               goto yy2;
+       }
+}
+
+re2c: warning: line 3: rule matches empty string [-Wmatch-empty-string]
+re2c: warning: line 3: tag 'p' is non-deterministic and induces 2 parallel instances [-Wnondeterministic-tags]
diff --git a/re2c/test/tags/mapping2.i--tags--dfa-mapping(injective).re b/re2c/test/tags/mapping2.i--tags--dfa-mapping(injective).re
new file mode 100644 (file)
index 0000000..56625e4
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+
+(@p | [^a]) [a]* [^b]* {}
+
+*/
diff --git a/re2c/test/tags/mapping2.i--tags.c b/re2c/test/tags/mapping2.i--tags.c
new file mode 100644 (file)
index 0000000..a898ee4
--- /dev/null
@@ -0,0 +1,33 @@
+/* Generated by re2c */
+
+{
+       YYCTYPE yych;
+       if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'b':       goto yy5;
+       default:
+               yyt1 = YYCURSOR;
+               goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+       if (YYLIMIT <= YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+yy3:
+       switch (yych) {
+       case 'b':       goto yy4;
+       default:        goto yy2;
+       }
+yy4:
+       p = yyt1;
+       {}
+yy5:
+       ++YYCURSOR;
+       yyt1 = NULL;
+       yych = *YYCURSOR;
+       goto yy3;
+}
+
+re2c: warning: line 3: rule matches empty string [-Wmatch-empty-string]
+re2c: warning: line 3: tag 'p' is non-deterministic and induces 2 parallel instances [-Wnondeterministic-tags]
diff --git a/re2c/test/tags/mapping2.i--tags.re b/re2c/test/tags/mapping2.i--tags.re
new file mode 100644 (file)
index 0000000..56625e4
--- /dev/null
@@ -0,0 +1,5 @@
+/*!re2c
+
+(@p | [^a]) [a]* [^b]* {}
+
+*/