作者在 2007-06-03 06:44:00 发布以下内容
/*输出StateTable,测试用*/
void showStateTable(pStateTable pst) {
pState tmp;
pStateCollectionEle pscele;
printf("debug: ################### there is the NFA table basic info: #######################\n");
printf("debug: StateCount = %d\n", pst->stateCount);
printf("head->%x\tcur->%x\ttail->%x\n", pst->head, pst->curState, pst->tail);
printf("debug: ################### there is the NFA table: #######################\n");
tmp = pst->head;
while (tmp != NULL) {
printf("#%x->", tmp);
pscele = tmp->destStateCollection->head;
while (pscele != NULL) {
printf("[%d]%x | ", pscele->eleindex, pscele->destState);
pscele = pscele->next;
}
printf("\n");
tmp = tmp->next;
}
printf("debug: ################### the NFA table ended #######################\n");
printf("debug: StateCount = %d\n", pst->stateCount);
printf("head->%x\tcur->%x\ttail->%x\n", pst->head, pst->curState, pst->tail);
printf("debug: ################### the NFA table basic info ended #######################\n");
}
pStateTable cloneSubStateTable(pStateTable pst, pState ps_start, pState ps_end) {
pStateTable pstnew = NULL;
pState ps, psnew; /*临时指针:原状态和目标状态*/
pStateCollectionEle pse, psenew; /*临时的状态集合元素指针,替换目标状态使用*/
if (pst != NULL) {
pstnew = newStateTable(pst->eleCount); /*新建一个状态表*/
if (pstnew != NULL) {
ps = ps_start;
while (ps != NULL) {
psnew = cloneState(ps); /*克隆当前状态*/
psnew->next = NULL;
appendStateTable(pstnew, psnew); /*加入到新的状态表*/
/*将新的克隆状态加入原状态的目标状态集合中,一会儿要做目标状态的替换*/
appendStateCollection(ps->destStateCollection, newStateCollectionEle(NULL, psnew));
if (ps == ps_end) {
break; /*到了结束的状态,返回结果*/
void showStateTable(pStateTable pst) {
pState tmp;
pStateCollectionEle pscele;
printf("debug: ################### there is the NFA table basic info: #######################\n");
printf("debug: StateCount = %d\n", pst->stateCount);
printf("head->%x\tcur->%x\ttail->%x\n", pst->head, pst->curState, pst->tail);
printf("debug: ################### there is the NFA table: #######################\n");
tmp = pst->head;
while (tmp != NULL) {
printf("#%x->", tmp);
pscele = tmp->destStateCollection->head;
while (pscele != NULL) {
printf("[%d]%x | ", pscele->eleindex, pscele->destState);
pscele = pscele->next;
}
printf("\n");
tmp = tmp->next;
}
printf("debug: ################### the NFA table ended #######################\n");
printf("debug: StateCount = %d\n", pst->stateCount);
printf("head->%x\tcur->%x\ttail->%x\n", pst->head, pst->curState, pst->tail);
printf("debug: ################### the NFA table basic info ended #######################\n");
}
pStateTable cloneSubStateTable(pStateTable pst, pState ps_start, pState ps_end) {
pStateTable pstnew = NULL;
pState ps, psnew; /*临时指针:原状态和目标状态*/
pStateCollectionEle pse, psenew; /*临时的状态集合元素指针,替换目标状态使用*/
if (pst != NULL) {
pstnew = newStateTable(pst->eleCount); /*新建一个状态表*/
if (pstnew != NULL) {
ps = ps_start;
while (ps != NULL) {
psnew = cloneState(ps); /*克隆当前状态*/
psnew->next = NULL;
appendStateTable(pstnew, psnew); /*加入到新的状态表*/
/*将新的克隆状态加入原状态的目标状态集合中,一会儿要做目标状态的替换*/
appendStateCollection(ps->destStateCollection, newStateCollectionEle(NULL, psnew));
if (ps == ps_end) {
break; /*到了结束的状态,返回结果*/