Mercurial > hg > Applications > Grep
view c/regexParser/subsetConstraction.cc @ 143:32977f5a2ed0 pairPro
add charClassMerge
author | masa |
---|---|
date | Fri, 11 Dec 2015 15:04:58 +0900 |
parents | de0f332d560c |
children | d8a4922eceae |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <ctype.h> #include "subsetConstraction.h" CharClassPtr charClassMerge(CharClassPtr src, CharClassPtr add) { // 重なっているccの領域を分割する // 必要ならばnextStateを重ねあわせる // 変更があった場合は新しくリストを作って返す if (src->type == 'a') { if (add->type == 'a') { if (src->cond.w.word[0] > add->cond.w.word[0]) { // add のほうが小さいので小さい順のccをつくる CharClassPtr left = charClassMerge(add->left.src); return createCharClassWord(add->cond->w.word, left, add->right); } else { } } else if (add->type == 'c') { // if (src->cond.w.word[0] < add->cond.range.begin) { } else (src->cond->w.word[0] < add->end) { } else if (src->type == 'c') { } } 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; }