From: helly Date: Sat, 9 Jul 2005 23:33:40 +0000 (+0000) Subject: - . must not include \n X-Git-Tag: 0.13.6~621 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=18b4f450b98621e378187cb92a76d880ce2a7d81;p=re2c - . must not include \n --- diff --git a/actions.cc b/actions.cc index 29a4d160..334da2b2 100644 --- a/actions.cc +++ b/actions.cc @@ -694,6 +694,18 @@ RegExp *invToRE(SubStr s) return inv; } +RegExp *mkDot() +{ + RegExp * any = ranToRE(SubStr("[\\000-\\377]")); + RegExp * ran = matchChar('\n'); + RegExp * inv = mkDiff(any, ran); + + delete ran; + delete any; + + return inv; +} + char *RuleOp::type = "RuleOp"; RuleOp::RuleOp(RegExp *e, RegExp *c, Token *t, uint a) diff --git a/bootstrap/scanner.cc b/bootstrap/scanner.cc index 32ae6fa5..f8a3373d 100644 --- a/bootstrap/scanner.cc +++ b/bootstrap/scanner.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.9.9.dev on Sat Jul 9 20:41:37 2005 */ +/* Generated by re2c 0.9.9.dev on Sun Jul 10 01:26:44 2005 */ #line 1 "scanner.re" /* $Id$ */ #include @@ -368,7 +368,7 @@ yy51: ++YYCURSOR; yy52: #line 197 "scanner.re" { cur = cursor; - yylval.regexp = ranToRE("[\\000-\\377]"); + yylval.regexp = mkDot(); return RANGE; } #line 375 "scanner.cc" diff --git a/re.h b/re.h index 22015823..1bfc2c62 100644 --- a/re.h +++ b/re.h @@ -292,6 +292,7 @@ public: extern void genCode(std::ostream&, RegExp*); extern RegExp *mkDiff(RegExp*, RegExp*); +extern RegExp *mkDot(); extern RegExp *strToRE(SubStr); extern RegExp *ranToRE(SubStr); extern RegExp *invToRE(SubStr); diff --git a/scanner.re b/scanner.re index 1086e206..5d9fd3cc 100644 --- a/scanner.re +++ b/scanner.re @@ -195,7 +195,7 @@ scan: } "." { cur = cursor; - yylval.regexp = ranToRE("[\\000-\\377]"); + yylval.regexp = mkDot(); return RANGE; } diff --git a/test/input7.c b/test/input7.c index 300284c3..61df86c9 100755 --- a/test/input7.c +++ b/test/input7.c @@ -9,13 +9,22 @@ yy0: if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; - goto yy2; + switch(yych){ + case 0x0A: goto yy4; + default: goto yy2; + } yy2: ++YYCURSOR; goto yy3; yy3: -#line 3 "input7.re" +#line 5 "input7.re" { return 0; } -#line 19 "" +#line 22 "" +yy4: ++YYCURSOR; + goto yy5; +yy5: +#line 6 "input7.re" +{ return 1; } +#line 28 "" } -#line 5 "input7.re" +#line 8 "input7.re" diff --git a/test/input7.re b/test/input7.re index 4af565db..2f4f4171 100755 --- a/test/input7.re +++ b/test/input7.re @@ -1,5 +1,8 @@ /*!re2c +any = [\000-\377]; + . { return 0; } +any { return 1; } */ diff --git a/test/input8.c b/test/input8.c index a3296dcc..293089a6 100755 --- a/test/input8.c +++ b/test/input8.c @@ -10,40 +10,58 @@ yy0: if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; - goto yy2; + switch(yych){ + case 0x0A: goto yy4; + default: goto yy2; + } yy2: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); - if(yych <= 0x00) goto yy4; - goto yy6; + switch(yych){ + case 0x00: goto yy6; + case 0x0A: goto yy3; + default: goto yy8; + } yy3: -#line 4 "input8.re" +#line 6 "input8.re" { return 1; } -#line 22 "" -yy4: yyaccept = 1; - yych = *(YYMARKER = ++YYCURSOR); - if(yych <= 0x00) goto yy7; - goto yy8; +#line 28 "" +yy4: ++YYCURSOR; + goto yy5; yy5: -#line 3 "input8.re" +#line 7 "input8.re" +{ return 2; } +#line 34 "" +yy6: yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch(yych){ + case 0x00: goto yy10; + case 0x0A: goto yy7; + default: goto yy11; + } +yy7: +#line 5 "input8.re" { return 0; } -#line 30 "" -yy6: yych = *++YYCURSOR; - if(yych >= 0x01) goto yy8; - goto yy7; -yy7: yych = *++YYCURSOR; - if(yych <= 0x00) goto yy10; - goto yy5; +#line 45 "" yy8: yych = *++YYCURSOR; - if(yych <= 0x00) goto yy10; - goto yy9; + switch(yych){ + case 0x00: goto yy10; + case 0x0A: goto yy9; + default: goto yy11; + } yy9: YYCURSOR = YYMARKER; switch(yyaccept){ - case 1: goto yy5; + case 1: goto yy7; case 0: goto yy3; } -yy10: ++YYCURSOR; +yy10: yych = *++YYCURSOR; + if(yych <= 0x00) goto yy12; + goto yy7; +yy11: yych = *++YYCURSOR; + if(yych >= 0x01) goto yy9; + goto yy12; +yy12: ++YYCURSOR; yych = *YYCURSOR; - goto yy5; + goto yy7; } -#line 6 "input8.re" +#line 9 "input8.re" diff --git a/test/input8.re b/test/input8.re index 9d62783e..2a57f414 100755 --- a/test/input8.re +++ b/test/input8.re @@ -1,6 +1,9 @@ /*!re2c +any = [\000-\377]; + .{1,3}"\000" { return 0; } . { return 1; } +any { return 2; } */