summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-04-29 01:38:25 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-04-29 01:38:25 -0700
commit5765cb50dffd4923bfc31e2a0ed07211c7050d57 (patch)
tree1d6698f27c10ca2eadcf8bfbd8726bd60a904a32 /tests
parent7392351a8f54ecfcfcd81736f2c6e81854e057c7 (diff)
downloadtxr-5765cb50dffd4923bfc31e2a0ed07211c7050d57.tar.gz
txr-5765cb50dffd4923bfc31e2a0ed07211c7050d57.tar.bz2
txr-5765cb50dffd4923bfc31e2a0ed07211c7050d57.zip
match: ^#S() and ^#H(()) patterns must work
Quasiquote patterns not containing unquotes are not working, because the parser transforms them into quoted objects. For instance ^#S(time) becomes the form (quote #S(time)) and not the form (sys:qquote (sys:struct-lit time)). The pattern matching compiler doesn't treat quote specially, only sys:qquote. * parser.y (unquotes_occur): Function removed. (vector, hash, struct, tree, json_vals, json_pairs): Remove use of unquotes_occur. Thus vector, hash, struct, tree and JSON syntax occurring within a backquote will be turned into a special literal whether or not it contains unquotes. * lib.c (obj_print_impl): Do not print the form (sys:hash-lit) as #Hnil, but #H(). * stdlib/match.tl (transform-qquote): Add a case which will handle ^#H(), as if it were ^H(()). Bugfix in the ^H(() ...) case. The use of @(coll) means it fails to match the empty syntax when no key/value pairs are specified, whereas @(all) respects vacuous truth. * test/011/patmatch.tl: A few tests. * y.tab.shipped, y.tab.h.shipped: Updated.
Diffstat (limited to 'tests')
-rw-r--r--tests/011/patmatch.tl6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/011/patmatch.tl b/tests/011/patmatch.tl
index bace28ce..08de0151 100644
--- a/tests/011/patmatch.tl
+++ b/tests/011/patmatch.tl
@@ -568,3 +568,9 @@
(if-match @(< @nil 2) 1 :y :n) :y
(match @(@nil (< @x 0)) -1 x) -1
(match @(@nil (< @nil 0)) -1 t) t)
+
+(mtest
+ (match ^(foo) '(foo) t) t
+ (match ^#H() #H(() (a b)) t) t
+ (match ^#H(()) #H(() (a b)) t) t
+ (match ^#S(time) #S(time year 2023) t) t)