Mercurial > hg > Members > masakoha > testcode
changeset 98:d0d2262d4edf impl-bitvector
implement if (NodeChar == '+')
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 10 Nov 2015 18:08:53 +0900 |
parents | 0b6940588e88 |
children | 1e5b56e8263b |
files | c/regexParser/bitVector.cc c/regexParser/bitVector.h c/regexParser/createBitVectorList.cc |
diffstat | 3 files changed, 21 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/bitVector.cc Tue Nov 10 16:18:06 2015 +0900 +++ b/c/regexParser/bitVector.cc Tue Nov 10 18:08:53 2015 +0900 @@ -15,9 +15,6 @@ bi->arrayNum = (bitSetPosition + 1) / bitBlock; if (((bitSetPosition + 1) % bitBlock) != 0) bi->arrayNum++; - printf("Array Num : %d\n",bi->arrayNum); - - for (int i = 0; i < bi->arrayNum; i++) { bi->bitContainer[i] = 0; }
--- a/c/regexParser/bitVector.h Tue Nov 10 16:18:06 2015 +0900 +++ b/c/regexParser/bitVector.h Tue Nov 10 18:08:53 2015 +0900 @@ -4,6 +4,7 @@ }BitVector,*BitVectorPtr; typedef struct bitVectorList { + bitVectorList *self; BitVectorPtr bi; bitVectorList* next[256]; }BitVectorList, *BitVectorListPtr;
--- a/c/regexParser/createBitVectorList.cc Tue Nov 10 16:18:06 2015 +0900 +++ b/c/regexParser/createBitVectorList.cc Tue Nov 10 18:08:53 2015 +0900 @@ -11,19 +11,28 @@ int bvlIndex; BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { - bvl->next[(int)n->Value.character] = (BitVectorListPtr)malloc(sizeof(BitVectorList)); - bvl->next[(int)n->Value.character]->bi = bitSet(n->nodeNumber); + BitVectorListPtr nextBvl = bvl->next[(int)n->Value.character] = (BitVectorListPtr)malloc(sizeof(BitVectorList)); + nextBvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); + nextBvl->bi = bitSet(n->nodeNumber); + nextBvl->self = bvl->next[(int)n->Value.character]; + puts("-----"); - bitPrint(bvl->bi); - bitPrint(bvl->next[(int)n->Value.character]->bi); + printf(" state : "); bitPrint(bvl->bi); + for (int i = 0; i < 256; i++) { + if (bvl->next[i] != NULL) { + printf("input char : %c\n",i); + } + } + printf("next state : ");bitPrint(bvl->next[(int)n->Value.character]->bi); puts("-----"); return bvl->next[(int)n->Value.character]; } BitVectorListPtr initBitVector() { BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); - BitVectorPtr bi = bitSet(0); - bvl->bi = bi; + bvl->self = bvl; + bvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); + bvl->bi = bitSet(0); return bvl; } @@ -31,17 +40,14 @@ BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl) { if (n->tokenType == '*') { - descendTreeNode(n->left,bvl); + bvl = descendTreeNode(n->left,bvl); } else if (n->tokenType == '|') { } else if (n->Value.character == '+') { - descendTreeNode(n->left,bvl); - descendTreeNode(n->right,bvl); - } else { - if (n->parent->right->tokenType == 'a') { - descendTreeNode(n->parent->right,bvl); - bvl = createBitVector(n,bvl); - } + bvl = descendTreeNode(n->left,bvl); + bvl = descendTreeNode(n->right,bvl); + } else if (n->tokenType == 'a') { + bvl = createBitVector(n,bvl); } return bvl;