-
一个用MASM写的正则表达式引擎
此正则表达式引擎属于正统的NFA引擎,基本兼容Perl,简单说一下引擎是怎么实现的:
首先做一个递归下降语法分析,利用栈把正则表达式转换成NFA(以有向图的形式表现),再遍历NFA判断是否能到达完成节点。
实现正则表达式匹配的各种复杂功能的力量来自于回溯,而回溯的基础是栈,回溯能力是通过栈来达成的。
栈中保存了匹配路径中所有的状态,状态回溯就是出栈,状态匹配就是入栈。
除了回溯,一些扩展功能的实现也是通过栈来完成的,比如捕获和零宽断言,都要通过搜索或操纵栈来完成。
转换成NFA再匹配的好处是简化匹配和利于优化和DEBUG:因为不管再复杂的表达式转换成NFA之后只有边和节点组成,边和节点也只有顺序、分支、循环这三种形式组成。
详细原理说明看下面关于实现引擎的文章,第3条是我理解引擎匹配原理的入门参考。
支持GBK和UTF8编码
==参考和学习资料==
关于实现引擎的文章:
1、《Perl语言编程》第五章 书
2、《精通正则表达式》 书
3、构造正则表达式引擎 http://www.cppblog.com/vczh/archive/2008/05/22/50763.html 我的原理学习入门参考
4、NFA引擎匹配原理 http://blog.csdn.net/lxcnn/article/details/4304651
5、英文参考资料 请点击左侧文件开始预览 !预览只提供20%的代码片段,完整代码需下载后查看 加载中 侵权举报
- 2022-05-27 18:36:44下载
- 积分:1
-
这是我所有的家当哦,c语言源程序,其中有C语言二级考试的题目呢!...
这是我所有的家当哦,c语言源程序,其中有C语言二级考试的题目呢!-This is all my family"s, oh, c source language, which has two C-language examination questions!
- 2022-12-04 10:55:03下载
- 积分:1
-
SIMPLE algrithm in Computational fluid mechanics
应用背景This application is to focus on the numerical methods in Computational Fluid Mechanics, dealing with aeronautics, hydraulics, heat and mass transfer etc. We konw fluids have the ability to transport matter and its propertities as well as transmit force, therefore fluid mechanics is a subject that is particularly open to cross fertilization with other sciences and disciplines of engineering. The subject of fluid mechanics will be highly relevant in domains such as chemical,metallurgical, biological and ecological engineering.关键技术
SIMPLE (Semi-Implicit Method for Pressure Linked Equations) algrithm is the principal numerical method to numerical simulate incompressible fluid flow, it can remove the difficults of fake pressure disturbance and neglecting specific pressure equation for incompressible fluid flow successful. The main thoughts and steps of SIMPLE algorithm are given in this application.
The single-phase loc
- 2023-03-06 10:05:03下载
- 积分:1
-
优化算法,是FORTRUN语言写。都经过了运行。
优化算法,是FORTRUN语言写。都经过了运行。-this is code of the number caculation in opt
- 2022-04-10 05:21:22下载
- 积分:1
-
频繁项挖掘算法FP―Growth算法的实现,该算法使用java语言实现的...
频繁项挖掘算法FP―Growth算法的实现,该算法使用java语言实现的
- 2022-02-20 03:34:22下载
- 积分:1
-
数值计算,表达式求值, 如计算3 + 2 * ( 3 + 2) / 5 + 8 + Sin( pi() / 180 * 30 ) + 1 + 2 ^ 10, 可...
数值计算,表达式求值, 如计算3 + 2 * ( 3 + 2) / 5 + 8 + Sin( pi() / 180 * 30 ) + 1 + 2 ^ 10, 可自定义函数, 采用递归算法-numerical calculation, in the expression evaluates, as calculated 3 2* (2)/5 8 Sin (pi ()/180* 30) 1 2 ^ 10,- defined functions using recursive algorithm
- 2022-01-26 05:01:19下载
- 积分:1
-
数学建模最优化问题的lingo编程解法,一开始还先介绍lingo的基本知识。...
数学建模最优化问题的lingo编程解法,一开始还先介绍lingo的基本知识。-Optimization problem of mathematical modeling of lingo programming method, also the first one started to introduce basic knowledge of lingo.
- 2022-09-08 05:30:03下载
- 积分:1
-
工资管理系统
资源描述工资管理系统,C语言作业,简单,易用
- 2022-11-08 22:05:03下载
- 积分:1
-
c++的数学物理方程数值算法源程序。这是"Numerical Methods for Physics"第二版的源程序。...
c++的数学物理方程数值算法源程序。这是"Numerical Methods for Physics"第二版的源程序。-c mathematical physics equations numerical algorithm source. This is the "Numerical Methods for Physics," the second version of the source.
- 2022-05-20 21:11:10下载
- 积分:1
-
CG共轭梯度法迭代解矩阵方程,Hhestens和Stiefel给出,
CG共轭梯度法迭代解矩阵方程,Hhestens和Stiefel给出,-Conjugate gradient method CG iterative matrix equation solution, Hhestens and Stiefel given
- 2023-08-19 20:10:03下载
- 积分:1