aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2023-03-27 22:49:49 +0300
committerBonfaceKilz2023-04-05 16:17:11 +0300
commitdc1cdc6c11be05cb21e5b68b6f0d147165867864 (patch)
tree23de291f19d35ce704b390448f264971b7e67008
parent274c4cc42c5451fd073f577bf1592aed091dacf7 (diff)
downloadgn-transform-databases-dc1cdc6c11be05cb21e5b68b6f0d147165867864.tar.gz
Add new special form for representing blank nodes
* dump.scm (blank-node): New macro. Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rwxr-xr-xdump.scm22
1 files changed, 22 insertions, 0 deletions
diff --git a/dump.scm b/dump.scm
index b05af85..1f0a262 100755
--- a/dump.scm
+++ b/dump.scm
@@ -192,6 +192,28 @@ ALIST field-name) forms."
(string-append
dump-table "_" (remove-namespace (symbol->string predicate)))))))
+(define-syntax blank-node
+ (syntax-rules ()
+ "Allow having set and multiset within the context of a blank-node"
+ [(_ (op predicate object) ...)
+ (let [(node (string-join
+ (filter-map (match-lambda
+ ((pred . obj)
+ (match obj
+ ((and (? string? obj)
+ (? string-null? obj))
+ #f)
+ ((? symbol? obj)
+ (format #f "~a ~a" pred (symbol->string obj)))
+ (_
+ (format #f "~a ~s" pred obj)))))
+ (map-alist '()
+ (op predicate object) ...))
+ " ; "))]
+ (if (string-null? node)
+ ""
+ (format #f "[ ~a ]" node)))]))
+
(define-syntax syntax-let
(syntax-rules ()
"Like match-let, but for syntax.