Mercurial > hg > Members > masakoha > testcode
changeset 47:3d59066744d8
fix
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2015 14:50:51 +0900 |
parents | e13aac1cff0f |
children | 010ae96a3e4e |
files | c/dfaTobin/Makefile c/dfaTobin/main.cc |
diffstat | 2 files changed, 43 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <stdio.h> +#include <stdlib.h> +#include <string.h> + + +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; }