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.
Preview
Unable to display preview. Download preview PDF.
References
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.
Emanuelson, Pär, Haraldsson, Anders, On Compiling Embedded Languages in Lisp, Proc. 1980 Lisp Conference, 1980.
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.
Ershov, A.P., On the partial computation principle, Information Processing Letters, Number 2, 1977.
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.
Futamura, Y., Partial evaluation of computer programs: An approach to a compiler-compiler, J. Inst. Electronics and Communication Engineers, 1971.
Gimpel, J. F., A Theory of Discrete Patterns and Their Implementation in SNOBOL4, Comm. ACM, Vol. 16, Number 2, 1973.
Griswold, R. E., The SNOBOL4 programming language, Bell Telephone Laboratories Inc., 1971.
Griswold, Ralph E., String Scanning in SL5, SL5 Project Document S5LD5a, The University of Arizona, Tucson, Arizona, 1976
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.
Haraldsson, Anders, A Program Manipulation System Based on Partial Evaluation, Ph. D. Thesis, Informatics Laboratory, Linköping University, Sweden, 1977.
Haraldsson, Anders, Experiences From a Program Manipulation System, Informatics Laboratory, Linköping University, Sweden, 1980.
Henderson, Peter, Morris, James H., A Lazy Evaluator, In Conf Rec. third Annu. ACM Symp. Principles of Programming Languages, Jan 1976.
Masinter, Larry, The Clisp Pattern Compiler, printed in [TEI78].
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.
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.
Teitelman, Warren., Design and implementation of FLIP, a Lisp format directed list processor. Bolt Beranek and Newman Inc, 1967.
Teitelman, Warren., INTERLISP reference manual, Xerox Palo Alto Research Center, Oct 1978.
Tesler, Lawrence G., Enea, Horace J., Smith David C., The LISP70 Pattern Matching System, Proc. Third International Joint Conference on Artificial Intelligence, 1973.
Wegbreit, B., Goal-directed Program Transformation, Third ACM Symposium on Principles of Programming Languages, Atlanta, Georgia, 1976.
Author information
Authors and Affiliations
Editor information
Rights 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