Abstract
Parser combinators enable the construction of recursive descent parsers in a very clear and simple way. Unfortunately, the resulting parsers have a polynomial complexity and are far too slow for realistic inputs. We show how the speed of these parsers can be improved by one order of magnitude using continuations. These continuations prevents the creation of intermediate data structures. Furthermore, by using an exclusive or-combinator instead of the ordinary or-combinator the complexity for deterministic parsers can be reduced from polynomial to linear. The combination of both improvements turn parser combinators from a beautiful toy to a practically applicable tool which can be used for real world applications. The improved parser combinators remain very easy to use and are still able to handle ambiguous grammars.
Sponsored by STW project NWI.4411
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
A. Aho, R. Sethi and J.D. Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1986.
A. Appel. Compiling with Continuations. Cambridge University Press. 1992.
J. Fokker. Functional Parsers. In Advanced Functional Programming, 1st. International School on Functional Programming Techniques, Båstad, Sweden, volume 925 of LNCS, pages 1–23. Springer-Verlag, 1995.
A. Gill and S. Marlow. The Parser Generator for Haskell. University of Glasgow. 1995.
S. Hill. Combinators for Parsing Expressions. Journal of Functional Programming, 6(3):445–463, 1996.
G. Hutton. Higher Order Functions for Parsing. Journal of Functional Programming, 2:323–343, 1992.
S.C. Johnson. Yacc: Yet Another Compiler Compiler. UNIX On-Line Documentation. 1978.
P. Koopman. Parser Combinators. Chapter II.5 of Functional Programming in Clean In preparation (draft available at http://www.cs.kun.nl/~{}clean).
T. Mogensen. Ratatosk: A Parser Generator and Scanner Generator for Gofer. University of Copenhagen (DIKU), 1993.
S.L. Peyton Jones. Yacc in SASL, an Exercise in Functional Programming. Software: Practice and Experience, 15(8):807–820, 1995.
M.J. Plasmeijer and M.C.J.D. van Eekelen. The Concurrent Clean Language Report, Version 1.3. Nijmegen University, The Netherlands. 1998. http://www.cs.kun.nl/~{}clean.
D. Swierstra and L. Duponcheel. Deterministic, Error-Correcting Combinators Parsers. In Advanced Functional Programming. volume 1129 of LNCS, pages 185–207, Springer-Verlag, 1996
P.L. Wadler. How to Replace Failure by a List of Successes: a Method for Exception Handling, Backtracking, and Pattern Matching in Lazy Functional Languages. In J.P. Jouannaud, editor Proc. 1985 Conference on Functional Programming Languages and Computer Architecture (FPLCA’ 85). volume 201 of LNCS, pages 113–128, Springer-Verlag, 1985.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1999 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Koopman, P., Plasmeijer, R. (1999). Efficient Combinator Parsers. In: Hammond, K., Davie, T., Clack, C. (eds) Implementation of Functional Languages. IFL 1998. Lecture Notes in Computer Science, vol 1595. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-48515-5_8
Download citation
DOI: https://doi.org/10.1007/3-540-48515-5_8
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-66229-7
Online ISBN: 978-3-540-48515-5
eBook Packages: Springer Book Archive