]> granicus.if.org Git - re2c/commitdiff
Tags that occur earlier in regular expression must have greater priority.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 13 Feb 2017 12:52:32 +0000 (12:52 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 13 Feb 2017 12:52:32 +0000 (12:52 +0000)
re2c/src/ir/dfa/closure.cc
re2c/test/tags/ambiguity/alt0.i--tags.c [new file with mode: 0644]
re2c/test/tags/ambiguity/alt0.i--tags.re [new file with mode: 0644]
re2c/test/tags/topsort2.i--tags.c

index f14864f493045f42f8592dbe73500fd630fdca78..f0b9fd0aeecc3e7466b20e17dd7509f5abc1a6c6 100644 (file)
@@ -127,7 +127,7 @@ int compare(const clos_t &c1, const clos_t &c2, Tagpool &tagpool)
 
        // compare configurations tag by tag
        // (tags with greater numbers have lower priority)
-       for (size_t t = tagpool.ntags; t --> 0;) {
+       for (size_t t = 0; t < tagpool.ntags; ++t) {
 
                // lookahead tags gathered by epsilon-closure
                x = t1[t]; y = t2[t];
diff --git a/re2c/test/tags/ambiguity/alt0.i--tags.c b/re2c/test/tags/ambiguity/alt0.i--tags.c
new file mode 100644 (file)
index 0000000..63907cd
--- /dev/null
@@ -0,0 +1,13 @@
+/* Generated by re2c */
+// 'x' dominates 'y'
+
+{
+       YYCTYPE yych;
+       yyt2 = NULL;
+       yyt1 = YYCURSOR;
+       x = yyt1;
+       y = yyt2;
+       {}
+}
+
+re2c: warning: line 4: rule matches empty string [-Wmatch-empty-string]
diff --git a/re2c/test/tags/ambiguity/alt0.i--tags.re b/re2c/test/tags/ambiguity/alt0.i--tags.re
new file mode 100644 (file)
index 0000000..215e04c
--- /dev/null
@@ -0,0 +1,6 @@
+// 'x' dominates 'y'
+/*!re2c
+
+@x | @y {}
+
+*/
index 015e8d42276fa961831b1d8c12a867012fa08f61..817f7c1cb2a249b1c6ed7d16024477875579dcbb 100644 (file)
@@ -4,63 +4,51 @@
        YYCTYPE yych;
        if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
        yych = *YYCURSOR;
-       yyt1 = NULL;
-       yyt2 = YYCURSOR;
        switch (yych) {
-       case 'a':       goto yy3;
-       case 'b':       goto yy5;
-       default:        goto yy2;
+       case 'a':
+               yyt2 = NULL;
+               yyt1 = YYCURSOR;
+               goto yy3;
+       case 'b':
+               yyt2 = YYCURSOR;
+               goto yy5;
+       default:
+               yyt2 = NULL;
+               yyt1 = YYCURSOR;
+               goto yy2;
        }
 yy2:
-       p = yyt1;
-       q = yyt2;
+       p = yyt2;
+       q = yyt1;
        {}
 yy3:
        ++YYCURSOR;
        if (YYLIMIT <= YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
+yy4:
        switch (yych) {
        case 'a':       goto yy3;
        default:        goto yy2;
        }
 yy5:
        yych = *(YYMARKER = ++YYCURSOR);
+       yyt1 = NULL;
        switch (yych) {
-       case 'a':
-               yyt3 = NULL;
-               goto yy6;
-       case 'b':
-               yyt3 = NULL;
-               goto yy7;
-       default:
-               yyt1 = yyt2;
-               yyt2 = NULL;
-               goto yy2;
+       case 'b':       goto yy6;
+       default:        goto yy4;
        }
 yy6:
        yych = *++YYCURSOR;
        switch (yych) {
-       case 'a':
-               yyt1 = yyt2;
-               yyt2 = yyt3;
-               goto yy3;
-       default:        goto yy2;
+       case 'a':       goto yy8;
+       default:        goto yy7;
        }
 yy7:
-       yych = *++YYCURSOR;
-       switch (yych) {
-       case 'a':       goto yy9;
-       default:        goto yy8;
-       }
-yy8:
        YYCURSOR = YYMARKER;
-       yyt1 = yyt2;
-       yyt2 = NULL;
+       yyt1 = NULL;
        goto yy2;
-yy9:
+yy8:
        ++YYCURSOR;
-       yyt1 = yyt2;
-       yyt2 = yyt3;
        goto yy2;
 }