Mercurial > hg > Applications > Grep
comparison c/regexParser/createBitVectorList.cc @ 96:b807383bcc43 impl-bitvector
add createBitVectorList.cc
author | Masataka Kohagura <kohagura@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 10 Nov 2015 15:36:33 +0900 (2015-11-10) |
parents | |
children | d0d2262d4edf |
comparison
equal
deleted
inserted
replaced
95:1cdad0468484 | 96:b807383bcc43 |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include "bitVector.h" | |
4 #include "regexParser.h" | |
5 | |
6 extern BitVectorPtr bitSet(int); | |
7 extern void bitPrint(BitVectorPtr); | |
8 BitVectorListPtr createBitVector(NodePtr); | |
9 BitVectorListPtr descendTreeNode(NodePtr,BitVectorListPtr); | |
10 | |
11 int bvlIndex; | |
12 | |
13 BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { | |
14 bvl->next[(int)n->Value.character] = (BitVectorListPtr)malloc(sizeof(BitVectorList)); | |
15 bvl->next[(int)n->Value.character]->bi = bitSet(n->nodeNumber); | |
16 puts("-----"); | |
17 bitPrint(bvl->bi); | |
18 bitPrint(bvl->next[(int)n->Value.character]->bi); | |
19 puts("-----"); | |
20 return bvl->next[(int)n->Value.character]; | |
21 } | |
22 | |
23 BitVectorListPtr initBitVector() { | |
24 BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); | |
25 BitVectorPtr bi = bitSet(0); | |
26 bvl->bi = bi; | |
27 return bvl; | |
28 } | |
29 | |
30 | |
31 BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl) { | |
32 | |
33 if (n->tokenType == '*') { | |
34 descendTreeNode(n->left,bvl); | |
35 } else if (n->tokenType == '|') { | |
36 | |
37 } else if (n->Value.character == '+') { | |
38 descendTreeNode(n->left,bvl); | |
39 descendTreeNode(n->right,bvl); | |
40 } else { | |
41 if (n->parent->right->tokenType == 'a') { | |
42 descendTreeNode(n->parent->right,bvl); | |
43 bvl = createBitVector(n,bvl); | |
44 } | |
45 } | |
46 | |
47 return bvl; | |
48 } | |
49 | |
50 BitVectorListPtr createBitVectorList(NodePtr n) { | |
51 bvlIndex = 0; | |
52 BitVectorListPtr bvl = initBitVector(); | |
53 descendTreeNode(n,bvl); | |
54 | |
55 return bvl; | |
56 } |