2

用Pike's VM实现的非回溯正则表达式引擎

 3 years ago
source link: http://maskray.me/blog/2012-11-05-regex-engine
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

用Pike's VM实现的非回溯正则表达式引擎

Parser之外的部分参考http://swtch.com/~rsc/regexp/regexp2.html ,代码都模仿自http://code.google.com/p/re1/source/browse 。注意到正则表达式是operator-precedence grammar,可以用一个扩展的Shunting-Yard算法来解析,其中用了一些特殊构造处理后缀操作符和括号。

github上

Parsing Expressions by Recursive Descent

Share Comments


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK