From f218e5e444b9d4046a7e6adce487a14ab40248ac Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 25 Jun 2026 15:14:25 +0100 Subject: scripts: Spin off loader into ccwl-load in (ccwl lang). --- ccwl/lang.scm | 14 +++++++++++++- scripts/ccwl | 13 ++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/ccwl/lang.scm b/ccwl/lang.scm index 22eb9a7..c9ebae3 100644 --- a/ccwl/lang.scm +++ b/ccwl/lang.scm @@ -17,12 +17,15 @@ ;;; along with ccwl. If not, see . (define-module (ccwl lang) + #:declarative? #f #:use-module (rnrs conditions) #:use-module (rnrs exceptions) #:use-module (srfi srfi-1) #:use-module (ice-9 textual-ports) #:use-module (ccwl conditions) - #:export (ccwl-read)) + #:use-module (ccwl utils) + #:export (ccwl-read + ccwl-load)) (define (syntax-list->vector x) "Convert syntax @var{x} of a list into syntax of a vector." @@ -62,3 +65,12 @@ it." (condition-message c) (condition-irritants c))))) (read-syntax port))) + +(define (ccwl-load file) + "Load ccwl source @var{file}." + (let ((source-path (canonicalize-path file))) + ;; 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))))) diff --git a/scripts/ccwl b/scripts/ccwl index 6438e34..b2678ca 100755 --- a/scripts/ccwl +++ b/scripts/ccwl @@ -37,8 +37,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@" (ccwl cwl) (ccwl graphviz) (ccwl lang) - (ccwl ui) - (ccwl utils)) + (ccwl ui)) (define (invalid-option opt name arg result) (error "Invalid option" name)) @@ -91,15 +90,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@" (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)))))))) + (cut ccwl-load source)))) (unless (%compile-error) (if (or (command? result) (js-expression? result) -- cgit 1.4.1