From efea4dc93f2565555e47de0bfd027614a9c8674d Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Fri, 1 Jul 2005 23:55:56 +0000 Subject: Lots of changes, again. Lots of changes, notably the following: * skr/*.skr: Moved engines to `src/guile/skribilo/engine'. * src/guile/skribilo/engine.scm (lookup-engine): Rewritten. Don't use the auto-load alist. * src/guile/skribilo/evaluator.scm: New name of the `eval' module. `eval' couldn't be used as the module base-name because of Guile's recursive module name space. git-archimport-id: lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2--patch-2 --- src/guile/skribilo.scm | 177 +++++++++++++++++++++++++++---------------------- 1 file changed, 99 insertions(+), 78 deletions(-) (limited to 'src/guile/skribilo.scm') diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm index c352f7f..ae21fab 100755 --- a/src/guile/skribilo.scm +++ b/src/guile/skribilo.scm @@ -1,7 +1,7 @@ #!/bin/sh # aside from this initial boilerplate, this is actually -*- scheme -*- code main='(module-ref (resolve-module '\''(skribilo)) '\'main')' -exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" +exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@" !# ;;;; @@ -42,17 +42,11 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" ;; Allow for this `:style' of keywords. (read-set! keywords 'prefix) -;; Allow for DSSSL-style keywords (i.e. `#!key', etc.). -;; See http://lists.gnu.org/archive/html/guile-devel/2005-06/msg00060.html -;; for details. -(read-hash-extend #\! (lambda (chr port) - (symbol->keyword (read port)))) - (let ((gensym-orig gensym)) ;; In Skribe, `gensym' expects a symbol as its (optional) argument, while ;; Guile's `gensym' expect a string. XXX (set! gensym - (lambda (. args) + (lambda args (if (null? args) (gensym-orig) (let ((the-arg (car args))) @@ -64,45 +58,29 @@ exec ${GUILE-guile} -l $0 -c "(apply $main (cdr (command-line)))" "$@" (skribe-error 'gensym "Invalid argument type" the-arg)))))))) -; (use-modules (skribe eval) -; (skribe configure) -; (skribe runtime) -; (skribe engine) -; (skribe writer) -; (skribe verify) -; (skribe output) -; (skribe biblio) -; (skribe prog) -; (skribe resolve) -; (skribe source) -; (skribe lisp) -; (skribe xml) -; (skribe c) -; (skribe debug) -; (skribe color)) - -(use-modules (skribe runtime) - (skribe configure) - (skribe eval) - (skribe engine) - (skribe types) ;; because `new' is a macro and refers to classes - - (oop goops) ;; because `new' is a macro - (ice-9 optargs) - (ice-9 getopt-long)) +(set! %load-hook + (lambda (file) + (format #t "~~ loading `~a'...~%" file))) + +(define-module (skribilo)) -(load "skribe/lib.scm") +(use-modules (skribilo module) + (skribilo runtime) + (skribilo evaluator) + (skribilo types) + (skribilo engine) + (skribilo debug) + (skribilo vars) + (skribilo lib) -(load "../common/configure.scm") -(load "../common/param.scm") -(load "../common/lib.scm") -(load "../common/sui.scm") -(load "../common/index.scm") + (ice-9 optargs) + (ice-9 getopt-long)) -;; Markup definitions... -(load "../common/api.scm") + + +;;; FIXME: With my `#:reader' thing added to `define-module', @@ -115,7 +93,7 @@ specifications." ,@(if alternate `((single-char ,(string-ref alternate 0))) '()) - (value #f))) + (value ,(if arg #t #f)))) (define (raw-options->getopt-long options) "Converts @var{options} to a getopt-long-compatible representation." @@ -130,9 +108,9 @@ specifications." (("target" :alternate "t" :arg target :help "sets the output format to ") (set! engine (string->symbol target))) - (("I" :arg path :help "adds to Skribe path") + (("load-path" :alternate "I" :arg path :help "adds to Skribe path") (set! paths (cons path paths))) - (("B" :arg path :help "adds to bibliography path") + (("bib-path" :alternate "B" :arg path :help "adds to bibliography path") (skribe-bib-path-set! (cons path (skribe-bib-path)))) (("S" :arg path :help "adds to source path") (skribe-source-path-set! (cons path (skribe-source-path)))) @@ -247,7 +225,7 @@ Processes a Skribilo/Skribe source file and produces its output. ")) (define (skribilo-show-version) - (format #t "skribilo ~a~%" (skribe-release))) + (format #t "skribilo ~a~%" (skribilo-release))) ;;;; ====================================================================== ;;;; @@ -387,16 +365,20 @@ Processes a Skribilo/Skribe source file and produces its output. ;;;; S K R I B E ;;;; ;;;; ====================================================================== +; (define (doskribe) +; (let ((e (find-engine *skribe-engine*))) +; (if (and (engine? e) (pair? *skribe-precustom*)) +; (for-each (lambda (cv) +; (engine-custom-set! e (car cv) (cdr cv))) +; *skribe-precustom*)) +; (if (pair? *skribe-src*) +; (for-each (lambda (f) (skribe-load f :engine *skribe-engine*)) +; *skribe-src*) +; (skribe-eval-port (current-input-port) *skribe-engine*)))) + (define (doskribe) - (let ((e (find-engine *skribe-engine*))) - (if (and (engine? e) (pair? *skribe-precustom*)) - (for-each (lambda (cv) - (engine-custom-set! e (car cv) (cdr cv))) - *skribe-precustom*)) - (if (pair? *skribe-src*) - (for-each (lambda (f) (skribe-load f :engine *skribe-engine*)) - *skribe-src*) - (skribe-eval-port (current-input-port) *skribe-engine*)))) + (set-current-module (make-run-time-module)) + (skribe-eval-port (current-input-port) *skribe-engine*)) ;;;; ====================================================================== @@ -404,42 +386,81 @@ Processes a Skribilo/Skribe source file and produces its output. ;;;; M A I N ;;;; ;;;; ====================================================================== -(define (skribilo . args) - (let* ((options (getopt-long (cons "skribilo" args) skribilo-options)) - (target (option-ref options 'target #f)) +(define-public (skribilo . args) + (let* ((options (getopt-long (cons "skribilo" args) + skribilo-options)) + (engine (string->symbol + (option-ref options 'target "html"))) + (debugging-level (option-ref options 'debug 0)) + (load-path (option-ref options 'load-path ".")) + (bib-path (option-ref options 'bib-path ".")) + (preload '()) + (variants '()) + (help-wanted (option-ref options 'help #f)) (version-wanted (option-ref options 'version #f))) + ;; Set up the debugging infrastructure. + (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))) - (target (format #t "target set to `~a'~%" target))) + (version-wanted (begin (skribilo-show-version) (exit 1)))) + + ;; Parse the most important options. + + (set! *skribe-engine* engine) + + (set-skribe-debug! (string->number debugging-level)) + + (set! %skribilo-load-path + (cons load-path %skribilo-load-path)) + (set! %skribilo-bib-path + (cons bib-path %skribilo-bib-path)) + + (if (option-ref options 'verbose #f) + (set! *skribe-verbose* #t)) ;; Load the user rc file - (load-rc) + ;(load-rc) + + ;; load the basic Skribe modules + (load-skribe-modules) ;; Load the base file to bootstrap the system as well as the files - ;; that are in the *skribe-preload* variable - (skribe-load "base.skr" :engine 'base) + ;; that are in the PRELOAD variable. + (find-engine 'base) (for-each (lambda (f) (skribe-load f :engine *skribe-engine*)) - *skribe-preload*) + preload) - ;; Load the specified variants + ;; Load the specified variants. (for-each (lambda (x) (skribe-load (format #f "~a.skr" x) :engine *skribe-engine*)) - (reverse! *skribe-variants*)) - - ;; (if (string? *skribe-dest*) - ;; (with-handler (lambda (kind loc msg) - ;; (remove-file *skribe-dest*) - ;; (error loc msg)) - ;; (with-output-to-file *skribe-dest* doskribe)) - ;; (doskribe)) - (if (string? *skribe-dest*) - (with-output-to-file *skribe-dest* doskribe) - (doskribe)))) - -(display "skribilo loaded\n") + (reverse! variants)) + + (let ((files (option-ref options '() '()))) + (if (null? files) + (error "you must specify at least the input file" files)) + (if (> (length files) 2) + (error "you can specify at most one input file and one output file" + files)) + + (let* ((source-file (car files)) + (dest-file (if (null? (cdr files)) #f (cadr files))) + (source-port (open-input-file source-file))) + + (if (and dest-file (file-exists? dest-file)) + (delete-file dest-file)) + + (with-input-from-file source-file + (lambda () + (if (string? dest-file) + (with-output-to-file dest-file doskribe) + (doskribe)))))))) + (define main skribilo) -- cgit v1.2.3 From 2d740bec3cc50480980d8aae3a06e27a5f0649e5 Mon Sep 17 00:00:00 2001 From: Ludovic Courtes Date: Sat, 2 Jul 2005 02:04:46 +0000 Subject: Started relying on the per-module reader; first doc produced ever! First document compiled by Skribilo to HTML! * src/guile/skribilo/module.scm (define-skribe-module): Use the `#:reader' option of `define-module' (not yet integrated in Guile 1.7). Plus lots of other things... git-archimport-id: lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2--patch-3 --- src/guile/README | 4 +- src/guile/skribilo.scm | 36 +++++++------ src/guile/skribilo/biblio.scm | 11 ++-- src/guile/skribilo/engine/html.scm | 7 ++- src/guile/skribilo/evaluator.scm | 47 ---------------- src/guile/skribilo/lib.scm | 10 +++- src/guile/skribilo/module.scm | 105 ++++++++++++++++++++++-------------- src/guile/skribilo/output.scm | 7 +-- src/guile/skribilo/resolve.scm | 24 ++++----- src/guile/skribilo/runtime.scm | 102 ++++++++++++++++++----------------- src/guile/skribilo/skribe/api.scm | 1 + src/guile/skribilo/skribe/bib.scm | 1 - src/guile/skribilo/skribe/utils.scm | 3 +- src/guile/skribilo/source.scm | 18 +++---- src/guile/skribilo/types.scm | 6 ++- src/guile/skribilo/vars.scm | 8 ++- src/guile/skribilo/verify.scm | 31 ++++++----- src/guile/skribilo/writer.scm | 2 +- 18 files changed, 216 insertions(+), 207 deletions(-) (limited to 'src/guile/skribilo.scm') diff --git a/src/guile/README b/src/guile/README index 1b9a6c4..4bd7eff 100644 --- a/src/guile/README +++ b/src/guile/README @@ -1,4 +1,4 @@ -Skribilo +Skribilo -*- Outline -*- ======== Skribilo is a port of Skribe to GNU Guile. @@ -11,6 +11,8 @@ Here are a few goals. ** Better error handling, automatic back-traces, etc. +** Add an option to continuously watch a file and re-compile it + * Font-ends (readers) ** Implement a new front-end mechanism (see `(skribilo reader)') diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm index ae21fab..a43ec66 100755 --- a/src/guile/skribilo.scm +++ b/src/guile/skribilo.scm @@ -59,10 +59,6 @@ exec ${GUILE-guile} --debug -l $0 -c "(apply $main (cdr (command-line)))" "$@" the-arg)))))))) -(set! %load-hook - (lambda (file) - (format #t "~~ loading `~a'...~%" file))) - (define-module (skribilo)) @@ -415,6 +411,11 @@ Processes a Skribilo/Skribe source file and produces its output. (set-skribe-debug! (string->number debugging-level)) + (if (> (skribe-debug) 4) + (set! %load-hook + (lambda (file) + (format #t "~~ loading `~a'...~%" file)))) + (set! %skribilo-load-path (cons load-path %skribilo-load-path)) (set! %skribilo-bib-path @@ -426,9 +427,6 @@ Processes a Skribilo/Skribe source file and produces its output. ;; Load the user rc file ;(load-rc) - ;; load the basic Skribe modules - (load-skribe-modules) - ;; Load the base file to bootstrap the system as well as the files ;; that are in the PRELOAD variable. (find-engine 'base) @@ -442,24 +440,28 @@ Processes a Skribilo/Skribe source file and produces its output. (reverse! variants)) (let ((files (option-ref options '() '()))) - (if (null? files) - (error "you must specify at least the input file" files)) + (if (> (length files) 2) (error "you can specify at most one input file and one output file" files)) - (let* ((source-file (car files)) - (dest-file (if (null? (cdr files)) #f (cadr files))) - (source-port (open-input-file source-file))) + (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))))) (if (and dest-file (file-exists? dest-file)) (delete-file dest-file)) - (with-input-from-file source-file - (lambda () - (if (string? dest-file) - (with-output-to-file dest-file doskribe) - (doskribe)))))))) + (if source-file + (with-input-from-file source-file + do-it!) + (do-it!)))))) (define main skribilo) diff --git a/src/guile/skribilo/biblio.scm b/src/guile/skribilo/biblio.scm index d4a644e..f3ddf97 100644 --- a/src/guile/skribilo/biblio.scm +++ b/src/guile/skribilo/biblio.scm @@ -27,10 +27,11 @@ (define-module (skribilo biblio) - :use-module (skribilo runtime) - :export (bib-tables? make-bib-table default-bib-table - bib-load! resolve-bib resolve-the-bib - bib-sort/authors bib-sort/idents bib-sort/dates)) + :use-module (skribilo runtime) + :use-module (skribilo lib) ;; `when', `unless' + :use-module (skribilo vars) + :export (bib-table? make-bib-table default-bib-table + bib-add!)) (define *bib-table* #f) @@ -50,7 +51,7 @@ (make-hash-table)) (define (bib-table? obj) - (hashtable? obj)) + (hash-table? obj)) (define (default-bib-table) (unless *bib-table* diff --git a/src/guile/skribilo/engine/html.scm b/src/guile/skribilo/engine/html.scm index a20ea68..c85f18f 100644 --- a/src/guile/skribilo/engine/html.scm +++ b/src/guile/skribilo/engine/html.scm @@ -16,7 +16,8 @@ ;* @ref ../../doc/user/htmle.skb:ref@ */ ;*=====================================================================*/ -(define-skribe-module (skribilo engine html)) +(define-skribe-module (skribilo engine html) + #:use-module ((srfi srfi-19) :renamer (symbol-prefix-proc 's19:))) ;; Keep a reference to the base engine. @@ -843,7 +844,9 @@ :url (skribilo-url)) "." (linebreak) - "Last update: " (date))))) + "Last update: " + (s19:date->string + (s19:current-date)))))) e)))) :after "\n") diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm index b7e04c1..703186c 100644 --- a/src/guile/skribilo/evaluator.scm +++ b/src/guile/skribilo/evaluator.scm @@ -43,53 +43,6 @@ (oop goops)) - -;;; FIXME: The following page must eventually go to `module.scm'. - -(define *skribilo-user-module* #f) - -(define *skribilo-user-imports* - '((srfi srfi-1) - (srfi srfi-13) - (oop goops) - (skribilo module) - (skribilo config) - (skribilo vars) - (skribilo runtime) - (skribilo biblio) - (skribilo lib) - (skribilo resolve) - (skribilo engine) - (skribilo writer))) - -(define *skribe-core-modules* ;;; FIXME: From `module.scm'. - '("utils" "api" "bib" "index" "param" "sui")) - -;;; -;;; MAKE-RUN-TIME-MODULE -;;; -(define-public (make-run-time-module) - "Return a new module that imports all the necessary bindings required for -execution of Skribilo/Skribe code." - (let ((the-module (make-module))) - (for-each (lambda (iface) - (module-use! the-module (resolve-module iface))) - (append *skribilo-user-imports* - (map (lambda (mod) - `(skribilo skribe - ,(string->symbol mod))) - *skribe-core-modules*))) - (set-module-name! the-module '(skribilo-user)) - the-module)) - -;;; -;;; RUN-TIME-MODULE -;;; -(define-public (run-time-module) - "Return the default instance of a Skribilo/Skribe run-time module." - (if (not *skribilo-user-module*) - (set! *skribilo-user-module* (make-run-time-module))) - *skribilo-user-module*) diff --git a/src/guile/skribilo/lib.scm b/src/guile/skribilo/lib.scm index bb41597..ef8ef8d 100644 --- a/src/guile/skribilo/lib.scm +++ b/src/guile/skribilo/lib.scm @@ -58,6 +58,7 @@ hashtable-get hashtable-put! hashtable-update! hashtable->list + skribe-read find-runtime-type) :export-syntax (new define-markup define-simple-markup @@ -68,6 +69,8 @@ :use-module (skribilo config) :use-module (skribilo types) + :use-module (skribilo reader) + :use-module (skribilo vars) :use-module (srfi srfi-1) :use-module (ice-9 optargs)) @@ -105,7 +108,7 @@ (let ((name (car bindings)) (opts (cdr bindings))) - `(define* ,(cons name (fix-rest-arg opts)) ,@body))) + `(define*-public ,(cons name (fix-rest-arg opts)) ,@body))) ;;; @@ -352,6 +355,11 @@ ;;; Various things. ;;; +(define %skribe-reader (make-reader 'skribe)) + +(define* (skribe-read #:optional (port (current-input-port))) + (%skribe-reader port)) + (define (%procedure-arity proc) (car (procedure-property proc 'arity))) diff --git a/src/guile/skribilo/module.scm b/src/guile/skribilo/module.scm index 50c7b23..854c50d 100644 --- a/src/guile/skribilo/module.scm +++ b/src/guile/skribilo/module.scm @@ -22,6 +22,7 @@ :use-module (skribilo reader) :use-module (skribilo evaluator) :use-module (skribilo debug) + :use-module (srfi srfi-1) :use-module (ice-9 optargs)) ;;; Author: Ludovic Courtès @@ -36,47 +37,47 @@ ;;; ;;; Code: -(define-macro (define-skribe-module name) +(define *skribilo-user-imports* + ;; List of modules that should be imported by any good Skribilo module. + '((srfi srfi-1) ;; lists + (srfi srfi-13) ;; strings + ;(srfi srfi-19) ;; date and time + (oop goops) ;; `make' + (ice-9 optargs) ;; `define*' + + (skribilo module) + (skribilo types) ;; `', `document?', etc. + (skribilo config) + (skribilo vars) + (skribilo runtime) ;; `the-options', `the-body' + (skribilo biblio) + (skribilo lib) ;; `define-markup', `unwind-protect', etc. + (skribilo resolve) + (skribilo engine) + (skribilo writer) + (skribilo output) + (skribilo evaluator))) + +(define *skribe-core-modules* + '("utils" "api" "bib" "index" "param" "sui")) + +(define-macro (define-skribe-module name . options) `(begin - (define-module ,name) + (define-module ,name + #:reader (make-reader 'skribe) + #:use-module (skribilo reader) + ,@options) ;; Pull all the bindings that Skribe code may expect, plus those needed ;; to actually create and read the module. - (use-modules (skribilo module) - (skribilo reader) - (skribilo evaluator) ;; `run-time-module' - (skribilo engine) - (skribilo writer) - (skribilo types) - - (srfi srfi-1) - (ice-9 optargs) - - (skribilo lib) ;; `define-markup', `unwind-protect', etc. - (skribilo runtime) - (skribilo vars) - (skribilo config)) - - - ;; The `define' below results in a module-local definition. So the - ;; definition of `read' in the `(guile-user)' module is left untouched. - ;(define read ,(make-reader 'skribe)) - - ;; Everything is exported. -; (define-macro (define . things) -; (let* ((first (car things)) -; (binding (cond ((symbol? first) first) -; ((list? first) (car first)) -; ((pair? first) (car first)) -; (else -; (error "define/skribe: bad formals" first))))) -; `(begin -; (define-public ,@things) -; ;; Automatically push it to the run-time user module. -; ; (module-define! ,(run-time-module) -; ; (quote ,binding) ,binding) -; ))) - )) + ,(cons 'use-modules + (append *skribilo-user-imports* + (filter-map (lambda (mod) + (let ((m `(skribilo skribe + ,(string->symbol + mod)))) + (and (not (equal? m name)) m))) + *skribe-core-modules*))))) ;; Make it available to the top-level module. @@ -84,9 +85,35 @@ 'define-skribe-module define-skribe-module) -(define-public *skribe-core-modules* - '("utils" "api" "bib" "index" "param" "sui")) + +(define *skribilo-user-module* #f) + +;;; +;;; MAKE-RUN-TIME-MODULE +;;; +(define-public (make-run-time-module) + "Return a new module that imports all the necessary bindings required for +execution of Skribilo/Skribe code." + (let ((the-module (make-module))) + (for-each (lambda (iface) + (module-use! the-module (resolve-module iface))) + (append *skribilo-user-imports* + (map (lambda (mod) + `(skribilo skribe + ,(string->symbol mod))) + *skribe-core-modules*))) + (set-module-name! the-module '(skribilo-user)) + the-module)) + +;;; +;;; RUN-TIME-MODULE +;;; +(define-public (run-time-module) + "Return the default instance of a Skribilo/Skribe run-time module." + (if (not *skribilo-user-module*) + (set! *skribilo-user-module* (make-run-time-module))) + *skribilo-user-module*) ;; FIXME: This will eventually be replaced by the per-module reader thing in diff --git a/src/guile/skribilo/output.scm b/src/guile/skribilo/output.scm index eeff397..8a63a48 100644 --- a/src/guile/skribilo/output.scm +++ b/src/guile/skribilo/output.scm @@ -31,6 +31,7 @@ (skribilo types) ; (skribilo engine) (skribilo writer) + (skribilo lib) ;; `when', `unless' (oop goops)) @@ -60,10 +61,10 @@ (%out/writer node e (car writer))) ((not (car writer)) (skribe-error 'output - (format "Illegal ~A user writer" (engine-ident e)) + (format #f "illegal ~A user writer" (engine-ident e)) (if (markup? node) (markup-markup node) node))) (else - (skribe-error 'output "Illegal user writer" (car writer))))))) + (skribe-error 'output "illegal user writer" (car writer))))))) ;;; @@ -74,7 +75,7 @@ (define-method (out (node ) e) - (let Loop ((n* node)) + (let loop ((n* node)) (cond ((pair? n*) (out (car n*) e) diff --git a/src/guile/skribilo/resolve.scm b/src/guile/skribilo/resolve.scm index e59a2f8..14f36b2 100644 --- a/src/guile/skribilo/resolve.scm +++ b/src/guile/skribilo/resolve.scm @@ -1,24 +1,24 @@ ;;;; ;;;; 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, +;;;; 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) @@ -28,6 +28,7 @@ :use-module (skribilo debug) :use-module (skribilo runtime) :use-module (skribilo types) + :use-module (skribilo lib) ;; `unless' and `when' :use-module (oop goops) @@ -62,7 +63,7 @@ ;;;; ====================================================================== ;;;; -;;;; D O - R E S O L V E ! +;;;; D O - R E S O L V E ! ;;;; ;;;; ====================================================================== @@ -195,10 +196,10 @@ (debug-item "parent=" p " " (if (is-a? p 'markup) (slot-ref p 'markup) "???")) (cond - ((pred p) p) + ((pred p) p) ((is-a? p ) p) ((not p) #f) - (else (resolve-search-parent p e pred)))))) + (else (resolve-search-parent p e pred)))))) ;;;; ====================================================================== ;;;; @@ -231,7 +232,7 @@ (else (set-car! (cdr c) (+ 1 num)) (+ 1 num))))))) - + ;;;; ====================================================================== ;;;; ;;;; RESOLVE-IDENT @@ -259,4 +260,3 @@ (car mks)) (else (loop (cdr mks))))))))))) - diff --git a/src/guile/skribilo/runtime.scm b/src/guile/skribilo/runtime.scm index 2642f7e..1f411dc 100644 --- a/src/guile/skribilo/runtime.scm +++ b/src/guile/skribilo/runtime.scm @@ -27,6 +27,7 @@ (define-module (skribilo runtime) :export (;; Utilities strip-ref-base ast->file-location string-canonicalize + the-options the-body ;; Markup functions markup-option markup-option-add! markup-output @@ -49,6 +50,8 @@ (skribilo resolve) (skribilo output) (skribilo evaluator) + (skribilo vars) + (srfi srfi-13) (oop goops)) @@ -253,10 +256,10 @@ ;; The general version (lambda (str) (let ((out (open-output-string))) - (dotimes (i (string-length str)) - (let* ((ch (string-ref str i)) - (res (assq ch lst))) - (display (if res (cadr res) ch) out))) + (string-for-each (lambda (ch) + (let ((res (assq ch lst))) + (display (if res (cadr res) ch) out))) + str) (get-output-string out)))) (define string->html @@ -414,48 +417,49 @@ ;;NEW '())))))) ;;NEW -;;NEW ;;;; ====================================================================== -;;NEW ;;;; -;;NEW ;;;; M A R K U P A R G U M E N T P A R S I N G -;;NEW ;;; -;;NEW ;;;; ====================================================================== -;;NEW (define (the-body opt) -;;NEW ;; Filter out the options -;;NEW (let loop ((opt* opt) -;;NEW (res '())) -;;NEW (cond -;;NEW ((null? opt*) -;;NEW (reverse! res)) -;;NEW ((not (pair? opt*)) -;;NEW (skribe-error 'the-body "Illegal body" opt)) -;;NEW ((keyword? (car opt*)) -;;NEW (if (null? (cdr opt*)) -;;NEW (skribe-error 'the-body "Illegal option" (car opt*)) -;;NEW (loop (cddr opt*) res))) -;;NEW (else -;;NEW (loop (cdr opt*) (cons (car opt*) res)))))) -;;NEW -;;NEW -;;NEW -;;NEW (define (the-options opt+ . out) -;;NEW ;; Returns an list made of options.The OUT argument contains -;;NEW ;; keywords that are filtered out. -;;NEW (let loop ((opt* opt+) -;;NEW (res '())) -;;NEW (cond -;;NEW ((null? opt*) -;;NEW (reverse! res)) -;;NEW ((not (pair? opt*)) -;;NEW (skribe-error 'the-options "Illegal options" opt*)) -;;NEW ((keyword? (car opt*)) -;;NEW (cond -;;NEW ((null? (cdr opt*)) -;;NEW (skribe-error 'the-options "Illegal option" (car opt*))) -;;NEW ((memq (car opt*) out) -;;NEW (loop (cdr opt*) res)) -;;NEW (else -;;NEW (loop (cdr opt*) -;;NEW (cons (list (car opt*) (cadr opt*)) res))))) -;;NEW (else -;;NEW (loop (cdr opt*) res))))) -;;NEW + +;;;; ====================================================================== +;;;; +;;;; M A R K U P A R G U M E N T P A R S I N G +;;;; +;;;; ====================================================================== +(define (the-body opt) + ;; Filter out the options + (let loop ((opt* opt) + (res '())) + (cond + ((null? opt*) + (reverse! res)) + ((not (pair? opt*)) + (skribe-error 'the-body "Illegal body" opt)) + ((keyword? (car opt*)) + (if (null? (cdr opt*)) + (skribe-error 'the-body "Illegal option" (car opt*)) + (loop (cddr opt*) res))) + (else + (loop (cdr opt*) (cons (car opt*) res)))))) + + + +(define (the-options opt+ . out) + ;; Returns an list made of options.The OUT argument contains + ;; keywords that are filtered out. + (let loop ((opt* opt+) + (res '())) + (cond + ((null? opt*) + (reverse! res)) + ((not (pair? opt*)) + (skribe-error 'the-options "Illegal options" opt*)) + ((keyword? (car opt*)) + (cond + ((null? (cdr opt*)) + (skribe-error 'the-options "Illegal option" (car opt*))) + ((memq (car opt*) out) + (loop (cdr opt*) res)) + (else + (loop (cdr opt*) + (cons (list (car opt*) (cadr opt*)) res))))) + (else + (loop (cdr opt*) res))))) + diff --git a/src/guile/skribilo/skribe/api.scm b/src/guile/skribilo/skribe/api.scm index 2828908..e7ba4a6 100644 --- a/src/guile/skribilo/skribe/api.scm +++ b/src/guile/skribilo/skribe/api.scm @@ -253,6 +253,7 @@ ;* paragraph ... */ ;*---------------------------------------------------------------------*/ (define-simple-markup paragraph) +(define-public p paragraph) ;*---------------------------------------------------------------------*/ ;* footnote ... */ diff --git a/src/guile/skribilo/skribe/bib.scm b/src/guile/skribilo/skribe/bib.scm index f1a32c1..2ec5c0b 100644 --- a/src/guile/skribilo/skribe/bib.scm +++ b/src/guile/skribilo/skribe/bib.scm @@ -32,7 +32,6 @@ ;;; The contents of the file below are unchanged compared to Skribe 1.2d's ;;; `bib.scm' file found in the `common' directory. - ;*---------------------------------------------------------------------*/ ;* bib-load! ... */ ;*---------------------------------------------------------------------*/ diff --git a/src/guile/skribilo/skribe/utils.scm b/src/guile/skribilo/skribe/utils.scm index f963020..b2a5cfb 100644 --- a/src/guile/skribilo/skribe/utils.scm +++ b/src/guile/skribilo/skribe/utils.scm @@ -19,7 +19,8 @@ ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ;;; USA. -(define-skribe-module (skribilo skribe utils)) +(define-skribe-module (skribilo skribe utils) + #:export (ast-document)) ;;; Author: Manuel Serrano ;;; Commentary: diff --git a/src/guile/skribilo/source.scm b/src/guile/skribilo/source.scm index 1e88d45..c682687 100644 --- a/src/guile/skribilo/source.scm +++ b/src/guile/skribilo/source.scm @@ -1,24 +1,24 @@ ;;;; ;;;; source.stk -- Skibe SOURCE implementation stuff -;;;; +;;;; ;;;; 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, +;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, ;;;; USA. -;;;; +;;;; ;;;; Author: Erick Gallesio [eg@essi.fr] ;;;; Creation date: 3-Sep-2003 12:22 (eg) ;;;; Last file update: 27-Oct-2004 20:09 (eg) @@ -27,7 +27,8 @@ (define-module (skribilo source) - :export (source-read-lines source-read-definition source-fontify)) + :export (source-read-lines source-read-definition source-fontify) + :use-module (skribilo vars)) ;; Temporary solution @@ -187,4 +188,3 @@ (cons* 'eol (substring str j i) r)))) (else (loop (+ i 1) j r)))))) - diff --git a/src/guile/skribilo/types.scm b/src/guile/skribilo/types.scm index 0d51c70..0893587 100644 --- a/src/guile/skribilo/types.scm +++ b/src/guile/skribilo/types.scm @@ -33,10 +33,12 @@ node? node-options node-loc engine? engine-ident engine-format engine-customs engine-filter engine-symbol-table - writer? write-object + writer? write-object writer-options writer-ident + writer-before writer-action writer-after processor? processor-combinator processor-engine markup? bind-markup! markup-options is-markup? - markup-body find-markups write-object + markup-markup markup-body markup-ident markup-class + find-markups write-object container? container-options container-ident container-body document? document-ident document-body diff --git a/src/guile/skribilo/vars.scm b/src/guile/skribilo/vars.scm index 51a7ee7..7e75e0f 100644 --- a/src/guile/skribilo/vars.scm +++ b/src/guile/skribilo/vars.scm @@ -21,7 +21,8 @@ ;;; USA. -(define-module (skribilo vars)) +(define-module (skribilo vars) + #:use-module (srfi srfi-17)) ;;; ;;; Switches @@ -30,6 +31,11 @@ (define-public *skribe-warning* 5) (define-public *load-rc* #t) +(define-public skribe-debug + (let ((level 0)) + (getter-with-setter (lambda () level) + (lambda (val) (set! level val))))) + ;;; ;;; PATH variables ;;; diff --git a/src/guile/skribilo/verify.scm b/src/guile/skribilo/verify.scm index 93a1be3..1ff0b5b 100644 --- a/src/guile/skribilo/verify.scm +++ b/src/guile/skribilo/verify.scm @@ -1,24 +1,24 @@ ;;;; ;;;; 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, +;;;; 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) @@ -29,9 +29,10 @@ (use-modules (skribilo debug) ; (skribilo engine) -; (skribilo writer) + (skribilo writer) ; (skribilo runtime) (skribilo types) + (skribilo lib) ;; `when', `unless' (oop goops)) @@ -61,16 +62,16 @@ ;;; CHECK-OPTIONS ;;; (define (check-options lopts markup engine) - + ;; Only keywords are checked, symbols are voluntary left unchecked. */ (with-debug 6 'check-options (debug-item "markup=" (markup-markup markup)) (debug-item "options=" (slot-ref markup 'options)) (debug-item "lopts=" lopts) (for-each - (lambda (o2) + (lambda (o2) (for-each - (lambda (o) + (lambda (o) (if (and (keyword? o) (not (eq? o :&skribe-eval-location)) (not (memq o lopts))) @@ -85,11 +86,11 @@ (markup-option markup o))))) o2)) (slot-ref markup 'options)))) - + ;;; ====================================================================== ;;; -;;; V E R I F Y +;;; V E R I F Y ;;; ;;; ====================================================================== @@ -124,7 +125,7 @@ (with-debug 5 'verify:: (debug-item "node=" (markup-markup node)) (debug-item "options=" (slot-ref node 'options)) - (debug-item "e=" (engine-ident e)) + (debug-item "e=" (engine-ident e)) (next-method) @@ -157,5 +158,3 @@ (slot-ref e 'customs)) node) - - diff --git a/src/guile/skribilo/writer.scm b/src/guile/skribilo/writer.scm index 70ba817..eeefe8b 100644 --- a/src/guile/skribilo/writer.scm +++ b/src/guile/skribilo/writer.scm @@ -64,7 +64,7 @@ (define (lookup-markup-writer node e) (let ((writers (slot-ref e 'writers)) (delegate (slot-ref e 'delegate))) - (let Loop ((w* writers)) + (let loop ((w* writers)) (cond ((pair? w*) (let ((pred (slot-ref (car w*) 'pred))) -- cgit v1.2.3