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
中科院分区:
文献类型:
--
作者:
Claus Brabrand;Jakob G. Thomsen
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.