Idris TyRE:一种依赖类型的正则表达式解析器
Idris TyRE: a dependently typed regex parser
AI总结:
针对传统正则表达式解析器输出结构松散、存在重复设计的问题,研究扩展了类型化正则表达式TyRE的设计,在依赖类型语言Idris 2中实现了全层级类型安全的解析器。
摘要:
正则表达式(regexes)不仅被广泛用于验证,还可用于解析文本数据。通常,正则表达式解析器输出的结构较为松散,例如非结构化的匹配项列表,需要由用户自行验证输出的属性并将其转换为所需结构。由于正则表达式本身就携带结构信息,这种设计导致了不必要的重复。Radanne提出了类型化正则表达式(TyRE)——一种可叠加在现有正则表达式引擎之上的类型索引组合子层。我们扩展了Radanne的设计,实现了一个在所有层级都保持类型安全的解析器:用户侧的正则表达式、其内部去语法糖后的表示、编译后的有限状态自动机,以及自动机对应的用于构建解析树的指令集。我们在依赖类型语言Idris 2中实现了TyRE。
英文摘要:
Regular expressions -- regexes -- are widely used not only for validating, but also for parsing textual data. Generally, regex parsers output a loose structure, e.g. an unstructured list of matches, leaving it up to the user to validate the output's properties and transform it into the desired structure. Since the regex itself carries information about the structure, this design leads to unnecessary repetition. Radanne introduced typed regexes -- TyRE -- a type-indexed combinator layer that can be added on top of an existing regex engine. We extend Radanne's design, and implement a parser which maintains type-safety throughout all layers: the user-facing regexes; their internal, desugared, representation; its compiled finite-state automaton; and the automaton's associated instruction-set for constructing the parse-trees. We implemented TyRE in the dependently-typed language Idris 2.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。