]> granicus.if.org Git - re2c/commitdiff
Don't generate 'YYFILL' calls when EOF rule is used with 're2c:yyfill:enable = 0...
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 18 Jul 2019 16:26:27 +0000 (17:26 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 18 Jul 2019 16:26:27 +0000 (17:26 +0100)
Note: in the non-EOF-rule case 're2c:yyfill:enable = 0;' results in suppression
of the whole 'YYLIMIT' check together with 'YYFILL' call. In case of EOF rule,
however, we are not bound by backward compatibility and can do a more logical
thing.

src/codegen/emit_action.cc

index 1c20d24f73002e963998c49b368bce5dc46e2286..0201946af9ebd75ecece6398efb02da874c08383 100644 (file)
@@ -243,7 +243,7 @@ void need(Output &o, uint32_t ind, size_t some)
 void gen_rescan_label(Output &o, const State *s)
 {
     const opt_t *opts = o.block().opts;
-    if (opts->eof == NOEOF || endstate(s)) {
+    if (opts->eof == NOEOF || !opts->fill_use || endstate(s)) {
         // no rescan label
     }
     else if (opts->fFlag) {
@@ -364,9 +364,11 @@ void gen_on_eof(code_lines_t &code, const opt_t *opts, const DFA &dfa
         flushln(code, o);
     }
     else {
-        o << opts->indString << "if (" << opts->fill << " () == 0) "
-            << "goto " << opts->labelPrefix << retry->label << "_;";
-        flushln(code, o);
+        if (opts->fill_use) {
+            o << opts->indString << "if (" << opts->fill << " () == 0) "
+                << "goto " << opts->labelPrefix << retry->label << "_;";
+            flushln(code, o);
+        }
 
         if (from->action.type == Action::INITIAL) {
             o << opts->indString << "goto " << opts->labelPrefix << "eof;";