diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-04-29 01:38:25 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-04-29 01:38:25 -0700 |
commit | 5765cb50dffd4923bfc31e2a0ed07211c7050d57 (patch) | |
tree | 1d6698f27c10ca2eadcf8bfbd8726bd60a904a32 /lib.c | |
parent | 7392351a8f54ecfcfcd81736f2c6e81854e057c7 (diff) | |
download | txr-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 'lib.c')
-rw-r--r-- | lib.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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))) { |