Abstract
There are numerous ways to implement a parser for a given syntax; using parser combinators is a powerful approach to parsing which derives much of its power and expressiveness from the type system and semantics of the host programming language. This tutorial begins with the construction of a small library of parsing combinators. This library introduces the basics of combinator parsing and, more generally, demonstrates how domain specific embedded languages are able to leverage the facilities of the host language. After having constructed our small combinator library, we investigate some shortcomings of the naïve implementation introduced in the first part, and incrementally develop an implementation without these problems. Finally we discuss some further extensions of the presented library and compare our approach with similar libraries.
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Baars, A.I., Löh, A., Swierstra, S.D.: Parsing permutation phrases. J. Funct. Program. 14(6), 635–646 (2004)
Burge, W.H.: Recursive Programming Techniques. Addison-Wesley, Reading (1975)
Claessen, K.: Parallel parsing processes. Journal of Functional Programming 14(6), 741–757 (2004)
Fokker, J.: Functional parsers. In: Jeuring, J.T., Meijer, H.J.M. (eds.) AFP 1995. LNCS, vol. 925, pp. 1–23. Springer, Heidelberg (1995)
Heeren, B.: Top Quality Type Error Messages. PhD thesis, Utrecht University (2005)
Heeren, B., Hage, J., Swierstra, S.D.: Scripting the type inference process. In: Eighth ACM Sigplan International Conference on Functional Programming, pp. 3–13. ACM Press, New York (2003)
Hughes, J.: Generalising monads to arrows. Science of Computer Programming 37(1-3), 67–111 (2000)
Hutton, G., Meijer, E.: Monadic parsing in Haskell. J. Funct. Program. 8(4), 437–444 (1998)
Leijen, D.: Parsec, a fast combinator parser. Technical Report UU-CS-2001-26, Institute of Information and Computing Sciences, Utrecht University (2001)
Mcbride, C., Paterson, R.A.: Applicative programming with effects. Journal of Functional Programming 18(1), 1–13 (2008)
Peyton Jones, S.: Haskell 98 Language and Libraries. Cambridge University Press, Cambridge (2003), http://www.haskell.org/report
Röjemo, N.: Garbage collection and memory efficiency in lazy functional languages. PhD thesis, Chalmers University of Technology (1995)
Swierstra, S.D., Baars, A., Löh, A., Middelkoop, A.: uuag - Utrecht university attribute grammar system
Swierstra, S.D., Azero Alocer, P.R., Saraiava, J.: Designing and implementing combinator languages. In: Swierstra, S.D., Henriques, P., Oliveira, J. (eds.) AFP 1998. LNCS, vol. 1608, pp. 150–206. Springer, Heidelberg (1999)
Swierstra, S.D., Duponcheel, L.: Deterministic, error-correcting combinator parsers. In: Launchbury, J., Meijer, E., Sheard, T. (eds.) AFP 1996. LNCS, vol. 1129, pp. 184–207. Springer, Heidelberg (1996)
Viera, M., Doaitse Swierstra, S., Lempsink, E.: Haskell, do you read me?: constructing and composing efficient top-down parsers at runtime. In: Haskell 2008: Proceedings of the first ACM SIGPLAN symposium on Haskell, pp. 63–74. ACM, New York (2008)
Wadler, P.: How to replace failure with a list of successes. In: Jouannaud, J.-P. (ed.) FPCA 1985. LNCS, vol. 201, pp. 113–128. Springer, Heidelberg (1985)
Wagner, R.A., Fischer, M.J.: The string-to-string correction problem. J. ACM 21(1), 168–173 (1974)
Wallace, M.: Partial parsing: Combining choice with commitment. In: Chitil, O., Horváth, Z., Zsók, V. (eds.) IFL 2007. LNCS, vol. 5083, pp. 93–110. Springer, Heidelberg (2008)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2009 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Swierstra, S.D. (2009). Combinator Parsing: A Short Tutorial. In: Bove, A., Barbosa, L.S., Pardo, A., Pinto, J.S. (eds) Language Engineering and Rigorous Software Development. LerNet 2008. Lecture Notes in Computer Science, vol 5520. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03153-3_6
Download citation
DOI: https://doi.org/10.1007/978-3-642-03153-3_6
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-03152-6
Online ISBN: 978-3-642-03153-3
eBook Packages: Computer ScienceComputer Science (R0)