%PDF- %PDF-
Direktori : /usr/share/doc/re2c/examples/c/includes/ |
Current File : //usr/share/doc/re2c/examples/c/includes/include.c |
/* Generated by re2c */ // re2c $INPUT -o $OUTPUT -i #include <assert.h> typedef enum { OK, FAIL } Result; Result lex(const char *s) { const char *YYCURSOR = s, *YYMARKER; { char yych; unsigned int yyaccept = 0; yych = *YYCURSOR; switch (yych) { case '.': goto yy3; case '0': goto yy4; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy5; default: goto yy1; } yy1: ++YYCURSOR; yy2: { return FAIL; } yy3: 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 yy7; default: goto yy2; } yy4: yyaccept = 0; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '.': goto yy7; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy9; case 'E': case 'e': goto yy11; default: goto yy2; } yy5: yyaccept = 1; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '.': goto yy7; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy5; case 'E': case 'e': goto yy11; default: goto yy6; } yy6: { return OK; } yy7: yyaccept = 2; yych = *(YYMARKER = ++YYCURSOR); switch (yych) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy7; case 'E': case 'e': goto yy11; default: goto yy8; } yy8: { return OK; } yy9: yych = *++YYCURSOR; switch (yych) { case '.': goto yy7; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy9; case 'E': case 'e': goto yy11; default: goto yy10; } yy10: YYCURSOR = YYMARKER; switch (yyaccept) { case 0: goto yy2; case 1: goto yy6; default: goto yy8; } yy11: yych = *++YYCURSOR; switch (yych) { case '+': case '-': goto yy12; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': goto yy13; default: goto yy10; } yy12: 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 yy13; default: goto yy10; } yy13: 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 yy13; default: goto yy8; } } } int main() { assert(lex("123") == OK); assert(lex("123.4567") == OK); return 0; }