]> granicus.if.org Git - re2c/commitdiff
- Fixed #1529351 Segv bug on unterminated code blocks
authorhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sat, 29 Jul 2006 20:21:54 +0000 (20:21 +0000)
committerhelly <helly@642ea486-5414-0410-9d7f-a0204ed87703>
Sat, 29 Jul 2006 20:21:54 +0000 (20:21 +0000)
re2c/CHANGELOG
re2c/bootstrap/parser.cc
re2c/bootstrap/scanner.cc
re2c/parser.y
re2c/scanner.re
re2c/test/bug1529351.c [new file with mode: 0755]
re2c/test/bug1529351.re [new file with mode: 0644]

index 7c79e2bacbc5c7c4ebf9bf87838d17b508bd3306..bcba1e221d59ac5befe06a09487a28006857f95d 100644 (file)
@@ -1,5 +1,9 @@
 Version 0.11.0 (????-??-??)
 ---------------------------
+
+Version 0.10.6 (2006-??-??)
+---------------------------
+- Fixed #1529351 Segv bug on unterminated code blocks
 - Fixed #1528269 Invalid code generation.
 
 Version 0.10.5 (2006-06-11)
index 2617f37a88a7ead0268f73d7a2ec87040d05a668..6ae84b3f72c8c26998cdfae1a628ce4997d15480 100644 (file)
@@ -113,7 +113,7 @@ void yyerror(const char*);
 
 static re2c::uint accept;
 static RegExp *spec;
-static Scanner *in;
+static Scanner *in = NULL;
 
 /* Bison version 1.875 emits a definition that is not working
  * with several g++ version. Hence we disable it here.
@@ -1609,7 +1609,7 @@ void yyerror(const char* s)
 }
 
 int yylex(){
-    return in->scan();
+    return in ? in->scan() : 0;
 }
 } // end extern "C"
 
@@ -1639,6 +1639,7 @@ void parse(Scanner& i, std::ostream& o)
        RegExp::vFreeList.clear();
        Range::vFreeList.clear();
        Symbol::ClearTable();
+       in = NULL;
 }
 
 } // end namespace re2c
index 2ecd769c2d3a790c1e150ab9bf1299a8eb882d42..ddc9f6c43d7924f169e4ba48bec39e7a3097f3d3 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.11.0.dev on Thu Jul 27 03:06:48 2006 */
+/* Generated by re2c 0.11.0.dev on Sat Jul 29 22:25:10 2006 */
 #line 1 "scanner.re"
 /* $Id$ */
 #include <stdlib.h>
@@ -94,7 +94,7 @@ int Scanner::echo()
 echo:
 {
 
-#line 98 "<stdout>"
+#line 98 "scanner.cc"
        {
                YYCTYPE yych;
                unsigned int yyaccept = 0;
@@ -117,7 +117,7 @@ yy3:
                {
                                        goto echo;
                                }
-#line 121 "<stdout>"
+#line 121 "scanner.cc"
 yy4:
                yych = *++YYCURSOR;
                if(yych == '/') goto yy10;
@@ -134,7 +134,7 @@ yy5:
                                        tok = pos = cursor; cline++;
                                        goto echo;
                                }
-#line 138 "<stdout>"
+#line 138 "scanner.cc"
 yy7:
                ++YYCURSOR;
 #line 176 "scanner.re"
@@ -146,7 +146,7 @@ yy7:
                                                RETURN(0);
                                        }
                                }
-#line 150 "<stdout>"
+#line 150 "scanner.cc"
 yy9:
                yych = *++YYCURSOR;
                goto yy3;
@@ -170,7 +170,7 @@ yy11:
                                        tok = pos = cursor;
                                        goto echo;
                                }
-#line 174 "<stdout>"
+#line 174 "scanner.cc"
 yy12:
                yych = *++YYCURSOR;
                if(yych == 0x0A) goto yy14;
@@ -198,7 +198,7 @@ yy14:
                                        tok = pos = cursor;
                                        goto echo;
                                }
-#line 202 "<stdout>"
+#line 202 "scanner.cc"
 yy16:
                yych = *++YYCURSOR;
                if(yych != '!') goto yy13;
@@ -239,7 +239,7 @@ yy21:
                                        tok = cursor;
                                        RETURN(1);
                                }
-#line 243 "<stdout>"
+#line 243 "scanner.cc"
 yy26:
                yych = *++YYCURSOR;
                if(yych != 'x') goto yy13;
@@ -265,7 +265,7 @@ yy26:
                                        bUsedYYMaxFill = true;
                                        goto echo;
                                }
-#line 269 "<stdout>"
+#line 269 "scanner.cc"
 yy34:
                yych = *++YYCURSOR;
                if(yych != 't') goto yy13;
@@ -297,7 +297,7 @@ yy34:
                                        ignore_eoc = true;
                                        goto echo;
                                }
-#line 301 "<stdout>"
+#line 301 "scanner.cc"
 yy47:
                yych = *++YYCURSOR;
                if(yych != 'n') goto yy13;
@@ -324,7 +324,7 @@ yy47:
                                        ignore_eoc = true;
                                        goto echo;
                                }
-#line 328 "<stdout>"
+#line 328 "scanner.cc"
        }
 }
 #line 187 "scanner.re"
@@ -385,7 +385,7 @@ scan:
                112, 112, 112, 112, 112, 112, 112, 112, 
        };
 
-#line 389 "<stdout>"
+#line 389 "scanner.cc"
        {
                YYCTYPE yych;
                unsigned int yyaccept = 0;
@@ -463,14 +463,14 @@ yy61:
                { depth = 1;
                                  goto code;
                                }
-#line 467 "<stdout>"
+#line 467 "scanner.cc"
 yy62:
                ++YYCURSOR;
                if((yych = *YYCURSOR) == '*') goto yy121;
 yy63:
 #line 239 "scanner.re"
                { RETURN(*tok); }
-#line 474 "<stdout>"
+#line 474 "scanner.cc"
 yy64:
                ++YYCURSOR;
                if((yych = *YYCURSOR) == '/') goto yy119;
@@ -478,7 +478,7 @@ yy65:
 #line 241 "scanner.re"
                { yylval.op = *tok;
                                  RETURN(CLOSE); }
-#line 482 "<stdout>"
+#line 482 "scanner.cc"
 yy66:
                yyaccept = 1;
                yych = *(YYMARKER = ++YYCURSOR);
@@ -486,7 +486,7 @@ yy66:
 yy67:
 #line 226 "scanner.re"
                { fatal("unterminated string constant (missing \")"); }
-#line 490 "<stdout>"
+#line 490 "scanner.cc"
 yy68:
                yyaccept = 2;
                yych = *(YYMARKER = ++YYCURSOR);
@@ -494,7 +494,7 @@ yy68:
 yy69:
 #line 227 "scanner.re"
                { fatal("unterminated string constant (missing ')"); }
-#line 498 "<stdout>"
+#line 498 "scanner.cc"
 yy70:
                yyaccept = 3;
                yych = *(YYMARKER = ++YYCURSOR);
@@ -504,7 +504,7 @@ yy70:
 yy71:
 #line 237 "scanner.re"
                { fatal("unterminated range (missing ])"); }
-#line 508 "<stdout>"
+#line 508 "scanner.cc"
 yy72:
                yych = *++YYCURSOR;
                goto yy63;
@@ -520,7 +520,7 @@ yy75:
                { cur = cursor;
                                  yylval.symbol = Symbol::find(token());
                                  return ID; }
-#line 524 "<stdout>"
+#line 524 "scanner.cc"
 yy76:
                yych = *++YYCURSOR;
                goto yy90;
@@ -531,7 +531,7 @@ yy77:
                                  yylval.regexp = mkDot();
                                  return RANGE;
                                }
-#line 535 "<stdout>"
+#line 535 "scanner.cc"
 yy79:
                ++YYCURSOR;
                yych = *YYCURSOR;
@@ -539,7 +539,7 @@ yy79:
 yy80:
 #line 277 "scanner.re"
                { goto scan; }
-#line 543 "<stdout>"
+#line 543 "scanner.cc"
 yy81:
                ++YYCURSOR;
 yy82:
@@ -548,7 +548,7 @@ yy82:
                                  pos = cursor; cline++;
                                  goto scan;
                                }
-#line 552 "<stdout>"
+#line 552 "scanner.cc"
 yy83:
                ++YYCURSOR;
                if((yych = *YYCURSOR) == 0x0A) goto yy86;
@@ -560,7 +560,7 @@ yy84:
                                  fatal(msg.str().c_str());
                                  goto scan;
                                }
-#line 564 "<stdout>"
+#line 564 "scanner.cc"
 yy85:
                yych = *++YYCURSOR;
                goto yy84;
@@ -645,7 +645,7 @@ yy98:
                                  yylval.str = new Str(token());
                                  return CONFIG;
                                }
-#line 649 "<stdout>"
+#line 649 "scanner.cc"
 yy99:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -681,7 +681,7 @@ yy104:
                { cur = cursor;
                                  yylval.regexp = ranToRE(token());
                                  return RANGE; }
-#line 685 "<stdout>"
+#line 685 "scanner.cc"
 yy106:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -694,7 +694,7 @@ yy107:
                { cur = cursor;
                                  yylval.regexp = invToRE(token());
                                  return RANGE; }
-#line 698 "<stdout>"
+#line 698 "scanner.cc"
 yy109:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -716,7 +716,7 @@ yy112:
                { cur = cursor;
                                  yylval.regexp = strToCaseInsensitiveRE(token());
                                  return STRING; }
-#line 720 "<stdout>"
+#line 720 "scanner.cc"
 yy114:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -738,19 +738,19 @@ yy117:
                { cur = cursor;
                                  yylval.regexp = strToRE(token());
                                  return STRING; }
-#line 742 "<stdout>"
+#line 742 "scanner.cc"
 yy119:
                ++YYCURSOR;
 #line 215 "scanner.re"
                { tok = cursor;
                                  RETURN(0); }
-#line 748 "<stdout>"
+#line 748 "scanner.cc"
 yy121:
                ++YYCURSOR;
 #line 212 "scanner.re"
                { depth = 1;
                                  goto comment; }
-#line 754 "<stdout>"
+#line 754 "scanner.cc"
 yy123:
                yych = *++YYCURSOR;
                if(yych == ',') goto yy137;
@@ -771,14 +771,14 @@ yy126:
 yy127:
 #line 259 "scanner.re"
                { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); }
-#line 775 "<stdout>"
+#line 775 "scanner.cc"
 yy128:
                ++YYCURSOR;
 #line 247 "scanner.re"
                { yylval.extop.minsize = atoi((char *)tok+1);
                                  yylval.extop.maxsize = atoi((char *)tok+1);
                                  RETURN(CLOSESIZE); }
-#line 782 "<stdout>"
+#line 782 "scanner.cc"
 yy130:
                yyaccept = 6;
                yych = *(YYMARKER = ++YYCURSOR);
@@ -790,7 +790,7 @@ yy130:
                { yylval.extop.minsize = atoi((char *)tok+1);
                                  yylval.extop.maxsize = -1;
                                  RETURN(CLOSESIZE); }
-#line 794 "<stdout>"
+#line 794 "scanner.cc"
 yy133:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -803,7 +803,7 @@ yy133:
                { yylval.extop.minsize = atoi((char *)tok+1);
                                  yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1));
                                  RETURN(CLOSESIZE); }
-#line 807 "<stdout>"
+#line 807 "scanner.cc"
 yy137:
                yyaccept = 6;
                yych = *(YYMARKER = ++YYCURSOR);
@@ -814,7 +814,7 @@ yy137:
 #line 244 "scanner.re"
                { yylval.op = '*';
                                  RETURN(CLOSE); }
-#line 818 "<stdout>"
+#line 818 "scanner.cc"
        }
 }
 #line 290 "scanner.re"
@@ -857,26 +857,27 @@ code:
                192, 192, 192, 192, 192, 192, 192, 192, 
        };
 
-#line 861 "<stdout>"
+#line 861 "scanner.cc"
        {
                YYCTYPE yych;
                if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
                yych = *YYCURSOR;
                if(yych <= '&') {
                        if(yych <= 0x0A) {
-                               if(yych <= 0x09) goto yy148;
+                               if(yych <= 0x00) goto yy148;
+                               if(yych <= 0x09) goto yy150;
                                goto yy146;
                        } else {
-                               if(yych == '"') goto yy150;
-                               goto yy148;
+                               if(yych == '"') goto yy152;
+                               goto yy150;
                        }
                } else {
                        if(yych <= '{') {
-                               if(yych <= '\'') goto yy151;
-                               if(yych <= 'z') goto yy148;
+                               if(yych <= '\'') goto yy153;
+                               if(yych <= 'z') goto yy150;
                                goto yy144;
                        } else {
-                               if(yych != '}') goto yy148;
+                               if(yych != '}') goto yy150;
                        }
                }
                ++YYCURSOR;
@@ -887,13 +888,13 @@ code:
                                        return CODE;
                                  }
                                  goto code; }
-#line 891 "<stdout>"
+#line 892 "scanner.cc"
 yy144:
                ++YYCURSOR;
 #line 300 "scanner.re"
                { ++depth;
                                  goto code; }
-#line 897 "<stdout>"
+#line 898 "scanner.cc"
 yy146:
                ++YYCURSOR;
 #line 302 "scanner.re"
@@ -901,118 +902,128 @@ yy146:
                                  pos = cursor; cline++;
                                  goto code;
                                }
-#line 905 "<stdout>"
+#line 906 "scanner.cc"
 yy148:
                ++YYCURSOR;
-yy149:
 #line 306 "scanner.re"
-               { goto code; }
-#line 911 "<stdout>"
+               { if(cursor == eof) {
+                                       if (depth) fatal("missing '}'");
+                                       RETURN(0);
+                                 }
+                                 goto code;
+                               }
+#line 916 "scanner.cc"
 yy150:
-               yych = *(YYMARKER = ++YYCURSOR);
-               if(yych == 0x0A) goto yy149;
-               goto yy157;
+               ++YYCURSOR;
 yy151:
-               yych = *(YYMARKER = ++YYCURSOR);
-               if(yych == 0x0A) goto yy149;
-               goto yy153;
+#line 312 "scanner.re"
+               { goto code; }
+#line 922 "scanner.cc"
 yy152:
+               yych = *(YYMARKER = ++YYCURSOR);
+               if(yych == 0x0A) goto yy151;
+               goto yy159;
+yy153:
+               yych = *(YYMARKER = ++YYCURSOR);
+               if(yych == 0x0A) goto yy151;
+               goto yy155;
+yy154:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-yy153:
+yy155:
                if(yybm[0+yych] & 64) {
-                       goto yy152;
+                       goto yy154;
                }
-               if(yych <= '&') goto yy154;
-               if(yych <= '\'') goto yy148;
-               goto yy155;
-yy154:
+               if(yych <= '&') goto yy156;
+               if(yych <= '\'') goto yy150;
+               goto yy157;
+yy156:
                YYCURSOR = YYMARKER;
-               goto yy149;
-yy155:
+               goto yy151;
+yy157:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-               if(yych == 0x0A) goto yy154;
-               goto yy152;
-yy156:
+               if(yych == 0x0A) goto yy156;
+               goto yy154;
+yy158:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-yy157:
+yy159:
                if(yybm[0+yych] & 128) {
-                       goto yy156;
+                       goto yy158;
                }
-               if(yych <= '!') goto yy154;
-               if(yych <= '"') goto yy148;
+               if(yych <= '!') goto yy156;
+               if(yych <= '"') goto yy150;
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-               if(yych == 0x0A) goto yy154;
-               goto yy156;
+               if(yych == 0x0A) goto yy156;
+               goto yy158;
        }
 }
-#line 307 "scanner.re"
+#line 313 "scanner.re"
 
 
 comment:
 {
 
-#line 963 "<stdout>"
+#line 974 "scanner.cc"
        {
                YYCTYPE yych;
                if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
                yych = *YYCURSOR;
                if(yych <= ')') {
-                       if(yych == 0x0A) goto yy164;
-                       goto yy166;
+                       if(yych == 0x0A) goto yy166;
+                       goto yy168;
                } else {
-                       if(yych <= '*') goto yy161;
-                       if(yych == '/') goto yy163;
-                       goto yy166;
+                       if(yych <= '*') goto yy163;
+                       if(yych == '/') goto yy165;
+                       goto yy168;
                }
-yy161:
+yy163:
                ++YYCURSOR;
-               if((yych = *YYCURSOR) == '/') goto yy169;
-yy162:
-#line 322 "scanner.re"
+               if((yych = *YYCURSOR) == '/') goto yy171;
+yy164:
+#line 328 "scanner.re"
                { if(cursor == eof) RETURN(0);
                                  goto comment; }
-#line 983 "<stdout>"
-yy163:
+#line 994 "scanner.cc"
+yy165:
                yych = *++YYCURSOR;
-               if(yych == '*') goto yy167;
-               goto yy162;
-yy164:
+               if(yych == '*') goto yy169;
+               goto yy164;
+yy166:
                ++YYCURSOR;
-#line 318 "scanner.re"
+#line 324 "scanner.re"
                { if(cursor == eof) RETURN(0);
                                  tok = pos = cursor; cline++;
                                  goto comment;
                                }
-#line 995 "<stdout>"
-yy166:
+#line 1006 "scanner.cc"
+yy168:
                yych = *++YYCURSOR;
-               goto yy162;
-yy167:
+               goto yy164;
+yy169:
                ++YYCURSOR;
-#line 315 "scanner.re"
+#line 321 "scanner.re"
                { ++depth;
                                  fatal("ambiguous /* found");
                                  goto comment; }
-#line 1005 "<stdout>"
-yy169:
+#line 1016 "scanner.cc"
+yy171:
                ++YYCURSOR;
-#line 311 "scanner.re"
+#line 317 "scanner.re"
                { if(--depth == 0)
                                        goto scan;
                                    else
                                        goto comment; }
-#line 1013 "<stdout>"
+#line 1024 "scanner.cc"
        }
 }
-#line 324 "scanner.re"
+#line 330 "scanner.re"
 
 
 config:
@@ -1052,62 +1063,62 @@ config:
                  0,   0,   0,   0,   0,   0,   0,   0, 
        };
 
-#line 1056 "<stdout>"
+#line 1067 "scanner.cc"
        {
                YYCTYPE yych;
                if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
                yych = *YYCURSOR;
                if(yych <= 0x1F) {
-                       if(yych != 0x09) goto yy177;
+                       if(yych != 0x09) goto yy179;
                } else {
-                       if(yych <= ' ') goto yy173;
-                       if(yych == '=') goto yy175;
-                       goto yy177;
+                       if(yych <= ' ') goto yy175;
+                       if(yych == '=') goto yy177;
+                       goto yy179;
                }
-yy173:
+yy175:
                ++YYCURSOR;
                yych = *YYCURSOR;
-               goto yy182;
-yy174:
-#line 328 "scanner.re"
+               goto yy184;
+yy176:
+#line 334 "scanner.re"
                { goto config; }
-#line 1075 "<stdout>"
-yy175:
+#line 1086 "scanner.cc"
+yy177:
                ++YYCURSOR;
                yych = *YYCURSOR;
-               goto yy180;
-yy176:
-#line 329 "scanner.re"
+               goto yy182;
+yy178:
+#line 335 "scanner.re"
                { iscfg = 2;
                                  cur = cursor;
                                  RETURN('='); 
                                }
-#line 1086 "<stdout>"
-yy177:
+#line 1097 "scanner.cc"
+yy179:
                ++YYCURSOR;
-#line 333 "scanner.re"
+#line 339 "scanner.re"
                { fatal("missing '='"); }
-#line 1091 "<stdout>"
-yy179:
+#line 1102 "scanner.cc"
+yy181:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-yy180:
+yy182:
                if(yybm[0+yych] & 128) {
-                       goto yy179;
+                       goto yy181;
                }
-               goto yy176;
-yy181:
+               goto yy178;
+yy183:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-yy182:
-               if(yych == 0x09) goto yy181;
-               if(yych == ' ') goto yy181;
-               goto yy174;
+yy184:
+               if(yych == 0x09) goto yy183;
+               if(yych == ' ') goto yy183;
+               goto yy176;
        }
 }
-#line 334 "scanner.re"
+#line 340 "scanner.re"
 
 
 value:
@@ -1147,203 +1158,203 @@ value:
                248, 248, 248, 248, 248, 248, 248, 248, 
        };
 
-#line 1151 "<stdout>"
+#line 1162 "scanner.cc"
        {
                YYCTYPE yych;
                if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
                yych = *YYCURSOR;
                if(yych <= '&') {
                        if(yych <= 0x0D) {
-                               if(yych <= 0x08) goto yy191;
-                               if(yych <= 0x0A) goto yy185;
-                               if(yych <= 0x0C) goto yy191;
+                               if(yych <= 0x08) goto yy193;
+                               if(yych <= 0x0A) goto yy187;
+                               if(yych <= 0x0C) goto yy193;
                        } else {
                                if(yych <= ' ') {
-                                       if(yych <= 0x1F) goto yy191;
+                                       if(yych <= 0x1F) goto yy193;
                                } else {
-                                       if(yych == '"') goto yy193;
-                                       goto yy191;
+                                       if(yych == '"') goto yy195;
+                                       goto yy193;
                                }
                        }
                } else {
                        if(yych <= '/') {
-                               if(yych <= '\'') goto yy195;
-                               if(yych == '-') goto yy188;
-                               goto yy191;
+                               if(yych <= '\'') goto yy197;
+                               if(yych == '-') goto yy190;
+                               goto yy193;
                        } else {
                                if(yych <= '9') {
-                                       if(yych <= '0') goto yy186;
-                                       goto yy189;
+                                       if(yych <= '0') goto yy188;
+                                       goto yy191;
                                } else {
-                                       if(yych != ';') goto yy191;
+                                       if(yych != ';') goto yy193;
                                }
                        }
                }
-yy185:
-#line 343 "scanner.re"
+yy187:
+#line 349 "scanner.re"
                { cur = cursor;
                                  yylval.str = new Str(token());
                                  iscfg = 0;
                                  return VALUE;
                                }
-#line 1190 "<stdout>"
-yy186:
+#line 1201 "scanner.cc"
+yy188:
                ++YYCURSOR;
                if(yybm[0+(yych = *YYCURSOR)] & 8) {
-                       goto yy191;
+                       goto yy193;
                }
-yy187:
-#line 338 "scanner.re"
+yy189:
+#line 344 "scanner.re"
                { cur = cursor;
                                  yylval.number = atoi(token().to_string().c_str());
                                  iscfg = 0;
                                  return NUMBER;
                                }
-#line 1203 "<stdout>"
-yy188:
+#line 1214 "scanner.cc"
+yy190:
                yych = *++YYCURSOR;
-               if(yych <= '0') goto yy192;
-               if(yych >= ':') goto yy192;
-yy189:
+               if(yych <= '0') goto yy194;
+               if(yych >= ':') goto yy194;
+yy191:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
                if(yybm[0+yych] & 4) {
-                       goto yy189;
+                       goto yy191;
                }
                if(yych <= 0x0D) {
-                       if(yych <= 0x08) goto yy191;
-                       if(yych <= 0x0A) goto yy187;
-                       if(yych >= 0x0D) goto yy187;
+                       if(yych <= 0x08) goto yy193;
+                       if(yych <= 0x0A) goto yy189;
+                       if(yych >= 0x0D) goto yy189;
                } else {
                        if(yych <= ' ') {
-                               if(yych >= ' ') goto yy187;
+                               if(yych >= ' ') goto yy189;
                        } else {
-                               if(yych == ';') goto yy187;
+                               if(yych == ';') goto yy189;
                        }
                }
-yy191:
+yy193:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-yy192:
+yy194:
                if(yybm[0+yych] & 8) {
-                       goto yy191;
+                       goto yy193;
                }
-               goto yy185;
-yy193:
+               goto yy187;
+yy195:
                YYMARKER = ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
                if(yybm[0+yych] & 16) {
-                       goto yy193;
+                       goto yy195;
                }
                if(yych <= '!') {
-                       if(yych == 0x0A) goto yy185;
-                       goto yy203;
-               } else {
-                       if(yych <= '"') goto yy191;
-                       if(yych <= '[') goto yy203;
+                       if(yych == 0x0A) goto yy187;
                        goto yy205;
+               } else {
+                       if(yych <= '"') goto yy193;
+                       if(yych <= '[') goto yy205;
+                       goto yy207;
                }
-yy195:
+yy197:
                YYMARKER = ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
                if(yybm[0+yych] & 32) {
-                       goto yy195;
+                       goto yy197;
                }
                if(yych <= '&') {
-                       if(yych == 0x0A) goto yy185;
+                       if(yych == 0x0A) goto yy187;
                } else {
-                       if(yych <= '\'') goto yy191;
-                       if(yych >= '\\') goto yy200;
+                       if(yych <= '\'') goto yy193;
+                       if(yych >= '\\') goto yy202;
                }
-yy197:
+yy199:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
                if(yybm[0+yych] & 64) {
-                       goto yy197;
+                       goto yy199;
                }
-               if(yych <= '&') goto yy199;
-               if(yych <= '\'') goto yy201;
-               goto yy202;
-yy199:
+               if(yych <= '&') goto yy201;
+               if(yych <= '\'') goto yy203;
+               goto yy204;
+yy201:
                YYCURSOR = YYMARKER;
-               goto yy185;
-yy200:
+               goto yy187;
+yy202:
                YYMARKER = ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
                if(yych <= 0x0D) {
                        if(yych <= 0x09) {
-                               if(yych <= 0x08) goto yy195;
-                               goto yy197;
+                               if(yych <= 0x08) goto yy197;
+                               goto yy199;
                        } else {
-                               if(yych <= 0x0A) goto yy185;
-                               if(yych <= 0x0C) goto yy195;
-                               goto yy197;
+                               if(yych <= 0x0A) goto yy187;
+                               if(yych <= 0x0C) goto yy197;
+                               goto yy199;
                        }
                } else {
                        if(yych <= ' ') {
-                               if(yych <= 0x1F) goto yy195;
-                               goto yy197;
+                               if(yych <= 0x1F) goto yy197;
+                               goto yy199;
                        } else {
-                               if(yych == ';') goto yy197;
-                               goto yy195;
+                               if(yych == ';') goto yy199;
+                               goto yy197;
                        }
                }
-yy201:
+yy203:
                yych = *++YYCURSOR;
-               goto yy185;
-yy202:
+               goto yy187;
+yy204:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-               if(yych == 0x0A) goto yy199;
-               goto yy197;
-yy203:
+               if(yych == 0x0A) goto yy201;
+               goto yy199;
+yy205:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
                if(yybm[0+yych] & 128) {
-                       goto yy203;
+                       goto yy205;
                }
-               if(yych <= '!') goto yy199;
-               if(yych <= '"') goto yy201;
-               goto yy206;
-yy205:
+               if(yych <= '!') goto yy201;
+               if(yych <= '"') goto yy203;
+               goto yy208;
+yy207:
                YYMARKER = ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
                if(yych <= 0x0D) {
                        if(yych <= 0x09) {
-                               if(yych <= 0x08) goto yy193;
-                               goto yy203;
+                               if(yych <= 0x08) goto yy195;
+                               goto yy205;
                        } else {
-                               if(yych <= 0x0A) goto yy185;
-                               if(yych <= 0x0C) goto yy193;
-                               goto yy203;
+                               if(yych <= 0x0A) goto yy187;
+                               if(yych <= 0x0C) goto yy195;
+                               goto yy205;
                        }
                } else {
                        if(yych <= ' ') {
-                               if(yych <= 0x1F) goto yy193;
-                               goto yy203;
+                               if(yych <= 0x1F) goto yy195;
+                               goto yy205;
                        } else {
-                               if(yych == ';') goto yy203;
-                               goto yy193;
+                               if(yych == ';') goto yy205;
+                               goto yy195;
                        }
                }
-yy206:
+yy208:
                ++YYCURSOR;
                if(YYLIMIT == YYCURSOR) YYFILL(1);
                yych = *YYCURSOR;
-               if(yych == 0x0A) goto yy199;
-               goto yy203;
+               if(yych == 0x0A) goto yy201;
+               goto yy205;
        }
 }
-#line 348 "scanner.re"
+#line 354 "scanner.re"
 
 }
 
index 37885f8a7c53b9aa41b596f4c8c59e7257e408d7..7edf2a386cb65df6eb5ed390184e4f4e22bc9b96 100644 (file)
@@ -28,7 +28,7 @@ void yyerror(const char*);
 
 static re2c::uint accept;
 static RegExp *spec;
-static Scanner *in;
+static Scanner *in = NULL;
 
 /* Bison version 1.875 emits a definition that is not working
  * with several g++ version. Hence we disable it here.
@@ -182,7 +182,7 @@ void yyerror(const char* s)
 }
 
 int yylex(){
-    return in->scan();
+    return in ? in->scan() : 0;
 }
 } // end extern "C"
 
@@ -212,6 +212,7 @@ void parse(Scanner& i, std::ostream& o)
        RegExp::vFreeList.clear();
        Range::vFreeList.clear();
        Symbol::ClearTable();
+       in = NULL;
 }
 
 } // end namespace re2c
index 46ea9581e3a1e26b4872ce1c3ee38dc5e390fcc2..858a0f7dadbb7bd0518e53bff5cb8f72c72b6367 100644 (file)
@@ -299,10 +299,16 @@ code:
                                  goto code; }
        "{"                     { ++depth;
                                  goto code; }
-       "\n"                    { if(cursor == eof) fatal("missing '}'");
+       "\n"            { if(cursor == eof) fatal("missing '}'");
                                  pos = cursor; cline++;
                                  goto code;
                                }
+       zero            { if(cursor == eof) {
+                                       if (depth) fatal("missing '}'");
+                                       RETURN(0);
+                                 }
+                                 goto code;
+                               }
        dstring | sstring | any { goto code; }
 */
 
diff --git a/re2c/test/bug1529351.c b/re2c/test/bug1529351.c
new file mode 100755 (executable)
index 0000000..1a61908
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: line 3, column 9: missing '}'
diff --git a/re2c/test/bug1529351.re b/re2c/test/bug1529351.re
new file mode 100644 (file)
index 0000000..aca7877
--- /dev/null
@@ -0,0 +1,4 @@
+/*!re2c
+
+ "foo"  { func(); { func(); }
+*/