From ec5a5e9d846e4af1d2311ab37b13ecb7d596e490 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 15 Jan 2021 17:59:24 -0800 Subject: matcher: add support for @(op ...) predicate syntax. * share/txr/stdlib/match.tl (compile-op-match): New function. (compile-match): Route op operator to new function. --- share/txr/stdlib/match.tl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/share/txr/stdlib/match.tl b/share/txr/stdlib/match.tl index dda9a46f..423cbc9c 100644 --- a/share/txr/stdlib/match.tl +++ b/share/txr/stdlib/match.tl @@ -115,6 +115,11 @@ obj-var obj-var test-expr ^(equal ,obj-var ',atom))))) +(defun compile-op-match (op-expr obj-var) + (let ((var-match (compile-var-match nil obj-var))) + (set var-match.test-expr ^[,op-expr ,obj-var]) + var-match)) + (defun compile-predicate-match (pred-expr obj-var) (tree-bind (fun : sym) pred-expr (or (null sym) (bindable sym) @@ -240,6 +245,7 @@ (some (compile-loop-match exp obj-var)) (or (compile-parallel-match exp obj-var)) (and (compile-parallel-match exp obj-var)) + (op (compile-op-match exp obj-var)) (t (compile-predicate-match exp obj-var))) (compile-error *match-form* "unrecognized pattern syntax ~s" pat)))) -- cgit v1.2.3