arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1812.07429cs.PL
收藏

CPEG:一种基于正则表达式捕获的表达式语法分析树

CPEG: A Typed Tree Construction from Parsing Expression Grammars with Regex-Like Captures

Daisuke Yamaguchi, Kimio Kuramitsu

摘要:

CPEG是一种扩展的解析表达式语法,具有类似regex的捕获注释。两个注释(捕获和左折叠)允许从任意解析模式灵活地构建语法树。更重要的是,CPEG被设计为保证任何输入字符串的语法树的结构约束。这减少了检查预期元素是否存在所需的用户代码量。为了表示结构约束,我们专注于正则表达式类型,树自动机的变体形式主义,这已经在XML模式的上下文中进行了深入的研究。正则表达式的类型是从一个给定的CPEG的类型推断,本文正式开发。我们证明了类型推断的可靠性和唯一性。类型推断使CPEG能够充当输入的语法规范和输出的示意性规范。

英文摘要:

CPEG is an extended parsing expression grammar with regex-like capture annotation. Two annotations (capture and left-folding) allow a flexible construction of syntax trees from arbitrary parsing patterns. More importantly, CPEG is designed to guarantee structural constraints of syntax trees for any input strings. This reduces the amount of user code needed to check whether the intended elements exist. To represent the structural constraints, we focus on regular expression types, a variant formalism of tree automata, which have been intensively studied in the context of XML schemas. Regular expression type is inferred from a given CPEG by the type inference that is formally developed in this paper. We prove the soundness and the uniqueness of the type inference. The type inference enables a CPEG to serve both as a syntactic specification of the input and a schematic specification of the output.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑