Typed and unambiguous pattern matching on strings using regular expressions

Typed and unambiguous pattern matching on strings using regular expressions
复制标题

使用正则表达式对字符串进行类型化且明确的模式匹配

DOI:
10.1145/1836089.1836120
复制
发表时间:
2010
期刊:
--
影响因子:
--
通讯作者:
Jakob G. Thomsen
Jakob G. Thomsen
中科院分区:
--
文献类型:
--
作者:
Claus Brabrand;Jakob G. Thomsen

文献摘要

被引文献

相似文献

我们展示了如何使用使用简单记录操作符扩展的正则表达式在字符串上实现类型化和明确的声明性模式匹配。 我们给出了正则表达式的歧义性的一个特征,它导致了一个健全和完整的静态分析。该分析能够根据正则表达式的结构找出所有歧义,并报告最短的歧义字符串。我们还展示了如何将模式匹配集成到静态类型编程语言中,以解构字符串并重新生成类型化和结构化的值。 我们通过给出本文提出的方法的完整实现来验证我们的方法。生成的工具reg-exp-rec以独立和非侵入性的方式向Java添加了类型化和明确的模式匹配。我们使用几个实际的例子对该方法进行了评估。
We show how to achieve typed and unambiguous declarative pattern matching on strings using regular expressions extended with a simple recording operator. We give a characterization of ambiguity of regular expressions that leads to a sound and complete static analysis. The analysis is capable of pinpointing all ambiguities in terms of the structure of the regular expression and report shortest ambiguous strings. We also show how pattern matching can be integrated into statically typed programming languages for deconstructing strings and reproducing typed and structured values. We validate our approach by giving a full implementation of the approach presented in this paper. The resulting tool, reg-exp-rec, adds typed and unambiguous pattern matching to Java in a standalone and non-intrusive manner. We evaluate the approach using several realistic examples.