On the Relation between Context-Free Grammars and Parsing Expression Grammars
Fabio Mascarenhas, S\'ergio Medeiros, Roberto Ierusalimschy

TL;DR
This paper introduces a new formalism bridging CFGs and PEGs, clarifying their similarities and differences, and demonstrates how certain classes of grammars translate between the two formalisms without changing the language.
Contribution
It presents a novel formalism for CFGs inspired by PEGs, enabling direct comparison and translation between CFGs and PEGs, and proves language preservation for specific grammar classes.
Findings
LL(1) grammars define the same language under CFG and PEG interpretations.
Strong-LL(k), right-linear, and LL-regular grammars have simple language-preserving translations from CFGs to PEGs.
The new formalism clarifies the relationship between CFGs and PEGs.
Abstract
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.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
