Mercurial > hg > Members > masakoha > testcode
changeset 100:804e51f19f17 impl-bitvector
implement allocateBitVectorList
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Nov 2015 03:17:07 +0900 |
parents | 1e5b56e8263b |
children | 2cc097419169 |
files | c/regexParser/createBitVectorList.cc |
diffstat | 1 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/createBitVectorList.cc Tue Nov 10 20:57:59 2015 +0900 +++ b/c/regexParser/createBitVectorList.cc Tue Nov 17 03:17:07 2015 +0900 @@ -10,10 +10,17 @@ BitVectorListPtr initBvl; +BitVectorListPtr allocateBitVectorList() { + BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); + bvl->self = bvl; + bvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); + + return bvl; +} + BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { - BitVectorListPtr nextBvl = bvl->next[(int)n->Value.character] = (BitVectorListPtr)malloc(sizeof(BitVectorList)); + BitVectorListPtr nextBvl = bvl->next[(int)n->Value.character] = allocateBitVectorList(); nextBvl->self = bvl->next[(int)n->Value.character]; - nextBvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); nextBvl->bi = bitSet(n->nodeNumber); nextBvl->initBvl = initBvl; @@ -26,14 +33,21 @@ } 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)); - bvl->initBvl = bvl->self = initBvl = bvl; - bvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); + + BitVectorListPtr bvl = allocateBitVectorList(); + bvl->initBvl = initBvl = bvl; bvl->bi = bitSet(0); + + for (int i = 0; i < 256; i++) { + bvl->next[i] = NULL; + } + return bvl; } @@ -43,7 +57,8 @@ if (n->tokenType == '*') { bvl = descendTreeNode(n->left,bvl); } else if (n->tokenType == '|') { - + bvl = descendTreeNode(n->left,bvl); + bvl = descendTreeNode(n->parent->right,bvl); } else if (n->Value.character == '+') { bvl = descendTreeNode(n->left,bvl); bvl = descendTreeNode(n->right,bvl);