Left recursion in Parsing Expression Grammars

@article{Medeiros2014LeftRI,
  title={Left recursion in Parsing Expression Grammars},
  author={S{\'e}rgio Queiroz de Medeiros and Fabio Mascarenhas and Roberto Ierusalimschy},
  journal={Sci. Comput. Program.},
  year={2014},
  volume={96},
  pages={177-190}
}
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… Expand
Parsing expression grammars made practical
TLDR
Autumn is introduced, a general purpose PEG library that supports left-recursion, left and right associativity and precedence rules, and does so efficiently and compares its parser to both state of the art and battle-tested PEG and CFG parsers. Expand
On the relation between context-free grammars and parsing expression grammars
TLDR
A new formalism for CFGs is presented that borrows from PEGs the use of parsing expressions and the recognition-based semantics, and it is shown how one way of removing non-determinism from this formalism yields a formalism with the semantics of P EGs. Expand
A parsing machine for parsing expression grammars with labeled failures
TLDR
An updated semantics for PEGs with labeled failures is presented, and how to extend the parsing machine to support them is shown, and it is proved the correctness of the translation from P EGs with labels to programs of this extended parsing machine. Expand
Nez: practical open grammar language
TLDR
This work implements Nez with dynamic parsing, which allows users to integrate a Nez parser as a parser library that loads a grammar at runtime, and demonstrates that Nez dynamic parsers achieve very competitive performance compared to existing efficient parser generators. Expand
Exception Handling for Error Reporting in Parsing Expression Grammars
TLDR
This work proposes the introduction of labeled failures to PEGs for error reporting, as labels help to produce more meaningful error messages and is expressive enough to implement some previous work on parser combinators. Expand
Error reporting in Parsing Expression Grammars
TLDR
Labeled failures give a way to annotate grammars for better error reporting, to express some of the error reporting strategies used by deterministic parser combinators, and to encode predictive top-down parsing in a PEG. Expand
Pika parsing: parsing in reverse solves the left recursion and error recovery problems
TLDR
The pika parser is presented, a novel reformulation of packrat parsing using dynamic programming to parse the input in reverse: bottom-up and right to left, rather than top-down and left to right, which enables direct and optimal recovery from syntax errors, which is a crucial property for building IDEs and compilers. Expand
Recognising and Generating Terms using Derivatives of Parsing Expression Grammars
TLDR
This paper presents a novel technique for sentence generation based on derivatives, applicable to any grammatical formalism for which the derivative can be defined--now including PEGs, and proposes applying derivatives more generally to other problems facing language designers and implementers. Expand
parboiled2: a macro-based approach for effective generators of parsing expressions grammars in Scala
TLDR
This work shows the implementation of an internal Scala DSL that features intuitive syntax and semantics that can give the developer a better understanding of how to compose more effective grammars. Expand
Derivatives of Parsing Expression Grammars
TLDR
A new derivative parsing algorithm for recognition of parsing expression grammars is introduced, shown to have a polynomial worst-case time bound, an improvement on the exponential bound of the recursive descent algorithm. Expand
...
1
2
...

References

SHOWING 1-10 OF 51 REFERENCES
Direct left-recursive parsing expression grammars
TLDR
This paper shows how the approach proposed for direct left-recursive Packrat parsing by Warth et al. can be adapted for ‘pure’ PEGs, and outlines a restrictive subset of left- Recursion Grammars which can safely work with this algorithm. Expand
On the relation between context-free grammars and parsing expression grammars
TLDR
A new formalism for CFGs is presented that borrows from PEGs the use of parsing expressions and the recognition-based semantics, and it is shown how one way of removing non-determinism from this formalism yields a formalism with the semantics of P EGs. Expand
Parsing expression grammars: a recognition-based syntactic foundation
  • B. Ford
  • Computer Science
  • POPL '04
  • 2004
TLDR
PEGs address frequently felt expressiveness limitations of CFGs and REs, simplifying syntax definitions and making it unnecessary to separate their lexical and hierarchical components, and are here proven equivalent in effective recognition power. Expand
Parsing Expression Grammar as a Primitive Recursive-Descent Parser with Backtracking
TLDR
The exercise with defining the Java syntax in PEG formalism suggests that more work is needed on PEG as a language specification tool, and the resulting primitive parser shows an acceptable behavior, indicating that packrat parsing might be an overkill for practical languages. Expand
Simple, Functional, Sound and Complete Parsing for All Context-Free Grammars
TLDR
This work shows how to construct simple, sound and complete parser implementations directly from grammar specifications, for all context-free grammars, based on combinator parsing, and constructs a generic parser generator that is faster than the popular Happy parser generator. Expand
Some Aspects of Parsing Expression Grammar
TLDR
The first part is an attempt to find out the language actually defined by a given parsing expression, and the second part reports measurements of backtracking activity in a PEG-derived parser for the programming language C. Expand
A parsing machine for PEGs
TLDR
This work presents a new approach for implementing PEGs, based on a virtual parsing machine, which is more suitable for pattern matching, and shows how to transform P EGs to parsing machine programs, and gives a correctness proof of the transformation. Expand
Packet parsing : a practical linear-time algorithm with backtracking
TLDR
Three different packrat Parsers for the Java language are presented here, demonstrating the construction of packrat parsers in Haskell using primitive pattern matching, using monadic combinators, and by automatic generation from a declarative parser specification. Expand
Packrat Parsing: Simple, Powerful, Lazy, Linear Time
  • B. Ford
  • Computer Science
  • ICFP 2002
  • 2002
TLDR
This paper describes packrat parsing informally with emphasis on its use in practical applications, and explores its advantages and disadvantages with respect to the more conventional alternatives. Expand
Compact recursive‐descent parsing of expressions
TLDR
This paper describes a simple technique for parsing expressions using recursive descent that avoids the usual proliferation of procedures that occurs when recursive descent is used to parse expressions. Expand
...
1
2
3
4
5
...