From 559d3f64f4b051a39c91a3d53d3b41deee8ae42f Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Mon, 28 Nov 2005 14:23:48 +0000 Subject: Created a canonical module for Skribilo syntactic sugar. * src/guile/skribilo/utils/syntax.scm: New. Export `unless', `when', formerly defined in `lib.scm'. * src/guile/skribilo.scm: Use `(skribilo utils syntax)' and `%skribilo-module-reader'. Fixed parameterization of `*verbose*'. * src/guile/skribilo/ast.scm: Use `(skribilo utils syntax)' and `%skribilo-module-reader'. * src/guile/skribilo/biblio.scm: Likewise. * src/guile/skribilo/engine.scm: Likewise. * src/guile/skribilo/writer.scm: Likewise. * src/guile/skribilo/location.scm: Likewise. * src/guile/skribilo/lib.scm: Likewise. * src/guile/skribilo/source.scm: Likewise. * src/guile/skribilo/evaluator.scm: Likewise. Use `*document-path*' instead of `skribe-path'. * src/guile/skribilo/module.scm: Use `(system reader confinement)'. (%skribilo-user-imports): Moved some modules to... (%skribilo-user-autoloads): New. (define-skribe-module): Auto-load the modules specified in `%skribilo-user-autoloads'. Use `set-current-reader' instead of the `#:reader' option of `define-module'. * src/guile/skribilo/engine/lout.scm: Commented out a piece of text. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-13 --- src/guile/skribilo.scm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/guile/skribilo.scm') diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm index c4a5eac..92c5b35 100755 --- a/src/guile/skribilo.scm +++ b/src/guile/skribilo.scm @@ -39,9 +39,6 @@ exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@" ;;;; ;;;; Code: -;; Allow for this `:style' of keywords. -(read-set! keywords 'prefix) - (let ((gensym-orig gensym)) ;; In Skribe, `gensym' expects a symbol as its (optional) argument, while ;; Guile's `gensym' expect a string. XXX @@ -62,7 +59,11 @@ exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@" (define-module (skribilo) :autoload (skribilo module) (make-run-time-module) - :autoload (skribilo engine) (*current-engine*)) + :autoload (skribilo engine) (*current-engine*) + :use-module (skribilo utils syntax)) + +;; Install the Skribilo module syntax reader. +(set-current-reader %skribilo-module-reader) (use-modules (skribilo evaluator) (skribilo debug) @@ -405,7 +406,6 @@ Processes a Skribilo/Skribe source file and produces its output. (debug-enable 'debug) (debug-enable 'backtrace) (debug-enable 'procnames) - (read-enable 'positions) (cond (help-wanted (begin (skribilo-show-help) (exit 1))) (version-wanted (begin (skribilo-show-version) (exit 1)))) @@ -422,7 +422,10 @@ Processes a Skribilo/Skribe source file and produces its output. (parameterize ((*current-engine* engine) (*document-path* (cons load-path (*document-path*))) (*bib-path* (cons bib-path (*bib-path*))) - (*verbose* (option-ref options 'verbose #f))) + (*verbose* (let ((v (option-ref options + 'verbose 0))) + (if (number? v) v + (if v 1 0))))) ;; Load the user rc file ;;(load-rc) -- cgit v1.2.3 From 4686c3d129e4ebb3edc97e53a20a5f9db682f993 Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Mon, 28 Nov 2005 16:41:24 +0000 Subject: More `%skribilo-module-reader' fixes. * src/guile/skribilo.scm: Removed the executable bit. * configure.ac: Produce `src/guile/skribilo/utils/Makefile'. * src/guile/skribilo.scm: Call `set-current-reader' after the `use-modules' clause. (process-option-specs): Use `:kw'-style keywords. (*skribilo-output-port*): New. (doskribe): Use the above fluid. (main): Honor the `-o' option. * src/guile/skribilo/debug.scm: Use `(skribilo utils syntax)' and `%skribilo-module-reader'. * src/guile/skribilo/module.scm: Likewise. * src/guile/skribilo/output.scm: Likewise. * src/guile/skribilo/resolve.scm: Likewise. * src/guile/skribilo/verify.scm: Likewise. * src/guile/skribilo/parameters.scm (make-expect): New. (define-number-parameter): New. (define-list-parameter): New. * src/guile/skribilo/utils/Makefile.am (guilemoduledir): Fixed. * src/guile/skribilo/evaluator.scm (%evaluate): Commented out debugging statement. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-14 --- configure.ac | 1 + src/guile/skribilo.scm | 55 ++++++++++++++++++--------------- src/guile/skribilo/debug.scm | 27 +++++++++-------- src/guile/skribilo/evaluator.scm | 4 +-- src/guile/skribilo/module.scm | 24 +++++++++------ src/guile/skribilo/output.scm | 47 +++++++++++++++------------- src/guile/skribilo/parameters.scm | 33 ++++++++++++++++---- src/guile/skribilo/resolve.scm | 49 ++++++++++++++---------------- src/guile/skribilo/utils/Makefile.am | 2 +- src/guile/skribilo/verify.scm | 59 ++++++++++++++++++------------------ 10 files changed, 171 insertions(+), 130 deletions(-) mode change 100755 => 100644 src/guile/skribilo.scm (limited to 'src/guile/skribilo.scm') diff --git a/configure.ac b/configure.ac index 9bcf2d9..fb130d4 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_OUTPUT([Makefile src/guile/Makefile src/guile/skribilo/Makefile src/guile/skribilo/config.scm + src/guile/skribilo/utils/Makefile src/guile/skribilo/engine/Makefile src/guile/skribilo/reader/Makefile src/guile/skribilo/package/Makefile diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm old mode 100755 new mode 100644 index 92c5b35..de7dac2 --- a/src/guile/skribilo.scm +++ b/src/guile/skribilo.scm @@ -62,9 +62,6 @@ exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@" :autoload (skribilo engine) (*current-engine*) :use-module (skribilo utils syntax)) -;; Install the Skribilo module syntax reader. -(set-current-reader %skribilo-module-reader) - (use-modules (skribilo evaluator) (skribilo debug) (skribilo parameters) @@ -75,13 +72,18 @@ exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@" (ice-9 getopt-long)) +;; Install the Skribilo module syntax reader. +(set-current-reader %skribilo-module-reader) + +(if (not (keyword? :kw)) + (error "guile-reader sucks")) -(define* (process-option-specs longname #:key (alternate #f) - (arg #f) (help #f) - #:rest thunk) +(define* (process-option-specs longname + :key (alternate #f) (arg #f) (help #f) + :rest thunk) "Process STkLos-like option specifications and return getopt-long option specifications." `(,(string->symbol longname) @@ -181,6 +183,7 @@ specifications." (with-input-from-string expr (lambda () (eval (read)))))) + ; (define skribilo-options ; ;; Skribilo options in getopt-long's format, as computed by ; ;; `raw-options->getopt-long'. @@ -217,7 +220,7 @@ Processes a Skribilo/Skribe source file and produces its output. --help Give this help list --version Print program version -")) +~%")) (define (skribilo-show-version) (format #t "skribilo ~a~%" (skribilo-release))) @@ -371,15 +374,22 @@ Processes a Skribilo/Skribe source file and produces its output. ; *skribe-src*) ; (skribe-eval-port (current-input-port) *skribe-engine*)))) +(define *skribilo-output-port* (make-parameter (current-output-port))) + (define (doskribe) - (let ((user-module (current-module))) + (let ((output-port (current-output-port)) + (user-module (current-module))) (dynamic-wind (lambda () + ;; FIXME: Using this technique, anything written to `stderr' will + ;; also end up in the output file (e.g. Guile warnings). + (set-current-output-port (*skribilo-output-port*)) (set-current-module (make-run-time-module))) (lambda () - (format #t "engine is ~a~%" (*current-engine*)) + ;;(format #t "engine is ~a~%" (*current-engine*)) (skribe-eval-port (current-input-port) (*current-engine*))) (lambda () + (set-current-output-port output-port) (set-current-module user-module))))) @@ -393,6 +403,7 @@ Processes a Skribilo/Skribe source file and produces its output. skribilo-options)) (engine (string->symbol (option-ref options 'target "html"))) + (output-file (option-ref options 'output #f)) (debugging-level (option-ref options 'debug "0")) (load-path (option-ref options 'load-path ".")) (bib-path (option-ref options 'bib-path ".")) @@ -446,26 +457,22 @@ Processes a Skribilo/Skribe source file and produces its output. (error "you can specify at most one input file and one output file" files)) - (let* ((source-file (if (null? files) #f (car files))) - (dest-file (if (or (not source-file) - (null? (cdr files))) - #f - (cadr files))) - (do-it! (lambda () - (if (string? dest-file) - (with-output-to-file dest-file doskribe) - (doskribe))))) + (let* ((source-file (if (null? files) #f (car files)))) - (parameterize ((*destination-file* dest-file) - (*source-file* source-file)) + (if (and output-file (file-exists? output-file)) + (delete-file output-file)) - (if (and dest-file (file-exists? dest-file)) - (delete-file dest-file)) + (parameterize ((*destination-file* output-file) + (*source-file* source-file) + (*skribilo-output-port* + (if (string? output-file) + (open-output-file output-file) + (current-output-port)))) ;; (start-stack 7 (if source-file - (with-input-from-file source-file do-it!) - (do-it!)))))))) + (with-input-from-file source-file doskribe) + (doskribe)))))))) (define main skribilo) diff --git a/src/guile/skribilo/debug.scm b/src/guile/skribilo/debug.scm index cc0dfb2..953997e 100644 --- a/src/guile/skribilo/debug.scm +++ b/src/guile/skribilo/debug.scm @@ -1,8 +1,8 @@ +;;; debug.scm -- Debug facilities. ;;; -;;; debug.scm -- Debug Facilities (stolen to Manuel Serrano) +;;; Copyright 2003-2004 Erick Gallesio - I3S-CNRS/ESSI +;;; Copyright 2005 Ludovic Courtès ;;; -;;; -;;; Copyright © 2003-2004 Erick Gallesio - I3S-CNRS/ESSI ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or @@ -17,19 +17,20 @@ ;;; along with this program; if not, write to the Free Software ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ;;; USA. -;;; -;;; Author: Erick Gallesio [eg@essi.fr] -;;; Creation date: 10-Aug-2003 20:45 (eg) -;;; Last file update: 28-Oct-2004 13:16 (eg) -;;; (define-module (skribilo debug) - :export (with-debug %with-debug - debug-item skribe-debug set-skribe-debug! add-skribe-debug-symbol - no-debug-color) - :use-module (srfi srfi-17)) + :export (with-debug %with-debug + debug-item skribe-debug set-skribe-debug! add-skribe-debug-symbol + no-debug-color) + :use-module (skribilo utils syntax) + :use-module (srfi srfi-17)) +(set-current-reader %skribilo-module-reader) + + +;;; FIXME: Use SRFI-39 fluids. +;;; FIXME: Move this to `parameters.scm'? (define *skribe-debug* 0) (define *skribe-debug-symbols* '()) @@ -160,3 +161,5 @@ ; (debug-item 'foo4.2)) ; (debug-item 'foo3.3)) ; (debug-item 'foo2.4)) + +;;; debug.scm ends here diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm index 4c28b24..73f7db0 100644 --- a/src/guile/skribilo/evaluator.scm +++ b/src/guile/skribilo/evaluator.scm @@ -59,8 +59,8 @@ (let ((file (source-property expr 'filename)) (line (source-property expr 'line)) (column (source-property expr 'column))) - (format #t "~%~%*** source props for `~a': ~a~%~%" - result (source-properties expr)) +; (format #t "~%* source props for `~a': ~a~%" +; result (source-properties expr)) (slot-set! result 'loc (make :file file :line line :pos column)))) diff --git a/src/guile/skribilo/module.scm b/src/guile/skribilo/module.scm index 76d6717..2418a2c 100644 --- a/src/guile/skribilo/module.scm +++ b/src/guile/skribilo/module.scm @@ -23,7 +23,10 @@ :use-module (skribilo debug) :use-module (system reader confinement) ;; `set-current-reader' :use-module (srfi srfi-1) - :use-module (ice-9 optargs)) + :use-module (ice-9 optargs) + :use-module (skribilo utils syntax)) + +(set-current-reader %skribilo-module-reader) ;;; Author: Ludovic Courtès ;;; @@ -43,6 +46,7 @@ (srfi srfi-13) ;; strings (ice-9 optargs) ;; `define*' + (skribilo utils syntax) ;; `unless', `when', etc. (skribilo module) (skribilo compat) ;; `skribe-load-path', etc. (skribilo ast) ;; `', `document?', etc. @@ -73,14 +77,18 @@ '("utils" "api" "bib" "index" "param" "sui")) + +;; The very macro to turn a legacy Skribe file (which uses Skribe's syntax) +;; into a Guile module. + (define-macro (define-skribe-module name . options) `(begin (define-module ,name - #:use-module ((skribilo reader) #:select (%default-reader)) - #:use-module (system reader confinement) - #:use-module (srfi srfi-1) + :use-module ((skribilo reader) :select (%default-reader)) + :use-module (system reader confinement) + :use-module (srfi srfi-1) ,@(append-map (lambda (mod) - (list #:autoload (car mod) (cdr mod))) + (list :autoload (car mod) (cdr mod))) %skribilo-user-autoloads) ,@options) @@ -99,9 +107,7 @@ ;; Change the current reader to a Skribe-compatible reader. If this ;; primitive is not provided by Guile, it should be provided by the ;; `confinement' module (version 0.2 and later). - (set-current-reader %default-reader) - (format #t "module: ~a current-reader: ~a~%" - (current-module) (current-reader)))) + (set-current-reader %default-reader))) ;; Make it available to the top-level module. @@ -160,7 +166,7 @@ execution of Skribilo/Skribe code." (define-public (load-skribilo-file file reader-name) (load-file-with-read file (make-reader reader-name) (current-module))) -(define*-public (load-skribe-modules #:optional (debug? #f)) +(define*-public (load-skribe-modules :optional (debug? #f)) "Load the core Skribe modules, both in the @code{(skribilo skribe)} hierarchy and in @code{(run-time-module)}." (for-each (lambda (mod) diff --git a/src/guile/skribilo/output.scm b/src/guile/skribilo/output.scm index cbd4523..8110418 100644 --- a/src/guile/skribilo/output.scm +++ b/src/guile/skribilo/output.scm @@ -1,33 +1,38 @@ -;;;; output.scm -- Skribilo output stage. -;;;; -;;;; Copyright 2003-2004 Erick Gallesio - I3S-CNRS/ESSI -;;;; -;;;; -;;;; This program is free software; you can redistribute it and/or modify -;;;; it under the terms of the GNU General Public License as published by -;;;; the Free Software Foundation; either version 2 of the License, or -;;;; (at your option) any later version. -;;;; -;;;; This program is distributed in the hope that it will be useful, -;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;;; GNU General Public License for more details. -;;;; -;;;; You should have received a copy of the GNU General Public License -;;;; along with this program; if not, write to the Free Software -;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -;;;; USA. +;;; output.scm -- Skribilo output stage. +;;; +;;; Copyright 2003-2004 Erick Gallesio - I3S-CNRS/ESSI +;;; Copyright 2005 Ludovic Courtès +;;; +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +;;; USA. (define-module (skribilo output) :export (output) - :use-module (skribilo ast) - :use-module (skribilo writer) + :autoload (skribilo engine) (engine-ident) + :autoload (skribilo writer) (writer? writer-ident lookup-markup-writer) :use-module (skribilo lib) + :use-module (skribilo ast) :use-module (skribilo debug) + :use-module (skribilo utils syntax) :use-module (oop goops)) +(set-current-reader %skribilo-module-reader) + (define-generic out) (define (%out/writer n e w) diff --git a/src/guile/skribilo/parameters.scm b/src/guile/skribilo/parameters.scm index d8b259f..baab5ba 100644 --- a/src/guile/skribilo/parameters.scm +++ b/src/guile/skribilo/parameters.scm @@ -35,18 +35,39 @@ ;;; Switches. ;;; -(define-public *verbose* (make-parameter #f)) -(define-public *warning* (make-parameter 5)) +(define (make-expect pred pred-name parameter) + (let ((msg (string-append parameter ": " pred-name " expected"))) + (lambda (val) + (if (pred val) + val + (error msg val))))) + +(define-macro (define-number-parameter name) + `(define-public ,name + (make-parameter 0 + (make-expect number? "number" ,(symbol->string name))))) + +(define-number-parameter *verbose*) +(define-number-parameter *warning*) + (define-public *load-rc-file?* (make-parameter #f)) ;;; ;;; Paths. ;;; -(define-public *document-path* (make-parameter (list "."))) -(define-public *bib-path* (make-parameter (list "."))) -(define-public *source-path* (make-parameter (list "."))) -(define-public *image-path* (make-parameter (list "."))) + +(define-macro (define-path-parameter name) + `(define-public ,name + (make-parameter (list ".") + (make-expect list? "list" ,(symbol->string name))))) + + +(define-path-parameter *document-path*) +(define-path-parameter *bib-path*) +(define-path-parameter *source-path*) +(define-path-parameter *image-path*) + ;;; ;;; Files. diff --git a/src/guile/skribilo/resolve.scm b/src/guile/skribilo/resolve.scm index 7075f2d..cc1b14f 100644 --- a/src/guile/skribilo/resolve.scm +++ b/src/guile/skribilo/resolve.scm @@ -1,40 +1,37 @@ -;;;; -;;;; resolve.stk -- Skribe Resolve Stage -;;;; -;;;; Copyright © 2003-2004 Erick Gallesio - I3S-CNRS/ESSI -;;;; -;;;; -;;;; This program is free software; you can redistribute it and/or modify -;;;; it under the terms of the GNU General Public License as published by -;;;; the Free Software Foundation; either version 2 of the License, or -;;;; (at your option) any later version. -;;;; -;;;; This program is distributed in the hope that it will be useful, -;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;;; GNU General Public License for more details. -;;;; -;;;; You should have received a copy of the GNU General Public License -;;;; along with this program; if not, write to the Free Software -;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -;;;; USA. -;;;; -;;;; Author: Erick Gallesio [eg@essi.fr] -;;;; Creation date: 13-Aug-2003 18:39 (eg) -;;;; Last file update: 17-Feb-2004 14:43 (eg) -;;;; +;;; resolve.scm -- Skribilo reference resolution. +;;; +;;; Copyright 2003-2004 Erick Gallesio - I3S-CNRS/ESSI +;;; Copyright 2005 Ludovic Courtès +;;; +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +;;; USA. (define-module (skribilo resolve) :use-module (skribilo debug) :use-module (skribilo runtime) :use-module (skribilo ast) - :use-module (skribilo lib) ;; `unless' and `when' + :use-module (skribilo utils syntax) :use-module (oop goops) :export (resolve! resolve-search-parent resolve-children resolve-children* find1 resolve-counter resolve-parent resolve-ident)) +(set-current-reader %skribilo-module-reader) + (define *unresolved* #f) (define-generic do-resolve!) diff --git a/src/guile/skribilo/utils/Makefile.am b/src/guile/skribilo/utils/Makefile.am index e87696a..810ee48 100644 --- a/src/guile/skribilo/utils/Makefile.am +++ b/src/guile/skribilo/utils/Makefile.am @@ -1,4 +1,4 @@ -guilemoduledir = $(GUILE_SITE)/skribilo +guilemoduledir = $(GUILE_SITE)/skribilo/utils dist_guilemodule_DATA = syntax.scm ## arch-tag: 3a18b64b-1da2-417b-8338-2c534bca277f diff --git a/src/guile/skribilo/verify.scm b/src/guile/skribilo/verify.scm index aa2dd78..f407c87 100644 --- a/src/guile/skribilo/verify.scm +++ b/src/guile/skribilo/verify.scm @@ -1,42 +1,41 @@ -;;;; -;;;; verify.stk -- Skribe Verification Stage -;;;; -;;;; Copyright © 2003-2004 Erick Gallesio - I3S-CNRS/ESSI -;;;; -;;;; -;;;; This program is free software; you can redistribute it and/or modify -;;;; it under the terms of the GNU General Public License as published by -;;;; the Free Software Foundation; either version 2 of the License, or -;;;; (at your option) any later version. -;;;; -;;;; This program is distributed in the hope that it will be useful, -;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;;; GNU General Public License for more details. -;;;; -;;;; You should have received a copy of the GNU General Public License -;;;; along with this program; if not, write to the Free Software -;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, -;;;; USA. -;;;; -;;;; Author: Erick Gallesio [eg@essi.fr] -;;;; Creation date: 13-Aug-2003 11:57 (eg) -;;;; Last file update: 27-Oct-2004 16:35 (eg) -;;;; +;;; verify.scm -- Skribe AST verification. +;;; +;;; Copyright 2003-2004 Erick Gallesio - I3S-CNRS/ESSI +;;; Copyright 2005 Ludovic Courtès +;;; +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 2 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +;;; USA. (define-module (skribilo verify) - :export (verify)) + :autoload (skribilo engine) (engine-ident) + :autoload (skribilo writer) (writer? writer-options lookup-markup-writer) + :autoload (skribilo lib) (skribe-warning/ast skribe-warning + skribe-error) + :export (verify)) (use-modules (skribilo debug) - (skribilo engine) - (skribilo writer) (skribilo runtime) (skribilo ast) - (skribilo lib) ;; `when', `unless' + (skribilo utils syntax) (oop goops)) +(set-current-reader %skribilo-module-reader) + (define-generic verify) ;;; @@ -158,3 +157,5 @@ (slot-ref e 'customs)) node) + +;;; verify.scm ends here \ No newline at end of file -- cgit v1.2.3 From 3918fa2a728f00838ffda94ec6427b133c5abb68 Mon Sep 17 00:00:00 2001 From: Ludovic Court`es Date: Tue, 29 Nov 2005 13:32:30 +0000 Subject: Fixed `ref' and bibliography-related things. * src/guile/skribilo.scm (main): Handle `--warning'. * src/guile/skribilo/biblio.scm: Export `skribe-open-bib-file' and `parse-bib'. (parse-bib): Use `%default-reader'. * src/guile/skribilo/evaluator.scm (%evaluate): Cleaned up. (skribe-eval-port): Likewise. * src/guile/skribilo/module.scm (load-file-with-read): Removed. (load-skribilo-file): Removed. (load-skribilo-modules): Removed. * src/guile/skribilo/package/slide.scm (ref): Temporarily commented out. * src/guile/skribilo/skribe/bib.scm: Use `(skribilo biblio)'. git-archimport-id: lcourtes@laas.fr--2004-libre/skribilo--devel--1.2--patch-15 --- src/guile/skribilo.scm | 3 ++ src/guile/skribilo/biblio.scm | 41 +++++++++++--------- src/guile/skribilo/evaluator.scm | 10 ++--- src/guile/skribilo/module.scm | 34 ---------------- src/guile/skribilo/package/slide.scm | 75 +++++++++++++++++++++++------------- src/guile/skribilo/skribe/bib.scm | 3 +- 6 files changed, 79 insertions(+), 87 deletions(-) (limited to 'src/guile/skribilo.scm') diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm index de7dac2..a560b46 100644 --- a/src/guile/skribilo.scm +++ b/src/guile/skribilo.scm @@ -393,6 +393,7 @@ Processes a Skribilo/Skribe source file and produces its output. (set-current-module user-module))))) + ;;;; ====================================================================== ;;;; ;;;; M A I N @@ -405,6 +406,7 @@ Processes a Skribilo/Skribe source file and produces its output. (option-ref options 'target "html"))) (output-file (option-ref options 'output #f)) (debugging-level (option-ref options 'debug "0")) + (warning-level (option-ref options 'warning "2")) (load-path (option-ref options 'load-path ".")) (bib-path (option-ref options 'bib-path ".")) (preload '()) @@ -433,6 +435,7 @@ Processes a Skribilo/Skribe source file and produces its output. (parameterize ((*current-engine* engine) (*document-path* (cons load-path (*document-path*))) (*bib-path* (cons bib-path (*bib-path*))) + (*warning* (string->number warning-level)) (*verbose* (let ((v (option-ref options 'verbose 0))) (if (number? v) v diff --git a/src/guile/skribilo/biblio.scm b/src/guile/skribilo/biblio.scm index 045e3ae..cbb9202 100644 --- a/src/guile/skribilo/biblio.scm +++ b/src/guile/skribilo/biblio.scm @@ -25,10 +25,12 @@ :use-module (skribilo utils syntax) ;; `when', `unless' :use-module (skribilo module) :use-module (skribilo skribe bib) ;; `make-bib-entry' + :autoload (skribilo reader) (%default-reader) :autoload (skribilo parameters) (*bib-path*) :autoload (ice-9 format) (format) :export (bib-table? make-bib-table default-bib-table - bib-add!)) + bib-add! bib-duplicate + skribe-open-bib-file parse-bib)) (set-current-reader %skribilo-module-reader) @@ -92,24 +94,25 @@ ;;; ;;; ====================================================================== (define (parse-bib table port) - (if (not (bib-table? table)) - (skribe-error 'parse-bib "Illegal bibliography table" table) - (let ((from (port-file-name port))) - (let Loop ((entry (read port))) - (unless (eof-object? entry) - (cond - ((and (list? entry) (> (length entry) 2)) - (let* ((kind (car entry)) - (key (format #f "~A" (cadr entry))) - (fields (cddr entry)) - (old (hash-ref table key))) - (if old - (bib-duplicate ident from old) - (hash-set! table key - (make-bib-entry kind key fields from))) - (Loop (read port)))) - (else - (%bib-error 'bib-parse entry)))))))) + (let ((read %default-reader)) ;; FIXME: We should use a fluid + (if (not (bib-table? table)) + (skribe-error 'parse-bib "Illegal bibliography table" table) + (let ((from (port-filename port))) + (let Loop ((entry (read port))) + (unless (eof-object? entry) + (cond + ((and (list? entry) (> (length entry) 2)) + (let* ((kind (car entry)) + (key (format #f "~A" (cadr entry))) + (fields (cddr entry)) + (old (hash-ref table key))) + (if old + (bib-duplicate ident from old) + (hash-set! table key + (make-bib-entry kind key fields from))) + (Loop (read port)))) + (else + (%bib-error 'bib-parse entry))))))))) ;;; ====================================================================== diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm index 73f7db0..e4ef208 100644 --- a/src/guile/skribilo/evaluator.scm +++ b/src/guile/skribilo/evaluator.scm @@ -55,15 +55,15 @@ ;;; (define (%evaluate expr) (let ((result (eval expr (current-module)))) - (if (or (ast? result) (markup? result)) + + (if (ast? result) (let ((file (source-property expr 'filename)) (line (source-property expr 'line)) (column (source-property expr 'column))) -; (format #t "~%* source props for `~a': ~a~%" -; result (source-properties expr)) (slot-set! result 'loc (make :file file :line line :pos column)))) + result)) @@ -93,9 +93,7 @@ (let ((e (if (symbol? engine) (find-engine engine) engine))) (debug-item "e=" e) (if (not (engine? e)) - (begin - (format #t "engine: ~a~%" e) - (skribe-error 'skribe-eval-port "cannot find engine" engine)) + (skribe-error 'skribe-eval-port "cannot find engine" engine) (let loop ((exp (reader port))) (with-debug 10 'skribe-eval-port (debug-item "exp=" exp)) diff --git a/src/guile/skribilo/module.scm b/src/guile/skribilo/module.scm index 2418a2c..66f4940 100644 --- a/src/guile/skribilo/module.scm +++ b/src/guile/skribilo/module.scm @@ -146,38 +146,4 @@ execution of Skribilo/Skribe code." %skribilo-user-module) -;; FIXME: This will eventually be replaced by the per-module reader thing in -;; Guile. -(define-public (load-file-with-read file read module) - (with-debug 5 'load-file-with-read - (debug-item "loading " file) - - (with-input-from-file (search-path %load-path file) - (lambda () -; (format #t "load-file-with-read: ~a~%" read) - (let loop ((sexp (read)) - (result #f)) - (if (not (eof-object? sexp)) - (begin -; (format #t "preparing to evaluate `~a'~%" sexp) - (primitive-eval sexp) - (loop (read))))))))) - -(define-public (load-skribilo-file file reader-name) - (load-file-with-read file (make-reader reader-name) (current-module))) - -(define*-public (load-skribe-modules :optional (debug? #f)) - "Load the core Skribe modules, both in the @code{(skribilo skribe)} -hierarchy and in @code{(run-time-module)}." - (for-each (lambda (mod) - (format #t "~~ loading skribe module `~a'...~%" mod) - (load-skribilo-file (string-append "skribilo/skribe/" - mod ".scm") - 'skribe) - (module-use! (run-time-module) - (resolve-module `(skribilo skribe - ,(string->symbol mod))))) - %skribe-core-modules)) - - ;;; module.scm ends here diff --git a/src/guile/skribilo/package/slide.scm b/src/guile/skribilo/package/slide.scm index 37ee054..f5f0011 100644 --- a/src/guile/skribilo/package/slide.scm +++ b/src/guile/skribilo/package/slide.scm @@ -119,33 +119,52 @@ ;*---------------------------------------------------------------------*/ (define %slide-old-ref ref) -(define-markup (ref #!rest opt #!key (slide #f)) - (if (not slide) - (apply %slide-old-ref opt) - (new unresolved - (proc (lambda (n e env) - (cond - ((eq? slide 'next) - (let ((c (assq n %slide-the-slides))) - (if (pair? c) - (handle (cadr c)) - #f))) - ((eq? slide 'prev) - (let ((c (assq n (reverse %slide-the-slides)))) - (if (pair? c) - (handle (cadr c)) - #f))) - ((number? slide) - (let loop ((s %slide-the-slides)) - (cond - ((null? s) - #f) - ((= slide (markup-option (car s) :number)) - (handle (car s))) - (else - (loop (cdr s)))))) - (else - #f))))))) +;; Extend the definition of `ref'. +;; FIXME: This technique breaks `ref' for some reason. +; (set! ref +; (lambda args +; ;; Filter out ARGS and look for a `:slide' keyword argument. +; (let loop ((slide #f) +; (opt '()) +; (args args)) +; (if (null? args) +; (set! opt (reverse! opt)) +; (let ((s? (eq? (car args) :slide))) +; (loop (if s? (cadr args) #f) +; (if s? opt (cons (car args) opt)) +; (if s? (cddr args) (cdr args))))) + +; (format (current-error-port) +; "slide.scm:ref: slide=~a opt=~a~%" slide opt) + +; (if (not slide) +; (apply %slide-old-ref opt) +; (new unresolved +; (proc (lambda (n e env) +; (cond +; ((eq? slide 'next) +; (let ((c (assq n %slide-the-slides))) +; (if (pair? c) +; (handle (cadr c)) +; #f))) +; ((eq? slide 'prev) +; (let ((c (assq n (reverse %slide-the-slides)))) +; (if (pair? c) +; (handle (cadr c)) +; #f))) +; ((number? slide) +; (let loop ((s %slide-the-slides)) +; (cond +; ((null? s) +; #f) +; ((= slide (markup-option +; (car s) :number)) +; (handle (car s))) +; (else +; (loop (cdr s)))))) +; (else +; #f))))))))) + ;*---------------------------------------------------------------------*/ ;* slide-pause ... */ @@ -368,6 +387,8 @@ (define &latex-play #f) (define &latex-play* #f) +;;; FIXME: We shouldn't load `latex.scm' from here. Instead, we should +;;; register a hook on its load. (let ((le (find-engine 'latex))) ;; slide-vspace (markup-writer 'slide-vspace le diff --git a/src/guile/skribilo/skribe/bib.scm b/src/guile/skribilo/skribe/bib.scm index 0a80ec9..2bc2238 100644 --- a/src/guile/skribilo/skribe/bib.scm +++ b/src/guile/skribilo/skribe/bib.scm @@ -19,7 +19,8 @@ ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ;;; USA. -(define-skribe-module (skribilo skribe bib)) +(define-skribe-module (skribilo skribe bib) + :use-module (skribilo biblio)) ;;; Author: Manuel Serrano ;;; Commentary: -- cgit v1.2.3