Article ID Journal Published Year Pages File Type
434160 Science of Computer Programming 2014 16 Pages PDF
Abstract

•We present new formalizations of CFGs and PEGs, based on natural semantics.•We discuss the correspondence between the languages of CFGs and PEGs.•We show transformations from classes of CFGs to equivalent PEGs.•Transformations of LL(1)LL(1), strong-LL(k)LL(k) and LL-regular grammars are presented.•The transformations preserve the structure of the original grammars.

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)LL(1) grammars define the same language whether interpreted as CFGs or as PEGs, and also show how strong-LL(k)LL(k), right-linear, and LL-regular grammars have simple language-preserving translations from CFGs to PEGs. Once these classes of CFGs can be automatically translated to equivalent PEGs, we can reuse classic top-down grammars in PEG-based tools.

Related Topics
Physical Sciences and Engineering Computer Science Computational Theory and Mathematics
Authors
, , ,