Mercurial > hg > Members > masakoha > testcode
changeset 102:07f4761c6c58 impl-bitvector
revert descendTreeNode function
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Nov 2015 16:35:54 +0900 |
parents | 2cc097419169 |
children | 4ad2a75dec4a |
files | c/regexParser/createBitVectorList.cc |
diffstat | 1 files changed, 16 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/createBitVectorList.cc Tue Nov 17 06:51:12 2015 +0900 +++ b/c/regexParser/createBitVectorList.cc Tue Nov 17 16:35:54 2015 +0900 @@ -21,9 +21,8 @@ } BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { - // BitVectorListPtr nextBvl = bvl->next[(int)n->Value.character] = allocateBitVectorList(); - BitVectorListPtr nextBvl = allocateBitVectorList(); - // nextBvl->self = bvl->next[(int)n->Value.character]; + BitVectorListPtr nextBvl = bvl->next[(int)n->Value.character] = allocateBitVectorList(); + nextBvl->self = bvl->next[(int)n->Value.character]; nextBvl->bi = bitSet(n->nodeNumber); nextBvl->initBvl = initBvl; @@ -45,16 +44,16 @@ } void printBitVectorList (BitVectorListPtr bvl) { - bool flag = true; + bool initPrintFlag = true; for (int i = 0; i < 256; i++) { if (bvl->next[i] != NULL) { - if (flag){ - puts("----"); - printf(" state : "); bitPrint(bvl->bi); - flag = false; - } + if (initPrintFlag) { + puts("----"); + printf(" state : "); bitPrint(bvl->bi); + initPrintFlag = false; + } printf("input char : %c\n",i); - printf("next state : ");bitPrint(bvl->next[i]->bi); + printf("next state : "); bitPrint(bvl->next[i]->bi); } } @@ -66,29 +65,21 @@ } BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl) { - BitVectorListPtr prev = bvl; + if (n->tokenType == '*') { - - } else if (n->Value.character == '|') { - setNextBitVectorList(prev,descendTreeNode(n->left,bvl),n->left); - bvl = setNextBitVectorList(bvl,descendTreeNode(n->right,bvl),n->right); - + 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 = setNextBitVectorList(prev,descendTreeNode(n->left,bvl),n->left); - bvl = setNextBitVectorList(bvl,descendTreeNode(n->right,bvl),n->right); + bvl = descendTreeNode(n->left,bvl); + bvl = descendTreeNode(n->right,bvl); } else if (n->tokenType == 'a') { bvl = createBitVector(n,bvl); } return bvl; } -BitVectorListPtr setNextBitVectorList(BitVectorListPtr bvl, BitVectorListPtr next, NodePtr n){ - if (isalnum((int)n->Value.character)){ - bvl->next[(int)n->Value.character] = next; - } - return next; -} - BitVectorListPtr createBitVectorList(NodePtr n) { BitVectorListPtr bvl = initBitVector(); descendTreeNode(n,bvl);