]> granicus.if.org Git - re2c/commitdiff
Fixed bug #145 "Values for enum YYCONDTYPE are not generated
authorUlya Trofimovich <skvadrik@gmail.com>
Fri, 24 Jun 2016 21:46:16 +0000 (22:46 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Sun, 30 Jul 2017 15:00:19 +0000 (16:00 +0100)
when default rules with conditions are used".

Default rule is handled in a special (delayed) way;
re2c uses different code for default rule than for normal rules.
This special code simply forgot to add condition name to the list
of conditions.

Thanks to sirzooro for bug report.

re2c/test/bug145.ci.c [new file with mode: 0644]
re2c/test/bug145.ci.re [new file with mode: 0644]

diff --git a/re2c/test/bug145.ci.c b/re2c/test/bug145.ci.c
new file mode 100644 (file)
index 0000000..d4c5fd3
--- /dev/null
@@ -0,0 +1,59 @@
+/* Generated by re2c */
+#include <stdio.h>
+
+enum YYCONDTYPE {
+       yycinit,
+       yycC2,
+};
+
+
+int test(const char* str)
+{
+    const unsigned char* YYCURSOR = (const unsigned char*)str;
+    const unsigned char* YYMARKER;
+    const unsigned char *YYCTXMARKER;
+    int c = yycinit;
+
+    
+{
+       unsigned char yych;
+       switch (c) {
+       case yycinit: goto yyc_init;
+       case yycC2: goto yyc_C2;
+       }
+/* *********************************** */
+yyc_init:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'A':       goto yy5;
+       default:        goto yy3;
+       }
+yy3:
+       ++YYCURSOR;
+       { return 0; }
+yy5:
+       ++YYCURSOR;
+       c = yycC2;
+       goto yyc_C2;
+/* *********************************** */
+yyc_C2:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'B':       goto yy11;
+       default:        goto yy9;
+       }
+yy9:
+       ++YYCURSOR;
+       { return 0; }
+yy11:
+       ++YYCURSOR;
+       { return 1; }
+}
+
+}
+
+int main()
+{
+    printf("%d\n", test("AB"));
+    return 0;
+}
diff --git a/re2c/test/bug145.ci.re b/re2c/test/bug145.ci.re
new file mode 100644 (file)
index 0000000..9cf0793
--- /dev/null
@@ -0,0 +1,32 @@
+#include <stdio.h>
+
+/*!types:re2c*/
+
+int test(const char* str)
+{
+    const unsigned char* YYCURSOR = (const unsigned char*)str;
+    const unsigned char* YYMARKER;
+    const unsigned char *YYCTXMARKER;
+    int c = yycinit;
+
+    /*!re2c
+        re2c:define:YYCTYPE = "unsigned char";
+        re2c:yyfill:enable = 0;
+        re2c:define:YYGETCONDITION = "c";
+        re2c:define:YYGETCONDITION:naked = 1;
+        re2c:define:YYSETCONDITION = "c = @@;";
+        re2c:define:YYSETCONDITION:naked = 1;
+
+        //<*>* { return 0; }
+        <init>* { return 0; }
+        <init>"A" :=> C2
+        <C2>* { return 0; }
+        <C2>"B" { return 1; }
+    */
+}
+
+int main()
+{
+    printf("%d\n", test("AB"));
+    return 0;
+}