diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-01-15 17:59:24 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-01-15 17:59:24 -0800 |
commit | ec5a5e9d846e4af1d2311ab37b13ecb7d596e490 (patch) | |
tree | 013139c5893098773b42e03981dd1ffbf80da350 /share | |
parent | b0801ef509d80dcfea02434979ddbcb86db273c2 (diff) | |
download | txr-ec5a5e9d846e4af1d2311ab37b13ecb7d596e490.tar.gz txr-ec5a5e9d846e4af1d2311ab37b13ecb7d596e490.tar.bz2 txr-ec5a5e9d846e4af1d2311ab37b13ecb7d596e490.zip |
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.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/match.tl | 6 |
1 files changed, 6 insertions, 0 deletions
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)))) |