Mercurial > hg > Members > masakoha > testcode
view c/regexParser/subsetConstraction.cc @ 142:de0f332d560c pairPro
insert charClassMerge function
author | masa |
---|---|
date | Fri, 11 Dec 2015 14:54:00 +0900 |
parents | 71f36a59cf6a |
children | 32977f5a2ed0 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include "subsetConstraction.h" void printTransition(TransitionPtr ts) { for (;;) { printf("Input Condition : %c\n",ts->condition->cond->w->word); printf("Next State : "); bitPrint(ts->nextState); printf("\n"); if (ts->next == NULL) break; ts = ts->next; } } TGValue generateTransition(NodePtr n,TransitionGenerator tg) { if (n->tokenType == '+') { TGValue tgv = generateTransition(n->left,tg); if (tgv.asterisk) { TGValue tgv1 = generateTransition(n->right,tg); tgv.state |= tgv1.state; return tgv; } tgv.state = n->right->nodeNumber; return tgv; } else if (n->tokenType == '|') { tgv0 = generateTransition(n->left,tg); tgv1 = generateTransition(n->right,tg); tg->state->transition = appendTransition(tgv0->ts,tgv1->ts); } else if (n->tokenType == '*') { tgv0 = generateTransition(n->left,tg); tgv0->asterisk = true; } else { tgv0 = (TGValuePtr)malloc(sizeof(TGValue)); BitVectorPtr bi = createBitVector(n); tgv0->ts = createTransition(n->cc,bi); tgv0->asterisk = false; } return tgv0; } StatePtr createStateList(NodePtr n) { StatePtr s0 = NULL; if (n->left != NULL) { s0 = createStateList(n->left); } if (n->tokenType == 'a') { BitVectorPtr bi = createBitVector(n); StatePtr s1 = createState(bi,0,0); } else if (n->tokenType == '+' || n->tokenType == '|') { } if (n->right != NULL) { s0 = createStateList(n->right); } return s0; } TransitionGeneratorPtr generateTransitionList(NodePtr n) { TransitionGeneratorPtr tg = (TransitionGeneratorPtr)malloc(sizeof(TransitionGenerator)); int d = 0; tg->state = createStateList(n); generateTransition(n,tg); return tg; }