Mercurial > hg > Members > masakoha > testcode
changeset 105:766fc2476f01 bitVec-Kaito
fix indent size
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Nov 2015 19:33:07 +0900 |
parents | 3eb3cb5d581f |
children | 8e47f1618608 faa905e55fa4 |
files | c/regexParser/createBitVectorList.cc |
diffstat | 1 files changed, 70 insertions(+), 70 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/createBitVectorList.cc Tue Nov 17 22:20:42 2015 +0900 +++ b/c/regexParser/createBitVectorList.cc Wed Nov 18 19:33:07 2015 +0900 @@ -13,100 +13,100 @@ BitVectorListPtr initBvl; BitVectorListPtr allocateBitVectorList() { - BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); - bvl->self = bvl; - bvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); + BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); + bvl->self = bvl; + bvl->bi = (BitVectorPtr)malloc(sizeof(BitVector)); - return bvl; + return bvl; } BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { - BitVectorListPtr nextBvl = allocateBitVectorList(); - nextBvl->bi = bitSet(n->nodeNumber); - nextBvl->initBvl = initBvl; - return nextBvl; + BitVectorListPtr nextBvl = allocateBitVectorList(); + nextBvl->bi = bitSet(n->nodeNumber); + nextBvl->initBvl = initBvl; + return nextBvl; } BitVectorListPtr initBitVector() { - - BitVectorListPtr bvl = allocateBitVectorList(); - bvl->initBvl = initBvl = bvl; - bvl->bi = bitSet(0); + + BitVectorListPtr bvl = allocateBitVectorList(); + bvl->initBvl = initBvl = bvl; + bvl->bi = bitSet(0); - for (int i = 0; i < 256; i++) { - bvl->next[i] = NULL; - } + for (int i = 0; i < 256; i++) { + bvl->next[i] = NULL; + } - return bvl; + return bvl; } void printBitVectorList (BitVectorListPtr bvl) { - bool isFirstPrint = true; - for (int i = 0; i < 256; i++) { - if (bvl->next[i] != NULL) { - if (isFirstPrint){ - puts("----"); - printf(" state : "); bitPrint(bvl->bi); - isFirstPrint = false; - } - printf("input char : %c\n",i); - printf("next state : ");bitPrint(bvl->next[i]->bi); + bool isFirstPrint = true; + for (int i = 0; i < 256; i++) { + if (bvl->next[i] != NULL) { + if (isFirstPrint){ + puts("----"); + printf(" state : "); bitPrint(bvl->bi); + isFirstPrint = false; + } + printf("input char : %c\n",i); + printf("next state : ");bitPrint(bvl->next[i]->bi); + } } - } - - for (int i = 0; i < 256; i++) { - if (bvl->next[i] != NULL) { - printBitVectorList(bvl->next[i]); + + for (int i = 0; i < 256; i++) { + if (bvl->next[i] != NULL) { + printBitVectorList(bvl->next[i]); + } } - } } BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl, BitVectorListPtr prev, bool &fromOr) { - bool leftIsOr, rightIsOr; - if (n->tokenType == '*') { - - } else if (n->Value.character == '|') { - bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); - setNextBitVectorList(n->left, prev, bvl); - bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); - setNextBitVectorList(n->right, prev, bvl); - fromOr = true; - return prev; - } else if (n->Value.character == '+') { - bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); - setNextBitVectorList(n->left, prev, bvl); - prev = bvl; - bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); + bool leftIsOr, rightIsOr; + if (n->tokenType == '*') { + + } else if (n->Value.character == '|') { + bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); + setNextBitVectorList(n->left, prev, bvl); + bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); + setNextBitVectorList(n->right, prev, bvl); + fromOr = true; + return prev; + } else if (n->Value.character == '+') { + bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); + setNextBitVectorList(n->left, prev, bvl); + prev = bvl; + bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); - if (leftIsOr){ - for (int i = 0; i < 256; i++) - if (prev->next[i] != NULL) - setNextBitVectorList(n->right, prev->next[i], bvl); - } - else { - setNextBitVectorList(n->right, prev, bvl); + if (leftIsOr){ + for (int i = 0; i < 256; i++) + if (prev->next[i] != NULL) + setNextBitVectorList(n->right, prev->next[i], bvl); + } + else { + setNextBitVectorList(n->right, prev, bvl); + } + + fromOr = false; + } else if (n->tokenType == 'a') { + bvl = createBitVector(n,bvl); + fromOr = false; } - - fromOr = false; - } else if (n->tokenType == 'a') { - bvl = createBitVector(n,bvl); - fromOr = false; - } - return bvl; + return bvl; } BitVectorListPtr setNextBitVectorList(NodePtr n, BitVectorListPtr bvl, BitVectorListPtr next){ - if (isalnum((int)n->Value.character)){ - bvl->next[(int)n->Value.character] = next; - } - return next; + if (isalnum((int)n->Value.character)){ + bvl->next[(int)n->Value.character] = next; + } + return next; } BitVectorListPtr createBitVectorList(NodePtr n) { - BitVectorListPtr bvl = initBitVector(); - bool fromOr = false; - descendTreeNode(n, bvl, bvl, fromOr); - printBitVectorList(bvl); - return bvl; + BitVectorListPtr bvl = initBitVector(); + bool fromOr = false; + descendTreeNode(n, bvl, bvl, fromOr); + printBitVectorList(bvl); + return bvl; }