From: Ulya Trofimovich Date: Fri, 24 Jun 2016 21:46:16 +0000 (+0100) Subject: Fixed bug #145 "Values for enum YYCONDTYPE are not generated X-Git-Tag: 1.0~39^2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3f08578ccc517a800c737a881610b145c898f9a;p=re2c Fixed bug #145 "Values for enum YYCONDTYPE are not generated 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. --- diff --git a/re2c/test/bug145.ci.c b/re2c/test/bug145.ci.c new file mode 100644 index 00000000..d4c5fd3b --- /dev/null +++ b/re2c/test/bug145.ci.c @@ -0,0 +1,59 @@ +/* Generated by re2c */ +#include + +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 index 00000000..9cf0793d --- /dev/null +++ b/re2c/test/bug145.ci.re @@ -0,0 +1,32 @@ +#include + +/*!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; } + * { return 0; } + "A" :=> C2 + * { return 0; } + "B" { return 1; } + */ +} + +int main() +{ + printf("%d\n", test("AB")); + return 0; +}