From 8c08bb39c860ce264af1a35278d27658228c7a0e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 20 Apr 2021 07:50:34 -0700 Subject: matcher: new pattern operator @(end) * share/txr/stdlib/doc-syms.tl: New entry for end. * share/txr/stdlib/match.tl (check, check-end, check-sym, loosen, pat-len): New functions, taken from original local functions of sme macro. (sme): Refactored by hoisting local functions out. Some local variable renaming. (end): New pattern macro. * tests/011/patmatch.tl: New test for end. * txr.1: Documented. --- tests/011/patmatch.tl | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/011') diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index 4be407fa..346b21b6 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -314,3 +314,10 @@ (2 (3 5))) (test (when-match @(sme () () 5) 5 t) t) + +(test (when-match @(end 3 x) 3 x) 3) +(test (when-match @(end (2 @x) y) '(1 2 3) (list x y)) (3 (2 3))) +(test (when-match @(end (2 . @x) y) '(1 2 . 3) (list x y)) (3 (2 . 3))) + +(test (when-match @(as z @(end (2 @x) y)) '(1 2 3) (list x y z)) + (3 (2 3) (1 2 3))) -- cgit v1.2.3