Skip to main content

Strategic Pattern Matching

  • Conference paper
  • First Online:

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

Abstract

Stratego is a language for the specification of transformation rules and strategies for applying them. The basic actions of transformations are matching and building instantiations of first-order term patterns. The language supports concise formulation of generic and data type-specific term traversals. One of the unusual features of Stratego is the separation of scope from matching, allowing sharing of variables through traversals. The combination of first-order patterns with strategies forms an expressive formalism for pattern matching. In this paper we discuss three examples of strategic pattern matching: (1) Contextual rules allow matching and replacement of a pattern at an arbitrary depth of a subterm of the root pattern. (2) Recursive patterns can be used to characterize concisely the structure of languages that form a restriction of a larger language. (3) Overlays serve to hide the representation of a language in another (more generic) language. These techniques are illustrated by means of specifications in Stratego.

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. A. Aiken and B. Murphy. Implementing regular tree expressions. In Functional Programming and Computer Architecture (FPCA’91), pages 427–447, Aug. 1991.

    Google Scholar 

  2. W. E. Aitken and J. H. Reppy. Abstract value constructors. In ACM SIGPLAN Workshop on ML and its Applications, pages 1–11, San Francisco, Cal., June 1992.

    Google Scholar 

  3. P. Borovanský, C. Kirchner, and H. Kirchner. Controlling rewriting by rewriting. In J. Meseguer, editor, Proceedings of the First International Workshop on Rewriting Logic and its Applications, volume 4 of Electronic Notes in Theoretical Computer Science, Asilomar, Pacific Grove, CA, September 1996. Elsevier.

    Google Scholar 

  4. F. W. Burton and R. D. Cameron. Pattern matching with abstract data types. Journal of Functional Programming, 3(2):171–190, April 1993.

    Article  MathSciNet  Google Scholar 

  5. M. Clavel, S. Eker, P. Lincoln, and J. Meseguer. Principles of Maude. In J. Meseguer, editor, Proceedings of the First International Workshop on Rewriting Logic and its Applications, volume 4 of Electronic Notes in Theoretical Computer Science, pages 65–89, Asilomar, Pacific Grove, CA, September 1996. Elsevier.

    Google Scholar 

  6. J. R. Cordy, I. H. Carmichael, and R. Halliday. The TXL Programming Language, Version 8, Apr. 1995.

    Google Scholar 

  7. A. Van Deursen, J. Heering, and P. Klint, editors. Language Prototyping. An Algebraic Specification Approach, volume 5 of AMAST Series in Computing. World Scientific, Singapore, September 1996.

    Google Scholar 

  8. M. Erwig. Active patterns. In Implementation of Functional Languages, volume 1268 of Lecture Notes in Computer Science, pages 21–40, 1996.

    Google Scholar 

  9. M. Fähndrich and J. Boyland. Statically checkable pattern abstractions. In International Conference on Functional Programming (ICFP’97), pages 75–84, Amsterdam, The Netherlands, June 1997. ACM SIGPLAN.

    Google Scholar 

  10. C. D. Farnum. Pattern-Based Languages for Prototyping of Compiler Optimizers. PhD thesis, University of California, Berkeley, 1990. Technical Report CSD-90-608.

    Google Scholar 

  11. J. Heering. Second-order term rewriting specification of static semantics: An exercise. In Van Deursen et al. [7], chapter 8, pages 295–305.

    Google Scholar 

  12. P. Johann and E. Visser. Warm fusion in Stratego. A case study in generation of program transformation systems. Technical report, Department of Computer Science, Universiteit Utrecht, 1999. http://www.cs.uu.nl/~visser/stratego/.

  13. C. Kirchner, H. Kirchner, and M. Vittek. Implementing computational systems with constraints. In P. Kanellakis, J.-L. Lassez, and V. Saraswat, editors, Proceedings of the first Workshop on Principles and Practice of Constraint Programming, pages 166–175, Providence R.I., USA, 1993. Brown University.

    Google Scholar 

  14. B. Luttik and E. Visser. Specification of rewriting strategies. In M. P. A. Sellink, editor, 2nd International Workshop on the Theory and Practice of Algebraic Specifications (ASF+SDF’97), Electronic Workshops in Computing, Berlin, November 1997. Springer-Verlag.

    Google Scholar 

  15. A. Malton. The denotational semantics of a functional tree-manipulation language. Computer Languages, 19(3):157–168, 1993.

    Article  MATH  Google Scholar 

  16. M. Mohnen. Context patterns, part ii. In Implementation of Functional Languages, pages 338–357, 1997.

    Google Scholar 

  17. G. Nadathur and D. Miller. An overview of λProlog. In R. A. Kowalski, editor, Logic Programming. Proceedings of the Fifth International Conference and Symposium, volume 1, pages 810–827, Cambridge, Mass., USA, 1988. MIT Press.

    Google Scholar 

  18. C. Okasaki. Views for Standard ML. In SIGPLANWorkshop on ML, pages 14–23, Baltimore, Maryland, USA, September 1998.

    Google Scholar 

  19. P. A. Olivier and H. A. de Jong. Efficient annotated terms. Technical report, Programming Research Group, University of Amsterdam, August 1998.

    Google Scholar 

  20. M. P. A. Sellink and C. Verhoef. Native patterns. In M. Blaha, A. Quilici, and C. Verhoef, editors, Proceedings of the 5-th Working Conference on Reverse Engineering (WCRE’98), pages 89–103, Honolulu, Hawaii, USA, October 1998.

    Google Scholar 

  21. S. Thompson. Laws in Miranda. In ACM Symposium on Lisp and Functional Programming, pages 1–12. ACM, August 1986.

    Google Scholar 

  22. E. Visser and Z.-e.-A. Benaissa. A core language for rewriting. In C. Kirchner and H. Kirchner, editors, Second International Workshop on Rewriting Logic and its Applications (WRLA’98), Electronic Notes in Theoretical Computer Science, Pont-à-Mousson, France, September 1-4 1998. Elsevier.

    Google Scholar 

  23. E. Visser, Z.-e.-A. Benaissa, and A. Tolmach. Building program optimizers with rewriting strategies. In International Conference on Functional Programming (ICFP’98), pages 13–26, Baltimore, Maryland, September 1998. ACM.

    Google Scholar 

  24. P. Wadler. Views: A way for pattern matching to cohabit with data abstraction. In ACM Symposium on Principles of Programming Languages, pages 307–313, Munich, January 1987. ACM.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 1999 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Visser, E. (1999). Strategic Pattern Matching. In: Narendran, P., Rusinowitch, M. (eds) Rewriting Techniques and Applications. RTA 1999. Lecture Notes in Computer Science, vol 1631. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-48685-2_3

Download citation

  • DOI: https://doi.org/10.1007/3-540-48685-2_3

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-66201-3

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

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics