summaryrefslogtreecommitdiffstats
path: root/tests/012/readprint.tl
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-09-08 18:36:12 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-09-08 18:36:12 -0700
commit6fb34ff4e32cab93f437ed6c3d93042b87024437 (patch)
tree1518d00a53b217075ec432f7d6125d1c3ffefab6 /tests/012/readprint.tl
parent9083d40bfb936f58e09940e4a987ca7d341d7650 (diff)
downloadtxr-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 'tests/012/readprint.tl')
-rw-r--r--tests/012/readprint.tl7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/012/readprint.tl b/tests/012/readprint.tl
new file mode 100644
index 00000000..cf70320a
--- /dev/null
+++ b/tests/012/readprint.tl
@@ -0,0 +1,7 @@
+(load "../common")
+
+(mstest
+ '[ . a] "[. a]"
+ '[. a] "[. a]"
+ '[ . @a] "[. @a]"
+ '[. @a] "[. @a]")