#include "parser.h"
#include "dfa.h"
+namespace re2c
+{
+
Symbol *Symbol::first = NULL;
Symbol::Symbol(const SubStr &str) : next(first), name(str), re(NULL)
delete dfa;
delete [] ins;
}
+
+} // end namespace re2c
+
#include "config.h"
#endif
+namespace re2c
+{
+
#if SIZEOF_CHAR == 1
typedef unsigned char byte;
#elif SIZEOF_SHORT == 1
typedef unsigned long dword;
#endif
-#ifndef HAVE_UINT
typedef unsigned int uint;
-#endif
-
-#ifndef HAVE_UCHAR
typedef unsigned char uchar;
-#endif
-
-#ifndef HAVE_USHORT
typedef unsigned short ushort;
-#endif
-
-#ifndef HAVE_ULONG
typedef unsigned long ulong;
-#endif
+
+} // end namespace re2c
#endif
-/* Generated by re2c 0.9.4 on Mon Jul 26 23:14:20 2004 */
+/* Generated by re2c 0.9.4 on Sun Oct 31 21:27:49 2004 */
#line 1 "scanner.re"
/* $Id$ */
#include <stdlib.h>
#define RETURN(i) {cur = cursor; return i;}
+namespace re2c
+{
Scanner::Scanner(std::istream& i) : in(i),
bot(NULL), tok(NULL), ptr(NULL), cur(NULL), pos(NULL), lim(NULL),
return cursor;
}
-#line 72 "scanner.re"
+#line 74 "scanner.re"
int Scanner::echo(std::ostream &out){
if(yych == '*') goto yy7;
goto yy3;
yy3:
-#line 91 "scanner.re"
+#line 93 "scanner.re"
{ goto echo; }
#line 26 "scanner.cc"
yy4: ++YYCURSOR;
goto yy5;
yy5:
-#line 87 "scanner.re"
+#line 89 "scanner.re"
{ if(cursor == eof) RETURN(0);
out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok));
tok = pos = cursor; cline++;
yy13: ++YYCURSOR;
goto yy14;
yy14:
-#line 84 "scanner.re"
+#line 86 "scanner.re"
{ out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok));
tok = cursor;
RETURN(1); }
#line 64 "scanner.cc"
}
-#line 92 "scanner.re"
+#line 94 "scanner.re"
}
if(yych <= '9') goto yy63;
goto yy18;
yy18:
-#line 105 "scanner.re"
+#line 107 "scanner.re"
{ depth = 1;
goto code;
}
if((yych = *YYCURSOR) == '*') goto yy61;
goto yy20;
yy20:
-#line 131 "scanner.re"
+#line 133 "scanner.re"
{ RETURN(*tok); }
#line 141 "scanner.cc"
yy21: ++YYCURSOR;
if((yych = *YYCURSOR) == '/') goto yy59;
goto yy22;
yy22:
-#line 133 "scanner.re"
+#line 135 "scanner.re"
{ yylval.op = *tok;
RETURN(CLOSE); }
#line 149 "scanner.cc"
if(yych != 0x0A) goto yy55;
goto yy24;
yy24:
-#line 122 "scanner.re"
+#line 124 "scanner.re"
{ fatal("unterminated string constant (missing \")"); }
#line 157 "scanner.cc"
yy25: yyaccept = 2;
if(yych != 0x0A) goto yy50;
goto yy26;
yy26:
-#line 123 "scanner.re"
+#line 125 "scanner.re"
{ fatal("unterminated string constant (missing ')"); }
#line 165 "scanner.cc"
yy27: yyaccept = 3;
if(yych != 0x0A) goto yy44;
goto yy28;
yy28:
-#line 129 "scanner.re"
+#line 131 "scanner.re"
{ fatal("unterminated range (missing ])"); }
#line 173 "scanner.cc"
yy29: yych = *++YYCURSOR;
yych = *YYCURSOR;
goto yy42;
yy32:
-#line 148 "scanner.re"
+#line 150 "scanner.re"
{ cur = cursor;
yylval.symbol = Symbol::find(token());
return ID; }
yych = *YYCURSOR;
goto yy40;
yy34:
-#line 152 "scanner.re"
+#line 154 "scanner.re"
{ goto scan; }
#line 191 "scanner.cc"
yy35: ++YYCURSOR;
goto yy36;
yy36:
-#line 154 "scanner.re"
+#line 156 "scanner.re"
{ if(cursor == eof) RETURN(0);
pos = cursor; cline++;
goto scan;
yy37: ++YYCURSOR;
goto yy38;
yy38:
-#line 159 "scanner.re"
+#line 161 "scanner.re"
{ std::cerr << "unexpected character: " << *tok << std::endl;
goto scan;
}
yy47: ++YYCURSOR;
goto yy48;
yy48:
-#line 125 "scanner.re"
+#line 127 "scanner.re"
{ cur = cursor;
yylval.regexp = ranToRE(token());
return RANGE; }
yy52: ++YYCURSOR;
goto yy53;
yy53:
-#line 118 "scanner.re"
+#line 120 "scanner.re"
{ cur = cursor;
yylval.regexp = strToCaseInsensitiveRE(token());
return STRING; }
yy57: ++YYCURSOR;
goto yy58;
yy58:
-#line 114 "scanner.re"
+#line 116 "scanner.re"
{ cur = cursor;
yylval.regexp = strToRE(token());
return STRING; }
yy59: ++YYCURSOR;
goto yy60;
yy60:
-#line 111 "scanner.re"
+#line 113 "scanner.re"
{ tok = cursor;
RETURN(0); }
#line 326 "scanner.cc"
yy61: ++YYCURSOR;
goto yy62;
yy62:
-#line 108 "scanner.re"
+#line 110 "scanner.re"
{ depth = 1;
goto comment; }
#line 333 "scanner.cc"
yy65: ++YYCURSOR;
goto yy66;
yy66:
-#line 136 "scanner.re"
+#line 138 "scanner.re"
{ yylval.extop.minsize = atoi((char *)tok+1);
yylval.extop.maxsize = atoi((char *)tok+1);
RETURN(CLOSESIZE); }
yy68: ++YYCURSOR;
goto yy69;
yy69:
-#line 144 "scanner.re"
+#line 146 "scanner.re"
{ yylval.extop.minsize = atoi((char *)tok+1);
yylval.extop.maxsize = -1;
RETURN(CLOSESIZE); }
yy72: ++YYCURSOR;
goto yy73;
yy73:
-#line 140 "scanner.re"
+#line 142 "scanner.re"
{ yylval.extop.minsize = atoi((char *)tok+1);
yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1));
RETURN(CLOSESIZE); }
#line 382 "scanner.cc"
}
-#line 162 "scanner.re"
+#line 164 "scanner.re"
code:
yy76: ++YYCURSOR;
goto yy77;
yy77:
-#line 166 "scanner.re"
+#line 168 "scanner.re"
{ if(--depth == 0){
cur = cursor;
yylval.token = new Token(token(), tline);
yy78: ++YYCURSOR;
goto yy79;
yy79:
-#line 172 "scanner.re"
+#line 174 "scanner.re"
{ ++depth;
goto code; }
#line 430 "scanner.cc"
yy80: ++YYCURSOR;
goto yy81;
yy81:
-#line 174 "scanner.re"
+#line 176 "scanner.re"
{ if(cursor == eof) fatal("missing '}'");
pos = cursor; cline++;
goto code;
yy82: ++YYCURSOR;
goto yy83;
yy83:
-#line 178 "scanner.re"
+#line 180 "scanner.re"
{ goto code; }
#line 445 "scanner.cc"
yy84: yyaccept = 0;
if(yych == 0x0A) goto yy88;
goto yy90;
}
-#line 179 "scanner.re"
+#line 181 "scanner.re"
comment:
if((yych = *YYCURSOR) == '/') goto yy103;
goto yy96;
yy96:
-#line 193 "scanner.re"
+#line 195 "scanner.re"
{ goto comment; }
#line 522 "scanner.cc"
yy97: yych = *++YYCURSOR;
yy98: ++YYCURSOR;
goto yy99;
yy99:
-#line 189 "scanner.re"
+#line 191 "scanner.re"
{ if(cursor == eof) RETURN(0);
tok = pos = cursor; cline++;
goto comment;
yy101: ++YYCURSOR;
goto yy102;
yy102:
-#line 187 "scanner.re"
+#line 189 "scanner.re"
{ ++depth;
goto comment; }
#line 543 "scanner.cc"
yy103: ++YYCURSOR;
goto yy104;
yy104:
-#line 183 "scanner.re"
+#line 185 "scanner.re"
{ if(--depth == 0)
goto scan;
else
goto comment; }
#line 552 "scanner.cc"
}
-#line 194 "scanner.re"
+#line 196 "scanner.re"
}
<< msg << std::endl;
exit(1);
}
+
+} // end namespace re2c
+
#include "dfa.h"
#include "parser.h"
+namespace re2c
+{
+
// there must be at least one span in list; all spans must cover
// same range
delete [] saves;
delete [] rules;
}
+
+} // end namespace re2c
+
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([long])
-AC_CHECK_TYPE([uchar], [
- AC_DEFINE([HAVE_UCHAR], [1], [Define to 1 if you have uchar type definition])
-])
-AC_CHECK_TYPE([ushort], [
- AC_DEFINE([HAVE_USHORT], [1], [Define to 1 if you have ushort type definition])
-])
-AC_CHECK_TYPE([uint], [
- AC_DEFINE([HAVE_UINT], [1], [Define to 1 if you have uint type definition])
-])
-AC_CHECK_TYPE([ulong], [
- AC_DEFINE([HAVE_ULONG], [1], [Define to 1 if you have ulong type definition])
-])
-
AC_CONFIG_FILES([\
Makefile \
README \
#include "substr.h"
#include "dfa.h"
+namespace re2c
+{
+
inline char octCh(uint c)
{
return '0' + c % 8;
return s;
}
+
+} // end namespace re2c
+
#include <iosfwd>
#include "re.h"
+namespace re2c
+{
+
extern void prtCh(std::ostream&, uchar);
extern void prtChOrHex(std::ostream&, uchar);
extern void printSpan(std::ostream&, uint, uint);
return o << *dfa;
}
+} // end namespace re2c
+
#endif
#include "basics.h"
+namespace re2c
+{
+
extern char *fileName;
extern char *outputFileName;
extern bool sFlag;
extern uchar *xlat, *talx;
+} // end namespace re2c
+
#endif
#include "basics.h"
+namespace re2c
+{
+
const uint nChars = 256;
typedef uchar Char;
i->i.marked = false;
}
+} // end namespace re2c
+
#endif
#include "dfa.h"
#include "mbo_getopt.h"
+namespace re2c
+{
+
char *fileName = 0;
char *outputFileName = 0;
bool sFlag = false;
"-v --version Show version information.\n";
}
+} // end namespace re2c
+
+using namespace re2c;
+
int main(int argc, char *argv[])
{
int c;
return 0;
}
+
#define OPTERRNF (2)
#define OPTERRARG (3)
+namespace re2c
+{
static int mbo_opt_error(int argc, char * const *argv, int oint, int optchr, int err, int show_err)
{
assert(0);
return (0); /* never reached */
}
+
+} // end namespace re2c
+
* If short_open is '-' this is the last option.
*/
+#ifndef RE2C_MBO_GETOPT_H_INCLUDE_GUARD_
+#define RE2C_MBO_GETOPT_H_INCLUDE_GUARD_
+
+namespace re2c
+{
+
typedef struct _mbo_opt_struct
{
const char opt_char;
mbo_opt_struct;
int mbo_getopt(int argc, char* const *argv, const mbo_opt_struct opts[], char **optarg, int *optind, int show_err);
+
+} // end namespace re2c
+
+#endif
+
#include "re.h"
#include <iosfwd>
+namespace re2c
+{
+
class Symbol
{
void line_source(unsigned int, std::ostream&);
void parse(std::istream&, std::ostream&);
+} // end namespace re2c
+
#endif
#ifndef YYSTYPE
typedef union {
- Symbol *symbol;
- RegExp *regexp;
- Token *token;
+ re2c::Symbol *symbol;
+ re2c::RegExp *regexp;
+ re2c::Token *token;
char op;
} yystype;
# define YYSTYPE yystype
#include "globals.h"
#include "parser.h"
+#include "basics.h"
+
+using namespace re2c;
extern "C"
{
void yyerror(char*);
}
-static uint accept;
+static re2c::uint accept;
static RegExp *spec;
static Scanner *in;
%start spec
%union {
- Symbol *symbol;
- RegExp *regexp;
- Token *token;
+ re2c::Symbol *symbol;
+ re2c::RegExp *regexp;
+ re2c::Token *token;
char op;
- ExtOp extop;
+ re2c::ExtOp extop;
};
%token CLOSESIZE CLOSE ID CODE RANGE STRING
}
} // end extern "C"
+namespace re2c
+{
+
void line_source(unsigned int line, std::ostream& o)
{
char * fnamebuf;
line_source(in->line(), o);
}
}
+
+} // end namespace re2c
+
#include "token.h"
#include "ins.h"
+namespace re2c
+{
+
typedef struct extop
{
char op;
extern RegExp *ranToRE(SubStr);
extern RegExp *strToCaseInsensitiveRE(SubStr s);
+} // end namespace re2c
+
#endif
#include <iosfwd>
#include "token.h"
+namespace re2c
+{
+
class Scanner
{
return cline;
}
+} // end namespace re2c
+
#endif
#define RETURN(i) {cur = cursor; return i;}
+namespace re2c
+{
Scanner::Scanner(std::istream& i) : in(i),
bot(NULL), tok(NULL), ptr(NULL), cur(NULL), pos(NULL), lim(NULL),
<< msg << std::endl;
exit(1);
}
+
+} // end namespace re2c
+
#include "substr.h"
#include "globals.h"
+namespace re2c
+{
+
void SubStr::out(std::ostream& o) const
{
o.write(str, len);
str = (char*) - 1;
len = (uint) - 1;
}
+
+} // end namespace re2c
+
#include <iostream>
#include "basics.h"
+namespace re2c
+{
+
class SubStr
{
: str(s.str), len(s.len)
{ }
+} // end namespace re2c
+
#endif
#include "substr.h"
+namespace re2c
+{
+
class Token
{
;
}
+} // end namespace re2c
+
#endif
/* $Id$ */
#include "globals.h"
+namespace re2c
+{
+
uchar asc2asc[256] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f
};
+
+} // end namespace re2c
+