
arXiv: 2011.04360
Parsing Expression Grammars (PEGs) are a recognition-based formalism which allows to describe the syntactical and the lexical elements of a language. The main difference between Context-Free Grammars (CFGs) and PEGs relies on the interpretation of the choice operator: while the CFGs' unordered choice e | e' is interpreted as the union of the languages recognized by e and e, the PEGs' prioritized choice e/e' discards e' if e succeeds. Such subtle, but important difference, changes the language recognized and yields more efficient parsing algorithms. This paper proposes a rewriting logic semantics for PEGs. We start with a rewrite theory giving meaning to the usual constructs in PEGs. Later, we show that cuts, a mechanism for controlling backtracks in PEGs, finds also a natural representation in our framework. We generalize such mechanism, allowing for both local and global cuts with a precise, unified and formal semantics. Hence, our work strives at better understanding and controlling backtracks in parsers for PEGs. The semantics we propose is executable and, besides being a parser with modest efficiency, it can be used as a playground to test different optimization ideas. More importantly, it is a mathematical tool that can be used for different analyses.
FOS: Computer and information sciences, Computer Science - Programming Languages, D.3.4, Formal Languages and Automata Theory (cs.FL), [INFO.INFO-SC] Computer Science [cs]/Symbolic Computation [cs.SC], F.4.3, Computer Science - Formal Languages and Automata Theory, F.4.2, Programming Languages (cs.PL), F.4.2; F.4.3; D.3.4
FOS: Computer and information sciences, Computer Science - Programming Languages, D.3.4, Formal Languages and Automata Theory (cs.FL), [INFO.INFO-SC] Computer Science [cs]/Symbolic Computation [cs.SC], F.4.3, Computer Science - Formal Languages and Automata Theory, F.4.2, Programming Languages (cs.PL), F.4.2; F.4.3; D.3.4
| selected citations These citations are derived from selected sources. This is an alternative to the "Influence" indicator, which also reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically). | 1 | |
| popularity This indicator reflects the "current" impact/attention (the "hype") of an article in the research community at large, based on the underlying citation network. | Average | |
| influence This indicator reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically). | Average | |
| impulse This indicator reflects the initial momentum of an article directly after its publication, based on the underlying citation network. | Average |
