Skip to main content

Generating a Pattern Matching Compiler by Partial Evaluation

  • Conference paper

Part of the book series: Workshops in Computing ((WORKSHOPS COMP.))

Abstract

Partial evaluation can be used for automatic generation of compilers and was first implemented by Jones et. al. [9]. Since partial evaluation was extended to higher order functional languages, Jones et. al. [8] and Bondorf [2], it has become possible to write denotational semantics definitions of languages and implement these with very few changes in the language treated by partial evaluators.

In this paper we use this technique to generate a compiler for a small strict combinator language with pattern matching. First, a simple denotational specification for the language is written and a compiler is generated. This first compiler turns out not to generate too efficient code.

By changing the denotational specification, new compilers that generate more efficient code are obtained. This process can be described as generating optimizing compilers by changing specifications. The optimization concerns generation of object code for pattern matching and the final compiler does in fact generate very efficient code for this. Specifically, it treats non-uniform function definitions in a satisfactory way. The optimization performed can be viewed as being equivalent to the well-known compiler optimization called common subexpression elimination.

This work was supported by ESPRIT Basic Research Actions project 3124 “Semantique”

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. Lennart Augustsson. Compiling pattern matching. In J.-P. Jouannaud, editor, Conference on Functional Programming Languages and Computer Architecture, Nancy, France. Lecture Notes in Computer Science 201, pages 368–381, Springer-Verlag, 1985.

    Google Scholar 

  2. Anders Bondorf. Automatic autoprojection of higher order recursive equations. In Neil D. Jones, editor, ESOP’90, Copenhagen, Denmark. Lecture Notes in Computer Science 432, pages 70–87, Springer-Verlag, May 1990.

    Google Scholar 

  3. Anders Bondorf. Compiling laziness by partial evaluation. In 1990 Glasgow Workshop on Functional Programming, Ullapool, Computing Science Department, Glasgow University, Glasgow, Scotland, 1990.

    Google Scholar 

  4. Anders Bondorf and Olivier Danvy. Automatic autoprojection of recursive equations with global variables and abstract data types. Technical Report 90–4, DIKU, University of Copenhagen, Denmark, 1990.

    Google Scholar 

  5. Charles Consel and Olivier Danvy. Partial evaluation of pattern matching in strings. Information Processing Letters, 30 (2): 79–86, 1989.

    Article  Google Scholar 

  6. Pär Emanuelson. From abstract model to efficient compilation of patterns. In M. Dezani-Ciancaglini and U. Montanan, editors, International Symposium on Programming, 5th Colloquium, Turin, Lecture Notes in Computer Science 137, pages 91–104, Springer-Verlag, April 1982.

    Google Scholar 

  7. Yoshihiko Futamura and Kenroku Nogi. Genreralized partial computation. In Dines Bjorner, Andrei P. Ershov, and Neil D. Jones, editors, Partial Evaluation and Mixed Computation, pages 133–151, North-Holland, 1988.

    Google Scholar 

  8. Neil D. Jones, Carsten K. Cornard, Anders Bondorf, Olivier Danvy, and Tor-ben Æ. Mogensen. A self-applicable partial evaluator for the lambda calculus. In IEEE Computer Society 1990 International Conference on Computer Languages, IEEE, March 1990.

    Google Scholar 

  9. Neil D. Jones, Peter Sestoft, and Harald Sondergaard. An experiment in partial evaluation: the generation of a compiler generator. In J.-P. Jouannaud, editor, Rewriting Techniques and Applications, Dijon, France. Lecture Notes in Computer Science 202, pages 124–140, Springer-Verlag, 1985.

    Google Scholar 

  10. Donald E. Knuth, James H. Morris, and Vaughan R. Pratt. Fast pattern matching in strings. Siam Journal on Computing, 6 (2): 323–350, 1977.

    Article  MathSciNet  MATH  Google Scholar 

  11. Paul Hudak and Philip Wadler, editors. Report on the programming language Haskell. Technical Report, Yale University and Glasgow University, April 1990.

    Google Scholar 

  12. Jonathan Rees and William Clinger. Revised reporta on the algorithmic language scheme. Sigplan Notices, 21 (12): 37–79, December 1986.

    Article  Google Scholar 

  13. David A. Schmidt. De notational Semantics, a Methodology for Language Development. Allyn and Bacon, Boston, 1986.

    Google Scholar 

  14. Peter Sestoft. The structure of a self-applicable partial evaluator. In Harald Ganzinger and Neil D. Jones, editors, Programs as Data Objects, Copenhagen, Denmark. Lecture Notes in Computer Science 217, pages 236–256, Springer-Verlag, October 1985.

    Google Scholar 

  15. Valentin F. Turchin. The concept of a supercompiler. Transactions on Programming Languages and Systems, 8 (3): 292–325, 1986.

    Article  MATH  Google Scholar 

  16. David Turner. An overview of Miranda. Sigplan Notices, 21 (12): 158–166, December 1986.

    Article  Google Scholar 

  17. Philip Wadler. Efficient compilation of pattern-matching. In Simon L. Peyton Jones, editor, The Implementation of Functional Programming Languages, chapter 5, pages 78–103, Prentice-Hall, 1987.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Simon L. Peyton Jones Graham Hutton Carsten Kehler Holst

Rights and permissions

Reprints and permissions

Copyright information

© 1991 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Jørgensen, J. (1991). Generating a Pattern Matching Compiler by Partial Evaluation. In: Jones, S.L.P., Hutton, G., Holst, C.K. (eds) Functional Programming, Glasgow 1990. Workshops in Computing. Springer, London. https://doi.org/10.1007/978-1-4471-3810-5_15

Download citation

  • DOI: https://doi.org/10.1007/978-1-4471-3810-5_15

  • Publisher Name: Springer, London

  • Print ISBN: 978-3-540-19667-9

  • Online ISBN: 978-1-4471-3810-5

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics