论文标题

经过验证的Packrat解析器解释器语法解析语法

A Verified Packrat Parser Interpreter for Parsing Expression Grammars

论文作者

Blaudeau, Clement, Shankar, Natarajan

论文摘要

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

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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源