Results 1  10
of
10
Parser Combinators in Scala
, 2008
"... Parser combinators are wellknown in functional programming languages such as Haskell. In this paper, we describe how they are implemented as a library in Scala, a functional objectoriented language. Thanks to Scala’s flexible syntax, we are able to closely approximate the EBNF notation supported b ..."
Abstract

Cited by 8 (1 self)
 Add to MetaCart
Parser combinators are wellknown in functional programming languages such as Haskell. In this paper, we describe how they are implemented as a library in Scala, a functional objectoriented language. Thanks to Scala’s flexible syntax, we are able to closely approximate the EBNF notation supported by dedicated parser generators. For the uninitiated, we first explain the concept of parser combinators by developing a minimal library from scratch. We then turn to the existing Scala library, and discuss its features using various examples.
Validating LR(1) Parsers
"... Abstract. An LR(1) parser is a finitestate automaton, equipped with a stack, which uses a combination of its current state and one lookahead symbol in order to determine which action to perform next. We present a validator which, when applied to a contextfree grammar G and an automaton A, checks t ..."
Abstract

Cited by 3 (0 self)
 Add to MetaCart
Abstract. An LR(1) parser is a finitestate automaton, equipped with a stack, which uses a combination of its current state and one lookahead symbol in order to determine which action to perform next. We present a validator which, when applied to a contextfree grammar G and an automaton A, checks that A and G agree. Validating the parser provides the correctness guarantees required by verified compilers and other highassurance software that involves parsing. The validation process is independent of which technique was used to construct A. The validator is implemented and proved correct using the Coq proof assistant. As an application, we build a formallyverified parser for the C99 language. 1
Parsing with Derivatives A Functional Pearl Matthew
"... We present a functional approach to parsing unrestricted contextfree grammars based on Brzozowski’s derivative of regular expressions. If we consider contextfree grammars as recursive regular expressions, Brzozowski’s equational theory extends without modification to contextfree grammars (and it g ..."
Abstract
 Add to MetaCart
We present a functional approach to parsing unrestricted contextfree grammars based on Brzozowski’s derivative of regular expressions. If we consider contextfree grammars as recursive regular expressions, Brzozowski’s equational theory extends without modification to contextfree grammars (and it generalizes to parser combinators). The supporting actors in this story are three concepts familiar to functional programmers—laziness, memoization and fixed points; these allow Brzozowski’s original equations to be transliterated into purely functional code in about 30 lines spread over three functions. Yet, this almost impossibly brief implementation has a drawback: its performance is sour—in both theory and practice. The culprit? Each derivative can double the size of a grammar, and with it, the cost of the next derivative. Fortunately, much of the new structure inflicted by the derivative is either dead on arrival, or it dies after the very next derivative. To eliminate it, we once again exploit laziness and memoization to transliterate an equational theory that prunes such debris into working code. Thanks to this compaction, parsing times become reasonable in practice. We equip the functional programmer with two equational theories that, when combined, make for an abbreviated understanding and implementation of a system for parsing contextfree languages.
Practical Dynamic Grammars for . . .
"... Grammars for programming languages are traditionally specified statically. They are hard to compose and reuse due to ambiguities that inevitably arise. PetitParser combines ideas from scannerless parsing, parser combinators, parsing expression grammars and packrat parsers to model grammars and parse ..."
Abstract
 Add to MetaCart
Grammars for programming languages are traditionally specified statically. They are hard to compose and reuse due to ambiguities that inevitably arise. PetitParser combines ideas from scannerless parsing, parser combinators, parsing expression grammars and packrat parsers to model grammars and parsers as objects that can be reconfigured dynamically. Through examples and benchmarks we demonstrate that dynamic grammars are not only flexible but highly practical.
Direct LeftRecursive Parsing Expressing Grammars
"... Parsing Expression Grammars (PEGs) are specifications of unambiguous recursivedescent style parsers. PEGs incorporate both lexing and parsing phases and have valuable properties, such as being closed under composition. In common with most recursivedescent systems, raw PEGs cannot handle leftrec ..."
Abstract
 Add to MetaCart
Parsing Expression Grammars (PEGs) are specifications of unambiguous recursivedescent style parsers. PEGs incorporate both lexing and parsing phases and have valuable properties, such as being closed under composition. In common with most recursivedescent systems, raw PEGs cannot handle leftrecursion; traditional approaches to leftrecursion elimination lead to incorrect parses. In this paper, I show how the approach proposed for direct leftrecursive Packrat parsing by Warth et al. can be adapted for ‘pure ’ PEGs. I then demonstrate that this approach results in incorrect parses for some PEGs, before outlining a restrictive subset of leftrecursive PEGs which can safely work with this algorithm. Finally I suggest an alteration to Warth et al.’s algorithm that can correctly parse a less restrictive subset of directly recursive PEGs.
Grammars
, 2010
"... Abstract. Parsing Expression Grammars (PEGs) are specifications of unambiguous recursivedescent style parsers. PEGs incorporate both lexing and parsing phases and have valuable properties, such as being closed under composition. In common with most recursivedescent systems, raw PEGs cannot handle ..."
Abstract
 Add to MetaCart
Abstract. Parsing Expression Grammars (PEGs) are specifications of unambiguous recursivedescent style parsers. PEGs incorporate both lexing and parsing phases and have valuable properties, such as being closed under composition. In common with most recursivedescent systems, raw PEGs cannot handle leftrecursion; traditional approaches to leftrecursion elimination lead to incorrect parses. In this paper, I show how the approach proposed for direct leftrecursive Packrat parsing by Warth et al. can be adapted for ‘pure ’ PEGs. I then demonstrate that this approach results in incorrect parses for some PEGs, before outlining a restrictive subset of leftrecursive PEGs which can safely work with this algorithm. Finally I suggest an alteration to Warth et al.’s algorithm that can correctly parse a less restrictive subset of directly recursive PEGs. 1
2.2 Basic Idea......................................... 4
, 2009
"... ”The term pack rat is [..] used in English as slang to refer to a person who collects miscellaneous items and has trouble getting rid of them (a compulsive hoarder) [...] ” 1 ..."
Abstract
 Add to MetaCart
”The term pack rat is [..] used in English as slang to refer to a person who collects miscellaneous items and has trouble getting rid of them (a compulsive hoarder) [...] ” 1
DOI: 10.1007/9783642288692_20 Validating LR(1) Parsers
, 2013
"... Abstract. An LR(1) parser is a finitestate automaton, equipped with a stack, which uses a combination of its current state and one lookahead symbol in order to determine which action to perform next. We present a validator which, when applied to a contextfree grammar G and an automaton A, checks t ..."
Abstract
 Add to MetaCart
Abstract. An LR(1) parser is a finitestate automaton, equipped with a stack, which uses a combination of its current state and one lookahead symbol in order to determine which action to perform next. We present a validator which, when applied to a contextfree grammar G and an automaton A, checks that A and G agree. Validating the parser provides the correctness guarantees required by verified compilers and other highassurance software that involves parsing. The validation process is independent of which technique was used to construct A. The validator is implemented and proved correct using the Coq proof assistant. As an application, we build a formallyverified parser for the C99 language. 1
A Semantics for ContextSensitive Reduction Semantics
"... Abstract. This paper explores the semantics of the metanotation used in the style of operational semantics introduced by Felleisen and Hieb. Specifically, it defines a formal system that gives precise meanings to the notions of contexts, decomposition, and plugging (recomposition) left implicit in ..."
Abstract
 Add to MetaCart
Abstract. This paper explores the semantics of the metanotation used in the style of operational semantics introduced by Felleisen and Hieb. Specifically, it defines a formal system that gives precise meanings to the notions of contexts, decomposition, and plugging (recomposition) left implicit in most expositions. This semantics is not naturally algorithmic, so the paper also provides an algorithm and proves a correspondence with the declarative definition. The motivation for this investigation is PLT Redex, a domainspecific programming language designed to support FelleisenHiebstyle semantics. This style of semantics is the defacto standard in operational semantics and, as such, is widely used. Accordingly, our goal is that Redex programs should, as much as possible, look and behave like those semantics. Since Redex’s first public release more than seven years ago, its precise interpretation of contexts has changed several times, as we repeatedly encountered reduction systems that did not behave according to their authors ’ intent. This paper describes the culimation of that experience. To the best of our knowledge, the semantics given here accommodates even the most complex uses of contexts available. 1
scg.unibe.ch
, 2012
"... www.sweng.ch Grammars for programming languages are traditionally specified statically. They are hard to compose and reuse due to ambiguities that inevitably arise. PetitParser combines ideas from scannerless parsing, parser combinators, parsing expression grammars and packrat parsers to model gram ..."
Abstract
 Add to MetaCart
www.sweng.ch Grammars for programming languages are traditionally specified statically. They are hard to compose and reuse due to ambiguities that inevitably arise. PetitParser combines ideas from scannerless parsing, parser combinators, parsing expression grammars and packrat parsers to model grammars and parsers as objects that can be reconfigured dynamically. Through examples and benchmarks we demonstrate that dynamic grammars are not only flexible but highly practical. 1.