RegExp DEMO version -- [1]正则表达式 TO NFA表格

作者在 2007-06-02 21:04:00 发布以下内容

最近想做一个正则表达式的解析工具,
目前已经完成了正则表达式向NFA(不确定有穷自动机)表格的转换代码。
源代码包在这里下载:
======================================
       源代码zip包regexp.zip
======================================

我再跟几个帖子把核心代码贴出来一部分:供各位赏玩 。。。

readME文件如下
===================================
作者:王旭华
泰山学院
E-MAIL:qfhuazi@163.com
QQ: 471600163

文件:regexp-win.exe -- windows的编译
                         cfree3.5+win2003
       regexp-linux    -- linux下的编译
                         gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)

功能:将正则表达式转化为一个NFA表格
DEMO支持的运算符:
     重复运算:+ * ? {m} {m, } {m,n}
     连接运算:. |
     字母表运算: [] [^]
     转义字符: \xff \377 \77 \\ \r \n \f \v \t ...
               \d \D \s \S \w \W


                         2007年6月1日
PS:这个日子很有纪念意义啊 。。。
     ^-^!

=====================================

测试的屏幕拷贝[linux平台]
=====================================

[xuhua@linux xuhua]$ ./regexp.linux
Example: Shell>regexp "x(a[^\S]b)+y"
debug: JUST A TEST BEGIN...
debug: start scan the regexp:
         "x(a[^\S]b)+y"
debug: (A+)ONCE_MORE
debug: end scan the regexp:
         "x(a[^\S]b)+y"
debug: ################### there is the NFA table basic info: #######################
debug: StateCount = 11
head->842d020    cur->842d090     tail->842d090
debug: ################### there is the NFA table: #######################
#842d020->[256]842d070 |
#842d070->[120]842d0c0 |
#842d0c0->[256]842d110 |
#842d110->[97]842d160 |
#842d160->[256]842d1b0 |
#842d1b0->[32]842d1d0 | [13]842d1d0 | [12]842d1d0 | [11]842d1d0 | [10]842d1d0 | [9]842d1d0 |
#842d1d0->[98]842d270 | [256]842d1d0 |
#842d270->[256]842d130 |
#842d130->[121]842d2c0 | [256]842d110 |
#842d2c0->[256]842d090 |
#842d090->
debug: ################### the NFA table ended #######################
debug: StateCount = 11
head->842d020    cur->842d090     tail->842d090
debug: ################### the NFA table basic info ended #######################
debug: JUST A TEST END...

=====================================

测试的屏幕拷贝[win平台]
=====================================

D:\My_Prj\RegExp>RegExp-release.exe "\xcd\xf5王旭华"
debug: JUST A TEST BEGIN...
debug: start scan the regexp:
         "\xcd\xf5王旭华"
debug: end scan the regexp:
         "\xcd\xf5王旭华"
debug: ################### there is the NFA table basic info: ##################
#####
debug: StateCount = 11
head->272480     cur->272518      tail->272518
debug: ##############

C语言 | 阅读 1337 次
文章评论,共0条
游客请输入验证码