aboutsummaryrefslogtreecommitdiff
path: root/src/guile
diff options
context:
space:
mode:
authorLudovic Court`es2007-03-08 18:15:01 +0000
committerLudovic Court`es2007-03-08 18:15:01 +0000
commit02d895fdff9949c2f97afc4d51fa79feb39aaf66 (patch)
tree32ddfbd6e0c99e402c5a0d549500a545cbe0e3dc /src/guile
parent051e3c9a56fbb4598d5a57e17efe6a23ea5235ea (diff)
parent5c472e01c77418125580627c5ee572c148b19079 (diff)
downloadskribilo-02d895fdff9949c2f97afc4d51fa79feb39aaf66.tar.gz
skribilo-02d895fdff9949c2f97afc4d51fa79feb39aaf66.tar.lz
skribilo-02d895fdff9949c2f97afc4d51fa79feb39aaf66.zip
evaluator: Modularized the evaluation process.
* src/guile/skribilo/evaluator.scm (evaluate-ast-from-port): New. Based on code formerly in `evaluate-document-from-port'. Pass `(current-module)' instead of `module' when invoking `%evaluate'. (evaluate-document-from-port): Use it. git-archimport-id: skribilo@sv.gnu.org--2006/skribilo--devo--1.2--patch-61
Diffstat (limited to 'src/guile')
-rw-r--r--src/guile/skribilo/evaluator.scm48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm
index 5067b59..0598c86 100644
--- a/src/guile/skribilo/evaluator.scm
+++ b/src/guile/skribilo/evaluator.scm
@@ -1,7 +1,7 @@
;;; eval.scm -- Skribilo evaluator.
;;;
-;;; Copyright 2003-2004 Erick Gallesio - I3S-CNRS/ESSI <eg@essi.fr>
-;;; Copyright 2005,2006 Ludovic Courtès <ludovic.courtes@laas.fr>
+;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@essi.fr>
+;;; Copyright 2005, 2006, 2007 Ludovic Courtès <ludovic.courtes@laas.fr>
;;;
;;;
;;; This program is free software; you can redistribute it and/or modify
@@ -21,7 +21,8 @@
(define-module (skribilo evaluator)
- :export (evaluate-document evaluate-document-from-port
+ :export (evaluate-ast-from-port
+ evaluate-document evaluate-document-from-port
load-document include-document *load-options*)
:autoload (skribilo parameters) (*verbose* *document-path*)
:autoload (skribilo location) (<location>)
@@ -73,7 +74,29 @@
result))
+;;;
+;;; EVALUATE-AST-FROM-PORT
+;;;
+(define* (evaluate-ast-from-port port :key (reader (*document-reader*))
+ (module (*skribilo-user-module*)))
+ ;; Evaluate code from PORT in MODULE, reading it with READER, and return an
+ ;; AST (resulting from the last form evaluated). The returned AST is
+ ;; unresolved and unverified.
+ (save-module-excursion
+ (lambda ()
+ (with-debug 10 'evaluate-ast-from-port
+
+ (set-current-module module)
+
+ (let loop ((exp (reader port))
+ (result #f))
+ (debug-item "exp=" exp)
+ (if (eof-object? exp)
+ result
+ (loop (reader port)
+ (%evaluate exp (current-module)))))))))
+
;;;
;;; EVALUATE-DOCUMENT
;;;
@@ -103,20 +126,9 @@
(debug-item "e=" e)
(if (not (engine? e))
(skribe-error 'evaluate-document-from-port "cannot find engine" engine)
- (save-module-excursion
- (lambda ()
- (with-debug 10 'evaluate-document-from-port
- (debug-item "exp=" exp))
- (set-current-module (*skribilo-user-module*))
-
- (let loop ((exp (reader port)))
- (if (eof-object? exp)
- (evaluate-document (%evaluate exp module)
- e :env env)
- (begin
- (evaluate-document (%evaluate exp module)
- e :env env)
- (loop (reader port)))))))))))
+ (let ((ast (evaluate-ast-from-port port :reader reader
+ :module module)))
+ (evaluate-document ast engine :env env))))))
@@ -186,7 +198,7 @@
;;;
(define* (include-document file :key (path (*document-path*))
(reader (*document-reader*))
- (module (*skribilo-user-module*)))
+ (module (current-module)))
(unless (every string? path)
(raise (condition (&invalid-argument-error (proc-name 'include-document)
(argument path)))))