aboutsummaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2023-11-23 17:49:45 +0000
committerArun Isaac2023-11-23 19:02:58 +0000
commit9f601fc3f131e82e1ee5791783d330bddde468d2 (patch)
tree1a5cfe580722168270634a5d51f0f41df1033962 /ccwl
parent00c911b1bd5aca3800e0263240968ad8f3fbefde (diff)
downloadccwl-9f601fc3f131e82e1ee5791783d330bddde468d2.tar.gz
ccwl-9f601fc3f131e82e1ee5791783d330bddde468d2.tar.lz
ccwl-9f601fc3f131e82e1ee5791783d330bddde468d2.zip
ccwl: Implement item separators for array inputs.
* ccwl/ccwl.scm (<input>)[separator]: New field. * ccwl/ccwl.scm (run-arg-position, run-args): Support array input specifiers. (run-arg-separator): New function. (command): Set separator on input objects. * ccwl/cwl.scm (input->cwl-scm): Serialize itemSeparator. * tests/ccwl.scm ("commands with non-string #:separator parameters must raise a &ccwl-violation condition"): New test. * doc/ccwl.skb (Cookbook)[Array input item separators]: New section. * doc/array-input-item-separators.scm: New file.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/ccwl.scm47
-rw-r--r--ccwl/cwl.scm3
2 files changed, 43 insertions, 7 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index e602f0b..d00609d 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -65,6 +65,7 @@
input-default
input-position
input-prefix
+ input-separator
input-stage?
input-other
output?
@@ -93,6 +94,7 @@
(default input-default set-input-default)
(position input-position set-input-position)
(prefix input-prefix set-input-prefix)
+ (separator input-separator set-input-separator)
(stage? input-stage?)
(other input-other))
@@ -325,11 +327,19 @@ compared using @code{equal?}."
RUN-ARGS. If such an input is not present in RUN-ARGS, return #f."
(list-index (lambda (run-arg)
(let ((run-arg-input
- (syntax-case run-arg ()
+ (syntax-case run-arg (array)
+ ;; input
(input (identifier? #'input)
(syntax->datum #'input))
+ ;; prefixed input
((_ input) (identifier? #'input)
(syntax->datum #'input))
+ ;; array input specifier
+ ((array input _ ...) (identifier? #'input)
+ (syntax->datum #'input))
+ ;; prefixed array input specifier
+ ((_ (array input _ ...)) (identifier? #'input)
+ (syntax->datum #'input))
(_ #f))))
(and run-arg-input
(eq? run-arg-input input-id))))
@@ -342,12 +352,31 @@ input, return #f."
((prefix _) #'prefix)
(_ #f)))
+(define (run-arg-separator run-arg)
+ "Return the item separator specified in @var{run-arg} syntax."
+ (syntax-case run-arg (array)
+ ;; array input specifier
+ ((array _ args ...)
+ (apply (syntax-lambda** (#:key separator)
+ (if (and separator
+ (not (string? (syntax->datum separator))))
+ (raise-exception
+ (condition (ccwl-violation separator)
+ (formatted-message "Invalid #:separator parameter ~a. #:separator parameter must be a string."
+ (syntax->datum separator))))
+ separator))
+ #'(args ...)))
+ ;; prefixed array input specifier
+ ((_ (array input args ...))
+ (run-arg-separator #'(array input args ...)))
+ (_ #f)))
+
(define (run-args run defined-input-identifiers)
"Return a list of run arguments specified in @var{run}
syntax. @var{defined-input-identifiers} is the list of input
identifiers defined in the commands."
(define (syntax->run-arg x)
- (syntax-case x ()
+ (syntax-case x (array)
;; Replace input symbol with quoted symbol.
(input (identifier? #'input)
;; Ensure that specified input is defined in #:inputs of
@@ -363,6 +392,9 @@ identifiers defined in the commands."
;; Leave string as is.
(string-arg (string? (syntax->datum #'string-arg))
(list #'string-arg))
+ ;; Extract input symbol from array input specifier.
+ ((array input _ ...) (identifier? #'input)
+ (syntax->run-arg #'input))
;; Flatten prefixed string arguments. They have no
;; special meaning.
((prefix string-arg) (and (string? (syntax->datum #'prefix))
@@ -431,11 +463,14 @@ identifiers defined in the commands."
(position (run-arg-position id run))
(run-arg (and position
(list-ref run position))))
- #`(set-input-prefix
- (set-input-position #,(input input-spec)
- #,position)
+ #`(set-input-separator
+ (set-input-prefix
+ (set-input-position #,(input input-spec)
+ #,position)
+ #,(and run-arg
+ (run-arg-prefix run-arg)))
#,(and run-arg
- (run-arg-prefix run-arg)))))
+ (run-arg-separator run-arg)))))
inputs))
(list #,@(map output outputs))
(list #,@(run-args run (map input-spec-id inputs)))
diff --git a/ccwl/cwl.scm b/ccwl/cwl.scm
index 53e6548..b4a6025 100644
--- a/ccwl/cwl.scm
+++ b/ccwl/cwl.scm
@@ -142,7 +142,8 @@ CWL YAML specification."
;; no effect. So, leave this be.
(inputBinding . ,(filter-alist
`((position . ,(input-position input))
- (prefix . ,(input-prefix input)))))))
+ (prefix . ,(input-prefix input))
+ (itemSeparator . ,(input-separator input)))))))
'())
,@(input-other input)))