For and against PEGs: Why we need multi-ordered grammars

UMR 7266 LIENSs, CNRS, University of La Rochelle, La Rochelle, France
DOI
10.7287/peerj.preprints.27358v1
Subject Areas
Programming Languages, Software Engineering
Keywords
Grammars, Parsing, Languages, Multi-Ordered Grammars, Gray Algorithm
Copyright
© 2018 Papoulias
Licence
This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, reproduction and adaptation in any medium and for any purpose provided that it is properly attributed. For attribution, the original author(s), title, publication source (PeerJ Preprints) and either DOI or URL of the article must be cited.
Cite this article
Papoulias N. 2018. For and against PEGs: Why we need multi-ordered grammars. PeerJ Preprints 6:e27358v1

Abstract

Since their introduction in 2004, Parsing Expression Grammars (PEGs for short) have been gaining widespread adoption both in industry and academia. More than 400 subsequent works cite B. Ford's original paper, while a total of 29 implementations in 14 different programming languages are reported in active use. Nevertheless reviewing PEG-related bibliography reveals that the original argumentation in favor of PEGs has actually been weakened by subsequent work, regarding basic parsing features such as (a) recursion handling and (b) associativity support. To this day all proposed enhancements either address these issues in isolation or in implementation specific ways. It is still unclear if there is a single way to parse PEGs without facing these issues or introducing implementation directives external to the formalism. Our subsequent analysis takes us a step further, questioning the very core of the initial PEG proposal: (c) by design unambiguous grammars. We then discuss why a form of ordered choice and conditional operators that PEGs advocate are worth saving, but only within a wider synthesis that could address the aforementioned issues. To this end we present our on-going effort with the Gray algorithm and MOGs (Multi-Ordered Grammars), a possible alternative to the PEG and CFG formalisms.

Author Comment

This is a preprint submission to PeerJ.