From: Ulya Fokanova Date: Fri, 27 Dec 2013 18:58:37 +0000 (+0300) Subject: Test re2c on it's own scanner. X-Git-Tag: 0.13.7.1~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21a1a54113f38239e801a63fcdf35d8cbbf0dddf;p=re2c Test re2c on it's own scanner. --- diff --git a/re2c/test/scanner_re2c.bi.c b/re2c/test/scanner_re2c.bi.c new file mode 100644 index 00000000..322aa3c2 --- /dev/null +++ b/re2c/test/scanner_re2c.bi.c @@ -0,0 +1,2462 @@ +/* Generated by re2c */ +/* $Id$ */ +#include +#include +#include +#include +#include "scanner.h" +#include "parser.h" +#include "y.tab.h" +#include "globals.h" +#include "dfa.h" + +extern YYSTYPE yylval; + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define YYCTYPE unsigned char +#define YYCURSOR cursor +#define YYLIMIT lim +#define YYMARKER ptr +#define YYCTXMARKER ctx +#define YYFILL(n) {cursor = fill(cursor, n);} + +#define RETURN(i) {cur = cursor; return i;} + +namespace re2c +{ + + + +Scanner::ParseMode Scanner::echo() +{ + char *cursor = cur; + bool ignore_eoc = false; + int ignore_cnt = 0; + + if (eof && cursor == eof) // Catch EOF + { + return Stop; + } + + tok = cursor; +echo: + +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + static const unsigned char yybm[] = { + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 160, 0, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 160, 128, 0, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 0, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + }; + + if ((YYLIMIT - YYCURSOR) < 16) YYFILL(16); + yych = *YYCURSOR; + if (yych <= '%') { + if (yych <= '\t') { + if (yych <= 0x00) goto yy8; + goto yy10; + } else { + if (yych <= '\n') goto yy6; + if (yych <= '$') goto yy10; + } + } else { + if (yych <= '*') { + if (yych <= ')') goto yy10; + goto yy5; + } else { + if (yych == '/') goto yy4; + goto yy10; + } + } + ++YYCURSOR; + if ((yych = *YYCURSOR) == '{') goto yy58; +yy3: + { + goto echo; + } +yy4: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '*') goto yy38; + goto yy3; +yy5: + yych = *++YYCURSOR; + if (yych == '/') goto yy33; + goto yy3; +yy6: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy11; + } + if (yych == '#') goto yy14; +yy7: + { + if (ignore_eoc) + { + ignore_cnt++; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + cline++; + goto echo; + } +yy8: + ++YYCURSOR; + { + if (!ignore_eoc && !DFlag) + { + 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(Stop); + } + } +yy10: + yych = *++YYCURSOR; + goto yy3; +yy11: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy11; + } + if (yych == '#') goto yy14; +yy13: + YYCURSOR = YYMARKER; + if (yyaccept <= 1) { + if (yyaccept == 0) { + goto yy3; + } else { + goto yy7; + } + } else { + goto yy34; + } +yy14: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy14; + goto yy13; + } else { + if (yych <= ' ') goto yy14; + if (yych != 'l') goto yy13; + } + yych = *++YYCURSOR; + if (yych != 'i') goto yy13; + yych = *++YYCURSOR; + if (yych != 'n') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych <= '0') goto yy21; + if (yych <= '9') goto yy13; + goto yy21; +yy20: + YYCTXMARKER = YYCURSOR + 1; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy21: + if (yych <= 0x1F) { + if (yych == '\t') goto yy20; + goto yy13; + } else { + if (yych <= ' ') goto yy20; + if (yych <= '0') goto yy13; + if (yych >= ':') goto yy13; + } +yy22: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy22; + } + if (yych <= '\f') { + if (yych <= 0x08) goto yy13; + if (yych <= '\t') goto yy24; + if (yych <= '\n') goto yy26; + goto yy13; + } else { + if (yych <= '\r') goto yy28; + if (yych != ' ') goto yy13; + } +yy24: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy24; + goto yy13; + } else { + if (yych <= ' ') goto yy24; + if (yych == '"') goto yy29; + goto yy13; + } +yy26: + ++YYCURSOR; + YYCURSOR = YYCTXMARKER; + { + set_sourceline(cursor); + goto echo; + } +yy28: + yych = *++YYCURSOR; + if (yych == '\n') goto yy26; + goto yy13; +yy29: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy29; + } + if (yych <= '!') goto yy13; + if (yych <= '"') goto yy32; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy13; + goto yy29; +yy32: + yych = *++YYCURSOR; + if (yych == '\n') goto yy26; + if (yych == '\r') goto yy28; + goto yy13; +yy33: + yyaccept = 2; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '\n') goto yy36; + if (yych == '\r') goto yy35; +yy34: + { + if (ignore_eoc) + { + if (ignore_cnt) + { + out << "\n" << sourceFileInfo; + } + ignore_eoc = false; + ignore_cnt = 0; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + goto echo; + } +yy35: + yych = *++YYCURSOR; + if (yych != '\n') goto yy13; +yy36: + ++YYCURSOR; + { + cline++; + if (ignore_eoc) + { + if (ignore_cnt) + { + out << sourceFileInfo; + } + ignore_eoc = false; + ignore_cnt = 0; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + goto echo; + } +yy38: + yych = *++YYCURSOR; + if (yych != '!') goto yy13; + yych = *++YYCURSOR; + switch (yych) { + case 'g': goto yy42; + case 'i': goto yy41; + case 'm': goto yy43; + case 'r': goto yy45; + case 't': goto yy40; + case 'u': goto yy44; + default: goto yy13; + } +yy40: + yych = *++YYCURSOR; + if (yych == 'y') goto yy100; + goto yy13; +yy41: + yych = *++YYCURSOR; + if (yych == 'g') goto yy89; + goto yy13; +yy42: + yych = *++YYCURSOR; + if (yych == 'e') goto yy76; + goto yy13; +yy43: + yych = *++YYCURSOR; + if (yych == 'a') goto yy68; + goto yy13; +yy44: + yych = *++YYCURSOR; + if (yych == 's') goto yy60; + goto yy13; +yy45: + yych = *++YYCURSOR; + if (yych == 'e') goto yy46; + if (yych == 'u') goto yy47; + goto yy13; +yy46: + yych = *++YYCURSOR; + if (yych == '2') goto yy57; + goto yy13; +yy47: + yych = *++YYCURSOR; + if (yych != 'l') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != 's') goto yy13; + yych = *++YYCURSOR; + if (yych != ':') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != '2') goto yy13; + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; + ++YYCURSOR; + { + if (rFlag) + { + mapCodeName.clear(); + } + else + { + fatal("found 'rules:re2c' block without -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + tok = cursor; + RETURN(Rules); + } +yy57: + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; +yy58: + ++YYCURSOR; + { + if (rFlag) + { + fatal("found standard 're2c' block while using -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + if (!DFlag) + { + out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok)); + } + tok = cursor; + RETURN(Parse); + } +yy60: + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != ':') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != '2') goto yy13; + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; + ++YYCURSOR; + { + if (!rFlag) + { + fatal("found 'use:re2c' block without -r flag"); + } + reuse(); + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + if (!DFlag) + { + out.write((const char*)(tok), (const char*)(&cursor[-11]) - (const char*)(tok)); + } + tok = cursor; + RETURN(Reuse); + } +yy68: + yych = *++YYCURSOR; + if (yych != 'x') goto yy13; + yych = *++YYCURSOR; + if (yych != ':') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != '2') goto yy13; + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; + ++YYCURSOR; + { + if (bUsedYYMaxFill) + { + fatal("cannot generate YYMAXFILL twice"); + } + if (!DFlag) + { + out << "#define YYMAXFILL " << maxFill << std::endl; + } + tok = pos = cursor; + ignore_eoc = true; + bUsedYYMaxFill = true; + goto echo; + } +yy76: + yych = *++YYCURSOR; + if (yych != 't') goto yy13; + yych = *++YYCURSOR; + if (yych != 's') goto yy13; + yych = *++YYCURSOR; + if (yych != 't') goto yy13; + yych = *++YYCURSOR; + if (yych != 'a') goto yy13; + yych = *++YYCURSOR; + if (yych != 't') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != ':') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != '2') goto yy13; + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; + ++YYCURSOR; + { + tok = pos = cursor; + genGetStateGoto(out, topIndent, 0); + ignore_eoc = true; + goto echo; + } +yy89: + yych = *++YYCURSOR; + if (yych != 'n') goto yy13; + yych = *++YYCURSOR; + if (yych != 'o') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != ':') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != '2') goto yy13; + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; + ++YYCURSOR; + { + tok = pos = cursor; + ignore_eoc = true; + goto echo; + } +yy100: + yych = *++YYCURSOR; + if (yych != 'p') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != 's') goto yy13; + yych = *++YYCURSOR; + if (yych != ':') goto yy13; + yych = *++YYCURSOR; + if (yych != 'r') goto yy13; + yych = *++YYCURSOR; + if (yych != 'e') goto yy13; + yych = *++YYCURSOR; + if (yych != '2') goto yy13; + yych = *++YYCURSOR; + if (yych != 'c') goto yy13; + ++YYCURSOR; + { + if (bSinglePass) + { + fatal("cannot generate types inline in single pass mode"); + } + tok = pos = cursor; + ignore_eoc = true; + if (bLastPass && !DFlag) + { + out << outputFileInfo; + out << "\n"; + out << typesInline; + out << "\n"; + out << sourceFileInfo; + } + goto echo; + } +} + +} + +int Scanner::scan() +{ + char *cursor = cur; + uint depth; + +scan: + tchar = cursor - pos; + tline = cline; + tok = cursor; + if (iscfg == 1) + { + goto config; + } + else if (iscfg == 2) + { + goto value; + } + +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + static const unsigned char yybm[] = { + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 212, 0, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 212, 208, 192, 208, 208, 208, 208, 80, + 208, 208, 208, 208, 208, 208, 208, 208, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 208, 208, 208, 208, 208, 208, + 208, 240, 240, 240, 240, 240, 240, 240, + 240, 240, 240, 240, 240, 240, 240, 240, + 240, 240, 240, 240, 240, 240, 240, 240, + 240, 240, 240, 208, 0, 144, 208, 240, + 208, 240, 240, 240, 240, 240, 240, 240, + 240, 240, 240, 240, 240, 240, 240, 240, + 240, 240, 240, 240, 240, 240, 240, 240, + 240, 240, 240, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 208, + }; + if ((YYLIMIT - YYCURSOR) < 6) YYFILL(6); + yych = *YYCURSOR; + if (yych <= '.') { + if (yych <= '"') { + if (yych <= '\f') { + if (yych <= 0x08) goto yy140; + if (yych <= '\t') goto yy135; + if (yych <= '\n') goto yy137; + goto yy140; + } else { + if (yych <= 0x1F) { + if (yych <= '\r') goto yy139; + goto yy140; + } else { + if (yych <= ' ') goto yy135; + if (yych <= '!') goto yy140; + goto yy121; + } + } + } else { + if (yych <= ')') { + if (yych <= '%') { + if (yych <= '$') goto yy140; + goto yy118; + } else { + if (yych <= '&') goto yy140; + if (yych <= '\'') goto yy123; + goto yy128; + } + } else { + if (yych <= '+') { + if (yych <= '*') goto yy119; + goto yy129; + } else { + if (yych <= ',') goto yy128; + if (yych <= '-') goto yy140; + goto yy133; + } + } + } + } else { + if (yych <= '[') { + if (yych <= '<') { + if (yych <= '9') { + if (yych <= '/') goto yy116; + goto yy140; + } else { + if (yych <= ':') goto yy114; + if (yych <= ';') goto yy128; + goto yy127; + } + } else { + if (yych <= '?') { + if (yych <= '>') goto yy128; + goto yy129; + } else { + if (yych <= '@') goto yy140; + if (yych <= 'Z') goto yy132; + goto yy125; + } + } + } else { + if (yych <= 'q') { + if (yych <= '^') { + if (yych <= '\\') goto yy128; + goto yy140; + } else { + if (yych == '`') goto yy140; + goto yy132; + } + } else { + if (yych <= 'z') { + if (yych <= 'r') goto yy131; + goto yy132; + } else { + if (yych <= '{') goto yy112; + if (yych <= '|') goto yy128; + goto yy140; + } + } + } + } +yy112: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') { + if (yych <= '/') { + if (yych == ',') goto yy233; + } else { + if (yych <= '0') goto yy230; + if (yych <= '9') goto yy231; + } + } else { + if (yych <= '_') { + if (yych <= 'Z') goto yy228; + if (yych >= '_') goto yy228; + } else { + if (yych <= '`') goto yy113; + if (yych <= 'z') goto yy228; + } + } +yy113: + { + depth = 1; + goto code; + } +yy114: + YYCTXMARKER = YYCURSOR + 1; + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy224; +yy115: + { + std::ostringstream msg; + msg << "unexpected character: "; + prtChOrHex(msg, *tok); + fatal(msg.str().c_str()); + goto scan; + } +yy116: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '*') goto yy220; + if (yych == '/') goto yy222; +yy117: + { + RETURN(*tok); + } +yy118: + yych = *++YYCURSOR; + if (yych == '}') goto yy218; + goto yy115; +yy119: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '/') goto yy218; + { + yylval.op = *tok; + RETURN(STAR); + } +yy121: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '\n') goto yy214; +yy122: + { + fatal("unterminated string constant (missing \")"); + } +yy123: + yyaccept = 2; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '\n') goto yy209; +yy124: + { + fatal("unterminated string constant (missing ')"); + } +yy125: + yyaccept = 3; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '\n') goto yy126; + if (yych == '^') goto yy200; + goto yy199; +yy126: + { + fatal("unterminated range (missing ])"); + } +yy127: + yyaccept = 4; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '!') goto yy189; + if (yych == '>') goto yy191; + goto yy117; +yy128: + yych = *++YYCURSOR; + goto yy117; +yy129: + ++YYCURSOR; + { + yylval.op = *tok; + RETURN(CLOSE); + } +yy131: + YYCTXMARKER = YYCURSOR + 1; + yych = *++YYCURSOR; + if (yych == 'e') goto yy178; + goto yy167; +yy132: + YYCTXMARKER = YYCURSOR + 1; + yych = *++YYCURSOR; + goto yy167; +yy133: + ++YYCURSOR; + { + cur = cursor; + yylval.regexp = mkDot(); + return RANGE; + } +yy135: + ++YYCURSOR; + yych = *YYCURSOR; + goto yy165; +yy136: + { + goto scan; + } +yy137: + yyaccept = 5; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 4) { + goto yy142; + } + if (yych == '#') goto yy145; +yy138: + { + if (cursor == eof) RETURN(0); + pos = cursor; + cline++; + goto scan; + } +yy139: + yych = *++YYCURSOR; + if (yych == '\n') goto yy141; + goto yy115; +yy140: + yych = *++YYCURSOR; + goto yy115; +yy141: + yyaccept = 5; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 4) { + goto yy142; + } + if (yych == '#') goto yy145; + goto yy138; +yy142: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy142; + } + if (yych == '#') goto yy145; +yy144: + YYCURSOR = YYMARKER; + if (yyaccept <= 3) { + if (yyaccept <= 1) { + if (yyaccept == 0) { + goto yy113; + } else { + goto yy122; + } + } else { + if (yyaccept == 2) { + goto yy124; + } else { + goto yy126; + } + } + } else { + if (yyaccept <= 5) { + if (yyaccept == 4) { + goto yy117; + } else { + goto yy138; + } + } else { + if (yyaccept == 6) { + goto yy184; + } else { + goto yy234; + } + } + } +yy145: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy145; + goto yy144; + } else { + if (yych <= ' ') goto yy145; + if (yych != 'l') goto yy144; + } + yych = *++YYCURSOR; + if (yych != 'i') goto yy144; + yych = *++YYCURSOR; + if (yych != 'n') goto yy144; + yych = *++YYCURSOR; + if (yych != 'e') goto yy144; + yych = *++YYCURSOR; + if (yych <= '0') goto yy152; + if (yych <= '9') goto yy144; + goto yy152; +yy151: + YYCTXMARKER = YYCURSOR + 1; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy152: + if (yych <= 0x1F) { + if (yych == '\t') goto yy151; + goto yy144; + } else { + if (yych <= ' ') goto yy151; + if (yych <= '0') goto yy144; + if (yych >= ':') goto yy144; + } +yy153: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yybm[0+yych] & 8) { + goto yy153; + } + if (yych <= '\f') { + if (yych <= 0x08) goto yy144; + if (yych <= '\t') goto yy155; + if (yych <= '\n') goto yy157; + goto yy144; + } else { + if (yych <= '\r') goto yy159; + if (yych != ' ') goto yy144; + } +yy155: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy155; + goto yy144; + } else { + if (yych <= ' ') goto yy155; + if (yych == '"') goto yy160; + goto yy144; + } +yy157: + ++YYCURSOR; + YYCURSOR = YYCTXMARKER; + { + set_sourceline(cursor); + goto scan; + } +yy159: + yych = *++YYCURSOR; + if (yych == '\n') goto yy157; + goto yy144; +yy160: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy160; + } + if (yych <= '!') goto yy144; + if (yych <= '"') goto yy163; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy144; + goto yy160; +yy163: + yych = *++YYCURSOR; + if (yych == '\n') goto yy157; + if (yych == '\r') goto yy159; + goto yy144; +yy164: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy165: + if (yych == '\t') goto yy164; + if (yych == ' ') goto yy164; + goto yy136; +yy166: + YYCTXMARKER = YYCURSOR + 1; + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; +yy167: + if (yybm[0+yych] & 32) { + goto yy166; + } + if (yych <= ' ') { + if (yych == '\t') goto yy170; + if (yych <= 0x1F) goto yy169; + goto yy170; + } else { + if (yych <= ',') { + if (yych <= '+') goto yy169; + goto yy171; + } else { + if (yych <= '<') goto yy169; + if (yych <= '>') goto yy171; + goto yy169; + } + } +yy168: + YYCURSOR = YYCTXMARKER; + { + if (!FFlag) { + cur = cursor; + yylval.symbol = Symbol::find(token()); + return ID; + } else { + /* Add one char in front and one behind instead of 's or "s */ + cur = cursor; + if (bCaseInsensitive || bCaseInverted) + { + yylval.regexp = strToCaseInsensitiveRE(raw_token("\"")); + } + else + { + yylval.regexp = strToRE(raw_token("\"")); + } + return STRING; + } + } +yy169: + yych = *++YYCURSOR; + goto yy168; +yy170: + yych = *++YYCURSOR; + goto yy176; +yy171: + ++YYCURSOR; +yy172: + YYCURSOR = YYCTXMARKER; + { + cur = ptr > tok ? ptr - 1 : cursor; + yylval.symbol = Symbol::find(token()); + return ID; + } +yy173: + ++YYCURSOR; + YYCURSOR = YYCTXMARKER; + { + cur = ptr > tok ? ptr - 1 : cursor; + yylval.symbol = Symbol::find(token()); + return FFlag ? FID : ID; + } +yy175: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy176: + if (yych <= ' ') { + if (yych == '\t') goto yy175; + if (yych <= 0x1F) goto yy173; + goto yy175; + } else { + if (yych <= ',') { + if (yych <= '+') goto yy173; + } else { + if (yych <= '<') goto yy173; + if (yych >= '?') goto yy173; + } + } + yych = *++YYCURSOR; + goto yy172; +yy178: + YYCTXMARKER = YYCURSOR + 1; + yych = *++YYCURSOR; + if (yych != '2') goto yy167; + YYCTXMARKER = YYCURSOR + 1; + yych = *++YYCURSOR; + if (yych != 'c') goto yy167; + YYCTXMARKER = YYCURSOR + 1; + yych = *++YYCURSOR; + if (yych != ':') goto yy167; + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy168; + if (yych >= '[') goto yy168; + } else { + if (yych == '`') goto yy168; + if (yych >= '{') goto yy168; + } +yy182: + yyaccept = 6; + YYMARKER = ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '9') { + if (yych >= '0') goto yy182; + } else { + if (yych <= ':') goto yy186; + if (yych >= '@') goto yy185; + } + } else { + if (yych <= '_') { + if (yych <= 'Z') goto yy182; + if (yych >= '_') goto yy182; + } else { + if (yych <= '`') goto yy184; + if (yych <= 'z') goto yy182; + } + } +yy184: + { + cur = cursor; + tok += 5; /* skip "re2c:" */ + iscfg = 1; + yylval.str = new Str(token()); + return CONFIG; + } +yy185: + yych = *++YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy144; + if (yych <= 'Z') goto yy187; + goto yy144; + } else { + if (yych == '`') goto yy144; + if (yych <= 'z') goto yy187; + goto yy144; + } +yy186: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '^') { + if (yych <= '@') goto yy144; + if (yych <= 'Z') goto yy182; + goto yy144; + } else { + if (yych == '`') goto yy144; + if (yych <= 'z') goto yy182; + goto yy144; + } +yy187: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 'Z') { + if (yych <= '/') goto yy184; + if (yych <= '9') goto yy187; + if (yych <= '@') goto yy184; + goto yy187; + } else { + if (yych <= '_') { + if (yych <= '^') goto yy184; + goto yy187; + } else { + if (yych <= '`') goto yy184; + if (yych <= 'z') goto yy187; + goto yy184; + } + } +yy189: + ++YYCURSOR; + { + RETURN(SETUP); + } +yy191: + YYCTXMARKER = YYCURSOR + 1; + yych = *++YYCURSOR; + goto yy193; +yy192: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; +yy193: + if (yych <= '9') { + if (yych <= '\t') { + if (yych <= 0x08) goto yy144; + goto yy192; + } else { + if (yych == ' ') goto yy192; + goto yy144; + } + } else { + if (yych <= '=') { + if (yych <= ':') goto yy197; + if (yych <= '<') goto yy144; + goto yy196; + } else { + if (yych != '{') goto yy144; + } + } +yy194: + ++YYCURSOR; + YYCURSOR = YYCTXMARKER; + { + RETURN(NOCOND); + } +yy196: + yych = *++YYCURSOR; + if (yych == '>') goto yy194; + goto yy144; +yy197: + yych = *++YYCURSOR; + if (yych == '=') goto yy194; + goto yy144; +yy198: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy199: + if (yybm[0+yych] & 64) { + goto yy198; + } + if (yych <= '[') goto yy144; + if (yych <= '\\') goto yy202; + goto yy203; +yy200: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '[') { + if (yych == '\n') goto yy144; + goto yy200; + } else { + if (yych <= '\\') goto yy205; + if (yych <= ']') goto yy206; + goto yy200; + } +yy202: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy144; + goto yy198; +yy203: + ++YYCURSOR; + { + cur = cursor; + yylval.regexp = ranToRE(token()); + return RANGE; + } +yy205: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy144; + goto yy200; +yy206: + ++YYCURSOR; + { + cur = cursor; + yylval.regexp = invToRE(token()); + return RANGE; + } +yy208: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy209: + if (yybm[0+yych] & 128) { + goto yy208; + } + if (yych <= '&') goto yy144; + if (yych <= '\'') goto yy211; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy144; + goto yy208; +yy211: + ++YYCURSOR; + { + cur = cursor; + if (bCaseInverted) + { + yylval.regexp = strToRE(token()); + } + else + { + yylval.regexp = strToCaseInsensitiveRE(token()); + } + return STRING; + } +yy213: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy214: + if (yych <= '!') { + if (yych == '\n') goto yy144; + goto yy213; + } else { + if (yych <= '"') goto yy216; + if (yych != '\\') goto yy213; + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy144; + goto yy213; +yy216: + ++YYCURSOR; + { + cur = cursor; + if (bCaseInsensitive || bCaseInverted) + { + yylval.regexp = strToCaseInsensitiveRE(token()); + } + else + { + yylval.regexp = strToRE(token()); + } + return STRING; + } +yy218: + ++YYCURSOR; + { + tok = cursor; + RETURN(0); + } +yy220: + ++YYCURSOR; + { + depth = 1; + goto comment; + } +yy222: + ++YYCURSOR; + { + goto nextLine; + } +yy224: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '>') goto yy226; + { + cur = cursor; + tok += 2; /* skip ":=" */ + depth = 0; + goto code; + } +yy226: + ++YYCURSOR; + YYCURSOR = YYCTXMARKER; + { + RETURN(*tok); + } +yy228: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '^') { + if (yych <= '9') { + if (yych <= '/') goto yy144; + goto yy228; + } else { + if (yych <= '@') goto yy144; + if (yych <= 'Z') goto yy228; + goto yy144; + } + } else { + if (yych <= 'z') { + if (yych == '`') goto yy144; + goto yy228; + } else { + if (yych == '}') goto yy247; + goto yy144; + } + } +yy230: + yych = *++YYCURSOR; + if (yych == ',') goto yy244; + goto yy232; +yy231: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; +yy232: + if (yych <= '/') { + if (yych == ',') goto yy237; + goto yy144; + } else { + if (yych <= '9') goto yy231; + if (yych == '}') goto yy235; + goto yy144; + } +yy233: + ++YYCURSOR; +yy234: + { + fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); + } +yy235: + ++YYCURSOR; + { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = atoi((char *)tok+1); + RETURN(CLOSESIZE); + } +yy237: + yyaccept = 7; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '/') goto yy234; + if (yych <= '9') goto yy240; + if (yych != '}') goto yy234; + ++YYCURSOR; + { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = -1; + RETURN(CLOSESIZE); + } +yy240: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '/') goto yy144; + if (yych <= '9') goto yy240; + if (yych != '}') goto yy144; + ++YYCURSOR; + { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1)); + RETURN(CLOSESIZE); + } +yy244: + yyaccept = 7; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '/') goto yy234; + if (yych <= '9') goto yy240; + if (yych != '}') goto yy234; + ++YYCURSOR; + { + yylval.op = '*'; + RETURN(CLOSE); + } +yy247: + ++YYCURSOR; + { + if (!FFlag) { + fatal("curly braces for names only allowed with -F switch"); + } + cur = cursor; + yylval.symbol = Symbol::find(token(1, cur - tok - 2)); + return ID; + } +} + + +code: + +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + static const unsigned char yybm[] = { + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 112, 0, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 112, 48, 16, 48, 48, 48, 48, 32, + 48, 48, 48, 48, 48, 48, 48, 48, + 176, 176, 176, 176, 176, 176, 176, 176, + 176, 176, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 0, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + 48, 48, 48, 48, 48, 48, 48, 48, + }; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yych <= '&') { + if (yych <= '\n') { + if (yych <= 0x00) goto yy257; + if (yych <= '\t') goto yy259; + goto yy255; + } else { + if (yych == '"') goto yy261; + goto yy259; + } + } else { + if (yych <= '{') { + if (yych <= '\'') goto yy262; + if (yych <= 'z') goto yy259; + goto yy253; + } else { + if (yych != '}') goto yy259; + } + } + ++YYCURSOR; + { + if (depth == 0) + { + fatal("Curly braces are not allowed after ':='"); + } + else if (--depth == 0) + { + cur = cursor; + yylval.token = new Token(token(), sourceFileInfo.fname, tline); + return CODE; + } + goto code; + } +yy253: + ++YYCURSOR; + { + if (depth == 0) + { + fatal("Curly braces are not allowed after ':='"); + } + else + { + ++depth; + } + goto code; + } +yy255: + YYCTXMARKER = YYCURSOR + 1; + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\r') { + if (yych <= '\t') { + if (yych >= '\t') goto yy270; + } else { + if (yych <= '\n') goto yy272; + if (yych >= '\r') goto yy272; + } + } else { + if (yych <= ' ') { + if (yych >= ' ') goto yy270; + } else { + if (yych == '#') goto yy273; + } + } +yy256: + { + if (depth == 0) + { + cur = cursor; + tok += strspn(tok, " \t\r\n"); + while (cur > tok && strchr(" \t\r\n", cur[-1])) + { + --cur; + } + yylval.token = new Token(token(), sourceFileInfo.fname, tline); + return CODE; + } + else if (cursor == eof) + { + fatal("missing '}'"); + } + pos = cursor; + cline++; + goto code; + } +yy257: + ++YYCURSOR; + { + if (cursor == eof) + { + if (depth) + { + fatal("missing '}'"); + } + RETURN(0); + } + goto code; + } +yy259: + ++YYCURSOR; +yy260: + { + goto code; + } +yy261: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '\n') goto yy260; + goto yy268; +yy262: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '\n') goto yy260; + goto yy264; +yy263: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy264: + if (yybm[0+yych] & 16) { + goto yy263; + } + if (yych <= '&') goto yy265; + if (yych <= '\'') goto yy259; + goto yy266; +yy265: + YYCURSOR = YYMARKER; + if (yyaccept <= 1) { + if (yyaccept == 0) { + goto yy256; + } else { + goto yy260; + } + } else { + goto yy271; + } +yy266: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy265; + goto yy263; +yy267: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy268: + if (yybm[0+yych] & 32) { + goto yy267; + } + if (yych <= '!') goto yy265; + if (yych <= '"') goto yy259; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy265; + goto yy267; +yy270: + yyaccept = 2; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 0x1F) { + if (yych == '\t') goto yy292; + } else { + if (yych <= ' ') goto yy292; + if (yych == '#') goto yy273; + } +yy271: + YYCURSOR = YYCTXMARKER; + { + if (depth == 0) + { + goto code; + } + else if (cursor == eof) + { + fatal("missing '}'"); + } + pos = cursor; + cline++; + goto code; + } +yy272: + yych = *++YYCURSOR; + goto yy271; +yy273: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); + yych = *YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy273; + } + if (yych != 'l') goto yy265; + yych = *++YYCURSOR; + if (yych != 'i') goto yy265; + yych = *++YYCURSOR; + if (yych != 'n') goto yy265; + yych = *++YYCURSOR; + if (yych != 'e') goto yy265; + yych = *++YYCURSOR; + if (yych <= '0') goto yy280; + if (yych <= '9') goto yy265; + goto yy280; +yy279: + YYCTXMARKER = YYCURSOR + 1; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy280: + if (yych <= 0x1F) { + if (yych == '\t') goto yy279; + goto yy265; + } else { + if (yych <= ' ') goto yy279; + if (yych <= '0') goto yy265; + if (yych >= ':') goto yy265; + } +yy281: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy281; + } + if (yych <= '\f') { + if (yych <= 0x08) goto yy265; + if (yych <= '\t') goto yy283; + if (yych <= '\n') goto yy285; + goto yy265; + } else { + if (yych <= '\r') goto yy287; + if (yych != ' ') goto yy265; + } +yy283: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy283; + goto yy265; + } else { + if (yych <= ' ') goto yy283; + if (yych == '"') goto yy288; + goto yy265; + } +yy285: + ++YYCURSOR; + YYCURSOR = YYCTXMARKER; + { + set_sourceline(cursor); + goto code; + } +yy287: + yych = *++YYCURSOR; + if (yych == '\n') goto yy285; + goto yy265; +yy288: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yych <= '!') { + if (yych == '\n') goto yy265; + goto yy288; + } else { + if (yych <= '"') goto yy291; + if (yych != '\\') goto yy288; + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy265; + goto yy288; +yy291: + yych = *++YYCURSOR; + if (yych == '\n') goto yy285; + if (yych == '\r') goto yy287; + goto yy265; +yy292: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy292; + goto yy265; + } else { + if (yych <= ' ') goto yy292; + if (yych == '#') goto yy273; + goto yy265; + } +} + + +comment: + +{ + YYCTYPE yych; + static const unsigned char yybm[] = { + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 160, 0, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 160, 128, 0, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 0, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, + }; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= ')') { + if (yych == '\n') goto yy299; + goto yy301; + } else { + if (yych <= '*') goto yy296; + if (yych == '/') goto yy298; + goto yy301; + } +yy296: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '/') goto yy326; +yy297: + { + if (cursor == eof) + { + RETURN(0); + } + goto comment; + } +yy298: + yych = *++YYCURSOR; + if (yych == '*') goto yy324; + goto yy297; +yy299: + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy302; + } + if (yych == '#') goto yy305; +yy300: + { + if (cursor == eof) + { + RETURN(0); + } + tok = pos = cursor; + cline++; + goto comment; + } +yy301: + yych = *++YYCURSOR; + goto yy297; +yy302: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy302; + } + if (yych == '#') goto yy305; +yy304: + YYCURSOR = YYMARKER; + goto yy300; +yy305: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 5) YYFILL(5); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy305; + goto yy304; + } else { + if (yych <= ' ') goto yy305; + if (yych != 'l') goto yy304; + } + yych = *++YYCURSOR; + if (yych != 'i') goto yy304; + yych = *++YYCURSOR; + if (yych != 'n') goto yy304; + yych = *++YYCURSOR; + if (yych != 'e') goto yy304; + yych = *++YYCURSOR; + if (yych <= '0') goto yy312; + if (yych <= '9') goto yy304; + goto yy312; +yy311: + YYCTXMARKER = YYCURSOR + 1; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy312: + if (yych <= 0x1F) { + if (yych == '\t') goto yy311; + goto yy304; + } else { + if (yych <= ' ') goto yy311; + if (yych <= '0') goto yy304; + if (yych >= ':') goto yy304; + } +yy313: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy313; + } + if (yych <= '\f') { + if (yych <= 0x08) goto yy304; + if (yych <= '\t') goto yy315; + if (yych <= '\n') goto yy317; + goto yy304; + } else { + if (yych <= '\r') goto yy319; + if (yych != ' ') goto yy304; + } +yy315: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych == '\t') goto yy315; + goto yy304; + } else { + if (yych <= ' ') goto yy315; + if (yych == '"') goto yy320; + goto yy304; + } +yy317: + ++YYCURSOR; + YYCURSOR = YYCTXMARKER; + { + set_sourceline(cursor); + goto comment; + } +yy319: + yych = *++YYCURSOR; + if (yych == '\n') goto yy317; + goto yy304; +yy320: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy320; + } + if (yych <= '!') goto yy304; + if (yych <= '"') goto yy323; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy304; + goto yy320; +yy323: + yych = *++YYCURSOR; + if (yych == '\n') goto yy317; + if (yych == '\r') goto yy319; + goto yy304; +yy324: + ++YYCURSOR; + { + ++depth; + fatal("ambiguous /* found"); + goto comment; + } +yy326: + ++YYCURSOR; + { + if (--depth == 0) + { + goto scan; + } + else + { + goto comment; + } + } +} + + +nextLine: + +{ + YYCTYPE yych; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych != '\n') goto yy332; + ++YYCURSOR; + { if(cursor == eof) { + RETURN(0); + } + tok = pos = cursor; + cline++; + goto scan; + } +yy332: + ++YYCURSOR; + { if(cursor == eof) { + RETURN(0); + } + goto nextLine; + } +} + + +config: + +{ + YYCTYPE yych; + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 128, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych != '\t') goto yy340; + } else { + if (yych <= ' ') goto yy336; + if (yych == '=') goto yy338; + goto yy340; + } +yy336: + ++YYCURSOR; + yych = *YYCURSOR; + goto yy345; +yy337: + { + goto config; + } +yy338: + ++YYCURSOR; + yych = *YYCURSOR; + goto yy343; +yy339: + { + iscfg = 2; + cur = cursor; + RETURN('='); + } +yy340: + ++YYCURSOR; + { + fatal("missing '='"); + } +yy342: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy343: + if (yybm[0+yych] & 128) { + goto yy342; + } + goto yy339; +yy344: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy345: + if (yych == '\t') goto yy344; + if (yych == ' ') goto yy344; + goto yy337; +} + + +value: + +{ + YYCTYPE yych; + static const unsigned char yybm[] = { + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 192, 0, 248, 248, 192, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 192, 248, 104, 248, 248, 248, 248, 152, + 248, 248, 248, 248, 248, 248, 248, 248, + 252, 252, 252, 252, 252, 252, 252, 252, + 252, 252, 248, 192, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 8, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + 248, 248, 248, 248, 248, 248, 248, 248, + }; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '&') { + if (yych <= '\r') { + if (yych <= 0x08) goto yy354; + if (yych <= '\n') goto yy348; + if (yych <= '\f') goto yy354; + } else { + if (yych <= ' ') { + if (yych <= 0x1F) goto yy354; + } else { + if (yych == '"') goto yy356; + goto yy354; + } + } + } else { + if (yych <= '/') { + if (yych <= '\'') goto yy358; + if (yych == '-') goto yy351; + goto yy354; + } else { + if (yych <= '9') { + if (yych <= '0') goto yy349; + goto yy352; + } else { + if (yych != ';') goto yy354; + } + } + } +yy348: + { + cur = cursor; + yylval.str = new Str(token()); + iscfg = 0; + return VALUE; + } +yy349: + ++YYCURSOR; + if (yybm[0+(yych = *YYCURSOR)] & 8) { + goto yy354; + } +yy350: + { + cur = cursor; + yylval.number = atoi(token().to_string().c_str()); + iscfg = 0; + return NUMBER; + } +yy351: + yych = *++YYCURSOR; + if (yych <= '0') goto yy355; + if (yych >= ':') goto yy355; +yy352: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy352; + } + if (yych <= '\r') { + if (yych <= 0x08) goto yy354; + if (yych <= '\n') goto yy350; + if (yych >= '\r') goto yy350; + } else { + if (yych <= ' ') { + if (yych >= ' ') goto yy350; + } else { + if (yych == ';') goto yy350; + } + } +yy354: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy355: + if (yybm[0+yych] & 8) { + goto yy354; + } + goto yy348; +yy356: + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy356; + } + if (yych <= '!') { + if (yych == '\n') goto yy348; + goto yy366; + } else { + if (yych <= '"') goto yy354; + if (yych <= '[') goto yy366; + goto yy368; + } +yy358: + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy358; + } + if (yych <= '&') { + if (yych == '\n') goto yy348; + } else { + if (yych <= '\'') goto yy354; + if (yych >= '\\') goto yy363; + } +yy360: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy360; + } + if (yych <= '&') goto yy362; + if (yych <= '\'') goto yy364; + goto yy365; +yy362: + YYCURSOR = YYMARKER; + goto yy348; +yy363: + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\r') { + if (yych <= '\t') { + if (yych <= 0x08) goto yy358; + goto yy360; + } else { + if (yych <= '\n') goto yy348; + if (yych <= '\f') goto yy358; + goto yy360; + } + } else { + if (yych <= ' ') { + if (yych <= 0x1F) goto yy358; + goto yy360; + } else { + if (yych == ';') goto yy360; + goto yy358; + } + } +yy364: + yych = *++YYCURSOR; + goto yy348; +yy365: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy362; + goto yy360; +yy366: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy366; + } + if (yych <= '!') goto yy362; + if (yych <= '"') goto yy364; + goto yy369; +yy368: + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\r') { + if (yych <= '\t') { + if (yych <= 0x08) goto yy356; + goto yy366; + } else { + if (yych <= '\n') goto yy348; + if (yych <= '\f') goto yy356; + goto yy366; + } + } else { + if (yych <= ' ') { + if (yych <= 0x1F) goto yy356; + goto yy366; + } else { + if (yych == ';') goto yy366; + goto yy356; + } + } +yy369: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy362; + goto yy366; +} + +} + +void Scanner::set_sourceline(char *& cursor) +{ +sourceline: + tok = cursor; + +{ + YYCTYPE yych; + static const unsigned char yybm[] = { + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 0, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 0, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 192, 192, 192, 192, 192, 192, 192, 192, + 192, 192, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 0, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + }; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '!') { + if (yych == '\n') goto yy376; + goto yy378; + } else { + if (yych <= '"') goto yy374; + if (yych <= '0') goto yy378; + if (yych >= ':') goto yy378; + } + ++YYCURSOR; + yych = *YYCURSOR; + goto yy386; +yy373: + { + cur = cursor; + cline = atoi(token().to_string().c_str()); + goto sourceline; + } +yy374: + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '\n') goto yy380; +yy375: + { + goto sourceline; + } +yy376: + ++YYCURSOR; + { + if (cursor == eof) + { + --cursor; + } + else + { + pos = cursor; + } + tok = cursor; + return; + } +yy378: + yych = *++YYCURSOR; + goto yy375; +yy379: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy380: + if (yybm[0+yych] & 64) { + goto yy379; + } + if (yych <= '!') goto yy381; + if (yych <= '"') goto yy383; + goto yy382; +yy381: + YYCURSOR = YYMARKER; + goto yy375; +yy382: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '\n') goto yy381; + goto yy379; +yy383: + ++YYCURSOR; + { + cur = cursor; + sourceFileInfo.set_fname(token(1, cur - tok - 2).to_string()); + goto sourceline; + } +yy385: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy386: + if (yybm[0+yych] & 128) { + goto yy385; + } + goto yy373; +} + +} + +} // end namespace re2c diff --git a/re2c/test/scanner_re2c.bi.re b/re2c/test/scanner_re2c.bi.re new file mode 100644 index 00000000..1dd6dc10 --- /dev/null +++ b/re2c/test/scanner_re2c.bi.re @@ -0,0 +1,650 @@ +/* $Id$ */ +#include +#include +#include +#include +#include "scanner.h" +#include "parser.h" +#include "y.tab.h" +#include "globals.h" +#include "dfa.h" + +extern YYSTYPE yylval; + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define YYCTYPE unsigned char +#define YYCURSOR cursor +#define YYLIMIT lim +#define YYMARKER ptr +#define YYCTXMARKER ctx +#define YYFILL(n) {cursor = fill(cursor, n);} + +#define RETURN(i) {cur = cursor; return i;} + +namespace re2c +{ + +/*!re2c +zero = "\000"; +any = [\000-\377]; +dot = any \ [\n]; +esc = dot \ [\\]; +istring = "[" "^" ((esc \ [\]]) | "\\" dot)* "]" ; +cstring = "[" ((esc \ [\]]) | "\\" dot)* "]" ; +dstring = "\"" ((esc \ ["] ) | "\\" dot)* "\""; +sstring = "'" ((esc \ ['] ) | "\\" dot)* "'" ; +letter = [a-zA-Z]; +digit = [0-9]; +lineno = [1-9] digit*; +number = "0" | ("-"? [1-9] digit*); +name = (letter|"_") (letter|digit|"_")*; +cname = ":" name; +space = [ \t]; +ws = (space | [\r\n]); +eol = ("\r\n" | "\n"); +config = "re2c" cname+ ("@" name)?; +value = [^\r\n; \t]* | dstring | sstring; +lineinf = lineno (space+ dstring)? eol; +*/ + +Scanner::ParseMode Scanner::echo() +{ + char *cursor = cur; + bool ignore_eoc = false; + int ignore_cnt = 0; + + if (eof && cursor == eof) // Catch EOF + { + return Stop; + } + + tok = cursor; +echo: +/*!re2c + beginRE = "%{" | "/*!re2c"; + beginRE { + if (rFlag) + { + fatal("found standard 're2c' block while using -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + if (!DFlag) + { + out.write((const char*)(tok), (const char*)(&cursor[-7]) - (const char*)(tok)); + } + tok = cursor; + RETURN(Parse); + } + "/*!rules:re2c" { + if (rFlag) + { + mapCodeName.clear(); + } + else + { + fatal("found 'rules:re2c' block without -r flag"); + } + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + tok = cursor; + RETURN(Rules); + } + "/*!use:re2c" { + if (!rFlag) + { + fatal("found 'use:re2c' block without -r flag"); + } + reuse(); + if (bUsedYYMaxFill && bSinglePass) + { + fatal("found scanner block after YYMAXFILL declaration"); + } + if (!DFlag) + { + out.write((const char*)(tok), (const char*)(&cursor[-11]) - (const char*)(tok)); + } + tok = cursor; + RETURN(Reuse); + } + "/*!max:re2c" { + if (bUsedYYMaxFill) + { + fatal("cannot generate YYMAXFILL twice"); + } + if (!DFlag) + { + out << "#define YYMAXFILL " << maxFill << std::endl; + } + tok = pos = cursor; + ignore_eoc = true; + bUsedYYMaxFill = true; + goto echo; + } + "/*!getstate:re2c" { + tok = pos = cursor; + genGetStateGoto(out, topIndent, 0); + ignore_eoc = true; + goto echo; + } + "/*!ignore:re2c" { + tok = pos = cursor; + ignore_eoc = true; + goto echo; + } + "/*!types:re2c" { + if (bSinglePass) + { + fatal("cannot generate types inline in single pass mode"); + } + tok = pos = cursor; + ignore_eoc = true; + if (bLastPass && !DFlag) + { + out << outputFileInfo; + out << "\n"; + out << typesInline; + out << "\n"; + out << sourceFileInfo; + } + goto echo; + } + "*" "/" "\r"? "\n" { + cline++; + if (ignore_eoc) + { + if (ignore_cnt) + { + out << sourceFileInfo; + } + ignore_eoc = false; + ignore_cnt = 0; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + goto echo; + } + "*" "/" { + if (ignore_eoc) + { + if (ignore_cnt) + { + out << "\n" << sourceFileInfo; + } + ignore_eoc = false; + ignore_cnt = 0; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + goto echo; + } + "\n" space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto echo; + } + "\n" { + if (ignore_eoc) + { + ignore_cnt++; + } + else if (!DFlag) + { + out.write((const char*)(tok), (const char*)(cursor) - (const char*)(tok)); + } + tok = pos = cursor; + cline++; + goto echo; + } + zero { + if (!ignore_eoc && !DFlag) + { + 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(Stop); + } + } + any { + goto echo; + } +*/ +} + +int Scanner::scan() +{ + char *cursor = cur; + uint depth; + +scan: + tchar = cursor - pos; + tline = cline; + tok = cursor; + if (iscfg == 1) + { + goto config; + } + else if (iscfg == 2) + { + goto value; + } +/*!re2c + "{" { + depth = 1; + goto code; + } + + ":" / "=>" { + RETURN(*tok); + } + + ":=" { + cur = cursor; + tok += 2; /* skip ":=" */ + depth = 0; + goto code; + } + + "//" { + goto nextLine; + } + "/*" { + depth = 1; + goto comment; + } + + endRE = "%}" | "*/"; + endRE { + tok = cursor; + RETURN(0); + } + + dstring { + cur = cursor; + if (bCaseInsensitive || bCaseInverted) + { + yylval.regexp = strToCaseInsensitiveRE(token()); + } + else + { + yylval.regexp = strToRE(token()); + } + return STRING; + } + + sstring { + cur = cursor; + if (bCaseInverted) + { + yylval.regexp = strToRE(token()); + } + else + { + yylval.regexp = strToCaseInsensitiveRE(token()); + } + return STRING; + } + + "\"" { + fatal("unterminated string constant (missing \")"); + } + "'" { + fatal("unterminated string constant (missing ')"); + } + + istring { + cur = cursor; + yylval.regexp = invToRE(token()); + return RANGE; + } + + cstring { + cur = cursor; + yylval.regexp = ranToRE(token()); + return RANGE; + } + + "[" { + fatal("unterminated range (missing ])"); + } + + "<>" / (space* ("{" | "=>" | ":=")) { + RETURN(NOCOND); + } + ",()|=;/\\] { + RETURN(*tok); + } + + "*" { + yylval.op = *tok; + RETURN(STAR); + } + [+?] { + yylval.op = *tok; + RETURN(CLOSE); + } + + "{0,}" { + yylval.op = '*'; + RETURN(CLOSE); + } + + "{" [0-9]+ "}" { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = atoi((char *)tok+1); + RETURN(CLOSESIZE); + } + + "{" [0-9]+ "," [0-9]+ "}" { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = MAX(yylval.extop.minsize,atoi(strchr((char *)tok, ',')+1)); + RETURN(CLOSESIZE); + } + + "{" [0-9]+ ",}" { + yylval.extop.minsize = atoi((char *)tok+1); + yylval.extop.maxsize = -1; + RETURN(CLOSESIZE); + } + + "{" [0-9]* "," { + fatal("illegal closure form, use '{n}', '{n,}', '{n,m}' where n and m are numbers"); + } + + "{" name "}" { + if (!FFlag) { + fatal("curly braces for names only allowed with -F switch"); + } + cur = cursor; + yylval.symbol = Symbol::find(token(1, cur - tok - 2)); + return ID; + } + + config { + cur = cursor; + tok += 5; /* skip "re2c:" */ + iscfg = 1; + yylval.str = new Str(token()); + return CONFIG; + } + + name / (space+ [^=>,]) { + cur = ptr > tok ? ptr - 1 : cursor; + yylval.symbol = Symbol::find(token()); + return FFlag ? FID : ID; + } + + name / (space* [=>,]) { + cur = ptr > tok ? ptr - 1 : cursor; + yylval.symbol = Symbol::find(token()); + return ID; + } + + name / [^] { + if (!FFlag) { + cur = cursor; + yylval.symbol = Symbol::find(token()); + return ID; + } else { + /* Add one char in front and one behind instead of 's or "s */ + cur = cursor; + if (bCaseInsensitive || bCaseInverted) + { + yylval.regexp = strToCaseInsensitiveRE(raw_token("\"")); + } + else + { + yylval.regexp = strToRE(raw_token("\"")); + } + return STRING; + } + } + + "." { + cur = cursor; + yylval.regexp = mkDot(); + return RANGE; + } + + space+ { + goto scan; + } + + eol space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto scan; + } + + eol { + if (cursor == eof) RETURN(0); + pos = cursor; + cline++; + goto scan; + } + + any { + std::ostringstream msg; + msg << "unexpected character: "; + prtChOrHex(msg, *tok); + fatal(msg.str().c_str()); + goto scan; + } +*/ + +code: +/*!re2c + "}" { + if (depth == 0) + { + fatal("Curly braces are not allowed after ':='"); + } + else if (--depth == 0) + { + cur = cursor; + yylval.token = new Token(token(), sourceFileInfo.fname, tline); + return CODE; + } + goto code; + } + "{" { + if (depth == 0) + { + fatal("Curly braces are not allowed after ':='"); + } + else + { + ++depth; + } + goto code; + } + "\n" space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto code; + } + "\n" / ws { + if (depth == 0) + { + goto code; + } + else if (cursor == eof) + { + fatal("missing '}'"); + } + pos = cursor; + cline++; + goto code; + } + "\n" { + if (depth == 0) + { + cur = cursor; + tok += strspn(tok, " \t\r\n"); + while (cur > tok && strchr(" \t\r\n", cur[-1])) + { + --cur; + } + yylval.token = new Token(token(), sourceFileInfo.fname, tline); + return CODE; + } + else if (cursor == eof) + { + fatal("missing '}'"); + } + pos = cursor; + cline++; + goto code; + } + zero { + if (cursor == eof) + { + if (depth) + { + fatal("missing '}'"); + } + RETURN(0); + } + goto code; + } + dstring | sstring | any { + goto code; + } +*/ + +comment: +/*!re2c + "*/" { + if (--depth == 0) + { + goto scan; + } + else + { + goto comment; + } + } + "/*" { + ++depth; + fatal("ambiguous /* found"); + goto comment; + } + "\n" space* "#" space* "line" space+ / lineinf { + set_sourceline(cursor); + goto comment; + } + "\n" { + if (cursor == eof) + { + RETURN(0); + } + tok = pos = cursor; + cline++; + goto comment; + } + any { + if (cursor == eof) + { + RETURN(0); + } + goto comment; + } +*/ + +nextLine: +/*!re2c /* resync emacs */ + "\n" { if(cursor == eof) { + RETURN(0); + } + tok = pos = cursor; + cline++; + goto scan; + } + any { if(cursor == eof) { + RETURN(0); + } + goto nextLine; + } +*/ + +config: +/*!re2c + space+ { + goto config; + } + "=" space* { + iscfg = 2; + cur = cursor; + RETURN('='); + } + any { + fatal("missing '='"); + } +*/ + +value: +/*!re2c + number { + cur = cursor; + yylval.number = atoi(token().to_string().c_str()); + iscfg = 0; + return NUMBER; + } + value { + cur = cursor; + yylval.str = new Str(token()); + iscfg = 0; + return VALUE; + } +*/ +} + +void Scanner::set_sourceline(char *& cursor) +{ +sourceline: + tok = cursor; +/*!re2c + lineno { + cur = cursor; + cline = atoi(token().to_string().c_str()); + goto sourceline; + } + dstring { + cur = cursor; + sourceFileInfo.set_fname(token(1, cur - tok - 2).to_string()); + goto sourceline; + } + "\n" { + if (cursor == eof) + { + --cursor; + } + else + { + pos = cursor; + } + tok = cursor; + return; + } + any { + goto sourceline; + } +*/ +} + +} // end namespace re2c