# HG changeset patch # User Masataka Kohagura # Date 1432533051 -32400 # Node ID 3d59066744d8b10e070687f988f9e29f2576594a # Parent e13aac1cff0fb31bfce5a14c710dd556b2dfe328 fix diff -r e13aac1cff0f -r 3d59066744d8 c/dfaTobin/Makefile --- a/c/dfaTobin/Makefile Thu May 21 23:30:54 2015 +0900 +++ b/c/dfaTobin/Makefile Mon May 25 14:50:51 2015 +0900 @@ -1,4 +1,4 @@ -TARGET=read_lseek +TARGET=dfa2bin OPTION= -Wall -O0 -g $(TARGET):main.cc diff -r e13aac1cff0f -r 3d59066744d8 c/dfaTobin/main.cc --- a/c/dfaTobin/main.cc Thu May 21 23:30:54 2015 +0900 +++ b/c/dfaTobin/main.cc Mon May 25 14:50:51 2015 +0900 @@ -1,12 +1,48 @@ #include +#include +#include + + +const char *usr_help_str = "./dfa2bin -regex [regex]"; + +typedef struct dfa{ + short int state : 1; +}dfa,*dfaPtr; + +void checkAppearChar(unsigned char* regex, int regexLength){ + int charTable[256]; + + for (int i = 0; i < regexLength; i++) { + charTable[i] += 1; + } + + for (int i = 0; i < 256; i++) { + printf("charTable[%d] : %d\n",i,charTable[i]); + } +} + +void dfa2bin(unsigned char *regex){ + int regexLength = strlen((char*)regex); + char *regexCharTable = (char*)malloc(sizeof(char)*regexLength); + dfaPtr dfa = (dfaPtr)malloc(sizeof(dfa)*(regexLength+1)); + + for (int i = 0; i < regexLength+1 ; i++) { + dfa[i].state = 0; + } + + dfa[0].state = 1; + + checkAppearChar(regex,regexLength); +} + int main(int argc, char *argv[]){ - char *regex = 0; + unsigned char *regex = 0; for (int i = 1; argv[i]; ++i) { - if (strcmp(argv[i], "-file") == 0){ - regex = argv[i+1]; + if (strcmp(argv[i], "-regex") == 0){ + regex = (unsigned char*)argv[i+1]; } } @@ -15,5 +51,8 @@ exit(1); } + dfa2bin(regex); + + printf("regex : %s\n",regex); return 0; }