/* Generated by re2c */ #line 1 "ctx_s.re" // re2c $INPUT -o $OUTPUT -s #include #include struct Scanner { Scanner(char *txt) : cur(txt), lim(txt + strlen(txt)) { } char *cur; char *lim; char *ptr; char *ctx; char *tok; }; #define YYCTYPE char #define YYCURSOR s.cur #define YYLIMIT s.lim #define YYMARKER s.ptr #define YYCTXMARKER s.ctx #define YYFILL(n) enum What { UNEXPECTED, KEYWORD, NUMBER, EOI }; char * tokens[] = { "UNEXPECTED", "KEYWORD", "NUMBER", "EOI" }; int scan(Scanner &s) { YYCTYPE *cursor = s.cur; if(cursor == s.lim) return EOI; std: s.tok = cursor; #line 51 "ctx_s.c" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); yych = *YYCURSOR; if (yych <= ' ') { if (yych <= 0x08) goto yy1; if (yych <= '\n') goto yy3; if (yych >= ' ') goto yy3; } else { if (yych <= '9') { if (yych >= '0') goto yy4; } else { if (yych <= '`') goto yy1; if (yych <= 'b') goto yy6; } } yy1: ++YYCURSOR; yy2: #line 61 "ctx_s.re" { return UNEXPECTED; } #line 75 "ctx_s.c" yy3: ++YYCURSOR; #line 54 "ctx_s.re" { if(s.cur == s.lim) return EOI; cursor = s.cur; goto std; } #line 85 "ctx_s.c" yy4: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy5; if (yych <= '9') goto yy4; yy5: #line 51 "ctx_s.re" { return NUMBER; } #line 95 "ctx_s.c" yy6: yych = *++YYCURSOR; if (yych <= '/') goto yy2; if (yych == '1') { YYCTXMARKER = YYCURSOR; goto yy9; } if (yych >= ':') goto yy2; YYCTXMARKER = YYCURSOR; yy7: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; if (yych <= '/') goto yy8; if (yych <= '9') goto yy7; yy8: YYCURSOR = YYCTXMARKER; #line 50 "ctx_s.re" { return KEYWORD; } #line 115 "ctx_s.c" yy9: yych = *++YYCURSOR; if (yych <= '/') goto yy10; if (yych <= '9') goto yy7; yy10: YYCURSOR -= 1; #line 49 "ctx_s.re" { return KEYWORD; } #line 124 "ctx_s.c" } #line 64 "ctx_s.re" } #line 130 "ctx_s.c" #define YYMAXFILL 3 #line 67 "ctx_s.re" int main(int,char**) { Scanner s("a77 a1 b8 b1"); int t, n = 0; while ((t = scan(s)) != EOI) { std::cout << (++n) << ": " << tokens[t] << " = \""; std::cout.write(s.tok, s.cur-s.tok); std::cout << "\"" << std::endl; } }