Since McMicMac is intended to serve as a platform for writing tools that process programs, it is invaluable to have a utility that syntactically validates and de-constructs input program phrases. Since McMicMac is currently geared toward processing Scheme programs, it currently includes a pattern-matching utility that processes Scheme s-expressions in their McMicMac-enriched forms (i.e., embedded in the read type).
The pattern matcher in McMicMac is procedural in nature. This means that it does not define any macros or core forms; rather, patterns are defined and matched against using a series of procedure calls. A current area of investigation is into whether there is a reasonable syntactic interface that can be provided for these procedures and, if so, what that interface is.
This document describes McMicMac's pattern matcher and provides some examples of its use.
The pattern matcher includes a pattern compiler, which pre-processes patterns to generate efficient code that performs two tasks: to validate the input, and to bind pattern variables against the corresponding components of the input.
The pattern matcher introduces four new types: the keyword list, kwd-list; the (raw) pattern, pat; the compiled pattern, cpat; and the pattern environment, penv. For now, kwd-list is just a synonym for the type list(scheme-symbol).