The current version of the library declares the following syntax rules:
_
is a wildcard matcher that succeeds with anything and introduces no new bindings.
?x
triggers an unrestricted binding match. It will match anything and introduce a new binding from that symbol to the matched value.
(? <binding> <predicates...>)
triggers a binding iff all of the predicate functions appearing after the binding pass for the candidate.
(?? <binding>)
or ??x
inside of a sequence matches a segment of the list whose length isn't fixed. Segments will attempt to succed with successively longer prefixes of the remaining items in the list.
($$ <binding>)
or $$x
will only match after the same binding has already succeeded with a segment. If it has, - this will match a segment equal to the reverse of the already-bound segment.
(?? <binding> <predicates...>)
and ($$ <binding> <predicates...>)
are similar, but only pass iff all of the predicate functions appearing after the binding pass for the candidate sequence.
Any sequential entry, like a list or a vector, triggers a sequence
match. This will attempt to match a sequence, and only pass if its matcher arguments are able to match all entries in the sequence.
[[compile-pattern]] below allows a macro to take a pattern form with binding symbols unquoted. The disadvantage of a macro is that a user can't usually do things like splice in bindings that are in the current scope.
To fix this, we handle unquote
and unquote-splicing
directly.