正则表达式匹配与操作语义
Regular Expression Matching and Operational Semantics
摘要:
许多程序设计语言和工具(从grep到Java String库)都包含正则表达式匹配器。这样的实现不是首先将正则表达式转换为确定性有限自动机,而是通常动态地匹配正则表达式。因此,它们可以被看作是解释正则表达式的虚拟机,就好像它是一个具有一些非确定性结构(如Kleene星)的程序一样。我们使用操作语义形式化了正则表达式匹配的实现技术。具体来说,我们得到了一系列的抽象机器,从抽象的匹配定义越来越现实的机器。首先,将延续添加到操作语义中,以描述在当前表达式之后还需要匹配的内容。接下来,我们将表达式表示为使用指针的数据结构,这使得冗余搜索能够通过测试指针相等来消除。从那里,我们到达汤普森的锁步构造和并行执行一些操作的机器,适合在大量的核心上实现,如GPU。我们形式化的并行机使用进程代数和报告一些初步的实验与使用CUDA的图形处理器上的实现。
英文摘要:
Many programming languages and tools, ranging from grep to the Java String library, contain regular expression matchers. Rather than first translating a regular expression into a deterministic finite automaton, such implementations typically match the regular expression on the fly. Thus they can be seen as virtual machines interpreting the regular expression much as if it were a program with some non-deterministic constructs such as the Kleene star. We formalize this implementation technique for regular expression matching using operational semantics. Specifically, we derive a series of abstract machines, moving from the abstract definition of matching to increasingly realistic machines. First a continuation is added to the operational semantics to describe what remains to be matched after the current expression. Next, we represent the expression as a data structure using pointers, which enables redundant searches to be eliminated via testing for pointer equality. From there, we arrive both at Thompson's lockstep construction and a machine that performs some operations in parallel, suitable for implementation on a large number of cores, such as a GPU. We formalize the parallel machine using process algebra and report some preliminary experiments with an implementation on a graphics processor using CUDA.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。