From: helly Date: Sat, 24 Feb 2007 17:27:20 +0000 (+0000) Subject: - Add/fix tests X-Git-Tag: 0.13.6~227 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ad71a2702c1635f84999612ca9f73a9ace3bdf6e;p=re2c - Add/fix tests --- diff --git a/re2c/test/cvsignore.u.c b/re2c/test/cvsignore.u.c index 5ec7a4ab..e7b1a429 100755 --- a/re2c/test/cvsignore.u.c +++ b/re2c/test/cvsignore.u.c @@ -2,7 +2,7 @@ #line 1 "cvsignore.u.re" #define YYFILL(n) if (cursor >= limit) break; -#define YYCTYPE unsigned short +#define YYCTYPE unsigned int #define YYCURSOR cursor #define YYLIMIT limit #define YYMARKER marker diff --git a/re2c/test/cvsignore.u.re b/re2c/test/cvsignore.u.re index 442a45ed..11a03d70 100755 --- a/re2c/test/cvsignore.u.re +++ b/re2c/test/cvsignore.u.re @@ -1,6 +1,6 @@ #define YYFILL(n) if (cursor >= limit) break; -#define YYCTYPE unsigned short +#define YYCTYPE unsigned int #define YYCURSOR cursor #define YYLIMIT limit #define YYMARKER marker diff --git a/re2c/test/cvsignore.ub.c b/re2c/test/cvsignore.ub.c new file mode 100755 index 00000000..c7259626 --- /dev/null +++ b/re2c/test/cvsignore.ub.c @@ -0,0 +1,261 @@ +/* Generated by re2c */ +#line 1 "cvsignore.ub.re" + +#define YYFILL(n) if (cursor >= limit) break; +#define YYCTYPE unsigned int +#define YYCURSOR cursor +#define YYLIMIT limit +#define YYMARKER marker + +#line 16 "cvsignore.ub.re" + + +#define APPEND(text) \ + append(output, outsize, text, sizeof(text) - sizeof(YYCTYPE)) + +inline void append(YYCTYPE *output, size_t & outsize, const YYCTYPE * text, size_t len) +{ + memcpy(output + outsize, text, len); + outsize += (len / sizeof(YYCTYPE)); +} + +void scan(YYCTYPE *pText, size_t *pSize, int *pbChanged) +{ + // rule + // scan lines + // find $ in lines + // compact $: .. $ to $$ + + YYCTYPE *output; + const YYCTYPE *cursor, *limit, *marker; + + cursor = marker = output = *pText; + + size_t insize = *pSize; + size_t outsize = 0; + + limit = cursor + insize; + + while(1) { +loop: +{ + static const unsigned char yybm[] = { + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 0, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + }; + +#line 78 "" + { + YYCTYPE yych; + + if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); + yych = *YYCURSOR; + if(yych != '$') goto yy4; + yych = *(YYMARKER = ++YYCURSOR); + switch(yych) { + case 'D': goto yy10; + case 'I': goto yy9; + case 'L': goto yy8; + case 'R': goto yy7; + case 'S': goto yy5; + default: goto yy3; + } +yy3: +#line 53 "cvsignore.ub.re" + { output[outsize++] = cursor[-1]; if (cursor >= limit) break; goto loop; } +#line 97 "" +yy4: + yych = *++YYCURSOR; + goto yy3; +yy5: + yych = *++YYCURSOR; + if(yych == 'o') goto yy44; +yy6: + YYCURSOR = YYMARKER; + goto yy3; +yy7: + yych = *++YYCURSOR; + if(yych == 'e') goto yy32; + goto yy6; +yy8: + yych = *++YYCURSOR; + if(yych == 'o') goto yy25; + goto yy6; +yy9: + yych = *++YYCURSOR; + if(yych == 'd') goto yy19; + goto yy6; +yy10: + yych = *++YYCURSOR; + if(yych != 'a') goto yy6; + yych = *++YYCURSOR; + if(yych != 't') goto yy6; + yych = *++YYCURSOR; + if(yych != 'e') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy15; + if(yych != ':') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy6; + goto yy18; +yy15: + ++YYCURSOR; +#line 48 "cvsignore.ub.re" + { APPEND(L"$" L"Date$"); goto loop; } +#line 136 "" +yy17: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy18: + if(yych & ~0xFF) { + goto yy17; + } else if(yybm[0+yych] & 128) { + goto yy17; + } + if(yych <= '#') goto yy6; + goto yy15; +yy19: + yych = *++YYCURSOR; + if(yych == '$') goto yy21; + if(yych != ':') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy6; + goto yy24; +yy21: + ++YYCURSOR; +#line 49 "cvsignore.ub.re" + { APPEND(L"$" L"Id$"); goto loop; } +#line 160 "" +yy23: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy24: + if(yych == 0x0000000A) goto yy6; + if(yych == '$') goto yy21; + goto yy23; +yy25: + yych = *++YYCURSOR; + if(yych != 'g') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy28; + if(yych != ':') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy6; + goto yy31; +yy28: + ++YYCURSOR; +#line 50 "cvsignore.ub.re" + { APPEND(L"$" L"Log$"); goto loop; } +#line 182 "" +yy30: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy31: + if(yych == 0x0000000A) goto yy6; + if(yych == '$') goto yy28; + goto yy30; +yy32: + yych = *++YYCURSOR; + if(yych != 'v') goto yy6; + yych = *++YYCURSOR; + if(yych != 'i') goto yy6; + yych = *++YYCURSOR; + if(yych != 's') goto yy6; + yych = *++YYCURSOR; + if(yych != 'i') goto yy6; + yych = *++YYCURSOR; + if(yych != 'o') goto yy6; + yych = *++YYCURSOR; + if(yych != 'n') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy40; + if(yych != ':') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy6; + goto yy43; +yy40: + ++YYCURSOR; +#line 51 "cvsignore.ub.re" + { APPEND(L"$" L"Revision$"); goto loop; } +#line 214 "" +yy42: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy43: + if(yych == 0x0000000A) goto yy6; + if(yych == '$') goto yy40; + goto yy42; +yy44: + yych = *++YYCURSOR; + if(yych != 'u') goto yy6; + yych = *++YYCURSOR; + if(yych != 'r') goto yy6; + yych = *++YYCURSOR; + if(yych != 'c') goto yy6; + yych = *++YYCURSOR; + if(yych != 'e') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy50; + if(yych != ':') goto yy6; + yych = *++YYCURSOR; + if(yych == '$') goto yy6; + goto yy53; +yy50: + ++YYCURSOR; +#line 52 "cvsignore.ub.re" + { APPEND(L"$" L"Source$"); goto loop; } +#line 242 "" +yy52: + ++YYCURSOR; + if(YYLIMIT == YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy53: + if(yych == 0x0000000A) goto yy6; + if(yych == '$') goto yy50; + goto yy52; + } +} +#line 55 "cvsignore.ub.re" + + } + output[outsize] = '\0'; + + // set the new size + *pSize = outsize; + + *pbChanged = (insize == outsize) ? 0 : 1; +} diff --git a/re2c/test/cvsignore.ub.re b/re2c/test/cvsignore.ub.re new file mode 100755 index 00000000..11a03d70 --- /dev/null +++ b/re2c/test/cvsignore.ub.re @@ -0,0 +1,63 @@ + +#define YYFILL(n) if (cursor >= limit) break; +#define YYCTYPE unsigned int +#define YYCURSOR cursor +#define YYLIMIT limit +#define YYMARKER marker + +/*!re2c +any = (.|"\n"); +value = (":" (.\"$")+)?; +cvsdat = "Date"; +cvsid = "Id"; +cvslog = "Log"; +cvsrev = "Revision"; +cvssrc = "Source"; +*/ + +#define APPEND(text) \ + append(output, outsize, text, sizeof(text) - sizeof(YYCTYPE)) + +inline void append(YYCTYPE *output, size_t & outsize, const YYCTYPE * text, size_t len) +{ + memcpy(output + outsize, text, len); + outsize += (len / sizeof(YYCTYPE)); +} + +void scan(YYCTYPE *pText, size_t *pSize, int *pbChanged) +{ + // rule + // scan lines + // find $ in lines + // compact $: .. $ to $$ + + YYCTYPE *output; + const YYCTYPE *cursor, *limit, *marker; + + cursor = marker = output = *pText; + + size_t insize = *pSize; + size_t outsize = 0; + + limit = cursor + insize; + + while(1) { +loop: +/*!re2c + +"$" cvsdat value "$" { APPEND(L"$" L"Date$"); goto loop; } +"$" cvsid value "$" { APPEND(L"$" L"Id$"); goto loop; } +"$" cvslog value "$" { APPEND(L"$" L"Log$"); goto loop; } +"$" cvsrev value "$" { APPEND(L"$" L"Revision$"); goto loop; } +"$" cvssrc value "$" { APPEND(L"$" L"Source$"); goto loop; } +any { output[outsize++] = cursor[-1]; if (cursor >= limit) break; goto loop; } + +*/ + } + output[outsize] = '\0'; + + // set the new size + *pSize = outsize; + + *pbChanged = (insize == outsize) ? 0 : 1; +}