From 5765cb50dffd4923bfc31e2a0ed07211c7050d57 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 29 Apr 2023 01:38:25 -0700 Subject: 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. --- lib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index e995fcf0..417109dd 100644 --- a/lib.c +++ b/lib.c @@ -14260,10 +14260,13 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) obj_print_impl(arg, out, pretty, ctx); } else if (sym == hash_lit_s) { put_string(lit("#H"), out); - obj_print_impl(rest(obj), out, pretty, ctx); + if (!args) + put_string(lit("()"), out); + else + obj_print_impl(args, out, pretty, ctx); } else if (sym == struct_lit_s) { put_string(lit("#S"), out); - obj_print_impl(rest(obj), out, pretty, ctx); + obj_print_impl(args, out, pretty, ctx); } else if (sym == json_s && have_args && consp(cdr(args)) && nilp(cddr(args))) { -- cgit v1.2.3