diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-09-08 18:36:12 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-09-08 18:36:12 -0700 |
commit | 6fb34ff4e32cab93f437ed6c3d93042b87024437 (patch) | |
tree | 1518d00a53b217075ec432f7d6125d1c3ffefab6 /lib.c | |
parent | 9083d40bfb936f58e09940e4a987ca7d341d7650 (diff) | |
download | txr-6fb34ff4e32cab93f437ed6c3d93042b87024437.tar.gz txr-6fb34ff4e32cab93f437ed6c3d93042b87024437.tar.bz2 txr-6fb34ff4e32cab93f437ed6c3d93042b87024437.zip |
syntax: read and print [. x] and [. @x].
* lib.c (obj_print_impl): Handle (dwim . atom) syntax
by printing [. atom]. Note that (dwim . @var)
and (dwim . @(expr)) already print as [. @var]
and [. @(expr)]; this is not new. But none of these
forms are supported by reading without the
accompanying change to the parser.
* parser.y (dwim): Handle the [. expr] and [ . expr]
syntax, so that forms like [. a] and [. @a] have
print-read consistency. The motivation is to be
able to [. @args] in pattern matching to match a
DWIM forms; I tried that and was surprised to have it
blow up in my face.
* tests/012/readprint.tl: New test file. Future
printer/parser changes will be tested here. Historically,
changes to the syntax have not been consistently
unit-tested.
* y.tab.c.shipped: Regenerated.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -14099,8 +14099,14 @@ val obj_print_impl(val obj, val out, val pretty, struct strm_ctx *ctx) cnum max_len = ctx->strm->max_length; cnum max_count = max_len; - if (sym == dwim_s && have_args) { + if (sym == dwim_s) { put_char(chr('['), out); + if (!have_args) { + put_string(lit(". "), out); + obj_print_impl(args, out, pretty, ctx); + put_char(chr(']'), out); + break; + } obj = args; closepar = chr(']'); } else { |