-
一个用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
-
无网格伽辽金方法计算源程序
无网格伽辽金方法计算源程序(线弹性2D问题)-EFGM source method (2D linear elastic problems)无网格方法采用基于点的近似,可以彻底或部分地消除网格,不需要网格的初始划分和重构,不仅可以保证计算的精度,而且可以大大减小计算的难度。然而,由于目前的无网格近似一般没有解析表达式,且大都基于伽辽金原理,因此计算量很大,要超出传统的有限元法;另外,无网格近似大都是拟合,因此对于位移边界的处理比较困难,多采用拉格朗日乘子法处理。
- 2022-01-26 06:31:16下载
- 积分:1
-
Newton
牛顿法――数值分析,程序代码,参考数值分析课本,很简单的程序,大家一定看得懂-Newton-- numerical analysis code, the numerical analysis of reference books, a very simple procedure, we must understand the
- 2022-03-15 15:43:10下载
- 积分:1
-
线性回归分析算法
一元线性回归分析算法-a linear regression analysis algorithm
- 2023-07-20 08:10:03下载
- 积分:1
-
SystemC语言编写的随机数产生器,SystemC是C++语言的一个超集
SystemC语言编写的随机数产生器,SystemC是C++语言的一个超集-SystemC language random number generator, SystemC is C++ A superset of the language
- 2022-01-30 16:41:42下载
- 积分:1
-
轮围计算器
它用来计算车轮围此程序。
可以运行它在 linux 终端 (GCC 编译器) 中的命令:
"海湾合作委员会 wheelcircunferencecallculator.c-o wheelcircunference"
及后
"。 / wheelcircunference"
它是所有。
- 2022-05-19 21:07:52下载
- 积分:1
-
用fortran编写的复合形法的源程序,供大家参考。
用fortran编写的复合形法的源程序,供大家参考。-fortran prepared with the complex method of the source, for your reference.
- 2022-02-05 18:50:49下载
- 积分:1
-
改进的平方根法,比较简单的,用VC实现的
改进的平方根法,比较简单的,用VC实现的-improvements to the square root law, a simple comparison with the VC
- 2022-11-14 11:05:03下载
- 积分:1
-
It is the DOS environment to develop a mathematical calculation software, the ma...
它是在DOS环境下开发的数学计算软件,菜单中主要的一种是“有限元法”,使用的编程语言是C语言,解压无需密码。-It is the DOS environment to develop a mathematical calculation software, the main menu is a "finite element method", the use of the C programming language is the language, extract no password is required.
- 2023-01-04 08:40:03下载
- 积分:1
-
C#计算器
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.IO;
namespace 计算器
{
///
/// Form1 的摘要说明。
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button11;
private System.Windows.For
- 2023-01-30 17:15:03下载
- 积分:1