aboutsummaryrefslogtreecommitdiff
path: root/src/guile/skribilo/evaluator.scm
diff options
context:
space:
mode:
Diffstat (limited to 'src/guile/skribilo/evaluator.scm')
-rw-r--r--src/guile/skribilo/evaluator.scm54
1 files changed, 37 insertions, 17 deletions
diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm
index 616144d..974d72a 100644
--- a/src/guile/skribilo/evaluator.scm
+++ b/src/guile/skribilo/evaluator.scm
@@ -39,8 +39,11 @@
(skribilo types)
(skribilo lib)
(skribilo vars)
+
(ice-9 optargs)
- (oop goops))
+ (oop goops)
+ (srfi srfi-13)
+ (srfi srfi-1))
@@ -49,6 +52,9 @@
(define *skribe-loaded* '()) ;; List of already loaded files
(define *skribe-load-options* '())
+;;;
+;;; %EVALUATE
+;;;
(define (%evaluate expr)
(let ((result (eval expr (current-module))))
(if (or (ast? result) (markup? result))
@@ -84,6 +90,8 @@
(reader %default-reader))
(with-debug 2 'skribe-eval-port
(debug-item "engine=" engine)
+ (debug-item "reader=" reader)
+
(let ((e (if (symbol? engine) (find-engine engine) engine)))
(debug-item "e=" e)
(if (not (is-a? e <engine>))
@@ -114,22 +122,31 @@
((engine? engine) engine)
((not (symbol? engine))
(skribe-error 'skribe-load
- "Illegal engine" engine))
+ "illegal engine" engine))
(else engine)))
- (path (cond
- ((not path) (skribe-path))
- ((string? path) (list path))
- ((not (and (list? path) (every? string? path)))
- (skribe-error 'skribe-load "Illegal path" path))
- (else path)))
- (filep (search-path path file)))
+ (path (append (cond
+ ((not path) (skribe-path))
+ ((string? path) (list path))
+ ((not (and (list? path) (every? string? path)))
+ (skribe-error 'skribe-load "illegal path" path))
+ (else path))
+ %load-path))
+ (filep (or (search-path path file)
+ (search-path (append path %load-path) file)
+ (search-path (append path %load-path)
+ (let ((dot (string-rindex file #\.)))
+ (if dot
+ (string-append
+ (string-take file dot)
+ ".scm")
+ file))))))
(set! *skribe-load-options* opt)
(unless (and (string? filep) (file-exists? filep))
(skribe-error 'skribe-load
(string-append "cannot find `" file "' in path")
- (skribe-path)))
+ path))
;; Load this file if not already done
(unless (member filep *skribe-loaded*)
@@ -149,22 +166,25 @@
;;;
(define* (skribe-include file #:optional (path (skribe-path)))
(unless (every string? path)
- (skribe-error 'skribe-include "Illegal path" path))
+ (skribe-error 'skribe-include "illegal path" path))
(let ((path (search-path path file)))
(unless (and (string? path) (file-exists? path))
(skribe-error 'skribe-load
- (format "Cannot find ~S in path" file)
+ (format #t "cannot find ~S in path" file)
path))
(when (> *skribe-verbose* 0)
(format (current-error-port) " [including file: ~S]\n" path))
(with-input-from-file path
(lambda ()
- (let Loop ((exp (read (current-input-port)))
+ (let Loop ((exp (%default-reader (current-input-port)))
(res '()))
+ (format (current-error-port) "exp=~a~%" exp)
(if (eof-object? exp)
- (if (and (pair? res) (null? (cdr res)))
- (car res)
- (reverse! res))
- (Loop (read (current-input-port))
+ (begin
+ (format (current-error-port) "include: eof reached~%")
+ (if (and (pair? res) (null? (cdr res)))
+ (car res)
+ (reverse! res)))
+ (Loop (%default-reader (current-input-port))
(cons (%evaluate exp) res))))))))