# Parser Combinators for Ambiguous Left-Recursive Grammars

@inproceedings{Frost2008ParserCF, title={Parser Combinators for Ambiguous Left-Recursive Grammars}, author={Richard A. Frost and Rahmatullah Hafiz and Paul Callaghan}, booktitle={PADL}, year={2008} }

Parser combinators are higher-order functions used to build parsers as executable specifications of grammars. Some existing implementations are only able to handle limited ambiguity, some have exponential time and/or space complexity for ambiguous input, most cannot accommodate left-recursive grammars. This paper describes combinators, implemented in Haskell, which overcome all of these limitations.

## 59 Citations

Executable Specifications of Fully General Attribute Grammars with Ambiguity and Left-Recursion

- Computer ScienceCanadian Conference on AI
- 2009

A top-down parsing algorithm has been constructed to accommodate any form of ambiguous context-free grammar, augmented with semantic rules with arbitrary attribute dependencies, which allows Natural Language processors to be constructed as executable, modular and declarative specifications of Attribute Grammars.

Simple, Efficient, Sound and Complete Combinator Parsing for All Context-Free Grammars, Using an Oracle

- Computer ScienceSLE
- 2014

Parsers for context-free grammars can be implemented directly and naturally in a functional style known as “combinator parsing”, using recursion following the structure of the grammar rules.…

Lazy Combinators for Executable Specifications of General Attribute Grammars

- Computer SciencePADL
- 2010

A lazy-evaluation based top-down parsing algorithm has been implemented as a set of higher-order functions (combinators) which support directly-executable specifications of fully general attribute…

Total parser combinators

- Computer ScienceICFP '10
- 2010

A monadic parser combinator library which guarantees termination of parsing, while still allowing many forms of left recursion, is described. The library's interface is similar to those of many other…

Left Recursion in Parsing Expression Grammars

- Computer ScienceSBLP
- 2012

A simple conservative extension to the semantics of PEGs is presented that gives useful meaning to direct and indirect left-recursive rules, and it is shown that these extensions make it easy to express left- Recursion idioms from CFGs in P EGs, with similar results.

Simple, Functional, Sound and Complete Parsing for All Context-Free Grammars

- Computer ScienceCPP
- 2011

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.

Practical, general parser combinators

- Computer SciencePEPM
- 2016

This paper presents general parser combinators that support all context-free grammars and construct a parse forest in cubic time and space in the worst case, while behaving nearly linearly on Grammars of real programming languages.

Modular Natural Language Processing Using Declarative Attribute Grammars

- Computer ScienceMICAI
- 2011

A system based on a general top-down parsing algorithm has been developed which allows language processors to be created as executable specifications of arbitrary attribute grammars and an innovative technique allows parses to be pruned by arbitrary semantic constraints.

A new view on parser combinators

- Computer ScienceIFL
- 2019

The idea is to replace the ordinary combinators by a set of type constructor classes that makes the DSL type-safe and extendable without needing to change existing parts and implementations, and to make multiple interpretations, views, of the specified grammar.

GLL parsing with flexible combinators

- Computer ScienceSLE
- 2018

This paper presents a combinator library with a similar architecture to P3, adjusting it to avoid grammar binarisation, which has a significant positive effect on the running times of the underlying parsing procedure, which is demonstrated using real-world grammars.

## References

SHOWING 1-10 OF 33 REFERENCES

Modular and Efficient Top-Down Parsing for Ambiguous Left-Recursive Grammars

- Computer ScienceIWPT
- 2007

This paper combines aspects of previous approaches and presents a method by which parsers can be built as modular and efficient executable specifications of ambiguous grammars containing unconstrained left recursion.

Parsec: direct style monadic parser combinators for the real world

- Computer Science
- 2001

The Parsec parser combinator library described in this paper, utilizes a novel implementation technique for space and time e±cient parser combinators that in case of a parse error, report both the position of the error as well as all grammar productions that would have been legal at that point in the input.

A New Top-Down Parsing Algorithm for Left-Recursive DCGs

- Computer SciencePLILP
- 1993

Deterministic cancellation parsing with lookahead k can handle the C( k) grammars, which include the LL(k) Grammars and are contained in the LC(k).

Monadic parser combinators

- Computer Science
- 1996

The purpose of this report is to provide a step-by-step tutorial on the monadic approach to building functional parsers, and to explain some of the benefits that result from exploiting monads.

A new top-down parsing algorithm to accommodate ambiguity and left recursion in polynomial time

- Computer ScienceSIGP
- 2006

This work has shown that memoization and techniques for handling left recursion have either been presented independently, or else attempts at their integration have compromised modularity and clarity of the code.

Monadic Parsing in Haskell

- Computer ScienceJ. Funct. Program.
- 1998

The paper shows how to define monadic parsers using do notation in Haskell, targeted at the level of a good undergraduate student who is familiar with Haskell, and has completed a grammars and parsing course.

Packrat parsing:: simple, powerful, lazy, linear time, functional pearl

- Computer ScienceICFP '02
- 2002

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.

Efficiency in Large-scale Parsing Systems - Parser Comparison. Evaluation Methodology and Data

- Computer Science
- 2001

Investigation of efficient approaches to parsing is an important topic of research in response to the complexities of language-based application tasks such as speech-to-speech translation.

Packrat Parsing: Simple, Powerful, Lazy, Linear Time

- Computer ScienceICFP 2002
- 2002

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.

An efficient context-free parsing algorithm

- Computer ScienceCACM
- 1983

A parsing algorithm which seems to be the most efficient general context-free algorithm known is described and appears to be superior to the top-down and bottom-up algorithms studied by Griffiths and Petrick.