HackerPapers

arXiv:1207.0443cs.FL

Left Recursion in Parsing Expression Grammars

Sérgio Medeiros, Fabio Mascarenhas, Roberto Ierusalimschy

Early discovery. Linked by one identifiable commenter. This paper is outside the main ranking; a mention is not an endorsement.

Abstract

Parsing Expression Grammars (PEGs) are a formalism that can describe all deterministic context-free languages through a set of rules that specify a top-down parser for some language. PEGs are easy to use, and there are efficient implementations of PEG libraries in several programming languages. A frequently missed feature of PEGs is left recursion, which is commonly used in Context-Free Grammars (CFGs) to encode left-associative operations. We present a simple conservative extension to the semantics of PEGs that gives useful meaning to direct and indirect left-recursive rules, and show that our extensions make it easy to express left-recursive idioms from CFGs in PEGs, with similar results. We prove the conservativeness of these extensions, and also prove that they work with any left-recursive PEG. PEGs can also be compiled to programs in a low-level parsing machine. We present an extension to the semantics of the operations of this parsing machine that let it interpret left-recursive PEGs, and prove that this extension is correct with regards to our semantics for left-recursive PEGs.

arXiv comments
Extended version of the paper "Left Recursion in Parsing Expression Grammars", that was published on 2012 Brazilian Symposium on Programming Languages
Journal reference
DOI
doi:10.1016/j.scico.2014.01.013
Subjects
cs.FLFormal Languages and Automata Theory

On Hacker News

Linked by 1 identifiable commenter in 1 comment across 1 thread, from Dec 2015 to Dec 2015.

Comments linking this paper, per year.

Discussed in comments1 thread

    • If you're interested in left-recursion in PEGS then, at the risk of gross immodesty, you may be interested in http://tratt.net/laurie/research/pubs/html/tratt__direct_lef... With less risk of immodesty you may also find http://arxiv.org/pdf/1207.0443.pdf?ref=driverlayer.com/web…

      ltrattView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.