]> granicus.if.org Git - re2c/commitdiff
Added more tests for EOF rule.
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 6 Mar 2019 23:28:29 +0000 (23:28 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 6 Mar 2019 23:28:29 +0000 (23:28 +0000)
re2c/test/eof/eof_04.ie.c [new file with mode: 0644]
re2c/test/eof/eof_04.ie.re [new file with mode: 0644]
re2c/test/eof/eof_04.iu.c [new file with mode: 0644]
re2c/test/eof/eof_04.iu.re [new file with mode: 0644]
re2c/test/eof/eof_04.iw.c [new file with mode: 0644]
re2c/test/eof/eof_04.iw.re [new file with mode: 0644]
re2c/test/eof/eof_04.ix.c [new file with mode: 0644]
re2c/test/eof/eof_04.ix.re [new file with mode: 0644]

diff --git a/re2c/test/eof/eof_04.ie.c b/re2c/test/eof/eof_04.ie.c
new file mode 100644 (file)
index 0000000..72fed9b
--- /dev/null
@@ -0,0 +1,114 @@
+/* Generated by re2c */
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint8_t buf[SIZE + 1];
+    uint8_t *lim;
+    uint8_t *cur;
+    uint8_t *mar;
+    uint8_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint8_t), free, stdin);
+        lim[0] = 255;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        
+{
+       uint8_t yych;
+yy1_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x25:      goto yy5;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy1_;
+                       else goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+       ++in.cur;
+yy2_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x25:      goto yy4;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy2_;
+                       else goto yy4;
+               }
+               goto yy2;
+       }
+yy4:
+       { ++count; continue; }
+yy5:
+       ++in.cur;
+yy5_:
+       yych = *in.cur;
+       switch (yych) {
+       case 0x25:      goto yy5;
+       default:
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy5_;
+               }
+               goto yy7;
+       }
+yy7:
+       { continue; }
+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_04.ie.re b/re2c/test/eof/eof_04.ie.re
new file mode 100644 (file)
index 0000000..c001c0d
--- /dev/null
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint8_t buf[SIZE + 1];
+    uint8_t *lim;
+    uint8_t *cur;
+    uint8_t *mar;
+    uint8_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint8_t), free, stdin);
+        lim[0] = 255;
+        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 = uint8_t;
+            re2c:define:YYCURSOR = in.cur;
+            re2c:define:YYMARKER = in.mar;
+            re2c:define:YYLIMIT = in.lim;
+            re2c:define:YYFILL = in.fill;
+            re2c:eof = 255;
+
+            wsp = [\n]+;
+            num = .+;
+
+            *    { return false; }
+            $    { return true; }
+            wsp  { continue; }
+            num  { ++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_04.iu.c b/re2c/test/eof/eof_04.iu.c
new file mode 100644 (file)
index 0000000..8ca2b7d
--- /dev/null
@@ -0,0 +1,110 @@
+/* Generated by re2c */
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint32_t buf[SIZE + 1];
+    uint32_t *lim;
+    uint32_t *cur;
+    uint32_t *mar;
+    uint32_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint32_t), free, stdin);
+        lim[0] = 1114111;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        
+{
+       uint32_t yych;
+yy1_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy5;
+       if (yych >= 0x0010FFFF) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy1_;
+                       else goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+       ++in.cur;
+yy2_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy4;
+       if (yych <= 0x0010FFFE) goto yy2;
+       if (in.lim <= in.cur) {
+               if (in.fill () == 0) goto yy2_;
+               else goto yy4;
+       }
+       goto yy2;
+yy4:
+       { ++count; continue; }
+yy5:
+       ++in.cur;
+yy5_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy5;
+       if (yych >= 0x0010FFFF) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy5_;
+               }
+               goto yy7;
+       }
+yy7:
+       { continue; }
+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_04.iu.re b/re2c/test/eof/eof_04.iu.re
new file mode 100644 (file)
index 0000000..fd3e2d5
--- /dev/null
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint32_t buf[SIZE + 1];
+    uint32_t *lim;
+    uint32_t *cur;
+    uint32_t *mar;
+    uint32_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint32_t), free, stdin);
+        lim[0] = 1114111;
+        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 = uint32_t;
+            re2c:define:YYCURSOR = in.cur;
+            re2c:define:YYMARKER = in.mar;
+            re2c:define:YYLIMIT = in.lim;
+            re2c:define:YYFILL = in.fill;
+            re2c:eof = 1114111;
+
+            wsp = [\n]+;
+            num = .+;
+
+            *    { return false; }
+            $    { return true; }
+            wsp  { continue; }
+            num  { ++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_04.iw.c b/re2c/test/eof/eof_04.iw.c
new file mode 100644 (file)
index 0000000..8b3500e
--- /dev/null
@@ -0,0 +1,110 @@
+/* Generated by re2c */
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint16_t buf[SIZE + 1];
+    uint16_t *lim;
+    uint16_t *cur;
+    uint16_t *mar;
+    uint16_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint16_t), free, stdin);
+        lim[0] = 65535;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        
+{
+       uint16_t yych;
+yy1_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy5;
+       if (yych >= 0xFFFF) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy1_;
+                       else goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+       ++in.cur;
+yy2_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy4;
+       if (yych <= 0xFFFE) goto yy2;
+       if (in.lim <= in.cur) {
+               if (in.fill () == 0) goto yy2_;
+               else goto yy4;
+       }
+       goto yy2;
+yy4:
+       { ++count; continue; }
+yy5:
+       ++in.cur;
+yy5_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy5;
+       if (yych >= 0xFFFF) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy5_;
+               }
+               goto yy7;
+       }
+yy7:
+       { continue; }
+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_04.iw.re b/re2c/test/eof/eof_04.iw.re
new file mode 100644 (file)
index 0000000..0442773
--- /dev/null
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint16_t buf[SIZE + 1];
+    uint16_t *lim;
+    uint16_t *cur;
+    uint16_t *mar;
+    uint16_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint16_t), free, stdin);
+        lim[0] = 65535;
+        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 = uint16_t;
+            re2c:define:YYCURSOR = in.cur;
+            re2c:define:YYMARKER = in.mar;
+            re2c:define:YYLIMIT = in.lim;
+            re2c:define:YYFILL = in.fill;
+            re2c:eof = 65535;
+
+            wsp = [\n]+;
+            num = .+;
+
+            *    { return false; }
+            $    { return true; }
+            wsp  { continue; }
+            num  { ++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_04.ix.c b/re2c/test/eof/eof_04.ix.c
new file mode 100644 (file)
index 0000000..8b3500e
--- /dev/null
@@ -0,0 +1,110 @@
+/* Generated by re2c */
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint16_t buf[SIZE + 1];
+    uint16_t *lim;
+    uint16_t *cur;
+    uint16_t *mar;
+    uint16_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint16_t), free, stdin);
+        lim[0] = 65535;
+        if (lim < buf + SIZE) {
+            eof = true;
+        }
+        return 0;
+    }
+};
+
+static bool lex(input_t & in, unsigned int &count)
+{
+    for (count = 0;;) {
+        in.tok = in.cur;
+        
+{
+       uint16_t yych;
+yy1_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy5;
+       if (yych >= 0xFFFF) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy1_;
+                       else goto yyeof;
+               }
+               goto yy2;
+       }
+yy2:
+       ++in.cur;
+yy2_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy4;
+       if (yych <= 0xFFFE) goto yy2;
+       if (in.lim <= in.cur) {
+               if (in.fill () == 0) goto yy2_;
+               else goto yy4;
+       }
+       goto yy2;
+yy4:
+       { ++count; continue; }
+yy5:
+       ++in.cur;
+yy5_:
+       yych = *in.cur;
+       if (yych == '\n') goto yy5;
+       if (yych >= 0xFFFF) {
+               if (in.lim <= in.cur) {
+                       if (in.fill () == 0) goto yy5_;
+               }
+               goto yy7;
+       }
+yy7:
+       { continue; }
+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_04.ix.re b/re2c/test/eof/eof_04.ix.re
new file mode 100644 (file)
index 0000000..0442773
--- /dev/null
@@ -0,0 +1,82 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+static const size_t SIZE = 4096;
+
+struct input_t {
+    uint16_t buf[SIZE + 1];
+    uint16_t *lim;
+    uint16_t *cur;
+    uint16_t *mar;
+    uint16_t *tok;
+    bool eof;
+
+    input_t()
+        : buf()
+        , lim(buf + SIZE)
+        , cur(lim)
+        , mar(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;
+        mar -= free;
+        tok -= free;
+        lim += fread(lim, sizeof(uint16_t), free, stdin);
+        lim[0] = 65535;
+        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 = uint16_t;
+            re2c:define:YYCURSOR = in.cur;
+            re2c:define:YYMARKER = in.mar;
+            re2c:define:YYLIMIT = in.lim;
+            re2c:define:YYFILL = in.fill;
+            re2c:eof = 65535;
+
+            wsp = [\n]+;
+            num = .+;
+
+            *    { return false; }
+            $    { return true; }
+            wsp  { continue; }
+            num  { ++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;
+}