Compilation of non-linear, second order patterns on S-expressions

  • Christian Queinnec
Implementation Of Pattern Matching
Part of the Lecture Notes in Computer Science book series (LNCS, volume 456)


Pattern matching is a key concept for rule-based expert systems. Simple pattern interpreters appear in nearly every book on Lisp. Pattern matching is also a useful tool for case analyses as provided by functional languages such as ML or Miranda™. These two uses are somewhat different since functional languages emphasize a discrimination based on types while Lisp, or Plasma, make use of S-expressions or segments of S-expressions within patterns. The paper presents an intermediate language for patterns and its denotational semantics. This reduced language is powerful enough to express boolean composition of patterns as well as segment handling and unbounded pattern repetition. A compiler is then defined which translates patterns into functional code. We discuss some compilation variant as well as the integration of the pattern sub-language into Lisp. These capabilities make pattern matching an useful and efficient tool for a wide class of applicative languages and allow to incorporate into patterns more knowledge about the form or gestalt of the data to be matched.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [Abelson & Sussman 85]
    Harold Abelson, Gerald Sussman, with Julie Sussman, Structure and Interpretation of Computer Programs, MIT Press, Cambridge MA, 1985.Google Scholar
  2. [Arcangeli & Pomian 90]
    Jean-Paul Arcangeli, Christian Pomian, Principles of Plasma pattern and alternative structure compilation, Theoretical Computer Science, Vol 71, 1970, pp 177–191.Google Scholar
  3. [Augustsson 85]
    Lennart Augustsson, Compiling Pattern Matching, Conference on Functional Programming and Machine Architecture, Nancy 1985, Lecture Note in Computer Science 201, Springer Verlag 1985.Google Scholar
  4. [Burstall 69]
    R. M. Burstall, Proving Properties of Programs by structural Induction, The Computer Journal, Vol 12, No 1.Google Scholar
  5. [Dybvig, Friedman & Haynes 88]
    R. Kent Dybvig, Daniel P. Friedman, Christopher T. Haynes, Expansion-Passing-Style: A General Macro Mechanism, Lisp and Symbolic Computation, Vol 1, n 1, June 1988, pp 53–76.Google Scholar
  6. [Heckmann 88]
    Reinhold Heckmann, A Functional Language for the Specification of Complex Tree Transformations, ESOP 88, Lecture Notes on Computer Science, Springer 1988.Google Scholar
  7. [Hewitt & Smith 75]
    C. Hewitt, B. Smith, Towards a programming Apprentice, IEEE Transactions on Software Engineering, SE-1, No 1, March 1975, pp 26–45.Google Scholar
  8. [Hudak & Wadler 90]
    Paul Hudak & Philip Wadler (eds), Report on the Programming Language Haskell, YALEU/DCS/RR-777, 1 April 1990.Google Scholar
  9. [Kessler 88]
    Robert R. Kessler, Lisp, Objects, and Symbolic Programming, Scott, Foreman/Little, Brown College Division, Glenview, Illinois, 1988.Google Scholar
  10. [Laville 88]
    Alain Laville, Évaluation paresseuse des filtrages avec priorité, Application au langage ML, Thèse de Doctorat, Université Paris VII, Février 1988.Google Scholar
  11. [Neidl 83]
    Eugen Neidl, Étude des relations avec l'interprète dans la compilation de Lisp, Thèse de troisième cycle, Université Paris VI, 1984.Google Scholar
  12. [Peyton Jones 86]
    Simon L. Peyton Jones, The Implementation of Functional Programming Languages, Prentice-Hall, May 1986.Google Scholar
  13. [Queinnec 84]
    Christian Queinnec, Lisp, Macmillan, 1984.Google Scholar
  14. [Rees & Clinger 86]
    Jonathan A. Rees, William Clinger, Revised 3 Report on the Algorithmic Language Scheme, ACM SIGPLAN Notices, 21, 12, Dec 1986, pp 37–79.Google Scholar
  15. [Schmidt 86]
    David A. Schmidt, Denotational Semantics, A Methodology for Language Development, Allyn and Bacon, Inc., Newton, Mass., 1986.Google Scholar
  16. [Stoy 77]
    Joseph E. Stoy, Denotational Semantics: The Scott-Strachey Approach to Programming Language Theory, MIT Press, Cambridge, Mass., 1977.Google Scholar
  17. [Takeichi 88]
    M. Takeichi, Lambda-Hoisting: a Transformation technique for fully lazy evaluation of functional program, New Generation Computing, Vol 5, 1988, pp 377–391.Google Scholar
  18. [Teitelman 78]
    Warren Teitelman, InterLisp Reference Manual, 1978.Google Scholar
  19. [Turner 76]
    D. A. Turner, The SASL Language Manual, Technical Report CS/75/1, Department of Computational Science, University of Saint Andrews.Google Scholar
  20. [Wadler 86]
    Philip Wadler, Efficient Compilation of Pattern-Matching, in PeytonJones86.Google Scholar
  21. [Weis 89]
    Pierre Weis, The CAML Reference Manual, INRIA 1989.Google Scholar
  22. [Winston 88]
    Patrick H. Winston, Berthold K. Horn, Lisp, 3rd Edition, Addison Wesley, 1988.Google Scholar

Copyright information

© Springer-Verlag 1990

Authors and Affiliations

  • Christian Queinnec
    • 1
    • 2
  1. 1.École Polytechnique—INRIAFrance
  2. 2.Laboratoire d'Informatique de l'École PolytechniquePalaiseau CedexFrance

Personalised recommendations