-/* Generated by re2c 0.10.0.dev on Sat Jan 21 16:15:00 2006 */
+/* Generated by re2c 0.10.0.dev on Sun Jan 22 18:04:36 2006 */
#line 1 "scanner.re"
/* $Id$ */
#include <stdlib.h>
#include <string.h>
#include <iostream>
+#include <sstream>
#include "scanner.h"
#include "parser.h"
#include "y.tab.h"
#include "globals.h"
+#include "dfa.h"
extern YYSTYPE yylval;
namespace re2c
{
-Scanner::Scanner(std::istream& i) : in(i),
- bot(NULL), tok(NULL), ptr(NULL), cur(NULL), pos(NULL), lim(NULL),
- top(NULL), eof(NULL), tchar(0), tline(0), cline(1), iscfg(0)
+Scanner::Scanner(std::istream& i, std::ostream& o)
+ : in(i)
+ , out(o)
+ , bot(NULL), tok(NULL), ptr(NULL), cur(NULL), pos(NULL), lim(NULL)
+ , top(NULL), eof(NULL), tchar(0), tline(0), cline(1), iscfg(0)
{
;
}
return cursor;
}
-#line 91 "scanner.re"
+#line 95 "scanner.re"
int Scanner::echo(std::ostream &out){
tok = cursor;
echo:
-#line 92 "scanner.cc"
+#line 96 "scanner.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
+
if((YYLIMIT - YYCURSOR) < 11) YYFILL(11);
yych = *YYCURSOR;
if(yych <= ')') {
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '*') goto yy12;
yy3:
-#line 137 "scanner.re"
+#line 141 "scanner.re"
{
goto echo;
}
-#line 114 "scanner.cc"
+#line 119 "scanner.cc"
yy4:
yych = *++YYCURSOR;
if(yych == '/') goto yy10;
goto yy3;
yy5:
++YYCURSOR;
-#line 126 "scanner.re"
+#line 130 "scanner.re"
{
out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
tok = pos = cursor; cline++;
goto echo;
}
-#line 127 "scanner.cc"
+#line 132 "scanner.cc"
yy7:
++YYCURSOR;
-#line 131 "scanner.re"
+#line 135 "scanner.re"
{
out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok) - 1); // -1 so we don't write out the \0
if(cursor == eof) {
RETURN(0);
}
}
-#line 137 "scanner.cc"
+#line 142 "scanner.cc"
yy9:
yych = *++YYCURSOR;
goto yy3;
yy10:
++YYCURSOR;
-#line 117 "scanner.re"
+#line 121 "scanner.re"
{
if (ignore_eoc) {
ignore_eoc = false;
tok = pos = cursor;
goto echo;
}
-#line 153 "scanner.cc"
+#line 158 "scanner.cc"
yy12:
yych = *++YYCURSOR;
if(yych == '!') goto yy14;
yych = *++YYCURSOR;
if(yych != 'c') goto yy13;
++YYCURSOR;
-#line 106 "scanner.re"
+#line 110 "scanner.re"
{
out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
tok = cursor;
RETURN(1);
}
-#line 185 "scanner.cc"
+#line 190 "scanner.cc"
yy21:
yych = *++YYCURSOR;
if(yych != 'x') goto yy13;
yych = *++YYCURSOR;
if(yych != 'c') goto yy13;
++YYCURSOR;
-#line 111 "scanner.re"
+#line 115 "scanner.re"
{
out << "#define YYMAXFILL " << maxFill << std::endl;
tok = pos = cursor;
ignore_eoc = true;
goto echo;
}
-#line 207 "scanner.cc"
+#line 212 "scanner.cc"
}
-#line 140 "scanner.re"
+#line 144 "scanner.re"
}
goto value;
}
-#line 232 "scanner.cc"
+#line 237 "scanner.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
if(yych <= '9') goto yy95;
}
yy32:
-#line 162 "scanner.re"
+#line 166 "scanner.re"
{ depth = 1;
goto code;
}
-#line 310 "scanner.cc"
+#line 315 "scanner.cc"
yy33:
++YYCURSOR;
if((yych = *YYCURSOR) == '*') goto yy92;
yy34:
-#line 192 "scanner.re"
+#line 196 "scanner.re"
{ RETURN(*tok); }
-#line 317 "scanner.cc"
+#line 322 "scanner.cc"
yy35:
++YYCURSOR;
if((yych = *YYCURSOR) == '/') goto yy90;
yy36:
-#line 194 "scanner.re"
+#line 198 "scanner.re"
{ yylval.op = *tok;
RETURN(CLOSE); }
-#line 325 "scanner.cc"
+#line 330 "scanner.cc"
yy37:
yyaccept = 1;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != 0x0A) goto yy86;
yy38:
-#line 179 "scanner.re"
+#line 183 "scanner.re"
{ fatal("unterminated string constant (missing \")"); }
-#line 333 "scanner.cc"
+#line 338 "scanner.cc"
yy39:
yyaccept = 2;
yych = *(YYMARKER = ++YYCURSOR);
if(yych != 0x0A) goto yy81;
yy40:
-#line 180 "scanner.re"
+#line 184 "scanner.re"
{ fatal("unterminated string constant (missing ')"); }
-#line 341 "scanner.cc"
+#line 346 "scanner.cc"
yy41:
yyaccept = 3;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == '^') goto yy72;
goto yy71;
yy42:
-#line 190 "scanner.re"
+#line 194 "scanner.re"
{ fatal("unterminated range (missing ])"); }
-#line 351 "scanner.cc"
+#line 356 "scanner.cc"
yy43:
yych = *++YYCURSOR;
goto yy34;
if((yych = *YYCURSOR) == 'e') goto yy62;
goto yy61;
yy46:
-#line 221 "scanner.re"
+#line 225 "scanner.re"
{ cur = cursor;
yylval.symbol = Symbol::find(token());
return ID; }
-#line 367 "scanner.cc"
+#line 372 "scanner.cc"
yy47:
yych = *++YYCURSOR;
goto yy61;
yy48:
++YYCURSOR;
-#line 225 "scanner.re"
+#line 229 "scanner.re"
{ cur = cursor;
yylval.regexp = mkDot();
return RANGE;
}
-#line 378 "scanner.cc"
+#line 383 "scanner.cc"
yy50:
++YYCURSOR;
yych = *YYCURSOR;
goto yy59;
yy51:
-#line 230 "scanner.re"
+#line 234 "scanner.re"
{ goto scan; }
-#line 386 "scanner.cc"
+#line 391 "scanner.cc"
yy52:
++YYCURSOR;
yy53:
-#line 232 "scanner.re"
+#line 236 "scanner.re"
{ if(cursor == eof) RETURN(0);
pos = cursor; cline++;
goto scan;
}
-#line 395 "scanner.cc"
+#line 400 "scanner.cc"
yy54:
++YYCURSOR;
if((yych = *YYCURSOR) == 0x0A) goto yy57;
yy55:
-#line 237 "scanner.re"
- { std::cerr << "line " << tline << ", column " << (tchar + 1)
- << ": unexpected character: ";
- if (isprint(*tok))
- {
- std::cerr << *tok << std::endl;
- }
- else
- {
- std::cerr << "0x" << hexCh(*tok >> 4) << hexCh(*tok) << std::endl;
- }
+#line 241 "scanner.re"
+ { std::ostringstream msg;
+ msg << "unexpected character: ";
+ prtChOrHex(msg, *tok);
+ fatal(msg.str().c_str());
goto scan;
}
-#line 413 "scanner.cc"
+#line 412 "scanner.cc"
yy56:
yych = *++YYCURSOR;
goto yy55;
}
}
yy69:
-#line 214 "scanner.re"
+#line 218 "scanner.re"
{ cur = cursor;
tok+= 5; /* skip "re2c:" */
iscfg = 1;
yylval.str = new Str(token());
return CONFIG;
}
-#line 498 "scanner.cc"
+#line 497 "scanner.cc"
yy70:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
goto yy70;
yy75:
++YYCURSOR;
-#line 186 "scanner.re"
+#line 190 "scanner.re"
{ cur = cursor;
yylval.regexp = ranToRE(token());
return RANGE; }
-#line 536 "scanner.cc"
+#line 535 "scanner.cc"
yy77:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
goto yy72;
yy78:
++YYCURSOR;
-#line 182 "scanner.re"
+#line 186 "scanner.re"
{ cur = cursor;
yylval.regexp = invToRE(token());
return RANGE; }
-#line 549 "scanner.cc"
+#line 548 "scanner.cc"
yy80:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
goto yy80;
yy83:
++YYCURSOR;
-#line 175 "scanner.re"
+#line 179 "scanner.re"
{ cur = cursor;
yylval.regexp = strToCaseInsensitiveRE(token());
return STRING; }
-#line 573 "scanner.cc"
+#line 572 "scanner.cc"
yy85:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
goto yy85;
yy88:
++YYCURSOR;
-#line 171 "scanner.re"
+#line 175 "scanner.re"
{ cur = cursor;
yylval.regexp = strToRE(token());
return STRING; }
-#line 597 "scanner.cc"
+#line 596 "scanner.cc"
yy90:
++YYCURSOR;
-#line 168 "scanner.re"
+#line 172 "scanner.re"
{ tok = cursor;
RETURN(0); }
-#line 603 "scanner.cc"
+#line 602 "scanner.cc"
yy92:
++YYCURSOR;
-#line 165 "scanner.re"
+#line 169 "scanner.re"
{ depth = 1;
goto comment; }
-#line 609 "scanner.cc"
+#line 608 "scanner.cc"
yy94:
yych = *++YYCURSOR;
if(yych == ',') goto yy108;
yy97:
++YYCURSOR;
yy98:
-#line 212 "scanner.re"
+#line 216 "scanner.re"
{ fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); }
-#line 632 "scanner.cc"
+#line 631 "scanner.cc"
yy99:
++YYCURSOR;
-#line 200 "scanner.re"
+#line 204 "scanner.re"
{ yylval.extop.minsize = atoi((char *)tok+1);
yylval.extop.maxsize = atoi((char *)tok+1);
RETURN(CLOSESIZE); }
-#line 639 "scanner.cc"
+#line 638 "scanner.cc"
yy101:
yyaccept = 6;
yych = *(YYMARKER = ++YYCURSOR);
if(yych <= '9') goto yy104;
if(yych != '}') goto yy98;
++YYCURSOR;
-#line 208 "scanner.re"
+#line 212 "scanner.re"
{ yylval.extop.minsize = atoi((char *)tok+1);
yylval.extop.maxsize = -1;
RETURN(CLOSESIZE); }
-#line 651 "scanner.cc"
+#line 650 "scanner.cc"
yy104:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
if(yych <= '9') goto yy104;
if(yych != '}') goto yy66;
++YYCURSOR;
-#line 204 "scanner.re"
+#line 208 "scanner.re"
{ yylval.extop.minsize = atoi((char *)tok+1);
yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1));
RETURN(CLOSESIZE); }
-#line 664 "scanner.cc"
+#line 663 "scanner.cc"
yy108:
yyaccept = 6;
yych = *(YYMARKER = ++YYCURSOR);
if(yych <= '9') goto yy104;
if(yych != '}') goto yy98;
++YYCURSOR;
-#line 197 "scanner.re"
+#line 201 "scanner.re"
{ yylval.op = '*';
RETURN(CLOSE); }
-#line 675 "scanner.cc"
+#line 674 "scanner.cc"
}
-#line 249 "scanner.re"
+#line 247 "scanner.re"
code:
-#line 682 "scanner.cc"
+#line 681 "scanner.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
}
}
++YYCURSOR;
-#line 253 "scanner.re"
+#line 251 "scanner.re"
{ if(--depth == 0){
cur = cursor;
yylval.token = new Token(token(), tline);
return CODE;
}
goto code; }
-#line 713 "scanner.cc"
+#line 712 "scanner.cc"
yy115:
++YYCURSOR;
-#line 259 "scanner.re"
+#line 257 "scanner.re"
{ ++depth;
goto code; }
-#line 719 "scanner.cc"
+#line 718 "scanner.cc"
yy117:
++YYCURSOR;
-#line 261 "scanner.re"
+#line 259 "scanner.re"
{ if(cursor == eof) fatal("missing '}'");
pos = cursor; cline++;
goto code;
}
-#line 727 "scanner.cc"
+#line 726 "scanner.cc"
yy119:
++YYCURSOR;
yy120:
-#line 265 "scanner.re"
+#line 263 "scanner.re"
{ goto code; }
-#line 733 "scanner.cc"
+#line 732 "scanner.cc"
yy121:
yyaccept = 0;
yych = *(YYMARKER = ++YYCURSOR);
if(yych == 0x0A) goto yy125;
goto yy127;
}
-#line 266 "scanner.re"
+#line 264 "scanner.re"
comment:
-#line 790 "scanner.cc"
+#line 789 "scanner.cc"
{
YYCTYPE yych;
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
++YYCURSOR;
if((yych = *YYCURSOR) == '/') goto yy140;
yy133:
-#line 281 "scanner.re"
+#line 279 "scanner.re"
{ if(cursor == eof) RETURN(0);
goto comment; }
-#line 810 "scanner.cc"
+#line 809 "scanner.cc"
yy134:
yych = *++YYCURSOR;
if(yych == '*') goto yy138;
goto yy133;
yy135:
++YYCURSOR;
-#line 277 "scanner.re"
+#line 275 "scanner.re"
{ if(cursor == eof) RETURN(0);
tok = pos = cursor; cline++;
goto comment;
}
-#line 822 "scanner.cc"
+#line 821 "scanner.cc"
yy137:
yych = *++YYCURSOR;
goto yy133;
yy138:
++YYCURSOR;
-#line 274 "scanner.re"
+#line 272 "scanner.re"
{ ++depth;
fatal("ambiguous /* found");
goto comment; }
-#line 832 "scanner.cc"
+#line 831 "scanner.cc"
yy140:
++YYCURSOR;
-#line 270 "scanner.re"
+#line 268 "scanner.re"
{ if(--depth == 0)
goto scan;
else
goto comment; }
-#line 840 "scanner.cc"
+#line 839 "scanner.cc"
}
-#line 283 "scanner.re"
+#line 281 "scanner.re"
config:
-#line 847 "scanner.cc"
+#line 846 "scanner.cc"
{
YYCTYPE yych;
if((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
goto yy153;
yy145:
-#line 287 "scanner.re"
+#line 285 "scanner.re"
{ goto config; }
-#line 866 "scanner.cc"
+#line 865 "scanner.cc"
yy146:
++YYCURSOR;
yych = *YYCURSOR;
goto yy151;
yy147:
-#line 288 "scanner.re"
+#line 286 "scanner.re"
{ iscfg = 2;
cur = cursor;
RETURN('=');
}
-#line 877 "scanner.cc"
+#line 876 "scanner.cc"
yy148:
++YYCURSOR;
-#line 292 "scanner.re"
+#line 290 "scanner.re"
{ fatal("missing '='"); }
-#line 882 "scanner.cc"
+#line 881 "scanner.cc"
yy150:
++YYCURSOR;
if(YYLIMIT == YYCURSOR) YYFILL(1);
if(yych == ' ') goto yy152;
goto yy145;
}
-#line 293 "scanner.re"
+#line 291 "scanner.re"
value:
-#line 905 "scanner.cc"
+#line 904 "scanner.cc"
{
YYCTYPE yych;
unsigned int yyaccept = 0;
}
}
yy156:
-#line 302 "scanner.re"
+#line 300 "scanner.re"
{ cur = cursor;
yylval.str = new Str(token());
iscfg = 0;
return VALUE;
}
-#line 945 "scanner.cc"
+#line 944 "scanner.cc"
yy157:
++YYCURSOR;
if((yych = *YYCURSOR) <= 0x0D) {
}
}
yy158:
-#line 297 "scanner.re"
+#line 295 "scanner.re"
{ cur = cursor;
yylval.number = atoi(token().to_string().c_str());
iscfg = 0;
return NUMBER;
}
-#line 966 "scanner.cc"
+#line 965 "scanner.cc"
yy159:
yych = *++YYCURSOR;
if(yych <= '0') goto yy163;
if(yych == 0x0A) goto yy170;
goto yy174;
}
-#line 307 "scanner.re"
+#line 305 "scanner.re"
}
void Scanner::fatal(uint ofs, const char *msg) const
{
- std::cerr << "line " << tline << ", column " << (tchar + ofs + 1) << ": "
+ out.flush();
+ std::cerr << "re2c: error: "
+ << "line " << tline << ", column " << (tchar + ofs + 1) << ": "
<< msg << std::endl;
- exit(1);
-}
-
-void Scanner::fatal(const char *msg) const
-{
- fatal(0, msg);
+ exit(1);
}
} // end namespace re2c
+
#include <stdlib.h>
#include <string.h>
#include <iostream>
+#include <sstream>
#include "scanner.h"
#include "parser.h"
#include "y.tab.h"
#include "globals.h"
+#include "dfa.h"
extern YYSTYPE yylval;
namespace re2c
{
-Scanner::Scanner(std::istream& i) : in(i),
- bot(NULL), tok(NULL), ptr(NULL), cur(NULL), pos(NULL), lim(NULL),
- top(NULL), eof(NULL), tchar(0), tline(0), cline(1), iscfg(0)
+Scanner::Scanner(std::istream& i, std::ostream& o)
+ : in(i)
+ , out(o)
+ , bot(NULL), tok(NULL), ptr(NULL), cur(NULL), pos(NULL), lim(NULL)
+ , top(NULL), eof(NULL), tchar(0), tline(0), cline(1), iscfg(0)
{
;
}
goto scan;
}
- any { std::cerr << "line " << tline << ", column " << (tchar + 1)
- << ": unexpected character: ";
- if (isprint(*tok))
- {
- std::cerr << *tok << std::endl;
- }
- else
- {
- std::cerr << "0x" << hexCh(*tok >> 4) << hexCh(*tok) << std::endl;
- }
+ any { std::ostringstream msg;
+ msg << "unexpected character: ";
+ prtChOrHex(msg, *tok);
+ fatal(msg.str().c_str());
goto scan;
}
*/
void Scanner::fatal(uint ofs, const char *msg) const
{
- std::cerr << "line " << tline << ", column " << (tchar + ofs + 1) << ": "
+ out.flush();
+ std::cerr << "re2c: error: "
+ << "line " << tline << ", column " << (tchar + ofs + 1) << ": "
<< msg << std::endl;
- exit(1);
-}
-
-void Scanner::fatal(const char *msg) const
-{
- fatal(0, msg);
+ exit(1);
}
} // end namespace re2c
+