diff options
Diffstat (limited to 'src')
-rw-r--r--[-rwxr-xr-x] | src/guile/skribilo.scm | 55 | ||||
-rw-r--r-- | src/guile/skribilo/debug.scm | 27 | ||||
-rw-r--r-- | src/guile/skribilo/evaluator.scm | 4 | ||||
-rw-r--r-- | src/guile/skribilo/module.scm | 24 | ||||
-rw-r--r-- | src/guile/skribilo/output.scm | 47 | ||||
-rw-r--r-- | src/guile/skribilo/parameters.scm | 33 | ||||
-rw-r--r-- | src/guile/skribilo/resolve.scm | 49 | ||||
-rw-r--r-- | src/guile/skribilo/utils/Makefile.am | 2 | ||||
-rw-r--r-- | src/guile/skribilo/verify.scm | 59 |
9 files changed, 170 insertions, 130 deletions
diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm index 92c5b35..de7dac2 100755..100644 --- 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 <eg@unice.fr> +;;; Copyright 2005 Ludovic Courtès <ludovic.courtes@laas.fr> ;;; -;;; -;;; Copyright © 2003-2004 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr> ;;; 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 <location> :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>', `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 <eg@unice.fr> -;;;; -;;;; -;;;; 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 <eg@unice.fr> +;;; Copyright 2005 Ludovic Courtès <ludovic.courtes@laas.fr> +;;; +;;; +;;; 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 <eg@unice.fr> -;;;; -;;;; -;;;; 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 <eg@unice.fr> +;;; Copyright 2005 Ludovic Courtès <ludovic.courtes@laas.fr> +;;; +;;; +;;; 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 <eg@unice.fr> -;;;; -;;;; -;;;; 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 <eg@unice.fr> +;;; Copyright 2005 Ludovic Courtès <ludovic.courtes@laas.fr> +;;; +;;; +;;; 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 |