Mercurial > hg > Applications > Grep
changeset 107:c9f5ee891b5e impl-bitvector
change variable of setNextBitVectorList()
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 Nov 2015 17:23:06 +0900 |
parents | 8e47f1618608 |
children | 70069d4647a0 |
files | c/regexParser/createBitVectorList.cc |
diffstat | 1 files changed, 17 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/c/regexParser/createBitVectorList.cc Wed Nov 18 19:36:12 2015 +0900 +++ b/c/regexParser/createBitVectorList.cc Thu Nov 19 17:23:06 2015 +0900 @@ -8,7 +8,7 @@ extern void bitPrint(BitVectorPtr); BitVectorListPtr createBitVector(NodePtr); BitVectorListPtr descendTreeNode(NodePtr, BitVectorListPtr, BitVectorListPtr, bool&); -BitVectorListPtr setNextBitVectorList(NodePtr n, BitVectorListPtr bvl, BitVectorListPtr next); +BitVectorListPtr setNextBitVectorList(unsigned char, BitVectorListPtr, BitVectorListPtr); BitVectorListPtr initBvl; @@ -64,28 +64,34 @@ BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl, BitVectorListPtr prev, bool &fromOr) { bool leftIsOr, rightIsOr; - if (n->tokenType == '*') { - + if (n->Value.character == '*') { + bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); + unsigned char repertChar = 0; + for (int i = 0; i < 256; i++) { + if (prev->next[i] != NULL) repertChar = i; + } + setNextBitVectorList(repertChar, prev->next[repertChar], bvl); // here + return prev; } else if (n->Value.character == '|') { bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); - setNextBitVectorList(n->left, prev, bvl); + setNextBitVectorList(n->left->Value.character, prev, bvl); bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); - setNextBitVectorList(n->right, prev, bvl); + setNextBitVectorList(n->right->Value.character, prev, bvl); fromOr = true; return prev; } else if (n->Value.character == '+') { bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); - setNextBitVectorList(n->left, prev, bvl); + setNextBitVectorList(n->left->Value.character, 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); + setNextBitVectorList(n->right->Value.character, prev->next[i], bvl); } else { - setNextBitVectorList(n->right, prev, bvl); + setNextBitVectorList(n->right->Value.character, prev, bvl); } fromOr = false; @@ -96,9 +102,9 @@ return bvl; } -BitVectorListPtr setNextBitVectorList(NodePtr n, BitVectorListPtr bvl, BitVectorListPtr next){ - if (isalnum((int)n->Value.character)){ - bvl->next[(int)n->Value.character] = next; +BitVectorListPtr setNextBitVectorList(unsigned char inputChar, BitVectorListPtr bvl, BitVectorListPtr next){ + if (isalnum((int)inputChar)){ + bvl->next[(int)inputChar] = next; } return next; }