From 2a6e91240f8ff72cc340b7910cec23eea0533ccd Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 24 Jan 2021 13:10:20 -0800 Subject: matcher: rescind support for @(rcons ...) patterns. There is no longer any way to write a @(rcons ...) pattern using the range syntax, so there is no point in supporting that operator. The silly syntax @@a..@b which previously worked was actually due to a mistaken requirement in the parser. * share/txr/stdlib/match.tl (compile-range-match): Function moved closer to compile-atom-match, below compile-vec-match. The argument is now a range object containing patterns, so we pull it apart with from and to. (compile-atom-match): Pass range directly to compile-range-match; no need to construct (rcons ...) syntax. * tests/011/patmatch.tl: Add range tests from documentation and a few others. * txr.1: References to @(rcons ...) pattern scrubbed. One wrong #R pattern example corrected. --- tests/011/patmatch.tl | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/011') diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl index d045c45b..ac474738 100644 --- a/tests/011/patmatch.tl +++ b/tests/011/patmatch.tl @@ -135,3 +135,12 @@ (test (when-match @(hash (x @y) (@(symbolp y) @datum)) #H(() (x k) (k 42)) datum) (42)) + +(test (if-match #R(10 20) 10..20 :yes :no) :yes) +(test (if-match #R(10 20) #R(10 20) :yes :no) :yes) +(test (if-match #R(10 20) #R(1 2) :yes :no) :no) +(test (when-match #R(@a @b) 1..2 (list a b)) (1 2)) +(test (when-match #R(@a 2) 1..2 a) 1) +(test (when-match #R(1 @a) 1..2 a) 2) +(test (when-match #R(2 @a) 1..2 a) nil) +(test (when-match #R(@a 1) 1..2 a) nil) -- cgit v1.2.3