Mercurial > hg > Members > masakoha > testcode
changeset 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 |
parents | 1cdad0468484 |
children | 0b6940588e88 |
files | c/regexParser/createBitVectorList.cc |
diffstat | 1 files changed, 56 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c/regexParser/createBitVectorList.cc Tue Nov 10 15:36:33 2015 +0900 @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <stdlib.h> +#include "bitVector.h" +#include "regexParser.h" + +extern BitVectorPtr bitSet(int); +extern void bitPrint(BitVectorPtr); +BitVectorListPtr createBitVector(NodePtr); +BitVectorListPtr descendTreeNode(NodePtr,BitVectorListPtr); + +int bvlIndex; + +BitVectorListPtr createBitVector(NodePtr n,BitVectorListPtr bvl) { + bvl->next[(int)n->Value.character] = (BitVectorListPtr)malloc(sizeof(BitVectorList)); + bvl->next[(int)n->Value.character]->bi = bitSet(n->nodeNumber); + puts("-----"); + bitPrint(bvl->bi); + bitPrint(bvl->next[(int)n->Value.character]->bi); + puts("-----"); + return bvl->next[(int)n->Value.character]; +} + +BitVectorListPtr initBitVector() { + BitVectorListPtr bvl = (BitVectorListPtr)malloc(sizeof(BitVectorList)); + BitVectorPtr bi = bitSet(0); + bvl->bi = bi; + return bvl; +} + + +BitVectorListPtr descendTreeNode(NodePtr n,BitVectorListPtr bvl) { + + if (n->tokenType == '*') { + descendTreeNode(n->left,bvl); + } else if (n->tokenType == '|') { + + } else if (n->Value.character == '+') { + descendTreeNode(n->left,bvl); + descendTreeNode(n->right,bvl); + } else { + if (n->parent->right->tokenType == 'a') { + descendTreeNode(n->parent->right,bvl); + bvl = createBitVector(n,bvl); + } + } + + return bvl; +} + +BitVectorListPtr createBitVectorList(NodePtr n) { + bvlIndex = 0; + BitVectorListPtr bvl = initBitVector(); + descendTreeNode(n,bvl); + + return bvl; +}