Implementation Of Pattern Matching

Programming Language Implementation and Logic Programming

Volume 456 of the series Lecture Notes in Computer Science pp 340-357


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

  • Christian QueinnecAffiliated withÉcole Polytechnique—INRIALaboratoire d'Informatique de l'École Polytechnique

* Final gross prices may vary according to local VAT.

Get Access


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.