Mercurial > hg > Members > shinya > pyrect
view code/c/regcbc.c @ 0:02656ea776f3
Regexp-Compiler with LLVM
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Jun 2010 00:54:59 +0900 |
parents | |
children | a193b4ff3909 |
line wrap: on
line source
#include <stdio.h> __code state_14(char* s); __code state_12(char* s); __code state_9_11_13_15(char* s); __code state_7_11_13_15(char* s); __code state_2_6_8_10(char* s); __code state_4_6_8_10(char* s); __code state_1_3_5(char* s); __code accept(char* s); __code reject(char* s); int main(int argc, char* argv[]) { puts("regexp: (f|F)(o|O)(o|O)"); puts("number of state: 7"); printf("string: %s\n", argv[1]); goto state_1_3_5(argv[1]); return 0; } __code state_14(char* s) { switch(*s++) { case '\0': goto accept(s); break; default: goto reject(s); } } __code state_12(char* s) { switch(*s++) { case '\0': goto accept(s); break; default: goto reject(s); } } __code state_9_11_13_15(char* s) { switch(*s++) { case 'o': goto state_12(s); break; case 'O': goto state_14(s); break; default: goto reject(s); } } __code state_7_11_13_15(char* s) { switch(*s++) { case 'o': goto state_12(s); break; case 'O': goto state_14(s); break; default: goto reject(s); } } __code state_2_6_8_10(char* s) { switch(*s++) { case 'o': goto state_7_11_13_15(s); break; case 'O': goto state_9_11_13_15(s); break; default: goto reject(s); } } __code state_4_6_8_10(char* s) { switch(*s++) { case 'O': goto state_9_11_13_15(s); break; case 'o': goto state_7_11_13_15(s); break; default: goto reject(s); } } __code state_1_3_5(char* s) { switch(*s++) { case 'F': goto state_4_6_8_10(s); break; case 'f': goto state_2_6_8_10(s); break; default: goto reject(s); } } __code accept(char* s) { printf("\nstring matches regexp. \n\n"); } __code reject(char* s) { printf("\nstring does not match regexp. \n\n"); }