Mercurial > hg > Members > masakoha > testcode
comparison c/regexParser/createBitVectorList.cc @ 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 | 766fc2476f01 |
children | 70069d4647a0 |
comparison
equal
deleted
inserted
replaced
106:8e47f1618608 | 107:c9f5ee891b5e |
---|---|
6 | 6 |
7 extern BitVectorPtr bitSet(int); | 7 extern BitVectorPtr bitSet(int); |
8 extern void bitPrint(BitVectorPtr); | 8 extern void bitPrint(BitVectorPtr); |
9 BitVectorListPtr createBitVector(NodePtr); | 9 BitVectorListPtr createBitVector(NodePtr); |
10 BitVectorListPtr descendTreeNode(NodePtr, BitVectorListPtr, BitVectorListPtr, bool&); | 10 BitVectorListPtr descendTreeNode(NodePtr, BitVectorListPtr, BitVectorListPtr, bool&); |
11 BitVectorListPtr setNextBitVectorList(NodePtr n, BitVectorListPtr bvl, BitVectorListPtr next); | 11 BitVectorListPtr setNextBitVectorList(unsigned char, BitVectorListPtr, BitVectorListPtr); |
12 | 12 |
13 BitVectorListPtr initBvl; | 13 BitVectorListPtr initBvl; |
14 | 14 |
15 BitVectorListPtr allocateBitVectorList() { | 15 BitVectorListPtr allocateBitVectorList() { |
16 BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); | 16 BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl, BitVectorListPtr prev, bool &fromOr) { | 65 BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl, BitVectorListPtr prev, bool &fromOr) { |
66 bool leftIsOr, rightIsOr; | 66 bool leftIsOr, rightIsOr; |
67 if (n->tokenType == '*') { | 67 if (n->Value.character == '*') { |
68 | 68 bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); |
69 unsigned char repertChar = 0; | |
70 for (int i = 0; i < 256; i++) { | |
71 if (prev->next[i] != NULL) repertChar = i; | |
72 } | |
73 setNextBitVectorList(repertChar, prev->next[repertChar], bvl); // here | |
74 return prev; | |
69 } else if (n->Value.character == '|') { | 75 } else if (n->Value.character == '|') { |
70 bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); | 76 bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); |
71 setNextBitVectorList(n->left, prev, bvl); | 77 setNextBitVectorList(n->left->Value.character, prev, bvl); |
72 bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); | 78 bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); |
73 setNextBitVectorList(n->right, prev, bvl); | 79 setNextBitVectorList(n->right->Value.character, prev, bvl); |
74 fromOr = true; | 80 fromOr = true; |
75 return prev; | 81 return prev; |
76 } else if (n->Value.character == '+') { | 82 } else if (n->Value.character == '+') { |
77 bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); | 83 bvl = descendTreeNode(n->left, bvl, prev, leftIsOr); |
78 setNextBitVectorList(n->left, prev, bvl); | 84 setNextBitVectorList(n->left->Value.character, prev, bvl); |
79 prev = bvl; | 85 prev = bvl; |
80 bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); | 86 bvl = descendTreeNode(n->right, bvl, prev, rightIsOr); |
81 | 87 |
82 if (leftIsOr){ | 88 if (leftIsOr){ |
83 for (int i = 0; i < 256; i++) | 89 for (int i = 0; i < 256; i++) |
84 if (prev->next[i] != NULL) | 90 if (prev->next[i] != NULL) |
85 setNextBitVectorList(n->right, prev->next[i], bvl); | 91 setNextBitVectorList(n->right->Value.character, prev->next[i], bvl); |
86 } | 92 } |
87 else { | 93 else { |
88 setNextBitVectorList(n->right, prev, bvl); | 94 setNextBitVectorList(n->right->Value.character, prev, bvl); |
89 } | 95 } |
90 | 96 |
91 fromOr = false; | 97 fromOr = false; |
92 } else if (n->tokenType == 'a') { | 98 } else if (n->tokenType == 'a') { |
93 bvl = createBitVector(n,bvl); | 99 bvl = createBitVector(n,bvl); |
94 fromOr = false; | 100 fromOr = false; |
95 } | 101 } |
96 return bvl; | 102 return bvl; |
97 } | 103 } |
98 | 104 |
99 BitVectorListPtr setNextBitVectorList(NodePtr n, BitVectorListPtr bvl, BitVectorListPtr next){ | 105 BitVectorListPtr setNextBitVectorList(unsigned char inputChar, BitVectorListPtr bvl, BitVectorListPtr next){ |
100 if (isalnum((int)n->Value.character)){ | 106 if (isalnum((int)inputChar)){ |
101 bvl->next[(int)n->Value.character] = next; | 107 bvl->next[(int)inputChar] = next; |
102 } | 108 } |
103 return next; | 109 return next; |
104 } | 110 } |
105 | 111 |
106 BitVectorListPtr createBitVectorList(NodePtr n) { | 112 BitVectorListPtr createBitVectorList(NodePtr n) { |