diff options
author | Arun Isaac | 2021-08-17 16:00:23 +0530 |
---|---|---|
committer | Arun Isaac | 2021-08-17 16:00:23 +0530 |
commit | 22977baf000ff18941eb78dcc300d115667e5ec8 (patch) | |
tree | 60c3847db226df694d9af77c91b11481d6acd589 /ccwl | |
parent | 99b11c99393e2d5e52347c456c4370f842c0fb49 (diff) | |
download | ccwl-22977baf000ff18941eb78dcc300d115667e5ec8.tar.gz ccwl-22977baf000ff18941eb78dcc300d115667e5ec8.tar.lz ccwl-22977baf000ff18941eb78dcc300d115667e5ec8.zip |
ccwl: Define output objects using a macro instead of a function.
This allows us to do sophisticated syntax checking at an early stage,
very close to the user interface. That way error messages from ccwl
will make a lot more sense.
* ccwl/ccwl.scm (output): Re-implement as macro.
(command): Use the new macro interface.
* doc/capture-output-file-with-parameter-reference.scm,
doc/capture-output-file.scm, doc/capture-stdout.scm, doc/checksum.scm,
doc/decompress-compile-run.scm: Use new quoting syntax for output
types.
Diffstat (limited to 'ccwl')
-rw-r--r-- | ccwl/ccwl.scm | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 48c2d50..f3ffffd 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -78,9 +78,15 @@ (source output-source set-output-source) (other output-other)) -(define* (output id #:key (type 'File) binding source (other '())) - "Build and return an <output> object." - (make-output id type binding source other)) +(define (output output-spec) + "Return syntax to build an <output> object from OUTPUT-SPEC." + (syntax-case output-spec () + ((id args ...) (identifier? #'id) + (apply (syntax-lambda** (id #:key (type #'File) binding source #:key* other) + #`(make-output '#,id '#,type #,binding #,source '#,other)) + #'(id args ...))) + (id (identifier? #'id) (output #'(id))) + (_ (error "Invalid output:" (syntax->datum output-spec))))) (define (filter-alist alist) "Filter ALIST removing entries with #f as the value. If the @@ -161,15 +167,7 @@ RUN-ARGS. If such an input is not present in RUN-ARGS, return #f." #,(run-arg-position id run)) #,(run-arg-prefix id run)))) inputs)) - (list #,@(map (lambda (x) - ;; Instantiate <output> object. - (syntax-case x () - ((id args ...) (identifier? #'id) - #'(output 'id args ...)) - (id (identifier? #'id) #'(output 'id)) - (_ (error "Invalid output:" - (syntax->datum x))))) - outputs)) + (list #,@(map output outputs)) (list #,@(map (lambda (x) (syntax-case x () ;; Replace input symbol with quoted symbol. |