]> granicus.if.org Git - re2c/commitdiff
Added test for EOF rule.
authorUlya Trofimovich <skvadrik@gmail.com>
Thu, 27 Dec 2018 22:10:49 +0000 (22:10 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Thu, 27 Dec 2018 22:10:49 +0000 (22:10 +0000)
re2c/test/eof/eof_00.i.c [new file with mode: 0644]
re2c/test/eof/eof_00.i.re [new file with mode: 0644]
re2c/test/eof/eof_01.i--eager-skip.c [new file with mode: 0644]
re2c/test/eof/eof_01.i--eager-skip.re [new file with mode: 0644]
re2c/test/eof/eof_01.i.c [new file with mode: 0644]
re2c/test/eof/eof_01.i.re [new file with mode: 0644]

diff --git a/re2c/test/eof/eof_00.i.c b/re2c/test/eof/eof_00.i.c
new file mode 100644 (file)
index 0000000..01f5a39
--- /dev/null
@@ -0,0 +1,630 @@
+/* Generated by re2c */
+#include <stdio.h>
+#include <string.h>
+
+#define YYMAXFILL 10
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    char buf[SIZE + YYMAXFILL];
+    char *lim;
+    char *cur;
+    char *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , tok(lim)
+        , eof(false)
+    {}
+    bool fill(size_t need)
+    {
+        if (eof) {
+            return false;
+        }
+        const size_t free = tok - buf;
+        if (free < need) {
+            return false;
+        }
+        memmove(buf, tok, lim - tok);
+        lim -= free;
+        cur -= free;
+        tok -= free;
+        lim += fread(lim, 1, free, stdin);
+        if (lim < buf + SIZE) {
+            eof = true;
+            memset(lim, 0, YYMAXFILL);
+            lim += YYMAXFILL;
+        }
+        return true;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        
+{
+       char yych;
+       if ((in.lim - in.cur) < 10) if (!in.fill(10)) return false;
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:      goto yy2;
+       case '\n':      goto yy6;
+       case '"':       goto yy9;
+       case '\'':      goto yy11;
+       case '+':
+       case '-':       goto yy13;
+       case '0':       goto yy14;
+       case '1':       goto yy16;
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy18;
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'U':
+       case 'V':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 'u':
+       case 'v':
+       case 'x':
+       case 'y':
+       case 'z':       goto yy20;
+       case 'F':
+       case 'f':       goto yy23;
+       case 'M':
+       case 'm':       goto yy24;
+       case 'S':
+       case 's':       goto yy25;
+       case 'T':
+       case 't':       goto yy26;
+       case 'W':
+       case 'w':       goto yy27;
+       default:        goto yy4;
+       }
+yy2:
+       ++in.cur;
+       { return YYMAXFILL == in.lim - in.tok; }
+yy4:
+       ++in.cur;
+yy5:
+       { return false; }
+yy6:
+       ++in.cur;
+       if (in.lim <= in.cur) if (!in.fill(1)) return false;
+       yych = *in.cur;
+       switch (yych) {
+       case '\n':      goto yy6;
+       default:        goto yy8;
+       }
+yy8:
+       { continue; }
+yy9:
+       ++in.cur;
+       if (in.lim <= in.cur) if (!in.fill(1)) return false;
+       yych = *in.cur;
+       switch (yych) {
+       case '"':       goto yy28;
+       case '\\':      goto yy30;
+       default:        goto yy9;
+       }
+yy11:
+       ++in.cur;
+       if (in.lim <= in.cur) if (!in.fill(1)) return false;
+       yych = *in.cur;
+       switch (yych) {
+       case '\'':      goto yy31;
+       case '\\':      goto yy33;
+       default:        goto yy11;
+       }
+yy13:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':       goto yy14;
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy18;
+       default:        goto yy5;
+       }
+yy14:
+       ++in.cur;
+yy15:
+       { ++count; continue; }
+yy16:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy18;
+       case '2':       goto yy34;
+       default:        goto yy17;
+       }
+yy17:
+       { ++count; continue; }
+yy18:
+       ++in.cur;
+       if (in.lim <= in.cur) if (!in.fill(1)) return false;
+       yych = *in.cur;
+yy19:
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy18;
+       default:        goto yy15;
+       }
+yy20:
+       ++in.cur;
+       if (in.lim <= in.cur) if (!in.fill(1)) return false;
+       yych = *in.cur;
+yy21:
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'F':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'M':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'S':
+       case 'T':
+       case 'U':
+       case 'V':
+       case 'W':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'f':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'm':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 's':
+       case 't':
+       case 'u':
+       case 'v':
+       case 'w':
+       case 'x':
+       case 'y':
+       case 'z':       goto yy20;
+       default:        goto yy22;
+       }
+yy22:
+       { ++count; continue; }
+yy23:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'R':
+       case 'r':       goto yy35;
+       default:        goto yy21;
+       }
+yy24:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'O':
+       case 'o':       goto yy36;
+       default:        goto yy21;
+       }
+yy25:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'A':
+       case 'a':       goto yy37;
+       case 'U':
+       case 'u':       goto yy36;
+       default:        goto yy21;
+       }
+yy26:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'H':
+       case 'h':       goto yy38;
+       case 'U':
+       case 'u':       goto yy39;
+       default:        goto yy21;
+       }
+yy27:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'E':
+       case 'e':       goto yy40;
+       default:        goto yy21;
+       }
+yy28:
+       ++in.cur;
+       { ++count; continue; }
+yy30:
+       ++in.cur;
+       if (in.lim <= in.cur) if (!in.fill(1)) return false;
+       yych = *in.cur;
+       goto yy9;
+yy31:
+       ++in.cur;
+       { ++count; continue; }
+yy33:
+       ++in.cur;
+       if (in.lim <= in.cur) if (!in.fill(1)) return false;
+       yych = *in.cur;
+       goto yy11;
+yy34:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy18;
+       case '3':       goto yy41;
+       default:        goto yy17;
+       }
+yy35:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'I':
+       case 'i':       goto yy42;
+       default:        goto yy21;
+       }
+yy36:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'N':
+       case 'n':       goto yy42;
+       default:        goto yy21;
+       }
+yy37:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'T':
+       case 't':       goto yy43;
+       default:        goto yy21;
+       }
+yy38:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'U':
+       case 'u':       goto yy44;
+       default:        goto yy21;
+       }
+yy39:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'E':
+       case 'e':       goto yy45;
+       default:        goto yy21;
+       }
+yy40:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'D':
+       case 'd':       goto yy46;
+       default:        goto yy21;
+       }
+yy41:
+       yych = *++in.cur;
+       switch (yych) {
+       case '4':       goto yy47;
+       default:        goto yy19;
+       }
+yy42:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'D':
+       case 'd':       goto yy48;
+       default:        goto yy21;
+       }
+yy43:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'U':
+       case 'u':       goto yy49;
+       default:        goto yy21;
+       }
+yy44:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'R':
+       case 'r':       goto yy45;
+       default:        goto yy21;
+       }
+yy45:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'S':
+       case 's':       goto yy42;
+       default:        goto yy21;
+       }
+yy46:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'N':
+       case 'n':       goto yy39;
+       default:        goto yy21;
+       }
+yy47:
+       yych = *++in.cur;
+       switch (yych) {
+       case '5':       goto yy50;
+       default:        goto yy19;
+       }
+yy48:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'A':
+       case 'a':       goto yy51;
+       default:        goto yy21;
+       }
+yy49:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'R':
+       case 'r':       goto yy42;
+       default:        goto yy21;
+       }
+yy50:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '7':
+       case '8':
+       case '9':       goto yy18;
+       case '6':       goto yy52;
+       default:        goto yy17;
+       }
+yy51:
+       yych = *++in.cur;
+       switch (yych) {
+       case 'Y':
+       case 'y':       goto yy53;
+       default:        goto yy21;
+       }
+yy52:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '8':
+       case '9':       goto yy18;
+       case '7':       goto yy55;
+       default:        goto yy17;
+       }
+yy53:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'F':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'M':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'S':
+       case 'T':
+       case 'U':
+       case 'V':
+       case 'W':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'f':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'm':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 's':
+       case 't':
+       case 'u':
+       case 'v':
+       case 'w':
+       case 'x':
+       case 'y':
+       case 'z':       goto yy20;
+       default:        goto yy54;
+       }
+yy54:
+       { ++count; continue; }
+yy55:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '9':       goto yy18;
+       case '8':       goto yy56;
+       default:        goto yy17;
+       }
+yy56:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':       goto yy18;
+       case '9':       goto yy57;
+       default:        goto yy17;
+       }
+yy57:
+       yych = *++in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy18;
+       default:        goto yy17;
+       }
+}
+
+    }
+}
+
+int main()
+{
+    input_t in;
+    unsigned int count;
+    if (lex(in, count)) {
+        printf("glorious %u numbers!\n", count);
+    } else {
+        printf("error\n");
+    }
+
+    return 0;
+}
diff --git a/re2c/test/eof/eof_00.i.re b/re2c/test/eof/eof_00.i.re
new file mode 100644 (file)
index 0000000..3751352
--- /dev/null
@@ -0,0 +1,88 @@
+#include <stdio.h>
+#include <string.h>
+
+/*!max:re2c*/
+static const size_t SIZE = 4096;
+
+struct input_t {
+    char buf[SIZE + YYMAXFILL];
+    char *lim;
+    char *cur;
+    char *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , tok(lim)
+        , eof(false)
+    {}
+    bool fill(size_t need)
+    {
+        if (eof) {
+            return false;
+        }
+        const size_t free = tok - buf;
+        if (free < need) {
+            return false;
+        }
+        memmove(buf, tok, lim - tok);
+        lim -= free;
+        cur -= free;
+        tok -= free;
+        lim += fread(lim, 1, free, stdin);
+        if (lim < buf + SIZE) {
+            eof = true;
+            memset(lim, 0, YYMAXFILL);
+            lim += YYMAXFILL;
+        }
+        return true;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        /*!re2c
+            re2c:define:YYCTYPE = char;
+            re2c:define:YYCURSOR = in.cur;
+            re2c:define:YYLIMIT = in.lim;
+            re2c:define:YYFILL = "if (!in.fill(@@)) return false;";
+            re2c:define:YYFILL:naked = 1;
+
+            end = "\x00";
+            wsp = [\n]+;
+            sstr = ["] ([^"\\] | "\\" [^])* ["];
+            dstr = ['] ([^'\\] | "\\" [^])* ['];
+            num = [+-]? ("0" | [1-9][0-9]*);
+            num1 = "1" | "12" | "12345" | "123456" | "1234567" | "12345678" | "123456789";
+            word = [_a-zA-Z][_a-zA-Z0-9]*;
+            day = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
+
+            *   { return false; }
+            end { return YYMAXFILL == in.lim - in.tok; }
+            wsp { continue; }
+            sstr { ++count; continue; }
+            dstr { ++count; continue; }
+            num1 { ++count; continue; }
+            num  { ++count; continue; }
+            day  { ++count; continue; }
+            word { ++count; continue; }
+        */
+    }
+}
+
+int main()
+{
+    input_t in;
+    unsigned int count;
+    if (lex(in, count)) {
+        printf("glorious %u numbers!\n", count);
+    } else {
+        printf("error\n");
+    }
+
+    return 0;
+}
diff --git a/re2c/test/eof/eof_01.i--eager-skip.c b/re2c/test/eof/eof_01.i--eager-skip.c
new file mode 100644 (file)
index 0000000..1857cd2
--- /dev/null
@@ -0,0 +1,918 @@
+/* Generated by re2c */
+#include <stdio.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    char buf[SIZE + 1];
+    char *lim;
+    char *cur;
+    char *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , tok(lim)
+        , eof(false)
+    {
+        fill();
+    }
+    int fill()
+    {
+        if (eof) {
+            return 1;
+        }
+        const size_t free = tok - buf;
+        if (free < 1) {
+            return 2;
+        }
+        memmove(buf, tok, lim - tok);
+        lim -= free;
+        cur -= free;
+        tok -= free;
+        lim += fread(lim, 1, free, stdin);
+        lim[0] = 0;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        
+{
+       char yych;
+yy1:
+yy1_:
+       yych = *in.cur++;
+       switch (yych) {
+       case '\n':      goto yy4;
+       case '"':       goto yy7;
+       case '\'':      goto yy9;
+       case '+':
+       case '-':       goto yy11;
+       case '0':       goto yy12;
+       case '1':       goto yy14;
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'U':
+       case 'V':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 'u':
+       case 'v':
+       case 'x':
+       case 'y':
+       case 'z':       goto yy18;
+       case 'F':
+       case 'f':       goto yy21;
+       case 'M':
+       case 'm':       goto yy22;
+       case 'S':
+       case 's':       goto yy23;
+       case 'T':
+       case 't':       goto yy24;
+       case 'W':
+       case 'w':       goto yy25;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy1_;
+                       else goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+yy3:
+       { return false; }
+yy4:
+yy4_:
+       yych = *in.cur;
+yy5:
+       switch (yych) {
+       case '\n':
+               ++in.cur;
+               goto yy4;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy4_;
+               }
+               goto yy6;
+       }
+yy6:
+       { continue; }
+yy7:
+yy7_:
+       yych = *in.cur;
+yy8:
+       ++in.cur;
+       switch (yych) {
+       case '"':       goto yy26;
+       case '\\':      goto yy28;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy7_;
+                       else goto yy3;
+               }
+               goto yy7;
+       }
+yy9:
+yy9_:
+       yych = *in.cur;
+yy10:
+       ++in.cur;
+       switch (yych) {
+       case '\'':      goto yy29;
+       case '\\':      goto yy31;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy9_;
+                       else goto yy3;
+               }
+               goto yy9;
+       }
+yy11:
+yy11_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+               ++in.cur;
+               goto yy12;
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy11_;
+               }
+               goto yy3;
+       }
+yy12:
+yy13:
+       { ++count; continue; }
+yy14:
+yy14_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       case '2':
+               ++in.cur;
+               goto yy32;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy14_;
+               }
+               goto yy15;
+       }
+yy15:
+       { ++count; continue; }
+yy16:
+yy16_:
+       yych = *in.cur;
+yy17:
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy16_;
+               }
+               goto yy13;
+       }
+yy18:
+yy18_:
+       yych = *in.cur;
+yy19:
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'F':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'M':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'S':
+       case 'T':
+       case 'U':
+       case 'V':
+       case 'W':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'f':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'm':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 's':
+       case 't':
+       case 'u':
+       case 'v':
+       case 'w':
+       case 'x':
+       case 'y':
+       case 'z':
+               ++in.cur;
+               goto yy18;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy18_;
+               }
+               goto yy20;
+       }
+yy20:
+       { ++count; continue; }
+yy21:
+yy21_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy21_;
+               }
+               goto yy20;
+       case 'R':
+       case 'r':
+               ++in.cur;
+               goto yy33;
+       default:        goto yy19;
+       }
+yy22:
+yy22_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy22_;
+               }
+               goto yy20;
+       case 'O':
+       case 'o':
+               ++in.cur;
+               goto yy34;
+       default:        goto yy19;
+       }
+yy23:
+yy23_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy23_;
+               }
+               goto yy20;
+       case 'A':
+       case 'a':
+               ++in.cur;
+               goto yy35;
+       case 'U':
+       case 'u':
+               ++in.cur;
+               goto yy34;
+       default:        goto yy19;
+       }
+yy24:
+yy24_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy24_;
+               }
+               goto yy20;
+       case 'H':
+       case 'h':
+               ++in.cur;
+               goto yy36;
+       case 'U':
+       case 'u':
+               ++in.cur;
+               goto yy37;
+       default:        goto yy19;
+       }
+yy25:
+yy25_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy25_;
+               }
+               goto yy20;
+       case 'E':
+       case 'e':
+               ++in.cur;
+               goto yy38;
+       default:        goto yy19;
+       }
+yy26:
+       { ++count; continue; }
+yy28:
+yy28_:
+       yych = *in.cur++;
+       if (yych <= 0x00) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy28_;
+                       else goto yy3;
+               }
+               goto yy7;
+       }
+       goto yy7;
+yy29:
+       { ++count; continue; }
+yy31:
+yy31_:
+       yych = *in.cur++;
+       if (yych <= 0x00) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy31_;
+                       else goto yy3;
+               }
+               goto yy9;
+       }
+       goto yy9;
+yy32:
+yy32_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       case '3':
+               ++in.cur;
+               goto yy39;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy32_;
+               }
+               goto yy15;
+       }
+yy33:
+yy33_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy33_;
+               }
+               goto yy20;
+       case 'I':
+       case 'i':
+               ++in.cur;
+               goto yy40;
+       default:        goto yy19;
+       }
+yy34:
+yy34_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy34_;
+               }
+               goto yy20;
+       case 'N':
+       case 'n':
+               ++in.cur;
+               goto yy40;
+       default:        goto yy19;
+       }
+yy35:
+yy35_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy35_;
+               }
+               goto yy20;
+       case 'T':
+       case 't':
+               ++in.cur;
+               goto yy41;
+       default:        goto yy19;
+       }
+yy36:
+yy36_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy36_;
+               }
+               goto yy20;
+       case 'U':
+       case 'u':
+               ++in.cur;
+               goto yy42;
+       default:        goto yy19;
+       }
+yy37:
+yy37_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy37_;
+               }
+               goto yy20;
+       case 'E':
+       case 'e':
+               ++in.cur;
+               goto yy43;
+       default:        goto yy19;
+       }
+yy38:
+yy38_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy38_;
+               }
+               goto yy20;
+       case 'D':
+       case 'd':
+               ++in.cur;
+               goto yy44;
+       default:        goto yy19;
+       }
+yy39:
+yy39_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy39_;
+               }
+               goto yy13;
+       case '4':
+               ++in.cur;
+               goto yy45;
+       default:        goto yy17;
+       }
+yy40:
+yy40_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy40_;
+               }
+               goto yy20;
+       case 'D':
+       case 'd':
+               ++in.cur;
+               goto yy46;
+       default:        goto yy19;
+       }
+yy41:
+yy41_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy41_;
+               }
+               goto yy20;
+       case 'U':
+       case 'u':
+               ++in.cur;
+               goto yy47;
+       default:        goto yy19;
+       }
+yy42:
+yy42_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy42_;
+               }
+               goto yy20;
+       case 'R':
+       case 'r':
+               ++in.cur;
+               goto yy43;
+       default:        goto yy19;
+       }
+yy43:
+yy43_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy43_;
+               }
+               goto yy20;
+       case 'S':
+       case 's':
+               ++in.cur;
+               goto yy40;
+       default:        goto yy19;
+       }
+yy44:
+yy44_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy44_;
+               }
+               goto yy20;
+       case 'N':
+       case 'n':
+               ++in.cur;
+               goto yy37;
+       default:        goto yy19;
+       }
+yy45:
+yy45_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy45_;
+               }
+               goto yy13;
+       case '5':
+               ++in.cur;
+               goto yy48;
+       default:        goto yy17;
+       }
+yy46:
+yy46_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy46_;
+               }
+               goto yy20;
+       case 'A':
+       case 'a':
+               ++in.cur;
+               goto yy49;
+       default:        goto yy19;
+       }
+yy47:
+yy47_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy47_;
+               }
+               goto yy20;
+       case 'R':
+       case 'r':
+               ++in.cur;
+               goto yy40;
+       default:        goto yy19;
+       }
+yy48:
+yy48_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '7':
+       case '8':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       case '6':
+               ++in.cur;
+               goto yy50;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy48_;
+               }
+               goto yy15;
+       }
+yy49:
+yy49_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy49_;
+               }
+               goto yy20;
+       case 'Y':
+       case 'y':
+               ++in.cur;
+               goto yy51;
+       default:        goto yy19;
+       }
+yy50:
+yy50_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '8':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       case '7':
+               ++in.cur;
+               goto yy53;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy50_;
+               }
+               goto yy15;
+       }
+yy51:
+yy51_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'F':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'M':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'S':
+       case 'T':
+       case 'U':
+       case 'V':
+       case 'W':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'f':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'm':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 's':
+       case 't':
+       case 'u':
+       case 'v':
+       case 'w':
+       case 'x':
+       case 'y':
+       case 'z':
+               ++in.cur;
+               goto yy18;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy51_;
+               }
+               goto yy52;
+       }
+yy52:
+       { ++count; continue; }
+yy53:
+yy53_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       case '8':
+               ++in.cur;
+               goto yy54;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy53_;
+               }
+               goto yy15;
+       }
+yy54:
+yy54_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+               ++in.cur;
+               goto yy16;
+       case '9':
+               ++in.cur;
+               goto yy55;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy54_;
+               }
+               goto yy15;
+       }
+yy55:
+yy55_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+               ++in.cur;
+               goto yy16;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy55_;
+               }
+               goto yy15;
+       }
+yyeof:
+       { return true; }
+}
+
+    }
+}
+
+int main()
+{
+    input_t in;
+    unsigned int count;
+    if (lex(in, count)) {
+        printf("glorious %u numbers!\n", count);
+    } else {
+        printf("error\n");
+    }
+
+    return 0;
+}
diff --git a/re2c/test/eof/eof_01.i--eager-skip.re b/re2c/test/eof/eof_01.i--eager-skip.re
new file mode 100644 (file)
index 0000000..3a8727d
--- /dev/null
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    char buf[SIZE + 1];
+    char *lim;
+    char *cur;
+    char *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , tok(lim)
+        , eof(false)
+    {
+        fill();
+    }
+    int fill()
+    {
+        if (eof) {
+            return 1;
+        }
+        const size_t free = tok - buf;
+        if (free < 1) {
+            return 2;
+        }
+        memmove(buf, tok, lim - tok);
+        lim -= free;
+        cur -= free;
+        tok -= free;
+        lim += fread(lim, 1, free, stdin);
+        lim[0] = 0;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        /*!re2c
+            re2c:define:YYCTYPE = char;
+            re2c:define:YYCURSOR = in.cur;
+            re2c:define:YYLIMIT = in.lim;
+            re2c:define:YYFILL = "in.fill";
+            re2c:eof = 0;
+
+            wsp = [\n]+;
+            sstr = ["] ([^"\\] | "\\" [^])* ["];
+            dstr = ['] ([^'\\] | "\\" [^])* ['];
+            num = [+-]? ("0" | [1-9][0-9]*);
+            num1 = "1" | "12" | "12345" | "123456" | "1234567" | "12345678" | "123456789";
+            word = [_a-zA-Z][_a-zA-Z0-9]*;
+            day = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
+
+            *    { return false; }
+            $    { return true; }
+            wsp  { continue; }
+            sstr { ++count; continue; }
+            dstr { ++count; continue; }
+            num1 { ++count; continue; }
+            num  { ++count; continue; }
+            day  { ++count; continue; }
+            word { ++count; continue; }
+        */
+    }
+}
+
+int main()
+{
+    input_t in;
+    unsigned int count;
+    if (lex(in, count)) {
+        printf("glorious %u numbers!\n", count);
+    } else {
+        printf("error\n");
+    }
+
+    return 0;
+}
diff --git a/re2c/test/eof/eof_01.i.c b/re2c/test/eof/eof_01.i.c
new file mode 100644 (file)
index 0000000..3f700f2
--- /dev/null
@@ -0,0 +1,873 @@
+/* Generated by re2c */
+#include <stdio.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    char buf[SIZE + 1];
+    char *lim;
+    char *cur;
+    char *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , tok(lim)
+        , eof(false)
+    {
+        fill();
+    }
+    int fill()
+    {
+        if (eof) {
+            return 1;
+        }
+        const size_t free = tok - buf;
+        if (free < 1) {
+            return 2;
+        }
+        memmove(buf, tok, lim - tok);
+        lim -= free;
+        cur -= free;
+        tok -= free;
+        lim += fread(lim, 1, free, stdin);
+        lim[0] = 0;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        
+{
+       char yych;
+yy1:
+yy1_:
+       yych = *in.cur;
+       switch (yych) {
+       case '\n':      goto yy4;
+       case '"':       goto yy7;
+       case '\'':      goto yy9;
+       case '+':
+       case '-':       goto yy11;
+       case '0':       goto yy12;
+       case '1':       goto yy14;
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'U':
+       case 'V':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 'u':
+       case 'v':
+       case 'x':
+       case 'y':
+       case 'z':       goto yy18;
+       case 'F':
+       case 'f':       goto yy21;
+       case 'M':
+       case 'm':       goto yy22;
+       case 'S':
+       case 's':       goto yy23;
+       case 'T':
+       case 't':       goto yy24;
+       case 'W':
+       case 'w':       goto yy25;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy1_;
+                       else goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+       ++in.cur;
+yy3:
+       { return false; }
+yy4:
+       ++in.cur;
+yy4_:
+       yych = *in.cur;
+yy5:
+       switch (yych) {
+       case '\n':      goto yy4;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy4_;
+               }
+               goto yy6;
+       }
+yy6:
+       { continue; }
+yy7:
+       ++in.cur;
+yy7_:
+       yych = *in.cur;
+yy8:
+       switch (yych) {
+       case '"':       goto yy26;
+       case '\\':      goto yy28;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy7_;
+                       else goto yy3;
+               }
+               goto yy7;
+       }
+yy9:
+       ++in.cur;
+yy9_:
+       yych = *in.cur;
+yy10:
+       switch (yych) {
+       case '\'':      goto yy29;
+       case '\\':      goto yy31;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy9_;
+                       else goto yy3;
+               }
+               goto yy9;
+       }
+yy11:
+       ++in.cur;
+yy11_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':       goto yy12;
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy11_;
+               }
+               goto yy3;
+       }
+yy12:
+       ++in.cur;
+yy13:
+       { ++count; continue; }
+yy14:
+       ++in.cur;
+yy14_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       case '2':       goto yy32;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy14_;
+               }
+               goto yy15;
+       }
+yy15:
+       { ++count; continue; }
+yy16:
+       ++in.cur;
+yy16_:
+       yych = *in.cur;
+yy17:
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy16_;
+               }
+               goto yy13;
+       }
+yy18:
+       ++in.cur;
+yy18_:
+       yych = *in.cur;
+yy19:
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'F':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'M':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'S':
+       case 'T':
+       case 'U':
+       case 'V':
+       case 'W':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'f':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'm':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 's':
+       case 't':
+       case 'u':
+       case 'v':
+       case 'w':
+       case 'x':
+       case 'y':
+       case 'z':       goto yy18;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy18_;
+               }
+               goto yy20;
+       }
+yy20:
+       { ++count; continue; }
+yy21:
+       ++in.cur;
+yy21_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy21_;
+               }
+               goto yy20;
+       case 'R':
+       case 'r':       goto yy33;
+       default:        goto yy19;
+       }
+yy22:
+       ++in.cur;
+yy22_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy22_;
+               }
+               goto yy20;
+       case 'O':
+       case 'o':       goto yy34;
+       default:        goto yy19;
+       }
+yy23:
+       ++in.cur;
+yy23_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy23_;
+               }
+               goto yy20;
+       case 'A':
+       case 'a':       goto yy35;
+       case 'U':
+       case 'u':       goto yy34;
+       default:        goto yy19;
+       }
+yy24:
+       ++in.cur;
+yy24_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy24_;
+               }
+               goto yy20;
+       case 'H':
+       case 'h':       goto yy36;
+       case 'U':
+       case 'u':       goto yy37;
+       default:        goto yy19;
+       }
+yy25:
+       ++in.cur;
+yy25_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy25_;
+               }
+               goto yy20;
+       case 'E':
+       case 'e':       goto yy38;
+       default:        goto yy19;
+       }
+yy26:
+       ++in.cur;
+       { ++count; continue; }
+yy28:
+       ++in.cur;
+yy28_:
+       yych = *in.cur;
+       if (yych <= 0x00) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy28_;
+                       else goto yy3;
+               }
+               goto yy7;
+       }
+       goto yy7;
+yy29:
+       ++in.cur;
+       { ++count; continue; }
+yy31:
+       ++in.cur;
+yy31_:
+       yych = *in.cur;
+       if (yych <= 0x00) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy31_;
+                       else goto yy3;
+               }
+               goto yy9;
+       }
+       goto yy9;
+yy32:
+       ++in.cur;
+yy32_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       case '3':       goto yy39;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy32_;
+               }
+               goto yy15;
+       }
+yy33:
+       ++in.cur;
+yy33_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy33_;
+               }
+               goto yy20;
+       case 'I':
+       case 'i':       goto yy40;
+       default:        goto yy19;
+       }
+yy34:
+       ++in.cur;
+yy34_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy34_;
+               }
+               goto yy20;
+       case 'N':
+       case 'n':       goto yy40;
+       default:        goto yy19;
+       }
+yy35:
+       ++in.cur;
+yy35_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy35_;
+               }
+               goto yy20;
+       case 'T':
+       case 't':       goto yy41;
+       default:        goto yy19;
+       }
+yy36:
+       ++in.cur;
+yy36_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy36_;
+               }
+               goto yy20;
+       case 'U':
+       case 'u':       goto yy42;
+       default:        goto yy19;
+       }
+yy37:
+       ++in.cur;
+yy37_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy37_;
+               }
+               goto yy20;
+       case 'E':
+       case 'e':       goto yy43;
+       default:        goto yy19;
+       }
+yy38:
+       ++in.cur;
+yy38_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy38_;
+               }
+               goto yy20;
+       case 'D':
+       case 'd':       goto yy44;
+       default:        goto yy19;
+       }
+yy39:
+       ++in.cur;
+yy39_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy39_;
+               }
+               goto yy13;
+       case '4':       goto yy45;
+       default:        goto yy17;
+       }
+yy40:
+       ++in.cur;
+yy40_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy40_;
+               }
+               goto yy20;
+       case 'D':
+       case 'd':       goto yy46;
+       default:        goto yy19;
+       }
+yy41:
+       ++in.cur;
+yy41_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy41_;
+               }
+               goto yy20;
+       case 'U':
+       case 'u':       goto yy47;
+       default:        goto yy19;
+       }
+yy42:
+       ++in.cur;
+yy42_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy42_;
+               }
+               goto yy20;
+       case 'R':
+       case 'r':       goto yy43;
+       default:        goto yy19;
+       }
+yy43:
+       ++in.cur;
+yy43_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy43_;
+               }
+               goto yy20;
+       case 'S':
+       case 's':       goto yy40;
+       default:        goto yy19;
+       }
+yy44:
+       ++in.cur;
+yy44_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy44_;
+               }
+               goto yy20;
+       case 'N':
+       case 'n':       goto yy37;
+       default:        goto yy19;
+       }
+yy45:
+       ++in.cur;
+yy45_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy45_;
+               }
+               goto yy13;
+       case '5':       goto yy48;
+       default:        goto yy17;
+       }
+yy46:
+       ++in.cur;
+yy46_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy46_;
+               }
+               goto yy20;
+       case 'A':
+       case 'a':       goto yy49;
+       default:        goto yy19;
+       }
+yy47:
+       ++in.cur;
+yy47_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy47_;
+               }
+               goto yy20;
+       case 'R':
+       case 'r':       goto yy40;
+       default:        goto yy19;
+       }
+yy48:
+       ++in.cur;
+yy48_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       case '6':       goto yy50;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy48_;
+               }
+               goto yy15;
+       }
+yy49:
+       ++in.cur;
+yy49_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x00:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy49_;
+               }
+               goto yy20;
+       case 'Y':
+       case 'y':       goto yy51;
+       default:        goto yy19;
+       }
+yy50:
+       ++in.cur;
+yy50_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '8':
+       case '9':       goto yy16;
+       case '7':       goto yy53;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy50_;
+               }
+               goto yy15;
+       }
+yy51:
+       ++in.cur;
+yy51_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':
+       case 'A':
+       case 'B':
+       case 'C':
+       case 'D':
+       case 'E':
+       case 'F':
+       case 'G':
+       case 'H':
+       case 'I':
+       case 'J':
+       case 'K':
+       case 'L':
+       case 'M':
+       case 'N':
+       case 'O':
+       case 'P':
+       case 'Q':
+       case 'R':
+       case 'S':
+       case 'T':
+       case 'U':
+       case 'V':
+       case 'W':
+       case 'X':
+       case 'Y':
+       case 'Z':
+       case '_':
+       case 'a':
+       case 'b':
+       case 'c':
+       case 'd':
+       case 'e':
+       case 'f':
+       case 'g':
+       case 'h':
+       case 'i':
+       case 'j':
+       case 'k':
+       case 'l':
+       case 'm':
+       case 'n':
+       case 'o':
+       case 'p':
+       case 'q':
+       case 'r':
+       case 's':
+       case 't':
+       case 'u':
+       case 'v':
+       case 'w':
+       case 'x':
+       case 'y':
+       case 'z':       goto yy18;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy51_;
+               }
+               goto yy52;
+       }
+yy52:
+       { ++count; continue; }
+yy53:
+       ++in.cur;
+yy53_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '9':       goto yy16;
+       case '8':       goto yy54;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy53_;
+               }
+               goto yy15;
+       }
+yy54:
+       ++in.cur;
+yy54_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':       goto yy16;
+       case '9':       goto yy55;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy54_;
+               }
+               goto yy15;
+       }
+yy55:
+       ++in.cur;
+yy55_:
+       yych = *in.cur;
+       switch (yych) {
+       case '0':
+       case '1':
+       case '2':
+       case '3':
+       case '4':
+       case '5':
+       case '6':
+       case '7':
+       case '8':
+       case '9':       goto yy16;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy55_;
+               }
+               goto yy15;
+       }
+yyeof:
+       { return true; }
+}
+
+    }
+}
+
+int main()
+{
+    input_t in;
+    unsigned int count;
+    if (lex(in, count)) {
+        printf("glorious %u numbers!\n", count);
+    } else {
+        printf("error\n");
+    }
+
+    return 0;
+}
diff --git a/re2c/test/eof/eof_01.i.re b/re2c/test/eof/eof_01.i.re
new file mode 100644 (file)
index 0000000..3a8727d
--- /dev/null
@@ -0,0 +1,87 @@
+#include <stdio.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    char buf[SIZE + 1];
+    char *lim;
+    char *cur;
+    char *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , tok(lim)
+        , eof(false)
+    {
+        fill();
+    }
+    int fill()
+    {
+        if (eof) {
+            return 1;
+        }
+        const size_t free = tok - buf;
+        if (free < 1) {
+            return 2;
+        }
+        memmove(buf, tok, lim - tok);
+        lim -= free;
+        cur -= free;
+        tok -= free;
+        lim += fread(lim, 1, free, stdin);
+        lim[0] = 0;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        /*!re2c
+            re2c:define:YYCTYPE = char;
+            re2c:define:YYCURSOR = in.cur;
+            re2c:define:YYLIMIT = in.lim;
+            re2c:define:YYFILL = "in.fill";
+            re2c:eof = 0;
+
+            wsp = [\n]+;
+            sstr = ["] ([^"\\] | "\\" [^])* ["];
+            dstr = ['] ([^'\\] | "\\" [^])* ['];
+            num = [+-]? ("0" | [1-9][0-9]*);
+            num1 = "1" | "12" | "12345" | "123456" | "1234567" | "12345678" | "123456789";
+            word = [_a-zA-Z][_a-zA-Z0-9]*;
+            day = 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday';
+
+            *    { return false; }
+            $    { return true; }
+            wsp  { continue; }
+            sstr { ++count; continue; }
+            dstr { ++count; continue; }
+            num1 { ++count; continue; }
+            num  { ++count; continue; }
+            day  { ++count; continue; }
+            word { ++count; continue; }
+        */
+    }
+}
+
+int main()
+{
+    input_t in;
+    unsigned int count;
+    if (lex(in, count)) {
+        printf("glorious %u numbers!\n", count);
+    } else {
+        printf("error\n");
+    }
+
+    return 0;
+}