]> granicus.if.org Git - re2c/commitdiff
Respect 're2c:define:YYFILL:naked' and 're2c:yyfill:parameter' configurations with...
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 28 Aug 2019 21:43:03 +0000 (22:43 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 28 Aug 2019 22:10:10 +0000 (23:10 +0100)
Thanks to Nazim Can Bedir for the bug report.

src/codegen/emit_action.cc
test/eof/eof_yyfill_naked_1.i.c [new file with mode: 0644]
test/eof/eof_yyfill_naked_1.i.re [new file with mode: 0644]
test/eof/eof_yyfill_naked_2.if.c [new file with mode: 0644]
test/eof/eof_yyfill_naked_2.if.re [new file with mode: 0644]
test/eof/utf8_any.i.re

index 07bb2fb08bdc9497e847293989d4f17f42dfbaa6..b31b7e67f9036c07526fa528ca268844ed1e6cd3 100644 (file)
@@ -382,7 +382,8 @@ void gen_on_eof(code_lines_t &code, const opt_t *opts, const DFA &dfa
         }
         flushln(code, o);
 
-        o << opts->indString << opts->fill << "();";
+        o << opts->indString << opts->fill
+            << (opts->fill_naked ? "" : opts->fill_arg_use ? "();" : ";");
         flushln(code, o);
 
         o << opts->indString << opts->labelPrefix << "eof" << fillidx << ":;";
@@ -392,8 +393,10 @@ void gen_on_eof(code_lines_t &code, const opt_t *opts, const DFA &dfa
     }
     else {
         if (opts->fill_use) {
-            o << opts->indString << "if (" << opts->fill << " () == 0) "
-                << "goto " << opts->labelPrefix << retry->label << "_;";
+            o << opts->indString << "if (" << opts->fill
+                << (opts->fill_naked ? ""
+                    : opts->fill_arg_use ? " () == 0" : " == 0")
+                << ") goto " << opts->labelPrefix << retry->label << "_;";
             flushln(code, o);
         }
         gen_on_eof_fail(code, opts, dfa, from, to, o);
diff --git a/test/eof/eof_yyfill_naked_1.i.c b/test/eof/eof_yyfill_naked_1.i.c
new file mode 100644 (file)
index 0000000..7f3a91c
--- /dev/null
@@ -0,0 +1,106 @@
+/* Generated by re2c */
+
+
+
+{
+       YYCTYPE yych;
+yy1_:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy4;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       if (fill() == 0) goto yy1_;
+                       goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+yy3:
+       { return FAIL; }
+yy4:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+}
+
+
+
+{
+       YYCTYPE yych;
+yy7_:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy10;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       if (fill() == 0) goto yy7_;
+                       goto yyeof;
+               }
+               goto yy8;
+       }
+yy8:
+       ++YYCURSOR;
+yy9:
+       { return FAIL; }
+yy10:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+}
+
+
+
+{
+       YYCTYPE yych;
+yy13_:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy16;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       if (fill () == 0) goto yy13_;
+                       goto yyeof;
+               }
+               goto yy14;
+       }
+yy14:
+       ++YYCURSOR;
+yy15:
+       { return FAIL; }
+yy16:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+}
+
+
+
+{
+       YYCTYPE yych;
+yy19_:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy22;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       if (fill() == 0) goto yy19_;
+                       goto yyeof;
+               }
+               goto yy20;
+       }
+yy20:
+       ++YYCURSOR;
+yy21:
+       { return FAIL; }
+yy22:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+}
+
diff --git a/test/eof/eof_yyfill_naked_1.i.re b/test/eof/eof_yyfill_naked_1.i.re
new file mode 100644 (file)
index 0000000..eaf9cde
--- /dev/null
@@ -0,0 +1,39 @@
+/*!re2c
+    re2c:eof = 0;
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill() == 0";
+    re2c:define:YYFILL:naked = 1;
+    re2c:yyfill:parameter = 1;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill() == 0";
+    re2c:define:YYFILL:naked = 1;
+    re2c:yyfill:parameter = 0;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill";
+    re2c:define:YYFILL:naked = 0;
+    re2c:yyfill:parameter = 1;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill()";
+    re2c:define:YYFILL:naked = 0;
+    re2c:yyfill:parameter = 0;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
diff --git a/test/eof/eof_yyfill_naked_2.if.c b/test/eof/eof_yyfill_naked_2.if.c
new file mode 100644 (file)
index 0000000..5f4bef7
--- /dev/null
@@ -0,0 +1,114 @@
+/* Generated by re2c */
+
+
+
+
+       switch (YYGETSTATE()) {
+       default: goto yy0;
+       case 0: if (YYLIMIT <= YYCURSOR) goto yyeof0; goto yyFillLabel0;
+       case 1: if (YYLIMIT <= YYCURSOR) goto yyeof1; goto yyFillLabel1;
+       case 2: if (YYLIMIT <= YYCURSOR) goto yyeof2; goto yyFillLabel2;
+       case 3: if (YYLIMIT <= YYCURSOR) goto yyeof3; goto yyFillLabel3;
+       }
+yy0:
+yyFillLabel0:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy4;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       YYSETSTATE(0);
+                       fill();
+                       yyeof0:;
+                       goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+       ++YYCURSOR;
+yy3:
+       { return FAIL; }
+yy4:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+
+
+
+
+yyFillLabel1:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy10;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       YYSETSTATE(1);
+                       fill();
+                       yyeof1:;
+                       goto yyeof;
+               }
+               goto yy8;
+       }
+yy8:
+       ++YYCURSOR;
+yy9:
+       { return FAIL; }
+yy10:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+
+
+
+
+yyFillLabel2:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy16;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       YYSETSTATE(2);
+                       fill();
+                       yyeof2:;
+                       goto yyeof;
+               }
+               goto yy14;
+       }
+yy14:
+       ++YYCURSOR;
+yy15:
+       { return FAIL; }
+yy16:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+
+
+
+
+yyFillLabel3:
+       yych = *YYCURSOR;
+       switch (yych) {
+       case 'a':       goto yy22;
+       default:
+               if (YYLIMIT <= YYCURSOR) {
+                       YYSETSTATE(3);
+                       fill();
+                       yyeof3:;
+                       goto yyeof;
+               }
+               goto yy20;
+       }
+yy20:
+       ++YYCURSOR;
+yy21:
+       { return FAIL; }
+yy22:
+       ++YYCURSOR;
+       { return OK; }
+yyeof:
+       { return EOF; }
+
diff --git a/test/eof/eof_yyfill_naked_2.if.re b/test/eof/eof_yyfill_naked_2.if.re
new file mode 100644 (file)
index 0000000..7e2a59d
--- /dev/null
@@ -0,0 +1,39 @@
+/*!re2c
+    re2c:eof = 0;
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill();";
+    re2c:define:YYFILL:naked = 1;
+    re2c:yyfill:parameter = 1;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill();";
+    re2c:define:YYFILL:naked = 1;
+    re2c:yyfill:parameter = 0;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill";
+    re2c:define:YYFILL:naked = 0;
+    re2c:yyfill:parameter = 1;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
+
+/*!re2c
+    re2c:define:YYFILL = "fill()";
+    re2c:define:YYFILL:naked = 0;
+    re2c:yyfill:parameter = 0;
+    *   { return FAIL; }
+    $   { return EOF; }
+    [a] { return OK; }
+*/
index 30c45fb76449c2cc1cf8ad76748f9d56a22016ee..192587e14a2d266b9659a13dfec9ff9f28f0b184 100644 (file)
@@ -104,6 +104,7 @@ static Result lex1_simple(uint8_t *cur, uint8_t* end, uint8_t* /* unused */)
     uint8_t *YYMARKER, *tok = cur;
     /*!re2c
         re2c:yyfill:enable = 1;
+        re2c:define:YYFILL:naked = 0;
         re2c:define:YYFILL = fill;
         re2c:eof = 0;