/* Generated by re2c */ #line 1 "calc_003.re" /* re2c lesson 001_upn_calculator, calc_003, (c) M. Boerger 2006 - 2007 */ #line 18 "calc_003.re" #include #include #include int scan(char *s, int l) { char *p = s; char *q = 0; #define YYCTYPE char #define YYCURSOR p #define YYLIMIT (s+l+2) #define YYMARKER q #define YYFILL(n) { printf("OOD\n"); return 2; } for(;;) { #line 25 "calc_003.c" { YYCTYPE yych; if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); yych = *YYCURSOR; switch (yych) { case 0x00: goto yy2; case '+': goto yy6; case '-': goto yy8; case '0': goto yy10; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy12; default: goto yy4; } yy2: ++YYCURSOR; #line 43 "calc_003.re" { printf("EOF\n"); return 0; } #line 50 "calc_003.c" yy4: ++YYCURSOR; #line 44 "calc_003.re" { printf("ERR\n"); return 1; } #line 55 "calc_003.c" yy6: ++YYCURSOR; #line 41 "calc_003.re" { printf("+\n"); continue; } #line 60 "calc_003.c" yy8: ++YYCURSOR; #line 42 "calc_003.re" { printf("+\n"); continue; } #line 65 "calc_003.c" yy10: yych = *++YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy15; default: goto yy11; } yy11: #line 40 "calc_003.re" { printf("Num\n"); continue; } #line 84 "calc_003.c" yy12: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy12; default: goto yy14; } yy14: #line 39 "calc_003.re" { printf("Num\n"); continue; } #line 105 "calc_003.c" yy15: ++YYCURSOR; if (YYLIMIT <= YYCURSOR) YYFILL(1); yych = *YYCURSOR; switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy15; default: goto yy17; } yy17: #line 38 "calc_003.re" { printf("Oct\n"); continue; } #line 126 "calc_003.c" } #line 45 "calc_003.re" } return 0; } int main(int argc, char **argv) { if (argc > 1) { return scan(argv[1], strlen(argv[1])); } else { fprintf(stderr, "%s \n", argv[0]); return 0; } }