Skip to main content

From abstract model to efficient compilation of patterns

  • Conference paper
  • First Online:
International Symposium on Programming (Programming 1982)

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

Included in the following conference series:

Abstract

Pattern matching is a technique which is used in many application areas such as text manipulation in editors, manipulation of arithmetic formulas in computer algebra systems and in artificial intelligence applications. In programming systems it can be a built-in language facility as string matching in SNOBOL4 or a language extension for matching of list structures as in INTERLISP.

This paper presents a strategy for achieving a pattern match facility with the following properties (1) it is based on a simple model of pattern matching in order to give a good understanding for the pattern matching process (2) it is powerful, that is, it contains the union of the facilities commonly found in pattern matchers (3) it provides compilation of patterns to efficient code.

Available implementations are oriented towards providing either a clear and extensible definition of pattern matching or towards good performance at execution. The underlying problem is that good optimizing compilers are too complex to also serve as a modifiable definition of the language.

Our strategy is based on the development of a simple formal definition of the problem. Then a pattern match interpreter in Lisp is developed as an extension of the formal definition and thus serves to reach the second goal. Powerful program manipulation tools are then used to transform the interpreter according to the partial evaluation principle. The Lisp code which is the result from partial evaluation is regarded as compiled patterns.

The stepwise development of a suitable model is described and the resulting Lisp program is shown. The partial evaluation of the program with respect to one given pattern is demonstrated. Examples of optimization in the pattern language is shown and similarities between partial evaluation and lazy evaluation are pointed out. Performance results of the full implementation are given. Other approaches to pattern matching systems are briefly described and related to our approach. Finally the effects of partial evaluation on the pattern matcher are characterized and their relative importance is evaluated. The outcome of applying this strategy to similar problems is discussed.

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

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Beckman, L., Haraldsson, A., Oskarsson Ö., Sandewall, E., A partial evaluator and its use as a programming tool, Artificial Intelligence Journal, Vol. 7, Number 4, 1976, 319–357.

    Google Scholar 

  2. Emanuelson, Pär, Haraldsson, Anders, On Compiling Embedded Languages in Lisp, Proc. 1980 Lisp Conference, 1980.

    Google Scholar 

  3. Emanuelson, Pär, Performance enhancement in a well-structured pattern matcher through partial evaluation. Ph.D. thesis. Software Systems Research Center, Linköping University, Sweden, 1980.

    Google Scholar 

  4. Ershov, A.P., On the partial computation principle, Information Processing Letters, Number 2, 1977.

    Google Scholar 

  5. Friedman, D.P., Wise, D.S., CONS Should Not Evaluate Its Arguments, in Automata, Languages and Programming, S Michaelson and R. Milner (eds), Edinburgh University Press, 1976.

    Google Scholar 

  6. Futamura, Y., Partial evaluation of computer programs: An approach to a compiler-compiler, J. Inst. Electronics and Communication Engineers, 1971.

    Google Scholar 

  7. Gimpel, J. F., A Theory of Discrete Patterns and Their Implementation in SNOBOL4, Comm. ACM, Vol. 16, Number 2, 1973.

    Google Scholar 

  8. Griswold, R. E., The SNOBOL4 programming language, Bell Telephone Laboratories Inc., 1971.

    Google Scholar 

  9. Griswold, Ralph E., String Scanning in SL5, SL5 Project Document S5LD5a, The University of Arizona, Tucson, Arizona, 1976

    Google Scholar 

  10. Griswold, Ralph E., Hanson, David R., An Alternative to the Use of Patterns in String Processing, ACM Transactions on Programming Languages and Systems, Vol 2, No 2, 1980.

    Google Scholar 

  11. Haraldsson, Anders, A Program Manipulation System Based on Partial Evaluation, Ph. D. Thesis, Informatics Laboratory, Linköping University, Sweden, 1977.

    Google Scholar 

  12. Haraldsson, Anders, Experiences From a Program Manipulation System, Informatics Laboratory, Linköping University, Sweden, 1980.

    Google Scholar 

  13. Henderson, Peter, Morris, James H., A Lazy Evaluator, In Conf Rec. third Annu. ACM Symp. Principles of Programming Languages, Jan 1976.

    Google Scholar 

  14. Masinter, Larry, The Clisp Pattern Compiler, printed in [TEI78].

    Google Scholar 

  15. Sacerdoti, Earl D., Fikes, Richard E., Reboh, Rene, Sagalowicz, Daniel, Waldinger, Richard J., Wilber, B. Michael, Qlisp: A Language for the Interactive Development of Complex Systems, Technical Note 120, Stanford Research Institute, 1976.

    Google Scholar 

  16. Stewart, G.F., An algebraic model for string patterns. In Conf. Rec. 2nd Annu. ACM Symp. Principles of Programming Languages, Jan 1975, pp 167–184.

    Google Scholar 

  17. Teitelman, Warren., Design and implementation of FLIP, a Lisp format directed list processor. Bolt Beranek and Newman Inc, 1967.

    Google Scholar 

  18. Teitelman, Warren., INTERLISP reference manual, Xerox Palo Alto Research Center, Oct 1978.

    Google Scholar 

  19. Tesler, Lawrence G., Enea, Horace J., Smith David C., The LISP70 Pattern Matching System, Proc. Third International Joint Conference on Artificial Intelligence, 1973.

    Google Scholar 

  20. Wegbreit, B., Goal-directed Program Transformation, Third ACM Symposium on Principles of Programming Languages, Atlanta, Georgia, 1976.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Mariangiola Dezani-Ciancaglini Ugo Montanari

Rights and permissions

Reprints and permissions

Copyright information

© 1982 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Emanuelson, P. (1982). From abstract model to efficient compilation of patterns. In: Dezani-Ciancaglini, M., Montanari, U. (eds) International Symposium on Programming. Programming 1982. Lecture Notes in Computer Science, vol 137. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-11494-7_8

Download citation

  • DOI: https://doi.org/10.1007/3-540-11494-7_8

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

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

  • Online ISBN: 978-3-540-39184-5

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics