LL(1)使用导数和Zippers进行语法分析
LL(1) Parsing with Derivatives and Zippers
摘要:
本文基于形式语言的派生概念,提出了一种高效的、功能性的、形式验证过的LL(1)上下文无关表达式解析算法。导数解析是一种优雅的解析技术,在一般情况下,它遭受立方最坏情况时间复杂度和缓慢的性能在实践中。我们专门分析与衍生物算法LL(1)上下文无关的表达式,其中替代品可以选择给定的一个单一的令牌的前瞻性。我们形式化LL(1)表达式的概念,并展示如何有效地检查LL(1)属性。接下来,我们提出了一种新的线性时间解析算法的衍生物LL(1)表达式操作的拉链启发数据结构。我们在Coq中证明了该算法的正确性,并在Scala中实现了一个解析器组合子框架,具有枚举和漂亮的打印功能。
英文摘要:
In this paper, we present an efficient, functional, and formally verified parsing algorithm for LL(1) context-free expressions based on the concept of derivatives of formal languages. Parsing with derivatives is an elegant parsing technique, which, in the general case, suffers from cubic worst-case time complexity and slow performance in practice. We specialise the parsing with derivatives algorithm to LL(1) context-free expressions, where alternatives can be chosen given a single token of lookahead. We formalise the notion of LL(1) expressions and show how to efficiently check the LL(1) property. Next, we present a novel linear-time parsing with derivatives algorithm for LL(1) expressions operating on a zipper-inspired data structure. We prove the algorithm correct in Coq and present an implementation as a parser combinators framework in Scala, with enumeration and pretty printing capabilities.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。