作者在 2007-06-03 06:39:00 发布以下内容
这里是[regexp.h]的全部代码,所有的数据结构和针对他们的操作函数都在这里了,
总揽一下哈:
终结符类型
状态
新建,销毁,置目标状态,克隆
状态集合的元素(相当于一条弧线:输入元素和目标状态)
新建,销毁,克隆
状态集合
新建,销毁,克隆,追加一个状态元素
状态表格
新建,销毁,克隆,追加一个状态,用于调试的showStateTable()
状态机
新建,销毁
状态机堆栈
新建,销毁,push(),pop()
更加详细的内容,让代码告诉你吧。
=========================================
总揽一下哈:
终结符类型
状态
新建,销毁,置目标状态,克隆
状态集合的元素(相当于一条弧线:输入元素和目标状态)
新建,销毁,克隆
状态集合
新建,销毁,克隆,追加一个状态元素
状态表格
新建,销毁,克隆,追加一个状态,用于调试的showStateTable()
状态机
新建,销毁
状态机堆栈
新建,销毁,push(),pop()
更加详细的内容,让代码告诉你吧。
=========================================
/*global data type*/
/*##############################################*/
/*终结符类型*/
typedef enum SymbolType_enum {
UNKNOWN = 0,
END_REGEXP,
START_REGEXP,
INPUT_ELE,
REPEAT_ZERO_MORE, REPEAT_ZERO_ONCE, REPEAT_ONCE_MORE,
REPEAT_RANGE_MN, REPEAT_RANGE_M, REPEAT_RANGE_M_MORE,
AND_MACHINE_BEGIN, AND_MACHINE_END,
OR_MACHINE_BEGIN, OR_MACHINE_END,
NOT_OP, DOT, BACKTRACE,
NUMBER, NOT_NUMBER,
ALL_SPACE, NOT_ALL_SPACE,
AZaz09_, NOT_AZaz09_,
LETTER_RANGE
}SymbolType;
/*##############################################*/
/*状态*/
typedef struct Statetag {
struct StateCollectiontag *destStateCollection; /*目标状态集合*/
struct Statetag *next;
}State, *pState;
/*相关操作函数声明*/
pState newState();
void destroyState(pState s);
pState setdestState(pState srcS, int eleindex, pState destS);
pState getdestState(pState srcS, int eleindex);
pState cloneState(pState s);
/*##############################################*/
/*状态集合的元素*/
typedef struct StateCollectionEletag {
int eleindex; /*元素*/
pState destState; /*目标状态*/
struct StateCollectionEletag *next;
}StateCollectionEle, *pStateCollectionEle;
/*相关操作函数声明*/
pStateCollectionEle newStateCollectionEle(int eleindex, pState destS);
void destroyStateCollectionEle(pStateCollectionEle pSCEle);
pStateCollectionEle cloneStateCollectionEle(pStateCollectionEle pSCEle);
/*##############################################*/
/*状态集合*/
typedef struct StateCollectiontag {
int destStateCount; /*目标状态数组的大小*/
pStateCollectionEle head; /*目标状态链表指针*/
}StateCollection, *pStateCollection;
/*相关操作函数声明*/
pStateCollection newStateCollection(); /*新建状态集合*/
void destroyStateCollection(pStateCollecti
/*##############################################*/
/*终结符类型*/
typedef enum SymbolType_enum {
UNKNOWN = 0,
END_REGEXP,
START_REGEXP,
INPUT_ELE,
REPEAT_ZERO_MORE, REPEAT_ZERO_ONCE, REPEAT_ONCE_MORE,
REPEAT_RANGE_MN, REPEAT_RANGE_M, REPEAT_RANGE_M_MORE,
AND_MACHINE_BEGIN, AND_MACHINE_END,
OR_MACHINE_BEGIN, OR_MACHINE_END,
NOT_OP, DOT, BACKTRACE,
NUMBER, NOT_NUMBER,
ALL_SPACE, NOT_ALL_SPACE,
AZaz09_, NOT_AZaz09_,
LETTER_RANGE
}SymbolType;
/*##############################################*/
/*状态*/
typedef struct Statetag {
struct StateCollectiontag *destStateCollection; /*目标状态集合*/
struct Statetag *next;
}State, *pState;
/*相关操作函数声明*/
pState newState();
void destroyState(pState s);
pState setdestState(pState srcS, int eleindex, pState destS);
pState getdestState(pState srcS, int eleindex);
pState cloneState(pState s);
/*##############################################*/
/*状态集合的元素*/
typedef struct StateCollectionEletag {
int eleindex; /*元素*/
pState destState; /*目标状态*/
struct StateCollectionEletag *next;
}StateCollectionEle, *pStateCollectionEle;
/*相关操作函数声明*/
pStateCollectionEle newStateCollectionEle(int eleindex, pState destS);
void destroyStateCollectionEle(pStateCollectionEle pSCEle);
pStateCollectionEle cloneStateCollectionEle(pStateCollectionEle pSCEle);
/*##############################################*/
/*状态集合*/
typedef struct StateCollectiontag {
int destStateCount; /*目标状态数组的大小*/
pStateCollectionEle head; /*目标状态链表指针*/
}StateCollection, *pStateCollection;
/*相关操作函数声明*/
pStateCollection newStateCollection(); /*新建状态集合*/
void destroyStateCollection(pStateCollecti