summaryrefslogtreecommitdiffstats
path: root/stdlib
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 /stdlib
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 'stdlib')
-rw-r--r--stdlib/match.tl4
1 files changed, 3 insertions, 1 deletions
diff --git a/stdlib/match.tl b/stdlib/match.tl
index c59179f3..92206e0b 100644
--- a/stdlib/match.tl
+++ b/stdlib/match.tl
@@ -1065,9 +1065,11 @@
(defun transform-qquote (syn)
(match-case syn
- ((sys:hash-lit nil . @(coll (@key @val)))
+ ((sys:hash-lit nil . @(all (@key @val)))
^@(hash ,*(zip [mapcar transform-qquote key]
[mapcar transform-qquote val])))
+ ((sys:hash-lit)
+ '@(hash))
((sys:struct-lit @type . @args)
^@(struct ,(transform-qquote type)
,*[mapcar transform-qquote args]))