کد مقاله | کد نشریه | سال انتشار | مقاله انگلیسی | نسخه تمام متن |
---|---|---|---|---|
434160 | 1441682 | 2014 | 16 صفحه PDF | دانلود رایگان |
• 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.
Journal: Science of Computer Programming - Volume 89, Part C, 1 September 2014, Pages 235–250