Mercurial > hg > Members > masakoha > testcode
changeset 153:e2e717fbeb2f pairPro
fix
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Dec 2015 14:02:41 +0900 |
parents | 1c9e8ba64f6a |
children | 1fad21fd6028 |
files | c/regexParser/Makefile c/regexParser/main.cc c/regexParser/subsetConstraction.cc c/regexParser/transition.h |
diffstat | 4 files changed, 31 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/Makefile Wed Dec 16 17:28:53 2015 +0900 +++ b/c/regexParser/Makefile Fri Dec 18 14:02:41 2015 +0900 @@ -3,7 +3,7 @@ CC= clang++ SRCS_TMP = $(wildcard *.cc) -SRCS_EXCLUDE = determinize.cc subsetConstraction.cc +SRCS_EXCLUDE = determinize.cc SRCS = $(filter-out $(SRCS_EXCLUDE),$(SRCS_TMP)) OBJS = $(SRCS:.cc=.o)
--- a/c/regexParser/main.cc Wed Dec 16 17:28:53 2015 +0900 +++ b/c/regexParser/main.cc Fri Dec 18 14:02:41 2015 +0900 @@ -20,5 +20,6 @@ printf("regex : %s\n",ri->ptr); NodePtr n = regex(ri); printTree(n); + TransitionGenerator tg = generateTransitionList(n); return 0; }
--- a/c/regexParser/subsetConstraction.cc Wed Dec 16 17:28:53 2015 +0900 +++ b/c/regexParser/subsetConstraction.cc Fri Dec 18 14:02:41 2015 +0900 @@ -14,12 +14,12 @@ // 必要ならばnextStateを重ねあわせる // 変更があった場合は新しくリストを作って返す if (end < cc->cond.range.begin ) { // 1 - CharClassPtr cc1 = createCharClassRange(cc->cond.range.begin,cc->cond.range.end,cc->left,cc->right); + CharClassPtr cc1 = charClassMerge(cc,cc->cond.range.begin,cc->cond.range.end,nextState); if (cc->left) { cc1->left = charClassMerge(cc->left,begin,end,nextState); return cc1; } else { - CharClassPtr cc2 = createCharClassRange(begin,end,0,0); + CharClassPtr cc2 = charClassMerge(begin,end,0,0); cc2->nextState = nextState; cc1->left = cc2; return cc1; @@ -36,7 +36,7 @@ if (cc->right) { cc->right = charClassMerge(cc->right,begin,end); } else { - cc->right = createCharClassRange(begin,end,0,0); + cc->right = charClassMerge(begin,end,0,0); } return cc; } @@ -48,7 +48,7 @@ } if (begin >= cc->cond.range.begin && begin <= cc->cond.range.end) { // 12 if (end > cc->cond.range.end) cc->cond.range.end = end; // 11,8 - } else if (begin < cc->cond.range.begin) { // 6 + } else if (begin < cc->cond.range.begin) { // 5 cc->cond.range.begin = begin; cc->cond.range.end = end; } else { @@ -57,35 +57,51 @@ return cc; } -void printTransition(TransitionPtr ts) { - -} - TGValue generateTransition(NodePtr n,TransitionGenerator tg) { if (n->tokenType == '+') { TGValue tgv = generateTransition(n->left,tg); if (tgv.asterisk) { TGValue tgv1 = generateTransition(n->right,tg); - tgv.ts->state->bitContainer |= tgv1.ts->state->bitContainer; + tgv.ts->nextState->bitContainer |= tgv1.ts->nextState->bitContainer; return tgv; } - bitSet(tgv.ts->state,n->right->nodeNumber); + TGValue tgv1 = generateTransition(n->right,tg); + tgv.ts->nextState = tgv1.ts->nextState; return tgv; } else if (n->tokenType == '|') { - + TGValue tgv = generateTransition(n->left,tg); + TGValue tgv1 = generateTransition(n->right,tg); + tgv.ts = appendTransition(tgv.ts,tgv1.ts); + return tgv; } else if (n->tokenType == '*') { - + TGValue tgv = generateTransition(n->left,tg); + tgv.asterisk = true; + return tgv; } else if (n->tokenType == 'c'){ } else if (n->tokenType == 'a'){ - + TGValue tgv; + tgv.ts = (TransitionPtr)malloc(sizeof(Transition)); + tgv.ts->condition = n->cc; + tgv.ts->nextState = (BitVectorPtr)malloc(sizeof(BitVector)); + bitSet(tgv.ts->nextState,n->nodeNumber); + tg.ts = appendTransition(tg.ts,tgv.ts); + return tgv; } else { // error } } +void printTransitionList(TransitionPtr ts) { + for (;ts;ts = ts->next) { + printf("\n"); + } +} + TransitionGenerator generateTransitionList(NodePtr n) { TransitionGenerator tg; + tg.ts = (TransitionPtr)malloc(sizeof(Transition)); generateTransition(n,tg); + printTransitionList(tg.ts); return tg; }