Skip to main content

Efficient Combinator Parsers

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 1595))

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

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. A. Aho, R. Sethi and J.D. Ullman. Compilers: Principles, Techniques and Tools. Addison-Wesley, 1986.

    Google Scholar 

  2. A. Appel. Compiling with Continuations. Cambridge University Press. 1992.

    Google Scholar 

  3. 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.

    Google Scholar 

  4. A. Gill and S. Marlow. The Parser Generator for Haskell. University of Glasgow. 1995.

    Google Scholar 

  5. S. Hill. Combinators for Parsing Expressions. Journal of Functional Programming, 6(3):445–463, 1996.

    Article  MATH  Google Scholar 

  6. G. Hutton. Higher Order Functions for Parsing. Journal of Functional Programming, 2:323–343, 1992.

    MATH  MathSciNet  Google Scholar 

  7. S.C. Johnson. Yacc: Yet Another Compiler Compiler. UNIX On-Line Documentation. 1978.

    Google Scholar 

  8. P. Koopman. Parser Combinators. Chapter II.5 of Functional Programming in Clean In preparation (draft available at http://www.cs.kun.nl/~{}clean).

  9. T. Mogensen. Ratatosk: A Parser Generator and Scanner Generator for Gofer. University of Copenhagen (DIKU), 1993.

    Google Scholar 

  10. S.L. Peyton Jones. Yacc in SASL, an Exercise in Functional Programming. Software: Practice and Experience, 15(8):807–820, 1995.

    Article  Google Scholar 

  11. 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.

    Google Scholar 

  12. D. Swierstra and L. Duponcheel. Deterministic, Error-Correcting Combinators Parsers. In Advanced Functional Programming. volume 1129 of LNCS, pages 185–207, Springer-Verlag, 1996

    Google Scholar 

  13. 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.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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

Publish with us

Policies and ethics