From a9fe2ff7e428a7213b833f8937c5a497c19302d4 Mon Sep 17 00:00:00 2001 From: crc Date: Thu, 7 May 2020 16:05:25 +0000 Subject: [PATCH] new example from kiyoshi: forth style comments FossilOrigin-Name: d2bdb59da9bb7ab85b5e662cde55f2f57f4fe9c4ead33785fa94331a4089c803 --- example/forth-style-comments.retro | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 example/forth-style-comments.retro diff --git a/example/forth-style-comments.retro b/example/forth-style-comments.retro new file mode 100644 index 0000000..b35363f --- /dev/null +++ b/example/forth-style-comments.retro @@ -0,0 +1,24 @@ +# Forth-style comments + +End-of-Comment `Eo(` is a char, `)` by default. +If inconvenient, use some other char like + + $| !Eo( -( blah foo| + +Then `Eo(` is reverted to `)` . + +~~~ +'Eo( var (end-of-comment_char +{{ + :parse (-s) [ @Eo( eq? ] parse-until ; + :revert (-) $) !Eo( ; + revert +---reveal--- + :-( (c-) parse drop revert ; immediate + :+( (c-) parse s:put nl revert ; immediate +}} +~~~ + +``` +#0 -( #1 #2 ) $| !Eo( +( #3 #4 | #5 -( #6 #7 ) #8 +```