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
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 << "<stdin>";
- }
-
- 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;
}
}
-/* 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 <stdlib.h>
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
if((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
yych = *YYCURSOR;
if(yych <= ')') {
{
goto echo;
}
-#line 115 "scanner.cc"
+#line 114 "scanner.cc"
yy4:
yych = *++YYCURSOR;
if(yych == '/') goto yy10;
#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"
RETURN(0);
}
}
-#line 138 "scanner.cc"
+#line 137 "scanner.cc"
yy9:
yych = *++YYCURSOR;
goto yy3;
tok = pos = cursor;
goto echo;
}
-#line 154 "scanner.cc"
+#line 153 "scanner.cc"
yy12:
yych = *++YYCURSOR;
if(yych == '!') goto yy14;
tok = cursor;
RETURN(1);
}
-#line 186 "scanner.cc"
+#line 185 "scanner.cc"
yy21:
yych = *++YYCURSOR;
if(yych != 'x') goto yy13;
ignore_eoc = true;
goto echo;
}
-#line 208 "scanner.cc"
+#line 207 "scanner.cc"
}
#line 140 "scanner.re"
goto value;
}
-#line 233 "scanner.cc"
+#line 232 "scanner.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
{ 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;
#line 194 "scanner.re"
{ yylval.op = *tok;
RETURN(CLOSE); }
-#line 326 "scanner.cc"
+#line 325 "scanner.cc"
yy37:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
yy38:
#line 179 "scanner.re"
{ fatal("unterminated string constant (missing \")"); }
-#line 334 "scanner.cc"
+#line 333 "scanner.cc"
yy39:
yyaccept = 2;
yych = *(YYMARKER = ++YYCURSOR);
yy40:
#line 180 "scanner.re"
{ fatal("unterminated string constant (missing ')"); }
-#line 342 "scanner.cc"
+#line 341 "scanner.cc"
yy41:
yyaccept = 3;
yych = *(YYMARKER = ++YYCURSOR);
yy42:
#line 190 "scanner.re"
{ fatal("unterminated range (missing ])"); }
-#line 352 "scanner.cc"
+#line 351 "scanner.cc"
yy43:
yych = *++YYCURSOR;
goto yy34;
{ cur = cursor;
yylval.symbol = Symbol::find(token());
return ID; }
-#line 368 "scanner.cc"
+#line 367 "scanner.cc"
yy47:
yych = *++YYCURSOR;
goto yy61;
yylval.regexp = mkDot();
return RANGE;
}
-#line 379 "scanner.cc"
+#line 378 "scanner.cc"
yy50:
++YYCURSOR;
yych = *YYCURSOR;
yy51:
#line 230 "scanner.re"
{ goto scan; }
-#line 387 "scanner.cc"
+#line 386 "scanner.cc"
yy52:
++YYCURSOR;
yy53:
pos = cursor; cline++;
goto scan;
}
-#line 396 "scanner.cc"
+#line 395 "scanner.cc"
yy54:
++YYCURSOR;
if((yych = *YYCURSOR) == 0x0A) goto yy57;
}
goto scan;
}
-#line 414 "scanner.cc"
+#line 413 "scanner.cc"
yy56:
yych = *++YYCURSOR;
goto yy55;
yylval.str = new Str(token());
return CONFIG;
}
-#line 499 "scanner.cc"
+#line 498 "scanner.cc"
yy70:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{ cur = cursor;
yylval.regexp = ranToRE(token());
return RANGE; }
-#line 537 "scanner.cc"
+#line 536 "scanner.cc"
yy77:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{ cur = cursor;
yylval.regexp = invToRE(token());
return RANGE; }
-#line 550 "scanner.cc"
+#line 549 "scanner.cc"
yy80:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{ cur = cursor;
yylval.regexp = strToCaseInsensitiveRE(token());
return STRING; }
-#line 574 "scanner.cc"
+#line 573 "scanner.cc"
yy85:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{ 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;
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);
{ 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);
{ 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);
#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;
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"
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);
comment:
-#line 791 "scanner.cc"
+#line 790 "scanner.cc"
{
YYCTYPE yych;
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
#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;
tok = pos = cursor; cline++;
goto comment;
}
-#line 823 "scanner.cc"
+#line 822 "scanner.cc"
yy137:
yych = *++YYCURSOR;
goto yy133;
{ ++depth;
fatal("ambiguous /* found");
goto comment; }
-#line 833 "scanner.cc"
+#line 832 "scanner.cc"
yy140:
++YYCURSOR;
#line 270 "scanner.re"
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);
yy145:
#line 287 "scanner.re"
{ goto config; }
-#line 867 "scanner.cc"
+#line 866 "scanner.cc"
yy146:
++YYCURSOR;
yych = *YYCURSOR;
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);
value:
-#line 906 "scanner.cc"
+#line 905 "scanner.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
iscfg = 0;
return VALUE;
}
-#line 946 "scanner.cc"
+#line 945 "scanner.cc"
yy157:
++YYCURSOR;
if((yych = *YYCURSOR) <= 0x0D) {
iscfg = 0;
return NUMBER;
}
-#line 967 "scanner.cc"
+#line 966 "scanner.cc"
yy159:
yych = *++YYCURSOR;
if(yych <= '0') goto yy163;
if (j % 8 == 0)
{
o << "\n" << indent(ind+1);
- ++oline;
}
if (yybmHexTable)
}
o << "\n" << indent(ind) << "};\n";
- oline += 2;
}
}
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);
}
{
fillIndex = vFillIndexes++;
o << indent(ind) << "YYSETSTATE(" << fillIndex << ");\n";
- ++oline;
}
else
{
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
readCh = false;
}
- ++oline;
-
if (state->link)
{
need(o, ind, state->depth, readCh);
if (state->link)
{
o << indent(ind) << "++YYCURSOR;\n";
- oline++;
if (vUsedLabels.count(label))
{
o << "yy" << label << ":\n";
- oline++;
}
need(o, ind, state->depth, readCh);
}
{
/* 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;
}
if (!startLabelName.empty())
{
o << startLabelName << ":\n";
- oline++;
}
if (vUsedLabels.count(label))
{
o << "yy" << label << ":\n";
- oline++;
+ }
+ else if (!label)
+ {
+ o << "\n";
}
if (state->link)
{
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;
}
}
bUsedYYAccept = true;
o << indent(ind) << "YYCURSOR = YYMARKER;\n";
o << indent(ind) << "switch(yyaccept){\n";
- oline += 2;
}
o << indent(ind) << "case " << saves[i] << ":";
if (!first)
{
o << indent(ind) << "}\n";
- ++oline;
}
}
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)
if (!newLine)
{
o << "\n";
- ++oline;
}
newLine = true;
if (lb < s->ub)
}
o << "\n";
- ++oline;
newLine = true;
}
}
if (dFlag)
{
o << indent(ind) << "YYDEBUG(-1, yych);\n";
- ++oline;
}
if (readCh)
o << indent(ind) << "switch(yych){\n";
}
- ++oline;
-
while (t != &sP[0])
{
bool used = false;
o << indent(ind) << "default:";
genGoTo(o, 1, from, def, readCh);
o << indent(ind) << "}\n";
- ++oline;
delete [] sP;
}
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;
}
}
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 ";
}
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 ;
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);
if (bFlag)
{
o << indent(ind++) << "{\n";
- ++oline;
bitmap_brace = 1;
BitMap::gen(o, ind, lbChar, ubChar <= 256 ? ubChar : 256);
}
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)
o << indent(ind) << "default: /* abort() */;\n";
o << indent(ind) << "}\n";
o << "yyNext:\n";
-
- oline += maxFillIndexes;
- oline += 6;
}
for (s = head; s; s = s->next)
}
o << indent(--ind) << "}\n";
- ++oline;
if (bitmap_brace)
{
o << indent(--ind) << "}\n";
- ++oline;
}
if (BitMap::first)
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")
#endif
};
-template<class char_t>
-class basic_null_streambuf
- : public std::basic_streambuf<char_t>
-{
-public:
- basic_null_streambuf()
- : std::basic_streambuf<char_t>()
- {
- }
-};
-
#ifdef _MSC_VER
# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
#endif
-template<class char_t>
-class basic_null_stream
- : protected basic_null_streambuf<char_t>
- , public std::basic_ostream<char_t>
-{
-public:
- basic_null_stream()
- : basic_null_streambuf<char_t>()
- , std::basic_ostream<char_t>(static_cast<basic_null_streambuf<char_t>*>(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<char> null_stream;
-
} // end namespace re2c
#endif
}
}
-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]);
}
}
-void printSpan(std::ostream &o, uint lb, uint ub)
+void printSpan(std::ostream& o, uint lb, uint ub)
{
if (lb > ub)
{
o << "\n";
- ++oline;
-
uint lb = 0;
for (uint i = 0; i < s.go.nSpans; ++i)
for (State *s = dfa.head; s; s = s->next)
{
o << s << "\n\n";
- ++oline;
}
return o;
#include <set>
#include <algorithm>
#include <string>
+#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;
extern bool bUsedCtxMarker;
extern bool bUseStartLabel;
extern std::string startLabelName;
-extern unsigned int oline;
extern uint maxFill;
/* configurations */
{
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;
}
// set up the output stream
- ostream* output = 0;
-
- ofstream outputFile;
+ ofstream_lc outputFile;
if (outputFileName == 0 || (fileName[0] == '-' && fileName[1] == '\0'))
{
outputFileName = "<stdout>";
- 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 = "<stdin>";
+ }
- 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;
-
}
-
#endif
};
-void line_source(unsigned int, std::ostream&);
-void parse(std::istream&, std::ostream&);
+void parse(Scanner&, std::ostream&);
} // end namespace re2c
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 << "<stdin>";
- }
-
- 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;
}
}
#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
{
RelativePath="basics.h"
>
</File>
+ <File
+ RelativePath="code.h"
+ >
+ </File>
<File
RelativePath="config_w32.h"
>
RelativePath="scanner.h"
>
</File>
+ <File
+ RelativePath="stream_lc.h"
+ >
+ </File>
<File
RelativePath="substr.h"
>
.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
\"
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
<File
RelativePath="basics.h">
</File>
+ <File
+ RelativePath="code.h">
+ </File>
<File
RelativePath="config_w32.h">
</File>
<File
RelativePath="scanner.h">
</File>
+ <File
+ RelativePath="stream_lc.h">
+ </File>
<File
RelativePath="substr.h">
</File>
namespace re2c
{
-class Scanner
+class Scanner:
+ public line_number
{
-
private:
std::istream& in;
char *bot, *tok, *ptr, *cur, *pos, *lim, *top, *eof;
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;
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];
}
"\n" {
out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
- tok = pos = cursor; cline++; oline++;
+ tok = pos = cursor; cline++;
goto echo;
}
zero {
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)
#line 24 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 45) YYFILL(45);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 9) YYFILL(9);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 9) YYFILL(9);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 5) YYFILL(5);
yych = *YYCURSOR;
switch(yych){
#line 15 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
#line 15 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yych <= 'b') {
#line 15 "<stdout>"
{
YYCTYPE yych;
+
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
yy3:
#line 13 "config3.re"
{ return YYCURSOR; }
-#line 40 "<stdout>"
+#line 41 "<stdout>"
yy4:
++YYCURSOR;
#line 14 "config3.re"
{ return NULL; }
-#line 45 "<stdout>"
+#line 46 "<stdout>"
yy6:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{
char *q;
-#line 73 "<stdout>"
+#line 74 "<stdout>"
{
YYCTYPE yych;
yy8:
yy11:
#line 23 "config3.re"
{ return YYCURSOR; }
-#line 99 "<stdout>"
+#line 100 "<stdout>"
yy12:
++YYCURSOR;
#line 24 "config3.re"
{ return NULL; }
-#line 104 "<stdout>"
+#line 105 "<stdout>"
yy14:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{
char *q;
-#line 132 "<stdout>"
+#line 133 "<stdout>"
{
YYCTYPE yych;
startLabel:
yy19:
#line 33 "config3.re"
{ return YYCURSOR; }
-#line 158 "<stdout>"
+#line 159 "<stdout>"
yy20:
++YYCURSOR;
#line 34 "config3.re"
{ return NULL; }
-#line 163 "<stdout>"
+#line 164 "<stdout>"
yy22:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{
char *q;
-#line 191 "<stdout>"
+#line 192 "<stdout>"
{
YYCTYPE yych;
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yy27:
#line 43 "config3.re"
{ return YYCURSOR; }
-#line 216 "<stdout>"
+#line 217 "<stdout>"
yy28:
++YYCURSOR;
#line 44 "config3.re"
{ return NULL; }
-#line 221 "<stdout>"
+#line 222 "<stdout>"
yy30:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
{
YYCTYPE yych;
YYCTYPE *yyctxmarker = YYCURSOR;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
yych = *YYCURSOR;
if(yych <= ' ') {
{
YYCTYPE yych;
YYCTYPE *yyctxmarker = YYCURSOR;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
YYCTYPE *yyctxmarker = YYCURSOR;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 3) YYFILL(3);
yych = *YYCURSOR;
if(yych <= ' ') {
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 9) YYFILL(9);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
yych = *YYCURSOR;
if(yych != '$') goto yy4;
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
yych = *YYCURSOR;
if(yych != '$') goto yy4;
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
yych = *YYCURSOR;
if(yych != '$') goto yy4;
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
yych = *YYCURSOR;
if(yych != '$') goto yy4;
#line 19 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
#line 6 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yych <= 'E') {
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if(yych <= 'E') {
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 6) YYFILL(6);
yych = *YYCURSOR;
if(yych <= '@') {
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 6) YYFILL(6);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 6) YYFILL(6);
yych = *YYCURSOR;
if(yych <= '@') {
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
goto yy3;
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
goto yy3;
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if(YYLIMIT == YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 4) YYFILL(4);
yych = *YYCURSOR;
switch(yych){
#line 5 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){
YYCTYPE yych;
unsigned int yyaccept = 0;
YYCTYPE *yyctxmarker = YYCURSOR;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 15) YYFILL(15);
yych = *YYCURSOR;
switch(yych){
start:
- /*!re2c
-
+ /*!re2c
+ re2c:startlabel = 1;
eol = "\n";
eof = "\000";
digit = [0-9];
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 6) YYFILL(6);
yych = *YYCURSOR;
switch(yych){
{
YYCTYPE yych;
unsigned int yyaccept = 0;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 7) YYFILL(7);
yych = *YYCURSOR;
switch(yych){
#line 13 "<stdout>"
{
YYCTYPE yych;
-yy0:
+
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
switch(yych){