MatchMaker.jl

Julia-native symbolic pattern matching and rewriting for SymbolicUtils.jl expressions: literals, slots, sequence captures, optional positions, and associative/commutative matching with deterministic enumeration.

using MatchMaker, SymbolicUtils

Which API should I use?

I want to…Use
test whether a pattern matches a subjectmatch
get every match as dictionariesmatchall
stream matches lazilymatches / boundmatches
count or compare matches cheaplyboundmatches / boundmatchall
find where a pattern matches inside a subjectboundmatches_at / matches_at
substitute bindings into a templateinstantiate
rewrite a term with rulesmmrule + RuleWorkspace
rewrite a whole treerewrite
rewrite to a fixed pointfixpoint_rewrite
customize matching engine internalsMatchEngine + next_match!

The mental model

  1. Compile once — compile_pattern builds a Matcher (or mmrule/RuleSet for rewriting); the compiled form is immutable and shareable.
  2. Match at sites — the match functions drive a MatchEngine over the pattern; results arrive as bindings keyed by variable Sym.
  3. Consume results — lazily (SubstitutionView, BoundMatch) or materialized (MarkersMap), then instantiate into a template or feed RuleWorkspace rewrites.

See the Tutorial for a worked end-to-end example and the user guide for the semantics reference.

Module

MatchMaker.MatchMaker — Module
MatchMaker

Symbolic pattern matching on top of SymbolicUtils.jl.

The governing design document is DESIGN.md (section references throughout source comments point at it); DEVELOPING.md documents codebase navigation and the implicit contracts between components. This module file only declares dependencies and wires includes together; the file layout is DESIGN.md §6.

source