/* Generated by re2c */
#line 1 "src/pplex.re"
// vim:set ft=cpp:

#include "adlib/lib.h"
#include "adlib/set.h"
// "fixstr.h" must be included before "map.h"
#include "fixstr.h"
#include "adlib/map.h"

#include "pplex.h"

const char *SymbolNames[] = {
  "SymNone",
  "SymClass",
  "SymNamespace",
  "SymExtern",
  "SymVAR",
  "SymEXTERN_VAR",
  "SymSTATIC_VAR",
  "SymINST_VAR",
  "SymEXTERN_INST_VAR",
  "SymSTATIC_INST_VAR",
  "SymIdent",
  "SymLiteral",
  "SymOp",
  "SymSemicolon",
  "SymComma",
  "SymEqual",
  "SymAst",
  "SymAnd",
  "SymAndAnd",
  "SymColonColon",
  "SymLPar",
  "SymRPar",
  "SymLBrkt",
  "SymRBrkt",
  "SymLBrace",
  "SymRBrace",
  "SymWS",
  "SymEOL",
  "SymComment",
  "SymBAD",
  "SymLineDir",
  "SymEOF",
  "SymGen",
};

typedef Map<FixStr, Str *> InternMap;

Str *Intern(const char *ptr, Int len) {
  static InternMap *map = NULL;
  if (!map) {
    GCVar(map, new InternMap());
  }
  FixStr fs;
  fs.str = ptr;
  fs.len = len;
  Str *result = map->get(fs, NULL);
  if (!result) {
    result = new Str(ptr, len);
    // `ptr` above is an interior pointer whose contents may disappear
    // due to GC once the `SourceFile` object containing it is no
    // longer reachable.
    //
    // Therefore, we replace it with `result->c_str()`. This is not only
    // not an interior pointer, but is kept alive by the value that the
    // key is in use for.
    fs.str = result->c_str();
    map->add(fs, result);
  }
  return result;
}

#define PUSH_TOKEN(s) \
  token.sym = s; \
  goto pushtoken;

bool Tokenize(SourceFile *source) {
  Str *input = source->filedata;
  const char *cursor = input->c_str();
  const char *marker = NULL;
  const char *ctxmarker = NULL;
  bool done = false;
  bool error = false;
  TokenList *result = new TokenList();
  Token token;
  while (!done) {
    const char *last = cursor;

#line 92 "src/pplex.cc"
{
	unsigned char yych;
	unsigned int yyaccept = 0;
	yych = *cursor;
	switch (yych) {
	case 0x00:	goto yy2;
	case '\t':
	case '\f':
	case ' ':	goto yy6;
	case '\n':	goto yy9;
	case '\r':	goto yy11;
	case '!':
	case '%':
	case '^':	goto yy12;
	case '"':	goto yy14;
	case '#':	goto yy15;
	case '&':	goto yy16;
	case '\'':	goto yy18;
	case '(':	goto yy19;
	case ')':	goto yy21;
	case '*':	goto yy23;
	case '+':	goto yy25;
	case ',':	goto yy26;
	case '-':	goto yy28;
	case '.':	goto yy29;
	case '/':	goto yy30;
	case '0':	goto yy31;
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy33;
	case ':':	goto yy35;
	case ';':	goto yy36;
	case '<':	goto yy38;
	case '=':	goto yy39;
	case '>':	goto yy41;
	case '?':
	case '~':	goto yy42;
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'F':
	case 'G':
	case 'H':
	case 'J':
	case 'K':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'T':
	case 'U':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'd':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	case 'E':	goto yy46;
	case 'I':	goto yy47;
	case 'L':	goto yy48;
	case 'S':	goto yy49;
	case 'V':	goto yy50;
	case '[':	goto yy51;
	case '\\':	goto yy53;
	case ']':	goto yy54;
	case 'c':	goto yy56;
	case 'e':	goto yy57;
	case 'n':	goto yy58;
	case '{':	goto yy59;
	case '|':	goto yy61;
	case '}':	goto yy62;
	default:	goto yy4;
	}
yy2:
	++cursor;
#line 161 "src/pplex.re"
	{ done = true; continue; }
#line 201 "src/pplex.cc"
yy4:
	++cursor;
yy5:
#line 162 "src/pplex.re"
	{ error = true; PUSH_TOKEN(SymBAD); }
#line 207 "src/pplex.cc"
yy6:
	yych = *++cursor;
	switch (yych) {
	case '\t':
	case '\f':
	case ' ':	goto yy6;
	default:	goto yy8;
	}
yy8:
#line 157 "src/pplex.re"
	{ PUSH_TOKEN(SymWS); }
#line 219 "src/pplex.cc"
yy9:
	++cursor;
yy10:
#line 155 "src/pplex.re"
	{ PUSH_TOKEN(SymEOL); }
#line 225 "src/pplex.cc"
yy11:
	yych = *++cursor;
	switch (yych) {
	case '\n':	goto yy9;
	default:	goto yy10;
	}
yy12:
	yych = *++cursor;
	switch (yych) {
	case '=':	goto yy64;
	default:	goto yy13;
	}
yy13:
#line 150 "src/pplex.re"
	{ PUSH_TOKEN(SymOp); }
#line 241 "src/pplex.cc"
yy14:
	yyaccept = 0;
	yych = *(marker = ++cursor);
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':	goto yy5;
	default:	goto yy67;
	}
yy15:
	yyaccept = 0;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '\t':
	case '\f':
	case ' ':	goto yy72;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy74;
	default:	goto yy5;
	}
yy16:
	yych = *++cursor;
	switch (yych) {
	case '&':	goto yy76;
	case '=':	goto yy64;
	default:	goto yy17;
	}
yy17:
#line 146 "src/pplex.re"
	{ PUSH_TOKEN(SymAnd); }
#line 280 "src/pplex.cc"
yy18:
	yyaccept = 0;
	yych = *(marker = ++cursor);
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':
	case '\'':	goto yy5;
	case '\\':	goto yy79;
	default:	goto yy78;
	}
yy19:
	++cursor;
#line 137 "src/pplex.re"
	{ PUSH_TOKEN(SymLPar); }
#line 296 "src/pplex.cc"
yy21:
	++cursor;
#line 138 "src/pplex.re"
	{ PUSH_TOKEN(SymRPar); }
#line 301 "src/pplex.cc"
yy23:
	yych = *++cursor;
	switch (yych) {
	case '=':	goto yy64;
	default:	goto yy24;
	}
yy24:
#line 149 "src/pplex.re"
	{ PUSH_TOKEN(SymAst); }
#line 311 "src/pplex.cc"
yy25:
	yych = *++cursor;
	switch (yych) {
	case '+':
	case '=':	goto yy64;
	default:	goto yy13;
	}
yy26:
	++cursor;
#line 144 "src/pplex.re"
	{ PUSH_TOKEN(SymComma); }
#line 323 "src/pplex.cc"
yy28:
	yych = *++cursor;
	switch (yych) {
	case '-':
	case '=':
	case '>':	goto yy64;
	default:	goto yy13;
	}
yy29:
	yyaccept = 1;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '.':	goto yy80;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy81;
	default:	goto yy13;
	}
yy30:
	yyaccept = 1;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '*':	goto yy84;
	case '/':	goto yy86;
	case '=':	goto yy64;
	default:	goto yy13;
	}
yy31:
	yyaccept = 2;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '.':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'E':
	case 'e':	goto yy90;
	case 'L':
	case 'U':
	case 'l':
	case 'u':	goto yy93;
	case 'X':
	case 'x':	goto yy95;
	default:	goto yy32;
	}
yy32:
#line 131 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 386 "src/pplex.cc"
yy33:
	yyaccept = 2;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '.':	goto yy87;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy33;
	case 'E':
	case 'e':	goto yy92;
	case 'L':
	case 'U':
	case 'l':
	case 'u':	goto yy93;
	default:	goto yy32;
	}
yy35:
	yych = *++cursor;
	switch (yych) {
	case ':':	goto yy96;
	default:	goto yy13;
	}
yy36:
	++cursor;
#line 145 "src/pplex.re"
	{ PUSH_TOKEN(SymSemicolon); }
#line 420 "src/pplex.cc"
yy38:
	yych = *++cursor;
	switch (yych) {
	case '<':	goto yy98;
	case '=':	goto yy64;
	default:	goto yy13;
	}
yy39:
	yych = *++cursor;
	switch (yych) {
	case '=':	goto yy64;
	default:	goto yy40;
	}
yy40:
#line 143 "src/pplex.re"
	{ PUSH_TOKEN(SymEqual); }
#line 437 "src/pplex.cc"
yy41:
	yych = *++cursor;
	switch (yych) {
	case '=':	goto yy64;
	case '>':	goto yy98;
	default:	goto yy13;
	}
yy42:
	++cursor;
	goto yy13;
yy43:
	yych = *++cursor;
yy44:
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy45;
	}
yy45:
#line 128 "src/pplex.re"
	{ PUSH_TOKEN(SymIdent); }
#line 520 "src/pplex.cc"
yy46:
	yych = *++cursor;
	switch (yych) {
	case 'X':	goto yy99;
	default:	goto yy44;
	}
yy47:
	yych = *++cursor;
	switch (yych) {
	case 'N':	goto yy100;
	default:	goto yy44;
	}
yy48:
	yyaccept = 3;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '"':	goto yy66;
	case '\'':	goto yy101;
	default:	goto yy44;
	}
yy49:
	yych = *++cursor;
	switch (yych) {
	case 'T':	goto yy102;
	default:	goto yy44;
	}
yy50:
	yych = *++cursor;
	switch (yych) {
	case 'A':	goto yy103;
	default:	goto yy44;
	}
yy51:
	++cursor;
#line 139 "src/pplex.re"
	{ PUSH_TOKEN(SymLBrkt); }
#line 557 "src/pplex.cc"
yy53:
	yyaccept = 0;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '\t':
	case '\n':
	case '\f':
	case '\r':
	case ' ':	goto yy105;
	default:	goto yy5;
	}
yy54:
	++cursor;
#line 140 "src/pplex.re"
	{ PUSH_TOKEN(SymRBrkt); }
#line 573 "src/pplex.cc"
yy56:
	yych = *++cursor;
	switch (yych) {
	case 'l':	goto yy109;
	default:	goto yy44;
	}
yy57:
	yych = *++cursor;
	switch (yych) {
	case 'x':	goto yy110;
	default:	goto yy44;
	}
yy58:
	yych = *++cursor;
	switch (yych) {
	case 'a':	goto yy111;
	default:	goto yy44;
	}
yy59:
	++cursor;
#line 141 "src/pplex.re"
	{ PUSH_TOKEN(SymLBrace); }
#line 596 "src/pplex.cc"
yy61:
	yych = *++cursor;
	switch (yych) {
	case '=':
	case '|':	goto yy64;
	default:	goto yy13;
	}
yy62:
	++cursor;
#line 142 "src/pplex.re"
	{ PUSH_TOKEN(SymRBrace); }
#line 608 "src/pplex.cc"
yy64:
	++cursor;
yy65:
#line 151 "src/pplex.re"
	{ PUSH_TOKEN(SymOp); }
#line 614 "src/pplex.cc"
yy66:
	yych = *++cursor;
yy67:
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':	goto yy68;
	case '"':	goto yy69;
	case '\\':	goto yy71;
	default:	goto yy66;
	}
yy68:
	cursor = marker;
	switch (yyaccept) {
	case 0: 	goto yy5;
	case 1: 	goto yy13;
	case 2: 	goto yy32;
	case 3: 	goto yy45;
	case 4: 	goto yy83;
	case 5: 	goto yy88;
	default:	goto yy91;
	}
yy69:
	++cursor;
#line 133 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 641 "src/pplex.cc"
yy71:
	yych = *++cursor;
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':	goto yy68;
	default:	goto yy66;
	}
yy72:
	yych = *++cursor;
	switch (yych) {
	case '\t':
	case '\f':
	case ' ':	goto yy72;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy74;
	default:	goto yy68;
	}
yy74:
	yych = *++cursor;
	switch (yych) {
	case '"':	goto yy112;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy74;
	default:	goto yy68;
	}
yy76:
	++cursor;
#line 147 "src/pplex.re"
	{ PUSH_TOKEN(SymAndAnd); }
#line 688 "src/pplex.cc"
yy78:
	yych = *++cursor;
	switch (yych) {
	case '\'':	goto yy114;
	default:	goto yy68;
	}
yy79:
	yych = *++cursor;
	switch (yych) {
	case '\'':
	case '\\':	goto yy116;
	default:	goto yy117;
	}
yy80:
	yych = *++cursor;
	switch (yych) {
	case '.':	goto yy64;
	default:	goto yy68;
	}
yy81:
	yyaccept = 4;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy81;
	case 'E':
	case 'e':	goto yy118;
	case 'F':
	case 'L':
	case 'f':
	case 'l':	goto yy119;
	default:	goto yy83;
	}
yy83:
#line 135 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 733 "src/pplex.cc"
yy84:
	++cursor;
#line 154 "src/pplex.re"
	{ goto comment; }
#line 738 "src/pplex.cc"
yy86:
	yych = *++cursor;
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':	goto yy68;
	default:	goto yy120;
	}
yy87:
	yyaccept = 5;
	yych = *(marker = ++cursor);
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy81;
	case 'E':
	case 'e':	goto yy123;
	case 'F':
	case 'L':
	case 'f':
	case 'l':	goto yy124;
	default:	goto yy88;
	}
yy88:
#line 136 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 772 "src/pplex.cc"
yy89:
	yyaccept = 6;
	yych = *(marker = ++cursor);
yy90:
	switch (yych) {
	case '.':	goto yy87;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':	goto yy89;
	case '8':
	case '9':	goto yy33;
	case 'E':
	case 'e':	goto yy92;
	case 'L':
	case 'U':
	case 'l':
	case 'u':	goto yy125;
	default:	goto yy91;
	}
yy91:
#line 130 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 800 "src/pplex.cc"
yy92:
	yych = *++cursor;
	switch (yych) {
	case '+':
	case '-':	goto yy127;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy128;
	default:	goto yy68;
	}
yy93:
	yych = *++cursor;
	switch (yych) {
	case 'L':
	case 'U':
	case 'l':
	case 'u':	goto yy93;
	default:	goto yy32;
	}
yy95:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':	goto yy131;
	default:	goto yy68;
	}
yy96:
	++cursor;
#line 148 "src/pplex.re"
	{ PUSH_TOKEN(SymColonColon); }
#line 858 "src/pplex.cc"
yy98:
	yych = *++cursor;
	switch (yych) {
	case '=':	goto yy64;
	default:	goto yy65;
	}
yy99:
	yych = *++cursor;
	switch (yych) {
	case 'T':	goto yy134;
	default:	goto yy44;
	}
yy100:
	yych = *++cursor;
	switch (yych) {
	case 'S':	goto yy135;
	default:	goto yy44;
	}
yy101:
	yych = *++cursor;
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':
	case '\'':	goto yy68;
	case '\\':	goto yy79;
	default:	goto yy78;
	}
yy102:
	yych = *++cursor;
	switch (yych) {
	case 'A':	goto yy136;
	default:	goto yy44;
	}
yy103:
	yych = *++cursor;
	switch (yych) {
	case 'R':	goto yy137;
	default:	goto yy44;
	}
yy104:
	yych = *++cursor;
yy105:
	switch (yych) {
	case '\t':
	case '\f':
	case ' ':	goto yy104;
	case '\n':
		ctxmarker = cursor;
		goto yy106;
	case '\r':
		ctxmarker = cursor;
		goto yy108;
	default:	goto yy68;
	}
yy106:
	++cursor;
yy107:
	cursor = ctxmarker;
#line 156 "src/pplex.re"
	{ PUSH_TOKEN(SymWS); }
#line 920 "src/pplex.cc"
yy108:
	yych = *++cursor;
	switch (yych) {
	case '\n':	goto yy106;
	default:	goto yy107;
	}
yy109:
	yych = *++cursor;
	switch (yych) {
	case 'a':	goto yy139;
	default:	goto yy44;
	}
yy110:
	yych = *++cursor;
	switch (yych) {
	case 't':	goto yy140;
	default:	goto yy44;
	}
yy111:
	yych = *++cursor;
	switch (yych) {
	case 'm':	goto yy141;
	default:	goto yy44;
	}
yy112:
	yych = *++cursor;
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':
	case '\\':	goto yy68;
	case '"':	goto yy142;
	default:	goto yy112;
	}
yy114:
	++cursor;
#line 132 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 959 "src/pplex.cc"
yy116:
	yych = *++cursor;
yy117:
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':
	case '\\':	goto yy68;
	case '\'':	goto yy114;
	default:	goto yy116;
	}
yy118:
	yych = *++cursor;
	switch (yych) {
	case '+':
	case '-':	goto yy145;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy146;
	default:	goto yy68;
	}
yy119:
	++cursor;
	goto yy83;
yy120:
	yych = *++cursor;
	switch (yych) {
	case 0x00:
	case '\n':
	case '\r':	goto yy122;
	default:	goto yy120;
	}
yy122:
#line 153 "src/pplex.re"
	{ PUSH_TOKEN(SymComment); }
#line 1002 "src/pplex.cc"
yy123:
	yych = *++cursor;
	switch (yych) {
	case '+':
	case '-':	goto yy148;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy149;
	default:	goto yy68;
	}
yy124:
	++cursor;
	goto yy88;
yy125:
	yych = *++cursor;
	switch (yych) {
	case 'L':
	case 'U':
	case 'l':
	case 'u':	goto yy125;
	default:	goto yy91;
	}
yy127:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy128;
	default:	goto yy68;
	}
yy128:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy128;
	case 'F':
	case 'L':
	case 'f':
	case 'l':	goto yy151;
	default:	goto yy130;
	}
yy130:
#line 134 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 1069 "src/pplex.cc"
yy131:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':	goto yy131;
	case 'L':
	case 'U':
	case 'l':
	case 'u':	goto yy152;
	default:	goto yy133;
	}
yy133:
#line 129 "src/pplex.re"
	{ PUSH_TOKEN(SymLiteral); }
#line 1104 "src/pplex.cc"
yy134:
	yych = *++cursor;
	switch (yych) {
	case 'E':	goto yy154;
	default:	goto yy44;
	}
yy135:
	yych = *++cursor;
	switch (yych) {
	case 'T':	goto yy155;
	default:	goto yy44;
	}
yy136:
	yych = *++cursor;
	switch (yych) {
	case 'T':	goto yy156;
	default:	goto yy44;
	}
yy137:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy138;
	}
yy138:
#line 122 "src/pplex.re"
	{ PUSH_TOKEN(SymVAR); }
#line 1194 "src/pplex.cc"
yy139:
	yych = *++cursor;
	switch (yych) {
	case 's':	goto yy157;
	default:	goto yy44;
	}
yy140:
	yych = *++cursor;
	switch (yych) {
	case 'e':	goto yy158;
	default:	goto yy44;
	}
yy141:
	yych = *++cursor;
	switch (yych) {
	case 'e':	goto yy159;
	default:	goto yy44;
	}
yy142:
	yych = *++cursor;
	switch (yych) {
	case '\t':
	case '\f':
	case ' ':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy142;
	default:	goto yy144;
	}
yy144:
#line 158 "src/pplex.re"
	{
      PUSH_TOKEN(SymLineDir);
    }
#line 1236 "src/pplex.cc"
yy145:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy146;
	default:	goto yy68;
	}
yy146:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy146;
	case 'F':
	case 'L':
	case 'f':
	case 'l':	goto yy119;
	default:	goto yy83;
	}
yy148:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy149;
	default:	goto yy68;
	}
yy149:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy149;
	case 'F':
	case 'L':
	case 'f':
	case 'l':	goto yy124;
	default:	goto yy88;
	}
yy151:
	++cursor;
	goto yy130;
yy152:
	yych = *++cursor;
	switch (yych) {
	case 'L':
	case 'U':
	case 'l':
	case 'u':	goto yy152;
	default:	goto yy133;
	}
yy154:
	yych = *++cursor;
	switch (yych) {
	case 'R':	goto yy160;
	default:	goto yy44;
	}
yy155:
	yych = *++cursor;
	switch (yych) {
	case '_':	goto yy161;
	default:	goto yy44;
	}
yy156:
	yych = *++cursor;
	switch (yych) {
	case 'I':	goto yy162;
	default:	goto yy44;
	}
yy157:
	yych = *++cursor;
	switch (yych) {
	case 's':	goto yy163;
	default:	goto yy44;
	}
yy158:
	yych = *++cursor;
	switch (yych) {
	case 'r':	goto yy165;
	default:	goto yy44;
	}
yy159:
	yych = *++cursor;
	switch (yych) {
	case 's':	goto yy166;
	default:	goto yy44;
	}
yy160:
	yych = *++cursor;
	switch (yych) {
	case 'N':	goto yy167;
	default:	goto yy44;
	}
yy161:
	yych = *++cursor;
	switch (yych) {
	case 'V':	goto yy168;
	default:	goto yy44;
	}
yy162:
	yych = *++cursor;
	switch (yych) {
	case 'C':	goto yy169;
	default:	goto yy44;
	}
yy163:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy164;
	}
yy164:
#line 119 "src/pplex.re"
	{ PUSH_TOKEN(SymClass); }
#line 1442 "src/pplex.cc"
yy165:
	yych = *++cursor;
	switch (yych) {
	case 'n':	goto yy170;
	default:	goto yy44;
	}
yy166:
	yych = *++cursor;
	switch (yych) {
	case 'p':	goto yy172;
	default:	goto yy44;
	}
yy167:
	yych = *++cursor;
	switch (yych) {
	case '_':	goto yy173;
	default:	goto yy44;
	}
yy168:
	yych = *++cursor;
	switch (yych) {
	case 'A':	goto yy174;
	default:	goto yy44;
	}
yy169:
	yych = *++cursor;
	switch (yych) {
	case '_':	goto yy175;
	default:	goto yy44;
	}
yy170:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy171;
	}
yy171:
#line 121 "src/pplex.re"
	{ PUSH_TOKEN(SymExtern); }
#line 1544 "src/pplex.cc"
yy172:
	yych = *++cursor;
	switch (yych) {
	case 'a':	goto yy176;
	default:	goto yy44;
	}
yy173:
	yych = *++cursor;
	switch (yych) {
	case 'I':	goto yy177;
	case 'V':	goto yy178;
	default:	goto yy44;
	}
yy174:
	yych = *++cursor;
	switch (yych) {
	case 'R':	goto yy179;
	default:	goto yy44;
	}
yy175:
	yych = *++cursor;
	switch (yych) {
	case 'I':	goto yy181;
	case 'V':	goto yy182;
	default:	goto yy44;
	}
yy176:
	yych = *++cursor;
	switch (yych) {
	case 'c':	goto yy183;
	default:	goto yy44;
	}
yy177:
	yych = *++cursor;
	switch (yych) {
	case 'N':	goto yy184;
	default:	goto yy44;
	}
yy178:
	yych = *++cursor;
	switch (yych) {
	case 'A':	goto yy185;
	default:	goto yy44;
	}
yy179:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy180;
	}
yy180:
#line 125 "src/pplex.re"
	{ PUSH_TOKEN(SymINST_VAR); }
#line 1660 "src/pplex.cc"
yy181:
	yych = *++cursor;
	switch (yych) {
	case 'N':	goto yy186;
	default:	goto yy44;
	}
yy182:
	yych = *++cursor;
	switch (yych) {
	case 'A':	goto yy187;
	default:	goto yy44;
	}
yy183:
	yych = *++cursor;
	switch (yych) {
	case 'e':	goto yy188;
	default:	goto yy44;
	}
yy184:
	yych = *++cursor;
	switch (yych) {
	case 'S':	goto yy190;
	default:	goto yy44;
	}
yy185:
	yych = *++cursor;
	switch (yych) {
	case 'R':	goto yy191;
	default:	goto yy44;
	}
yy186:
	yych = *++cursor;
	switch (yych) {
	case 'S':	goto yy193;
	default:	goto yy44;
	}
yy187:
	yych = *++cursor;
	switch (yych) {
	case 'R':	goto yy194;
	default:	goto yy44;
	}
yy188:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy189;
	}
yy189:
#line 120 "src/pplex.re"
	{ PUSH_TOKEN(SymNamespace); }
#line 1774 "src/pplex.cc"
yy190:
	yych = *++cursor;
	switch (yych) {
	case 'T':	goto yy196;
	default:	goto yy44;
	}
yy191:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy192;
	}
yy192:
#line 123 "src/pplex.re"
	{ PUSH_TOKEN(SymEXTERN_VAR); }
#line 1852 "src/pplex.cc"
yy193:
	yych = *++cursor;
	switch (yych) {
	case 'T':	goto yy197;
	default:	goto yy44;
	}
yy194:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy195;
	}
yy195:
#line 124 "src/pplex.re"
	{ PUSH_TOKEN(SymSTATIC_VAR); }
#line 1930 "src/pplex.cc"
yy196:
	yych = *++cursor;
	switch (yych) {
	case '_':	goto yy198;
	default:	goto yy44;
	}
yy197:
	yych = *++cursor;
	switch (yych) {
	case '_':	goto yy199;
	default:	goto yy44;
	}
yy198:
	yych = *++cursor;
	switch (yych) {
	case 'V':	goto yy200;
	default:	goto yy44;
	}
yy199:
	yych = *++cursor;
	switch (yych) {
	case 'V':	goto yy201;
	default:	goto yy44;
	}
yy200:
	yych = *++cursor;
	switch (yych) {
	case 'A':	goto yy202;
	default:	goto yy44;
	}
yy201:
	yych = *++cursor;
	switch (yych) {
	case 'A':	goto yy203;
	default:	goto yy44;
	}
yy202:
	yych = *++cursor;
	switch (yych) {
	case 'R':	goto yy204;
	default:	goto yy44;
	}
yy203:
	yych = *++cursor;
	switch (yych) {
	case 'R':	goto yy206;
	default:	goto yy44;
	}
yy204:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy205;
	}
yy205:
#line 126 "src/pplex.re"
	{ PUSH_TOKEN(SymEXTERN_INST_VAR); }
#line 2050 "src/pplex.cc"
yy206:
	yych = *++cursor;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	case 'A':
	case 'B':
	case 'C':
	case 'D':
	case 'E':
	case 'F':
	case 'G':
	case 'H':
	case 'I':
	case 'J':
	case 'K':
	case 'L':
	case 'M':
	case 'N':
	case 'O':
	case 'P':
	case 'Q':
	case 'R':
	case 'S':
	case 'T':
	case 'U':
	case 'V':
	case 'W':
	case 'X':
	case 'Y':
	case 'Z':
	case '_':
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
	case 'l':
	case 'm':
	case 'n':
	case 'o':
	case 'p':
	case 'q':
	case 'r':
	case 's':
	case 't':
	case 'u':
	case 'v':
	case 'w':
	case 'x':
	case 'y':
	case 'z':	goto yy43;
	default:	goto yy207;
	}
yy207:
#line 127 "src/pplex.re"
	{ PUSH_TOKEN(SymSTATIC_INST_VAR); }
#line 2122 "src/pplex.cc"
}
#line 164 "src/pplex.re"

    comment:

#line 2128 "src/pplex.cc"
{
	unsigned char yych;
	yych = *cursor;
	switch (yych) {
	case 0x00:	goto yy210;
	case '*':	goto yy214;
	default:	goto yy212;
	}
yy210:
	++cursor;
#line 169 "src/pplex.re"
	{ done = true; PUSH_TOKEN(SymComment); }
#line 2141 "src/pplex.cc"
yy212:
	++cursor;
yy213:
#line 168 "src/pplex.re"
	{ goto comment; }
#line 2147 "src/pplex.cc"
yy214:
	yych = *++cursor;
	switch (yych) {
	case '/':	goto yy215;
	default:	goto yy213;
	}
yy215:
	++cursor;
#line 167 "src/pplex.re"
	{ PUSH_TOKEN(SymComment); }
#line 2158 "src/pplex.cc"
}
#line 170 "src/pplex.re"

    pushtoken:
      token.str = Intern(last, cursor - last);
      result->add(token);
  }
  token.sym = SymEOF;
  token.str = S("");
  result->add(token);
  source->tokens = result;
  return !error;
}

SourceFile *ReadSource(Str *filename, Str *filedata) {
  SourceFile *result = new SourceFile();
  result->filename = filename;
  Str *modulename = filename->clone();
  for (Int i = 0; i < modulename->len(); i++) {
    char ch = modulename->at(i);
    if (ch >= 'a' && ch <= 'z') continue;
    if (ch >= 'A' && ch <= 'Z') continue;
    if (ch >= '0' && ch <= '9') continue;
    if (ch == '_') continue;
    modulename->at(i) = '_';
  }
  result->modulename = modulename;
  if (!filedata)
    filedata = ReadFile(filename);
  result->filedata = filedata;
  if (!result->filedata)
    return NULL;
  Tokenize(result);
  return result;
}
