From: helly Date: Sat, 21 Jan 2006 15:51:02 +0000 (+0000) Subject: - Generic fix for oline generation (by providing specialized ostream whose X-Git-Tag: 0.13.6~491 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3dde0b011d56f5f10c191a751f8305750b4f26ca;p=re2c - Generic fix for oline generation (by providing specialized ostream whose stream_buffer count '\n's) - Change re2c:startlabel to 0 (makes more sense and results in clean code) --- diff --git a/Makefile.am b/Makefile.am index 726b537c..0c96da5f 100755 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ bin_PROGRAMS = re2c re2c_SOURCES = code.cc dfa.cc main.cc parser.cc actions.cc scanner.re substr.cc\ translate.cc scanner.cc mbo_getopt.cc \ basics.h dfa.h globals.h ins.h parser.h re.h scanner.h \ - substr.h token.h mbo_getopt.h code.h + substr.h token.h mbo_getopt.h code.h stream_lc.h BUILT_SOURCES = parser.cc scanner.cc man_MANS = re2c.1 diff --git a/bootstrap/parser.cc b/bootstrap/parser.cc index e5257a24..b1c4e004 100644 --- a/bootstrap/parser.cc +++ b/bootstrap/parser.cc @@ -1611,53 +1611,24 @@ int yylex(){ namespace re2c { -void line_source(unsigned int line, std::ostream& o) +void parse(Scanner& i, std::ostream& o) { - if (iFlag) - { - return; - } - - o << "#line " << line << " \""; - - if (fileName == NULL) - { - o << ""; - } - - std::string fname(fileName); - - for (size_t p = 0; p < fname.length(); ++p) - { - if (fname[p] == '\\') - { - fname.insert(++p, "\\"); - } - } - o << fname << "\"\n"; - ++oline; -} - -void parse(std::istream& i, std::ostream &o){ + in = &i; o << "/* Generated by re2c " PACKAGE_VERSION " on "; time_t now = time(&now); o.write(ctime(&now), 24); o << " */\n"; - oline += 2; - - in = new Scanner(i); - - line_source(in->line(), o); + o << sourceFileInfo; - while(in->echo(o)) + while(i.echo(o)) { yyparse(); if(spec) { genCode(o, topIndent, spec); } - line_source(in->line(), o); + o << sourceFileInfo; } } diff --git a/bootstrap/scanner.cc b/bootstrap/scanner.cc index 515e38e9..1e4916db 100644 --- a/bootstrap/scanner.cc +++ b/bootstrap/scanner.cc @@ -1,4 +1,4 @@ -/* Generated by re2c 0.10.0.dev on Fri Jan 20 21:46:02 2006 */ +/* Generated by re2c 0.10.0.dev on Sat Jan 21 16:15:00 2006 */ #line 1 "scanner.re" /* $Id$ */ #include @@ -92,7 +92,6 @@ echo: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); yych = *YYCURSOR; if(yych <= ')') { @@ -111,7 +110,7 @@ yy3: { goto echo; } -#line 115 "scanner.cc" +#line 114 "scanner.cc" yy4: yych = *++YYCURSOR; if(yych == '/') goto yy10; @@ -121,10 +120,10 @@ yy5: #line 126 "scanner.re" { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); - tok = pos = cursor; cline++; oline++; + tok = pos = cursor; cline++; goto echo; } -#line 128 "scanner.cc" +#line 127 "scanner.cc" yy7: ++YYCURSOR; #line 131 "scanner.re" @@ -134,7 +133,7 @@ yy7: RETURN(0); } } -#line 138 "scanner.cc" +#line 137 "scanner.cc" yy9: yych = *++YYCURSOR; goto yy3; @@ -150,7 +149,7 @@ yy10: tok = pos = cursor; goto echo; } -#line 154 "scanner.cc" +#line 153 "scanner.cc" yy12: yych = *++YYCURSOR; if(yych == '!') goto yy14; @@ -182,7 +181,7 @@ yy16: tok = cursor; RETURN(1); } -#line 186 "scanner.cc" +#line 185 "scanner.cc" yy21: yych = *++YYCURSOR; if(yych != 'x') goto yy13; @@ -204,7 +203,7 @@ yy21: ignore_eoc = true; goto echo; } -#line 208 "scanner.cc" +#line 207 "scanner.cc" } #line 140 "scanner.re" @@ -229,7 +228,7 @@ scan: goto value; } -#line 233 "scanner.cc" +#line 232 "scanner.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -307,14 +306,14 @@ yy32: { depth = 1; goto code; } -#line 311 "scanner.cc" +#line 310 "scanner.cc" yy33: ++YYCURSOR; if((yych = *YYCURSOR) == '*') goto yy92; yy34: #line 192 "scanner.re" { RETURN(*tok); } -#line 318 "scanner.cc" +#line 317 "scanner.cc" yy35: ++YYCURSOR; if((yych = *YYCURSOR) == '/') goto yy90; @@ -322,7 +321,7 @@ yy36: #line 194 "scanner.re" { yylval.op = *tok; RETURN(CLOSE); } -#line 326 "scanner.cc" +#line 325 "scanner.cc" yy37: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); @@ -330,7 +329,7 @@ yy37: yy38: #line 179 "scanner.re" { fatal("unterminated string constant (missing \")"); } -#line 334 "scanner.cc" +#line 333 "scanner.cc" yy39: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); @@ -338,7 +337,7 @@ yy39: yy40: #line 180 "scanner.re" { fatal("unterminated string constant (missing ')"); } -#line 342 "scanner.cc" +#line 341 "scanner.cc" yy41: yyaccept = 3; yych = *(YYMARKER = ++YYCURSOR); @@ -348,7 +347,7 @@ yy41: yy42: #line 190 "scanner.re" { fatal("unterminated range (missing ])"); } -#line 352 "scanner.cc" +#line 351 "scanner.cc" yy43: yych = *++YYCURSOR; goto yy34; @@ -364,7 +363,7 @@ yy46: { cur = cursor; yylval.symbol = Symbol::find(token()); return ID; } -#line 368 "scanner.cc" +#line 367 "scanner.cc" yy47: yych = *++YYCURSOR; goto yy61; @@ -375,7 +374,7 @@ yy48: yylval.regexp = mkDot(); return RANGE; } -#line 379 "scanner.cc" +#line 378 "scanner.cc" yy50: ++YYCURSOR; yych = *YYCURSOR; @@ -383,7 +382,7 @@ yy50: yy51: #line 230 "scanner.re" { goto scan; } -#line 387 "scanner.cc" +#line 386 "scanner.cc" yy52: ++YYCURSOR; yy53: @@ -392,7 +391,7 @@ yy53: pos = cursor; cline++; goto scan; } -#line 396 "scanner.cc" +#line 395 "scanner.cc" yy54: ++YYCURSOR; if((yych = *YYCURSOR) == 0x0A) goto yy57; @@ -410,7 +409,7 @@ yy55: } goto scan; } -#line 414 "scanner.cc" +#line 413 "scanner.cc" yy56: yych = *++YYCURSOR; goto yy55; @@ -495,7 +494,7 @@ yy69: yylval.str = new Str(token()); return CONFIG; } -#line 499 "scanner.cc" +#line 498 "scanner.cc" yy70: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -533,7 +532,7 @@ yy75: { cur = cursor; yylval.regexp = ranToRE(token()); return RANGE; } -#line 537 "scanner.cc" +#line 536 "scanner.cc" yy77: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -546,7 +545,7 @@ yy78: { cur = cursor; yylval.regexp = invToRE(token()); return RANGE; } -#line 550 "scanner.cc" +#line 549 "scanner.cc" yy80: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -570,7 +569,7 @@ yy83: { cur = cursor; yylval.regexp = strToCaseInsensitiveRE(token()); return STRING; } -#line 574 "scanner.cc" +#line 573 "scanner.cc" yy85: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -594,19 +593,19 @@ yy88: { cur = cursor; yylval.regexp = strToRE(token()); return STRING; } -#line 598 "scanner.cc" +#line 597 "scanner.cc" yy90: ++YYCURSOR; #line 168 "scanner.re" { tok = cursor; RETURN(0); } -#line 604 "scanner.cc" +#line 603 "scanner.cc" yy92: ++YYCURSOR; #line 165 "scanner.re" { depth = 1; goto comment; } -#line 610 "scanner.cc" +#line 609 "scanner.cc" yy94: yych = *++YYCURSOR; if(yych == ',') goto yy108; @@ -629,14 +628,14 @@ yy97: yy98: #line 212 "scanner.re" { fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); } -#line 633 "scanner.cc" +#line 632 "scanner.cc" yy99: ++YYCURSOR; #line 200 "scanner.re" { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = atoi((char *)tok+1); RETURN(CLOSESIZE); } -#line 640 "scanner.cc" +#line 639 "scanner.cc" yy101: yyaccept = 6; yych = *(YYMARKER = ++YYCURSOR); @@ -648,7 +647,7 @@ yy101: { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = -1; RETURN(CLOSESIZE); } -#line 652 "scanner.cc" +#line 651 "scanner.cc" yy104: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -661,7 +660,7 @@ yy104: { yylval.extop.minsize = atoi((char *)tok+1); yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1)); RETURN(CLOSESIZE); } -#line 665 "scanner.cc" +#line 664 "scanner.cc" yy108: yyaccept = 6; yych = *(YYMARKER = ++YYCURSOR); @@ -672,14 +671,14 @@ yy108: #line 197 "scanner.re" { yylval.op = '*'; RETURN(CLOSE); } -#line 676 "scanner.cc" +#line 675 "scanner.cc" } #line 249 "scanner.re" code: -#line 683 "scanner.cc" +#line 682 "scanner.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -710,13 +709,13 @@ code: return CODE; } goto code; } -#line 714 "scanner.cc" +#line 713 "scanner.cc" yy115: ++YYCURSOR; #line 259 "scanner.re" { ++depth; goto code; } -#line 720 "scanner.cc" +#line 719 "scanner.cc" yy117: ++YYCURSOR; #line 261 "scanner.re" @@ -724,13 +723,13 @@ yy117: pos = cursor; cline++; goto code; } -#line 728 "scanner.cc" +#line 727 "scanner.cc" yy119: ++YYCURSOR; yy120: #line 265 "scanner.re" { goto code; } -#line 734 "scanner.cc" +#line 733 "scanner.cc" yy121: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); @@ -787,7 +786,7 @@ yy128: comment: -#line 791 "scanner.cc" +#line 790 "scanner.cc" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -807,7 +806,7 @@ yy133: #line 281 "scanner.re" { if(cursor == eof) RETURN(0); goto comment; } -#line 811 "scanner.cc" +#line 810 "scanner.cc" yy134: yych = *++YYCURSOR; if(yych == '*') goto yy138; @@ -819,7 +818,7 @@ yy135: tok = pos = cursor; cline++; goto comment; } -#line 823 "scanner.cc" +#line 822 "scanner.cc" yy137: yych = *++YYCURSOR; goto yy133; @@ -829,7 +828,7 @@ yy138: { ++depth; fatal("ambiguous /* found"); goto comment; } -#line 833 "scanner.cc" +#line 832 "scanner.cc" yy140: ++YYCURSOR; #line 270 "scanner.re" @@ -837,14 +836,14 @@ yy140: goto scan; else goto comment; } -#line 841 "scanner.cc" +#line 840 "scanner.cc" } #line 283 "scanner.re" config: -#line 848 "scanner.cc" +#line 847 "scanner.cc" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -863,7 +862,7 @@ yy144: yy145: #line 287 "scanner.re" { goto config; } -#line 867 "scanner.cc" +#line 866 "scanner.cc" yy146: ++YYCURSOR; yych = *YYCURSOR; @@ -874,12 +873,12 @@ yy147: cur = cursor; RETURN('='); } -#line 878 "scanner.cc" +#line 877 "scanner.cc" yy148: ++YYCURSOR; #line 292 "scanner.re" { fatal("missing '='"); } -#line 883 "scanner.cc" +#line 882 "scanner.cc" yy150: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -902,7 +901,7 @@ yy153: value: -#line 906 "scanner.cc" +#line 905 "scanner.cc" { YYCTYPE yych; unsigned int yyaccept = 0; @@ -942,7 +941,7 @@ yy156: iscfg = 0; return VALUE; } -#line 946 "scanner.cc" +#line 945 "scanner.cc" yy157: ++YYCURSOR; if((yych = *YYCURSOR) <= 0x0D) { @@ -963,7 +962,7 @@ yy158: iscfg = 0; return NUMBER; } -#line 967 "scanner.cc" +#line 966 "scanner.cc" yy159: yych = *++YYCURSOR; if(yych <= '0') goto yy163; diff --git a/code.cc b/code.cc index 24b5e1c6..d913fa6a 100644 --- a/code.cc +++ b/code.cc @@ -229,7 +229,6 @@ void BitMap::gen(std::ostream &o, uint ind, uint lb, uint ub) if (j % 8 == 0) { o << "\n" << indent(ind+1); - ++oline; } if (yybmHexTable) @@ -245,7 +244,6 @@ void BitMap::gen(std::ostream &o, uint ind, uint lb, uint ub) } o << "\n" << indent(ind) << "};\n"; - oline += 2; } } @@ -269,12 +267,10 @@ void genGoTo(std::ostream &o, uint ind, const State *from, const State *to, bool if (readCh && from->label + 1 != to->label) { o << indent(ind) << "yych = *YYCURSOR;\n"; - ++oline; readCh = false; } o << indent(ind) << "goto yy" << to->label << ";\n"; - ++oline; vUsedLabels.insert(to->label); } @@ -304,7 +300,6 @@ static void need(std::ostream &o, uint ind, uint n, bool & readCh) { fillIndex = vFillIndexes++; o << indent(ind) << "YYSETSTATE(" << fillIndex << ");\n"; - ++oline; } else { @@ -314,23 +309,19 @@ static void need(std::ostream &o, uint ind, uint n, bool & readCh) if (n == 1) { o << indent(ind) << "if(YYLIMIT == YYCURSOR) YYFILL(1);\n"; - ++oline; } else { o << indent(ind) << "if((YYLIMIT - YYCURSOR) < " << n << ") YYFILL(" << n << ");\n"; - ++oline; } if ( hasFillIndex == true ) { o << "yyFillLabel" << fillIndex << ":\n"; - ++oline; } o << indent(ind) << "yych = *YYCURSOR;\n"; readCh = false; - ++oline; } void Match::emit(std::ostream &o, uint ind, bool &readCh) const @@ -351,8 +342,6 @@ void Match::emit(std::ostream &o, uint ind, bool &readCh) const readCh = false; } - ++oline; - if (state->link) { need(o, ind, state->depth, readCh); @@ -364,11 +353,9 @@ void Enter::emit(std::ostream &o, uint ind, bool &readCh) const if (state->link) { o << indent(ind) << "++YYCURSOR;\n"; - oline++; if (vUsedLabels.count(label)) { o << "yy" << label << ":\n"; - oline++; } need(o, ind, state->depth, readCh); } @@ -376,11 +363,9 @@ void Enter::emit(std::ostream &o, uint ind, bool &readCh) const { /* we shouldn't need 'rule-following' protection here */ o << indent(ind) << "yych = *++YYCURSOR;\n"; - oline++; if (vUsedLabels.count(label)) { o << "yy" << label << ":\n"; - oline++; } readCh = false; } @@ -391,12 +376,14 @@ void Initial::emit(std::ostream &o, uint ind, bool &readCh) const if (!startLabelName.empty()) { o << startLabelName << ":\n"; - oline++; } if (vUsedLabels.count(label)) { o << "yy" << label << ":\n"; - oline++; + } + else if (!label) + { + o << "\n"; } if (state->link) { @@ -413,19 +400,16 @@ void Save::emit(std::ostream &o, uint ind, bool &readCh) const if (bUsedYYAccept) { o << indent(ind) << "yyaccept = " << selector << ";\n"; - ++oline; } if (state->link) { o << indent(ind) << "YYMARKER = ++YYCURSOR;\n"; - ++oline; need(o, ind, state->depth, readCh); } else { o << indent(ind) << "yych = *(YYMARKER = ++YYCURSOR);\n"; - ++oline; readCh = false; } } @@ -459,7 +443,6 @@ void Accept::emit(std::ostream &o, uint ind, bool &readCh) const bUsedYYAccept = true; o << indent(ind) << "YYCURSOR = YYMARKER;\n"; o << indent(ind) << "switch(yyaccept){\n"; - oline += 2; } o << indent(ind) << "case " << saves[i] << ":"; @@ -469,7 +452,6 @@ void Accept::emit(std::ostream &o, uint ind, bool &readCh) const if (!first) { o << indent(ind) << "}\n"; - ++oline; } } @@ -485,21 +467,15 @@ void Rule::emit(std::ostream &o, uint ind, bool &) const if (back != 0u) { o << indent(ind) << "YYCURSOR = yyctxmarker;\n"; - oline++; } - line_source(rule->code->line, o); + RuleLine rl(*rule); + + o << file_info(sourceFileInfo, &rl); o << indent(ind); o << rule->code->text; - // Counting the oline's is done by SubStr::out() o << "\n"; - ++oline; - if (!iFlag) - { - o << "#line " << oline++ << " \"" << outputFileName << "\"\n"; - // o << "\n#line " << rule->code->line - // << "\n\t" << rule->code->text << "\n"; - } + o << outputFileInfo; } void doLinear(std::ostream &o, uint ind, Span *s, uint n, const State *from, const State *next, bool &readCh, uint mask) @@ -589,7 +565,6 @@ bool genCases(std::ostream &o, uint ind, uint lb, Span *s, bool &newLine, uint m if (!newLine) { o << "\n"; - ++oline; } newLine = true; if (lb < s->ub) @@ -611,7 +586,6 @@ bool genCases(std::ostream &o, uint ind, uint lb, Span *s, bool &newLine, uint m } o << "\n"; - ++oline; newLine = true; } } @@ -644,7 +618,6 @@ void Go::genSwitch(std::ostream &o, uint ind, const State *from, const State *ne if (dFlag) { o << indent(ind) << "YYDEBUG(-1, yych);\n"; - ++oline; } if (readCh) @@ -657,8 +630,6 @@ void Go::genSwitch(std::ostream &o, uint ind, const State *from, const State *ne o << indent(ind) << "switch(yych){\n"; } - ++oline; - while (t != &sP[0]) { bool used = false; @@ -699,7 +670,6 @@ void Go::genSwitch(std::ostream &o, uint ind, const State *from, const State *ne o << indent(ind) << "default:"; genGoTo(o, 1, from, def, readCh); o << indent(ind) << "}\n"; - ++oline; delete [] sP; } @@ -717,13 +687,10 @@ void doBinary(std::ostream &o, uint ind, Span *s, uint n, const State *from, con genIf(o, ind, "<=", s[h - 1].ub - 1, readCh); o << "{\n"; - ++oline; doBinary(o, ind+1, &s[0], h, from, next, readCh, mask); o << indent(ind) << "} else {\n"; - ++oline; doBinary(o, ind+1, &s[h], n - h, from, next, readCh, mask); o << indent(ind) << "}\n"; - ++oline; } } @@ -837,13 +804,10 @@ void Go::genGoto(std::ostream &o, uint ind, const State *from, const State *next if (readCh) { o << indent(ind) << "yych = *YYCURSOR;\n"; - oline++; readCh = false; } sYych = "yych"; o << indent(ind) << "if(yyh & 0xFF00) {\n"; - oline++; - /* here we need to reduce to those having high byte set */ genBase(o, ind+1, from, next, readCh, 1); o << indent(ind) << "} else "; } @@ -868,10 +832,8 @@ void Go::genGoto(std::ostream &o, uint ind, const State *from, const State *next o << (uint) b->m; } o << ") {\n"; - oline++; genGoTo(o, ind+1, from, to, readCh); o << indent(ind) << "}\n"; - oline++; go.genBase(o, ind, from, next, readCh, 0); delete [] go.span; return ; @@ -888,17 +850,14 @@ void State::emit(std::ostream &o, uint ind, bool &readCh) const if (vUsedLabels.count(label)) { o << "yy" << label << ":\n"; - oline++; } if (dFlag) { o << indent(ind) << "YYDEBUG(" << label << ", *YYCURSOR);\n"; - oline++; } if (isPreCtxt) { o << indent(ind) << "yyctxmarker = YYCURSOR + 1;\n"; - oline++; bUsedCtxMarker = true; } action->emit(o, ind, readCh); @@ -1357,7 +1316,6 @@ void DFA::emit(std::ostream &o, uint ind) if (bFlag) { o << indent(ind++) << "{\n"; - ++oline; bitmap_brace = 1; BitMap::gen(o, ind, lbChar, ubChar <= 256 ? ubChar : 256); } @@ -1381,49 +1339,38 @@ void DFA::emit(std::ostream &o, uint ind) s->label = label++; } - null_stream noWhere; - unsigned int nOrgOline = oline; uint maxFillIndexes = vFillIndexes; uint orgVFillIndexes = vFillIndexes; + null_stream null_dev; for (s = head; s; s = s->next) { bool readCh = false; - s->emit(noWhere, ind, readCh); - s->go.genGoto(noWhere, ind, s, s->next, readCh); + s->emit(null_dev, ind, readCh); + s->go.genGoto(null_dev, ind, s, s->next, readCh); } maxFillIndexes = vFillIndexes; vFillIndexes = orgVFillIndexes; - oline = nOrgOline; - o << "\n"; - ++oline; - if (!iFlag) - { - o << "#line " << oline++ << " \"" << outputFileName << "\"\n"; - } + o << "\n" << outputFileInfo; if (hasFillLabels == false) { o << indent(ind++) << "{\n"; o << indent(ind) << "YYCTYPE yych;\n"; - oline += 2; if (bUsedYYAccept) { o << indent(ind) << "unsigned int yyaccept = 0;\n"; - oline++; } } else { o << indent(ind++) << "{\n\n"; - oline += 2; } if (bUsedCtxMarker) { o << indent(ind) << "YYCTYPE *yyctxmarker = YYCURSOR;\n"; - ++oline; } if (hasFillLabels == true) @@ -1441,9 +1388,6 @@ void DFA::emit(std::ostream &o, uint ind) o << indent(ind) << "default: /* abort() */;\n"; o << indent(ind) << "}\n"; o << "yyNext:\n"; - - oline += maxFillIndexes; - oline += 6; } for (s = head; s; s = s->next) @@ -1454,11 +1398,9 @@ void DFA::emit(std::ostream &o, uint ind) } o << indent(--ind) << "}\n"; - ++oline; if (bitmap_brace) { o << indent(--ind) << "}\n"; - ++oline; } if (BitMap::first) @@ -1473,6 +1415,20 @@ void DFA::emit(std::ostream &o, uint ind) bUseStartLabel = false; } +std::ostream& operator << (std::ostream& o, const file_info& li) +{ + if (li.ln) + { + o << "#line " << li.ln->get_line() << " \"" << li.fname << "\"\n"; + } + return o; +} + +uint Scanner::get_line() const +{ + return cline; +} + void Scanner::config(const Str& cfg, int num) { if (cfg.to_string() == "indent:top") diff --git a/code.h b/code.h index b7643157..12b735e5 100755 --- a/code.h +++ b/code.h @@ -44,52 +44,10 @@ public: #endif }; -template -class basic_null_streambuf - : public std::basic_streambuf -{ -public: - basic_null_streambuf() - : std::basic_streambuf() - { - } -}; - #ifdef _MSC_VER # pragma warning(disable: 4355) /* 'this' : used in base member initializer list */ #endif -template -class basic_null_stream - : protected basic_null_streambuf - , public std::basic_ostream -{ -public: - basic_null_stream() - : basic_null_streambuf() - , std::basic_ostream(static_cast*>(this)) - { - } - - basic_null_stream& put(char_t) - { - // nothing to do - return *this; - } - - basic_null_stream& write(const char_t *, std::streamsize) - { - // nothing to do - return *this; - } -}; - -#ifdef _MSC_VER -# pragma warning(default: 4355) -#endif - -typedef basic_null_stream null_stream; - } // end namespace re2c #endif diff --git a/dfa.cc b/dfa.cc index 68ab6b79..2d3779f4 100644 --- a/dfa.cc +++ b/dfa.cc @@ -44,7 +44,7 @@ void prtHex(std::ostream& o, uint c, bool useTalx) } } -void prtCh(std::ostream &o, uint c, bool useTalx) +void prtCh(std::ostream& o, uint c, bool useTalx) { int oc = (int)(re2c::wFlag || !useTalx ? c : re2c::talx[c]); @@ -107,7 +107,7 @@ void prtCh(std::ostream &o, uint c, bool useTalx) } } -void printSpan(std::ostream &o, uint lb, uint ub) +void printSpan(std::ostream& o, uint lb, uint ub) { if (lb > ub) { @@ -152,8 +152,6 @@ std::ostream& operator<<(std::ostream &o, const State &s) o << "\n"; - ++oline; - uint lb = 0; for (uint i = 0; i < s.go.nSpans; ++i) @@ -169,7 +167,6 @@ std::ostream& operator<<(std::ostream &o, const DFA &dfa) for (State *s = dfa.head; s; s = s->next) { o << s << "\n\n"; - ++oline; } return o; diff --git a/globals.h b/globals.h index 18b590b7..d9e2b511 100644 --- a/globals.h +++ b/globals.h @@ -6,12 +6,14 @@ #include #include #include +#include "stream_lc.h" namespace re2c { -extern const char *fileName; -extern const char *outputFileName; +extern file_info sourceFileInfo; +extern file_info outputFileInfo; + extern bool bFlag; extern bool dFlag; extern bool eFlag; @@ -23,7 +25,6 @@ extern bool bUsedYYAccept; extern bool bUsedCtxMarker; extern bool bUseStartLabel; extern std::string startLabelName; -extern unsigned int oline; extern uint maxFill; /* configurations */ diff --git a/main.cc b/main.cc index 5e1a6e86..0f53af34 100644 --- a/main.cc +++ b/main.cc @@ -19,18 +19,22 @@ namespace re2c { const char *fileName = 0; +file_info sourceFileInfo; const char *outputFileName = 0; +file_info outputFileInfo; +std::ostream *output; + bool bFlag = false; bool dFlag = false; bool eFlag = false; bool iFlag = false; bool sFlag = false; bool wFlag = false; + bool bUsedYYAccept = false; bool bUsedCtxMarker= false; -bool bUseStartLabel= true; +bool bUseStartLabel= false; std::string startLabelName; -unsigned int oline = 1; uint maxFill = 1; uint topIndent = 0; @@ -231,46 +235,39 @@ int main(int argc, char *argv[]) } // set up the output stream - ostream* output = 0; - - ofstream outputFile; + ofstream_lc outputFile; if (outputFileName == 0 || (fileName[0] == '-' && fileName[1] == '\0')) { outputFileName = ""; - output = &cout; + outputFile.open(stdout); + output = &outputFile; } else { outputFile.open(outputFileName); + output = &outputFile; if (!outputFile) { cerr << "can't open " << outputFileName << "\n"; return 1; } + } - output = &outputFile; - - int len = strlen(outputFileName); - char *tmp = (char*)malloc((len+1)*2); - char *dst = tmp; + if (fileName == NULL) + { + fileName = ""; + } - for (const char *src = outputFileName; *src; ++src) - { - if (*src == '\\') - { - *dst++ = *src; - } - *dst++ = *src; - } - *dst = '\0'; - - outputFileName = tmp; + Scanner in(*input); + + if (!iFlag) + { + sourceFileInfo = file_info(fileName, &in); + outputFileInfo = file_info(outputFileName, &outputFile); } - parse(*input, *output); + parse(in, *output); return 0; - } - diff --git a/parser.h b/parser.h index 7abc0d37..53214182 100644 --- a/parser.h +++ b/parser.h @@ -54,8 +54,7 @@ private: #endif }; -void line_source(unsigned int, std::ostream&); -void parse(std::istream&, std::ostream&); +void parse(Scanner&, std::ostream&); } // end namespace re2c diff --git a/parser.y b/parser.y index a93d1c15..c9d3109b 100644 --- a/parser.y +++ b/parser.y @@ -185,53 +185,24 @@ int yylex(){ namespace re2c { -void line_source(unsigned int line, std::ostream& o) +void parse(Scanner& i, std::ostream& o) { - if (iFlag) - { - return; - } - - o << "#line " << line << " \""; - - if (fileName == NULL) - { - o << ""; - } - - std::string fname(fileName); - - for (size_t p = 0; p < fname.length(); ++p) - { - if (fname[p] == '\\') - { - fname.insert(++p, "\\"); - } - } - o << fname << "\"\n"; - ++oline; -} - -void parse(std::istream& i, std::ostream &o){ + in = &i; o << "/* Generated by re2c " PACKAGE_VERSION " on "; time_t now = time(&now); o.write(ctime(&now), 24); o << " */\n"; - oline += 2; - - in = new Scanner(i); - - line_source(in->line(), o); + o << sourceFileInfo; - while(in->echo(o)) + while(i.echo(o)) { yyparse(); if(spec) { genCode(o, topIndent, spec); } - line_source(in->line(), o); + o << sourceFileInfo; } } diff --git a/re.h b/re.h index 4742e757..d0367f4d 100644 --- a/re.h +++ b/re.h @@ -211,6 +211,23 @@ private: #endif }; +class RuleLine: public line_number +{ +public: + + RuleLine(const RuleOp& _op) + : op(_op) + { + } + + uint get_line() const + { + return op.code->line; + } + + const RuleOp& op; +}; + class AltOp: public RegExp { diff --git a/re2c-2005.vcproj b/re2c-2005.vcproj index 3a86eb40..25cc57a2 100755 --- a/re2c-2005.vcproj +++ b/re2c-2005.vcproj @@ -246,6 +246,10 @@ RelativePath="basics.h" > + + @@ -282,6 +286,10 @@ RelativePath="scanner.h" > + + diff --git a/re2c.1.in b/re2c.1.in index 06270290..2a39acdc 100644 --- a/re2c.1.in +++ b/re2c.1.in @@ -7,6 +7,11 @@ .ds rx regular expression .ds lx \fIl\fP-expression \"$Log$ +\"Revision 1.39 2006/01/21 15:51:02 helly +\"- Generic fix for oline generation (by providing specialized ostream whose +\" stream_buffer count '\n's) +\"- Change re2c:startlabel to 0 (makes more sense and results in clean code) +\" \"Revision 1.38 2006/01/20 20:53:59 helly \"- Update docu \" @@ -512,7 +517,7 @@ not want any indendation at all you can simply set this to \fB""\fP. If set to zero then a decimal table is being used else a hexadecimal table will be generated. .TP -\fIre2c:startlabel\fP \fB=\fP 1 \fB;\fP +\fIre2c:startlabel\fP \fB=\fP 0 \fB;\fP If set to a non zero integer then the start label of the next scanner blocks will be generated even if not used by the scanner itself. Otherwise the normal \fByy0\fP like start label is only being generated if needed. If set to a text diff --git a/re2c.vcproj b/re2c.vcproj index a8edba6c..03bced3e 100755 --- a/re2c.vcproj +++ b/re2c.vcproj @@ -151,6 +151,9 @@ + + @@ -178,6 +181,9 @@ + + diff --git a/scanner.h b/scanner.h index 4bcb87a2..e863cb62 100644 --- a/scanner.h +++ b/scanner.h @@ -11,9 +11,9 @@ namespace re2c { -class Scanner +class Scanner: + public line_number { - private: std::istream& in; char *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof; @@ -36,7 +36,7 @@ public: void config(const Str&, const Str&); SubStr token() const; - uint line() const; + virtual uint get_line() const; uint xlat(uint c) const; uint unescape(SubStr &s) const; @@ -57,11 +57,6 @@ inline SubStr Scanner::token() const return SubStr(tok, cur - tok); } -inline uint Scanner::line() const -{ - return cline; -} - inline uint Scanner::xlat(uint c) const { return re2c::wFlag ? c : re2c::xlat[c]; diff --git a/scanner.re b/scanner.re index 16e957b5..583cb8aa 100644 --- a/scanner.re +++ b/scanner.re @@ -125,7 +125,7 @@ echo: } "\n" { out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); - tok = pos = cursor; cline++; oline++; + tok = pos = cursor; cline++; goto echo; } zero { diff --git a/substr.cc b/substr.cc index 67c5cace..0a5d87f3 100644 --- a/substr.cc +++ b/substr.cc @@ -22,9 +22,6 @@ namespace re2c void SubStr::out(std::ostream& o) const { o.write(str, len); - oline += std::count(str, str + len, '\n'); - // This is only to be used in Rule::emit(), if this is going to change then - // oline counting must be done there and probably in other emit()'s, too. } bool operator==(const SubStr &s1, const SubStr &s2) diff --git a/test/bug1054496.c b/test/bug1054496.c index 7a4c8711..78a636b6 100755 --- a/test/bug1054496.c +++ b/test/bug1054496.c @@ -23,7 +23,7 @@ cont: #line 24 "" { YYCTYPE yych; -yy0: + if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych){ diff --git a/test/bug1163046.c b/test/bug1163046.c index 8800c0b3..5eb541b6 100755 --- a/test/bug1163046.c +++ b/test/bug1163046.c @@ -20,7 +20,7 @@ next: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 45) YYFILL(45); yych = *YYCURSOR; switch(yych){ diff --git a/test/bug1187785.c b/test/bug1187785.c index de99df19..bc1639c0 100755 --- a/test/bug1187785.c +++ b/test/bug1187785.c @@ -24,7 +24,7 @@ cont: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ diff --git a/test/bug1297658.c b/test/bug1297658.c index 9281abf8..7fda0fed 100644 --- a/test/bug1297658.c +++ b/test/bug1297658.c @@ -61,7 +61,7 @@ std: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch(yych){ diff --git a/test/bug1390174.c b/test/bug1390174.c index e55603be..07810627 100755 --- a/test/bug1390174.c +++ b/test/bug1390174.c @@ -19,7 +19,7 @@ const char *q; { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ diff --git a/test/c.c b/test/c.c index fe3246e9..8f5587e3 100644 --- a/test/c.c +++ b/test/c.c @@ -130,7 +130,7 @@ std: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 9) YYFILL(9); yych = *YYCURSOR; switch(yych){ diff --git a/test/cmmap.c b/test/cmmap.c index 377401c7..097d93ab 100644 --- a/test/cmmap.c +++ b/test/cmmap.c @@ -113,7 +113,7 @@ std: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 9) YYFILL(9); yych = *YYCURSOR; switch(yych){ diff --git a/test/cnokw.c b/test/cnokw.c index fe9d1b29..a81520b2 100644 --- a/test/cnokw.c +++ b/test/cnokw.c @@ -130,7 +130,7 @@ std: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 5) YYFILL(5); yych = *YYCURSOR; switch(yych){ diff --git a/test/config1.c b/test/config1.c index 3a0c0a14..61fce81e 100755 --- a/test/config1.c +++ b/test/config1.c @@ -14,7 +14,7 @@ char *scan0(char *p) #line 15 "" { YYCTYPE yych; -yy0: + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ diff --git a/test/config2.s.c b/test/config2.s.c index 22893c08..57feb23a 100755 --- a/test/config2.s.c +++ b/test/config2.s.c @@ -14,7 +14,7 @@ char *scan0(char *p) #line 15 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; if(yych <= 'b') { diff --git a/test/config3.c b/test/config3.c index a5cc784c..10c0c688 100755 --- a/test/config3.c +++ b/test/config3.c @@ -14,6 +14,7 @@ char *scan0(char *p) #line 15 "" { YYCTYPE yych; + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ @@ -36,12 +37,12 @@ yy2: yy3: #line 13 "config3.re" { return YYCURSOR; } -#line 40 "" +#line 41 "" yy4: ++YYCURSOR; #line 14 "config3.re" { return NULL; } -#line 45 "" +#line 46 "" yy6: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -69,7 +70,7 @@ char *scan1(char *p) { char *q; -#line 73 "" +#line 74 "" { YYCTYPE yych; yy8: @@ -95,12 +96,12 @@ yy10: yy11: #line 23 "config3.re" { return YYCURSOR; } -#line 99 "" +#line 100 "" yy12: ++YYCURSOR; #line 24 "config3.re" { return NULL; } -#line 104 "" +#line 105 "" yy14: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -128,7 +129,7 @@ char *scan2(char *p) { char *q; -#line 132 "" +#line 133 "" { YYCTYPE yych; startLabel: @@ -154,12 +155,12 @@ yy18: yy19: #line 33 "config3.re" { return YYCURSOR; } -#line 158 "" +#line 159 "" yy20: ++YYCURSOR; #line 34 "config3.re" { return NULL; } -#line 163 "" +#line 164 "" yy22: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); @@ -187,7 +188,7 @@ char *scan(char *p) { char *q; -#line 191 "" +#line 192 "" { YYCTYPE yych; if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); @@ -212,12 +213,12 @@ yy26: yy27: #line 43 "config3.re" { return YYCURSOR; } -#line 216 "" +#line 217 "" yy28: ++YYCURSOR; #line 44 "config3.re" { return NULL; } -#line 221 "" +#line 222 "" yy30: ++YYCURSOR; if(YYLIMIT == YYCURSOR) YYFILL(1); diff --git a/test/ctx.b.c b/test/ctx.b.c index 9da2f5d7..1606dc4d 100755 --- a/test/ctx.b.c +++ b/test/ctx.b.c @@ -83,7 +83,7 @@ std: { YYCTYPE yych; YYCTYPE *yyctxmarker = YYCURSOR; -yy0: + if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; if(yych <= ' ') { diff --git a/test/ctx.c b/test/ctx.c index b2a52f27..0ea67f15 100755 --- a/test/ctx.c +++ b/test/ctx.c @@ -48,7 +48,7 @@ std: { YYCTYPE yych; YYCTYPE *yyctxmarker = YYCURSOR; -yy0: + if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; switch(yych){ diff --git a/test/ctx.s.c b/test/ctx.s.c index 754c4c64..58b07c8b 100755 --- a/test/ctx.s.c +++ b/test/ctx.s.c @@ -48,7 +48,7 @@ std: { YYCTYPE yych; YYCTYPE *yyctxmarker = YYCURSOR; -yy0: + if((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; if(yych <= ' ') { diff --git a/test/cunroll.c b/test/cunroll.c index a677acff..7baa107b 100644 --- a/test/cunroll.c +++ b/test/cunroll.c @@ -130,7 +130,7 @@ std: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 9) YYFILL(9); yych = *YYCURSOR; switch(yych){ diff --git a/test/cvsignore.b.c b/test/cvsignore.b.c index b4c2f40b..fe0d91c3 100755 --- a/test/cvsignore.b.c +++ b/test/cvsignore.b.c @@ -78,7 +78,7 @@ loop: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); yych = *YYCURSOR; if(yych != '$') goto yy4; diff --git a/test/cvsignore.c b/test/cvsignore.c index 36aab03d..76a41d58 100755 --- a/test/cvsignore.c +++ b/test/cvsignore.c @@ -43,7 +43,7 @@ loop: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); yych = *YYCURSOR; switch(yych){ diff --git a/test/cvsignore.s.c b/test/cvsignore.s.c index e354eb2d..dcb168e4 100755 --- a/test/cvsignore.s.c +++ b/test/cvsignore.s.c @@ -43,7 +43,7 @@ loop: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); yych = *YYCURSOR; if(yych != '$') goto yy4; diff --git a/test/cvsignore.w.c b/test/cvsignore.w.c index 658bccf1..56d8b060 100755 --- a/test/cvsignore.w.c +++ b/test/cvsignore.w.c @@ -43,7 +43,7 @@ loop: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); yych = *YYCURSOR; if(yych != '$') goto yy4; diff --git a/test/cvsignore.wb.c b/test/cvsignore.wb.c index 4995ad79..eb352d89 100755 --- a/test/cvsignore.wb.c +++ b/test/cvsignore.wb.c @@ -78,7 +78,7 @@ loop: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 11) YYFILL(11); yych = *YYCURSOR; if(yych != '$') goto yy4; diff --git a/test/error3.c b/test/error3.c index 86d0c72d..2369521d 100755 --- a/test/error3.c +++ b/test/error3.c @@ -19,7 +19,7 @@ const char *q; #line 19 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ diff --git a/test/input1.c b/test/input1.c index ad323496..e0dac0dc 100644 --- a/test/input1.c +++ b/test/input1.c @@ -5,7 +5,7 @@ { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ diff --git a/test/input10.b.c b/test/input10.b.c index 27ec28bd..a1c206f2 100755 --- a/test/input10.b.c +++ b/test/input10.b.c @@ -5,7 +5,7 @@ #line 6 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; if(yych <= 'E') { diff --git a/test/input10.c b/test/input10.c index 9afb190f..f8f13f6d 100755 --- a/test/input10.c +++ b/test/input10.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ diff --git a/test/input10.s.c b/test/input10.s.c index ca203573..0d00db9f 100755 --- a/test/input10.s.c +++ b/test/input10.s.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; if(yych <= 'E') { diff --git a/test/input11.b.c b/test/input11.b.c index 1da8ed77..63af3e41 100755 --- a/test/input11.b.c +++ b/test/input11.b.c @@ -40,7 +40,7 @@ { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 6) YYFILL(6); yych = *YYCURSOR; if(yych <= '@') { diff --git a/test/input11.c b/test/input11.c index ab43e830..b183e883 100755 --- a/test/input11.c +++ b/test/input11.c @@ -5,7 +5,7 @@ { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 6) YYFILL(6); yych = *YYCURSOR; switch(yych){ diff --git a/test/input11.s.c b/test/input11.s.c index be679284..64c80d1b 100755 --- a/test/input11.s.c +++ b/test/input11.s.c @@ -5,7 +5,7 @@ { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 6) YYFILL(6); yych = *YYCURSOR; if(yych <= '@') { diff --git a/test/input2.c b/test/input2.c index 36a9f694..e577ba1c 100644 --- a/test/input2.c +++ b/test/input2.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ diff --git a/test/input3.c b/test/input3.c index e0529da8..415c5cff 100644 --- a/test/input3.c +++ b/test/input3.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ diff --git a/test/input4.c b/test/input4.c index f6fdb858..07e5a2f1 100755 --- a/test/input4.c +++ b/test/input4.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; goto yy3; diff --git a/test/input5.c b/test/input5.c index 2163d603..2388bd10 100755 --- a/test/input5.c +++ b/test/input5.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ diff --git a/test/input6.c b/test/input6.c index d994acb2..485d8167 100755 --- a/test/input6.c +++ b/test/input6.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; goto yy3; diff --git a/test/input7.c b/test/input7.c index eb74ab77..2f72532b 100755 --- a/test/input7.c +++ b/test/input7.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if(YYLIMIT == YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch(yych){ diff --git a/test/input8.c b/test/input8.c index 5cb60f54..6c8275cc 100755 --- a/test/input8.c +++ b/test/input8.c @@ -5,7 +5,7 @@ { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 4) YYFILL(4); yych = *YYCURSOR; switch(yych){ diff --git a/test/input9.c b/test/input9.c index 326193cd..dd4f51af 100755 --- a/test/input9.c +++ b/test/input9.c @@ -4,7 +4,7 @@ #line 5 "" { YYCTYPE yych; -yy0: + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){ diff --git a/test/modula.c b/test/modula.c index 5d39ac81..f1f7888a 100644 --- a/test/modula.c +++ b/test/modula.c @@ -68,7 +68,7 @@ std: YYCTYPE yych; unsigned int yyaccept = 0; YYCTYPE *yyctxmarker = YYCURSOR; -yy0: + if((YYLIMIT - YYCURSOR) < 15) YYFILL(15); yych = *YYCURSOR; switch(yych){ diff --git a/test/push.re b/test/push.re index 38ca5abe..5ad6e7ac 100755 --- a/test/push.re +++ b/test/push.re @@ -226,8 +226,8 @@ public: start: - /*!re2c - + /*!re2c + re2c:startlabel = 1; eol = "\n"; eof = "\000"; digit = [0-9]; diff --git a/test/repeater.c b/test/repeater.c index e18e8dd5..b3c451e9 100644 --- a/test/repeater.c +++ b/test/repeater.c @@ -19,7 +19,7 @@ const char *q; { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; switch(yych){ diff --git a/test/sample.c b/test/sample.c index 8062e754..e06f8c56 100644 --- a/test/sample.c +++ b/test/sample.c @@ -5,7 +5,7 @@ { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 6) YYFILL(6); yych = *YYCURSOR; switch(yych){ diff --git a/test/scanner.c b/test/scanner.c index cc0deaaa..24c80abb 100644 --- a/test/scanner.c +++ b/test/scanner.c @@ -79,7 +79,7 @@ echo: { YYCTYPE yych; unsigned int yyaccept = 0; -yy0: + if((YYLIMIT - YYCURSOR) < 7) YYFILL(7); yych = *YYCURSOR; switch(yych){ diff --git a/test/simple.c b/test/simple.c index 000d2b90..c9ec05f0 100644 --- a/test/simple.c +++ b/test/simple.c @@ -12,7 +12,7 @@ char *q; #line 13 "" { YYCTYPE yych; -yy0: + if((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch(yych){