diff options
| author | Arun Isaac | 2026-06-24 04:16:10 +0100 |
|---|---|---|
| committer | Arun Isaac | 2026-06-24 04:16:10 +0100 |
| commit | ff47e2dadee1aa864220f965e5c1a2c4b6972f28 (patch) | |
| tree | c74cf916b34f32a136233df1eea1532fa21a0c44 /scripts | |
| parent | bcacf8f76fb06129f2bbc760baf38fa5e2e814fc (diff) | |
| download | ccwl-ff47e2dadee1aa864220f965e5c1a2c4b6972f28.tar.gz ccwl-ff47e2dadee1aa864220f965e5c1a2c4b6972f28.tar.lz ccwl-ff47e2dadee1aa864220f965e5c1a2c4b6972f28.zip | |
scripts: Report all errors in source file, not just the first.
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/ccwl | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/scripts/ccwl b/scripts/ccwl index 0097108..bee3bef 100755 --- a/scripts/ccwl +++ b/scripts/ccwl @@ -108,6 +108,9 @@ it." (read-hash-extend #\( read-hash-vector) +(define %compile-error + (make-parameter #f)) + (define (ccwl-compile source to port) "Compile @var{source} file to @var{to} format writing output to @var{port}. @var{to} is either @code{'cwl} or @code{'dot}." @@ -119,31 +122,36 @@ it." (raise-exception (formatted-message "File ~a does not exist" source))) - ((case to - ((cwl) function->cwl) - ((dot) function->dot)) - (let ((result (guard (exception - ;; Handle syntax violation exceptions by - ;; reporting them and exiting. - ((ccwl-violation? exception) - (report-ccwl-violation exception) - (exit #f))) - (let ((source-path (canonicalize-path source))) - ;; Change directory before loading source file. - ;; The source file may reference other files with - ;; paths relative to its directory. - (call-with-current-directory (dirname source-path) - (lambda () - (load source-path - ccwl-read))))))) - (if (or (command? result) - (js-expression? result) - (workflow? result)) - result - (raise-exception - (formatted-message "Last expression in file ~a returns none of workflow, command or js-expression" - source)))) - port)) + (parameterize ((%compile-error #f)) + (let ((result + (with-exception-handler (lambda (c) + (if (ccwl-violation? c) + ;; Report syntax violations, + ;; and set the error state. + (begin + (report-ccwl-violation c) + (%compile-error #t)) + (raise-exception c))) + (lambda () + (let ((source-path (canonicalize-path source))) + ;; Change directory before loading source file. The + ;; source file may reference other files with paths + ;; relative to its directory. + (call-with-current-directory (dirname source-path) + (lambda () + (load source-path + ccwl-read)))))))) + (unless (%compile-error) + (if (or (command? result) + (js-expression? result) + (workflow? result)) + ((case to + ((cwl) function->cwl) + ((dot) function->dot)) + result port) + (raise-exception + (formatted-message "Last expression in file ~a returns none of workflow, command or js-expression" + source))))))) (define (main args) (with-exception-handler |
