]> granicus.if.org Git - re2c/commitdiff
- Add new test files
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 27 Dec 2005 22:55:13 +0000 (22:55 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Tue, 27 Dec 2005 22:55:13 +0000 (22:55 +0000)
test/bug1390174.c [new file with mode: 0755]
test/bug1390174.re [new file with mode: 0755]

diff --git a/test/bug1390174.c b/test/bug1390174.c
new file mode 100755 (executable)
index 0000000..80a14ad
--- /dev/null
@@ -0,0 +1,90 @@
+/* Generated by re2c */
+#line 1 "bug1390174.re"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define RET(n) return n
+
+int scan(const char *s, int l) {
+const char *p = s;
+const char *q;
+#define YYCTYPE         char
+#define YYCURSOR        p
+#define YYLIMIT         (s+l)
+#define YYMARKER        q
+#define YYFILL(n)
+
+#line 19 "<stdout>"
+{
+       YYCTYPE yych;
+       unsigned int yyaccept = 0;
+       goto yy0;
+       ++YYCURSOR;
+yy0:
+       if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
+       yych = *YYCURSOR;
+       switch(yych){
+       case 0x0A:      goto yy4;
+       case 'A':       case 'a':       goto yy2;
+       default:        goto yy6;
+       }
+yy2:   yyaccept = 0;
+       yych = *(YYMARKER = ++YYCURSOR);
+       switch(yych){
+       case 0x0A:      goto yy7;
+       case 'A':       case 'a':       goto yy8;
+       default:        goto yy3;
+       }
+yy3:
+#line 19 "bug1390174.re"
+{RET(0);}
+#line 43 "<stdout>"
+yy4:   ++YYCURSOR;
+       goto yy5;
+yy5:
+#line 18 "bug1390174.re"
+{RET(1);}
+#line 49 "<stdout>"
+yy6:   yych = *++YYCURSOR;
+       goto yy3;
+yy7:   yych = *++YYCURSOR;
+       goto yy5;
+yy8:   ++YYCURSOR;
+       if(YYLIMIT == YYCURSOR) YYFILL(1);
+       yych = *YYCURSOR;
+       goto yy9;
+yy9:   switch(yych){
+       case 0x0A:      goto yy7;
+       case 'A':       case 'a':       goto yy8;
+       default:        goto yy10;
+       }
+yy10:  YYCURSOR = YYMARKER;
+       switch(yyaccept){
+       case 0: goto yy3;
+       }
+}
+#line 20 "bug1390174.re"
+
+}
+
+void _do_scan(int exp, const char * str, int len)
+{
+       int ret = scan(str, len);
+       
+       printf("%d %s %d\n", exp, exp == ret ? "==" : "!=", ret);
+}
+
+#define do_scan(exp, str) _do_scan(exp, str, sizeof(str) - 1)
+
+main()
+{
+       do_scan(1, "a\n");
+       do_scan(1, "aa\n");
+       do_scan(1, "aaa\n");
+       do_scan(1, "aaaa\n");
+       do_scan(1, "\n");
+
+       do_scan(0, "q");
+       do_scan(0, "a");
+}
diff --git a/test/bug1390174.re b/test/bug1390174.re
new file mode 100755 (executable)
index 0000000..c6564b4
--- /dev/null
@@ -0,0 +1,42 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define RET(n) return n
+
+int scan(const char *s, int l) {
+const char *p = s;
+const char *q;
+#define YYCTYPE         char
+#define YYCURSOR        p
+#define YYLIMIT         (s+l)
+#define YYMARKER        q
+#define YYFILL(n)
+/*!re2c
+       any     = [\000-\377];
+
+       'a'{0,}"\n"     {RET(1);}
+       any             {RET(0);}
+*/
+}
+
+void _do_scan(int exp, const char * str, int len)
+{
+       int ret = scan(str, len);
+       
+       printf("%d %s %d\n", exp, exp == ret ? "==" : "!=", ret);
+}
+
+#define do_scan(exp, str) _do_scan(exp, str, sizeof(str) - 1)
+
+main()
+{
+       do_scan(1, "a\n");
+       do_scan(1, "aa\n");
+       do_scan(1, "aaa\n");
+       do_scan(1, "aaaa\n");
+       do_scan(1, "\n");
+
+       do_scan(0, "q");
+       do_scan(0, "a");
+}