Journal of Functional Programming · 1998 · 181 citations · 6 references
ComputingComputer ScienceProgramming LanguagesSyntaxTheory Of ComputationFunctional ProgrammingParsingSyntactic AnalysisSyntactic ParsingSyntax AnalysisSyntax ParsingBottom-up ParsingMonadic SemanticsMonadsParser CombinatorsParser GeneratorsParsing AlgorithmsRecursionRecursive Descent Parsing
This paper is a tutorial on defining recursive descent parsers in Haskell. In the spirit of one-stop shopping , the paper combines material from three areas into a single source. The three areas are functional parsers (Burge, 1975; Wadler, 1985; Hutton, 1992; Fokker, 1995), the use of monads to structure functional programs (Wadler, 1990, 1992a, 1992b), and the use of special syntax for monadic programs in Haskell (Jones, 1995; Peterson et al ., 1996). More specifically, the paper shows how to define monadic parsers using do notation in Haskell. Of course, recursive descent parsers defined by hand lack the efficiency of bottom-up parsers generated by machine (Aho et al ., 1986; Mogensen, 1993; Gill and Marlow, 1995). However, for many research applications, a simple recursive descent parser is perfectly sufficient. Moreover, while parser generators typically offer a fixed set of combinators for describing grammars, the method described here is completely extensible: parsers are first-class values, and we have the full power of Haskell available to define new combinators for special applications. The method is also an excellent illustration of the elegance of functional programming.
6
The essence of functional programming
Philip Wadler · 1992 · 676 citations · Full text
Philip Wadler · 1990 · 575 citations · Full text
Higher-order functions for parsing
Graham Hutton · Journal of Functional Programming · 1992 · 183 citations · Full text
How to replace failure by a list of successes
Philip Wadler · 1985 · 110 citations