当前位置: X-MOL 学术arXiv.cs.LO › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
A Verified Packrat Parser Interpreter for Parsing Expression Grammars
arXiv - CS - Logic in Computer Science Pub Date : 2020-01-13 , DOI: arxiv-2001.04457
Clement Blaudeau and Natarajan Shankar

Parsing expression grammars (PEGs) offer a natural opportunity for building verified parser interpreters based on higher-order parsing combinators. PEGs are expressive, unambiguous, and efficient to parse in a top-down recursive descent style. We use the rich type system of the PVS specification language and verification system to formalize the metatheory of PEGs and define a reference implementation of a recursive parser interpreter for PEGs. In order to ensure termination of parsing, we define a notion of a well-formed grammar. Rather than relying on an inductive definition of parsing, we use abstract syntax trees that represent the computational trace of the parser to provide an effective proof certificate for correct parsing and ensure that parsing properties including soundness and completeness are maintained. The correctness properties are embedded in the types of the operations so that the proofs can be easily constructed from local proof obligations. Building on the reference parser interpreter, we define a packrat parser interpreter as well as an extension that is capable of semantic interpretation. Both these parser interpreters are proved equivalent to the reference one. All of the parsers are executable. The proofs are formalized in mathematical terms so that similar parser interpreters can be defined in any specification language with a type system similar to PVS.

中文翻译:

用于解析表达式语法的经过验证的 Packrat 解析器解释器

解析表达式语法 (PEG) 为构建基于高阶解析组合子的经过验证的解析器解释器提供了自然的机会。PEG 具有表现力、明确且高效,可以以自上而下的递归下降风格进行解析。我们使用 PVS 规范语言和验证系统的丰富类型系统来形式化 PEG 的元理论,并为 PEG 定义递归解析器解释器的参考实现。为了确保解析的终止,我们定义了一个格式良好的文法的概念。我们不依赖解析的归纳定义,而是使用抽象语法树来表示解析器的计算轨迹,为正确解析提供有效的证明,并确保维护包括健全性和完整性在内的解析属性。正确性属性嵌入在操作的类型中,因此可以根据本地证明义务轻松构建证明。在参考解析器解释器的基础上,我们定义了一个 Packrat 解析器解释器以及一个能够进行语义解释的扩展。这两个解析器解释器都被证明与参考解释器等效。所有的解析器都是可执行的。证明是用数学术语形式化的,这样类似的解析器解释器可以用任何具有类似于 PVS 的类型系统的规范语言来定义。这两个解析器解释器都被证明与参考解释器等效。所有的解析器都是可执行的。证明是用数学术语形式化的,这样类似的解析器解释器可以用任何具有类似于 PVS 的类型系统的规范语言来定义。这两个解析器解释器都被证明与参考解释器等效。所有的解析器都是可执行的。证明是用数学术语形式化的,这样类似的解析器解释器可以用任何具有类似于 PVS 的类型系统的规范语言来定义。
更新日期:2020-01-14
down
wechat
bug