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

上下文无关文法与解析表达式文法的关系

On the Relation between Context-Free Grammars and Parsing Expression Grammars

Fabio Mascarenhas, Sérgio Medeiros, Roberto Ierusalimschy

摘要:

上下文无关文法(CFG)和解析表达式文法(PEG)在语法和语义上有一些相似之处和一些不同之处,但它们通常通过形式主义来表示,这妨碍了适当的比较。在本文中,我们提出了一个新的形式主义的CFGs,突出了它们之间的相似性和差异。新的形式主义借用PEG的使用解析表达式和基于解析的语义。我们展示了如何从这种形式主义中去除非确定性的一种方法产生了PEG语义的形式主义。我们还证明,基于这些新的形式主义,LL(1)文法如何定义相同的语言,无论是解释为CFG或PEG,也显示如何强LL(k),右线性,LL正则文法有简单的语言保持从CFG到PEG的翻译。

英文摘要:

Context-Free Grammars (CFGs) and Parsing Expression Grammars (PEGs) have several similarities and a few differences in both their syntax and semantics, but they are usually presented through formalisms that hinder a proper comparison. In this paper we present a new formalism for CFGs that highlights the similarities and differences between them. The new formalism borrows from PEGs the use of parsing expressions and the recognition-based semantics. We show how one way of removing non-determinism from this formalism yields a formalism with the semantics of PEGs. We also prove, based on these new formalisms, how LL(1) grammars define the same language whether interpreted as CFGs or as PEGs, and also show how strong-LL(k), right-linear, and LL-regular grammars have simple language-preserving translations from CFGs to PEGs.

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

↑