aboutsummaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2023-10-16 17:27:50 +0100
committerArun Isaac2023-10-16 17:27:50 +0100
commit7cc6abe4b5d1af4a05a58705279f6172cf270825 (patch)
tree4bd59a97fa98788ffbd16c5d3acba561d845d532 /ccwl
parent985f892b58a6f8b18f498d62d0ed6d4e6860b985 (diff)
downloadccwl-7cc6abe4b5d1af4a05a58705279f6172cf270825.tar.gz
ccwl-7cc6abe4b5d1af4a05a58705279f6172cf270825.tar.lz
ccwl-7cc6abe4b5d1af4a05a58705279f6172cf270825.zip
ccwl: Flatten prefixed string arguments in command definitions.
* ccwl/ccwl.scm (run-args): Flatten prefixed string arguments in command definitions. * tests/ccwl.scm ("tolerate prefixed string arguments in command definitions"): New test.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/ccwl.scm49
1 files changed, 27 insertions, 22 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index 1b1d8fe..a476406 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -286,28 +286,33 @@ identifiers defined in the commands."
(condition (ccwl-violation input)
(formatted-message "Undefined input ~a"
(syntax->datum input))))))))
- (map (lambda (x)
- (syntax-case x ()
- ;; Replace input symbol with quoted symbol.
- (input (identifier? #'input)
- (begin
- (ensure-input-is-defined #'input)
- #''input))
- ;; Leave string as is.
- (string-arg (string? (syntax->datum #'string-arg))
- #'string-arg)
- ;; Replace prefixed input symbol with quoted symbol.
- ((prefix input) (and (string? (syntax->datum #'prefix))
- (identifier? #'input))
- (begin
- (ensure-input-is-defined #'input)
- #''input))
- (_
- (raise-exception
- (condition (ccwl-violation x)
- (formatted-message "Invalid command element ~a. Command elements must either be input identifiers or literal strings."
- (syntax->datum x)))))))
- run)))
+ (append-map (lambda (x)
+ (syntax-case x ()
+ ;; Replace input symbol with quoted symbol.
+ (input (identifier? #'input)
+ (begin
+ (ensure-input-is-defined #'input)
+ (list #''input)))
+ ;; Leave string as is.
+ (string-arg (string? (syntax->datum #'string-arg))
+ (list #'string-arg))
+ ;; Replace prefixed input symbol with quoted symbol.
+ ((prefix input) (and (string? (syntax->datum #'prefix))
+ (identifier? #'input))
+ (begin
+ (ensure-input-is-defined #'input)
+ (list #''input)))
+ ;; Flatten prefixed string arguments. They have no
+ ;; special meaning.
+ ((prefix string-arg) (and (string? (syntax->datum #'prefix))
+ (string? (syntax->datum #'string-arg)))
+ (list #'prefix #'string-arg))
+ (_
+ (raise-exception
+ (condition (ccwl-violation x)
+ (formatted-message "Invalid command element ~a. Command elements must either be input identifiers or literal strings."
+ (syntax->datum x)))))))
+ run)))
;; TODO: Add fine-grained syntax checking.
(define-syntax command