summaryrefslogtreecommitdiff
path: root/src/guile
diff options
context:
space:
mode:
authorLudovic Court`es2005-11-28 14:23:48 +0000
committerLudovic Court`es2005-11-28 14:23:48 +0000
commit559d3f64f4b051a39c91a3d53d3b41deee8ae42f (patch)
tree2f4b5c13a79ee9c093edb204c3f2d7f70e2b2e12 /src/guile
parentd14b60a0b4ea1eb5ea84d74b1b2fe59d24ae9bf3 (diff)
downloadskribilo-559d3f64f4b051a39c91a3d53d3b41deee8ae42f.tar.gz
skribilo-559d3f64f4b051a39c91a3d53d3b41deee8ae42f.tar.lz
skribilo-559d3f64f4b051a39c91a3d53d3b41deee8ae42f.zip
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
Diffstat (limited to 'src/guile')
-rwxr-xr-xsrc/guile/skribilo.scm15
-rw-r--r--src/guile/skribilo/Makefile.am2
-rw-r--r--src/guile/skribilo/ast.scm3
-rw-r--r--src/guile/skribilo/biblio.scm3
-rw-r--r--src/guile/skribilo/engine.scm2
-rw-r--r--src/guile/skribilo/engine/lout.scm4
-rw-r--r--src/guile/skribilo/evaluator.scm19
-rw-r--r--src/guile/skribilo/lib.scm23
-rw-r--r--src/guile/skribilo/location.scm3
-rw-r--r--src/guile/skribilo/module.scm40
-rw-r--r--src/guile/skribilo/source.scm5
-rw-r--r--src/guile/skribilo/utils/Makefile.am4
-rw-r--r--src/guile/skribilo/utils/syntax.scm68
-rw-r--r--src/guile/skribilo/writer.scm4
14 files changed, 141 insertions, 54 deletions
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)
diff --git a/src/guile/skribilo/Makefile.am b/src/guile/skribilo/Makefile.am
index e41df66..c6765f5 100644
--- a/src/guile/skribilo/Makefile.am
+++ b/src/guile/skribilo/Makefile.am
@@ -7,4 +7,4 @@ dist_guilemodule_DATA = biblio.scm color.scm config.scm \
writer.scm ast.scm location.scm \
compat.scm
-SUBDIRS = reader engine package skribe coloring
+SUBDIRS = utils reader engine package skribe coloring
diff --git a/src/guile/skribilo/ast.scm b/src/guile/skribilo/ast.scm
index fc6859e..b1c9a14 100644
--- a/src/guile/skribilo/ast.scm
+++ b/src/guile/skribilo/ast.scm
@@ -22,6 +22,7 @@
(define-module (skribilo ast)
:use-module (oop goops)
:autoload (skribilo location) (location?)
+ :use-module (skribilo utils syntax)
:export (<ast> ast? ast-loc ast-loc-set!
ast-parent ast->string
@@ -54,7 +55,7 @@
;;;
;;; Code:
-(read-set! keywords 'prefix)
+(set-current-reader %skribilo-module-reader)
(define *node-table* (make-hash-table))
; Used to stores the nodes of an AST.
diff --git a/src/guile/skribilo/biblio.scm b/src/guile/skribilo/biblio.scm
index dd04f68..045e3ae 100644
--- a/src/guile/skribilo/biblio.scm
+++ b/src/guile/skribilo/biblio.scm
@@ -22,7 +22,7 @@
(define-module (skribilo biblio)
:use-module (skribilo runtime)
- :use-module (skribilo lib) ;; `when', `unless'
+ :use-module (skribilo utils syntax) ;; `when', `unless'
:use-module (skribilo module)
:use-module (skribilo skribe bib) ;; `make-bib-entry'
:autoload (skribilo parameters) (*bib-path*)
@@ -30,6 +30,7 @@
:export (bib-table? make-bib-table default-bib-table
bib-add!))
+(set-current-reader %skribilo-module-reader)
;; FIXME: Should be a fluid?
diff --git a/src/guile/skribilo/engine.scm b/src/guile/skribilo/engine.scm
index 5b18b5c..1c36e52 100644
--- a/src/guile/skribilo/engine.scm
+++ b/src/guile/skribilo/engine.scm
@@ -21,6 +21,7 @@
(define-module (skribilo engine)
:use-module (skribilo debug)
+ :use-module (skribilo utils syntax)
:use-module (skribilo lib)
;; `(skribilo writer)' depends on this module so it needs to be loaded
@@ -43,6 +44,7 @@
push-default-engine pop-default-engine))
+(set-current-reader %skribilo-module-reader)
;;;
diff --git a/src/guile/skribilo/engine/lout.scm b/src/guile/skribilo/engine/lout.scm
index 1d38b28..5c6ec22 100644
--- a/src/guile/skribilo/engine/lout.scm
+++ b/src/guile/skribilo/engine/lout.scm
@@ -2941,8 +2941,8 @@
(display (lout-embedded-postscript-code
(filter pdfmark))))))
-For movies, see
-http://www.tug.org/tex-archive/macros/latex/contrib/movie15/movie15.sty .
+;; For movies, see
+;; http://www.tug.org/tex-archive/macros/latex/contrib/movie15/movie15.sty .
(markup-writer 'slide-embed
:options '(:alt :geometry :rgeometry :geometry-opt :command)
;; FIXME: `pdfmark'.
diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm
index bbf92e3..4c28b24 100644
--- a/src/guile/skribilo/evaluator.scm
+++ b/src/guile/skribilo/evaluator.scm
@@ -23,7 +23,7 @@
(define-module (skribilo evaluator)
:export (skribe-eval skribe-eval-port skribe-load skribe-load-options
skribe-include)
- :autoload (skribilo parameters) (*verbose*)
+ :autoload (skribilo parameters) (*verbose* *document-path*)
:autoload (skribilo location) (<location>)
:autoload (skribilo ast) (ast? markup?)
:autoload (skribilo engine) (engine? find-engine engine-ident)
@@ -33,7 +33,8 @@
:autoload (skribilo resolve) (resolve!))
-(use-modules (skribilo debug)
+(use-modules (skribilo utils syntax)
+ (skribilo debug)
(skribilo output)
(skribilo lib)
@@ -43,7 +44,7 @@
(srfi srfi-1))
-
+(set-current-reader %skribilo-module-reader)
(define *skribe-loaded* '()) ;; List of already loaded files
@@ -71,7 +72,7 @@
;;;
;;; SKRIBE-EVAL
;;;
-(define* (skribe-eval a e #:key (env '()))
+(define* (skribe-eval a e :key (env '()))
(with-debug 2 'skribe-eval
(debug-item "a=" a " e=" (engine-ident e))
(let ((a2 (resolve! a e env)))
@@ -83,8 +84,8 @@
;;;
;;; SKRIBE-EVAL-PORT
;;;
-(define* (skribe-eval-port port engine #:key (env '())
- (reader %default-reader))
+(define* (skribe-eval-port port engine :key (env '())
+ (reader %default-reader))
(with-debug 2 'skribe-eval-port
(debug-item "engine=" engine)
(debug-item "reader=" reader)
@@ -112,7 +113,7 @@
(define (skribe-load-options)
*skribe-load-options*)
-(define* (skribe-load file #:key (engine #f) (path #f) #:rest opt)
+(define* (skribe-load file :key (engine #f) (path #f) :rest opt)
(with-debug 4 'skribe-load
(debug-item " engine=" engine)
(debug-item " path=" path)
@@ -120,7 +121,7 @@
(let* ((ei (*current-engine*))
(path (append (cond
- ((not path) (skribe-path))
+ ((not path) (*document-path*))
((string? path) (list path))
((not (and (list? path) (every? string? path)))
(skribe-error 'skribe-load "illegal path" path))
@@ -159,7 +160,7 @@
;;;
;;; SKRIBE-INCLUDE
;;;
-(define* (skribe-include file #:optional (path (skribe-path)))
+(define* (skribe-include file :optional (path (*document-path*)))
(unless (every string? path)
(skribe-error 'skribe-include "illegal path" path))
diff --git a/src/guile/skribilo/lib.scm b/src/guile/skribilo/lib.scm
index b15960e..7a0c306 100644
--- a/src/guile/skribilo/lib.scm
+++ b/src/guile/skribilo/lib.scm
@@ -20,9 +20,8 @@
;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;;; USA.
-(read-set! keywords 'prefix)
-
(define-module (skribilo lib)
+ :use-module (skribilo utils syntax)
:export (skribe-eval-location skribe-ast-error skribe-error
skribe-type-error
skribe-warning skribe-warning/ast
@@ -32,10 +31,7 @@
%procedure-arity)
:export-syntax (new define-markup define-simple-markup
- define-simple-container define-processor-markup
-
- ;; for compatibility
- unwind-protect unless when)
+ define-simple-container define-processor-markup)
:use-module (skribilo config)
:use-module (skribilo ast)
@@ -52,6 +48,7 @@
:use-module (ice-9 optargs))
+(set-current-reader %skribilo-module-reader)
;;;
@@ -253,7 +250,6 @@
;;; Various things.
;;;
-(define %skribe-reader (make-reader 'skribe))
(define* (skribe-read #:optional (port (current-input-port)))
(%skribe-reader port))
@@ -261,18 +257,5 @@
(define (%procedure-arity proc)
(car (procedure-property proc 'arity)))
-(define-macro (unwind-protect expr1 expr2)
- ;; This is no completely correct.
- `(dynamic-wind
- (lambda () #f)
- (lambda () ,expr1)
- (lambda () ,expr2)))
-
-(define-macro (unless condition . exprs)
- `(if (not ,condition) (begin ,@exprs)))
-
-(define-macro (when condition . exprs)
- `(if ,condition (begin ,@exprs)))
-
;;; lib.scm ends here
diff --git a/src/guile/skribilo/location.scm b/src/guile/skribilo/location.scm
index a134f8a..516d8ad 100644
--- a/src/guile/skribilo/location.scm
+++ b/src/guile/skribilo/location.scm
@@ -21,6 +21,7 @@
(define-module (skribilo location)
:use-module (oop goops)
+ :use-module ((skribilo utils syntax) :select (%skribilo-module-reader))
:export (<location> location? ast-location
location-file location-line location-pos))
@@ -32,7 +33,7 @@
;;;
;;; Code:
-(read-set! keywords 'prefix)
+(set-current-reader %skribilo-module-reader)
;;;
diff --git a/src/guile/skribilo/module.scm b/src/guile/skribilo/module.scm
index 21917b2..76d6717 100644
--- a/src/guile/skribilo/module.scm
+++ b/src/guile/skribilo/module.scm
@@ -19,8 +19,9 @@
;;; USA.
(define-module (skribilo module)
- :use-module (skribilo reader)
+ :autoload (skribilo reader) (make-reader)
:use-module (skribilo debug)
+ :use-module (system reader confinement) ;; `set-current-reader'
:use-module (srfi srfi-1)
:use-module (ice-9 optargs))
@@ -41,11 +42,8 @@
'((srfi srfi-1) ;; lists
(srfi srfi-13) ;; strings
(ice-9 optargs) ;; `define*'
- (ice-9 and-let-star) ;; `and-let*'
- (ice-9 receive) ;; `receive'
(skribilo module)
- (skribilo parameters) ;; run-time parameters
(skribilo compat) ;; `skribe-load-path', etc.
(skribilo ast) ;; `<document>', `document?', etc.
(skribilo config)
@@ -57,25 +55,38 @@
(skribilo writer)
(skribilo output)
(skribilo evaluator)
- (skribilo color)
(skribilo debug)
- (skribilo source) ;; `source-read-lines', `source-fontify', etc.
- (skribilo coloring lisp) ;; `skribe', `scheme', `lisp'
- (skribilo coloring xml) ;; `xml'
))
+(define %skribilo-user-autoloads
+ ;; List of auxiliary modules that may be lazily autoloaded.
+ '(((skribilo source) . (source-read-lines source-fontify))
+ ((skribilo coloring lisp) . (skribe scheme lisp))
+ ((skribilo coloring xml) . (xml))
+ ((skribilo color) .
+ (skribe-color->rgb skribe-get-used-colors skribe-use-color!))
+
+ ((ice-9 and-let-star) . (and-let*))
+ ((ice-9 receive) . (receive))))
+
(define %skribe-core-modules
'("utils" "api" "bib" "index" "param" "sui"))
+
(define-macro (define-skribe-module name . options)
`(begin
(define-module ,name
- #:reader (make-reader 'skribe)
- #:use-module (skribilo reader)
+ #: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)))
+ %skribilo-user-autoloads)
,@options)
;; Pull all the bindings that Skribe code may expect, plus those needed
;; to actually create and read the module.
+ ;; TODO: These should be auto-loaded.
,(cons 'use-modules
(append %skribilo-user-imports
(filter-map (lambda (mod)
@@ -83,7 +94,14 @@
,(string->symbol
mod))))
(and (not (equal? m name)) m)))
- %skribe-core-modules)))))
+ %skribe-core-modules)))
+
+ ;; 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))))
;; Make it available to the top-level module.
diff --git a/src/guile/skribilo/source.scm b/src/guile/skribilo/source.scm
index bd523f2..e4f9973 100644
--- a/src/guile/skribilo/source.scm
+++ b/src/guile/skribilo/source.scm
@@ -20,16 +20,17 @@
;;;; USA.
;;;;
-
(define-module (skribilo source)
:export (<language> language? language-extractor language-fontifier
source-read-lines source-read-definition source-fontify)
+ :use-module (skribilo utils syntax)
:use-module (skribilo parameters)
:use-module (skribilo lib)
:use-module (oop goops)
:use-module (ice-9 rdelim))
-(read-set! keywords 'prefix)
+
+(set-current-reader %skribilo-module-reader)
;;;
diff --git a/src/guile/skribilo/utils/Makefile.am b/src/guile/skribilo/utils/Makefile.am
new file mode 100644
index 0000000..e87696a
--- /dev/null
+++ b/src/guile/skribilo/utils/Makefile.am
@@ -0,0 +1,4 @@
+guilemoduledir = $(GUILE_SITE)/skribilo
+dist_guilemodule_DATA = syntax.scm
+
+## arch-tag: 3a18b64b-1da2-417b-8338-2c534bca277f
diff --git a/src/guile/skribilo/utils/syntax.scm b/src/guile/skribilo/utils/syntax.scm
new file mode 100644
index 0000000..24e8efa
--- /dev/null
+++ b/src/guile/skribilo/utils/syntax.scm
@@ -0,0 +1,68 @@
+;;; syntax.scm -- Syntactic candy for Skribilo modules.
+;;;
+;;; 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 utils syntax)
+ #:use-module (skribilo reader)
+ #:use-module (system reader library)
+ #:use-module (system reader confinement)
+ #:export (%skribe-reader %skribilo-module-reader)
+ #:export-syntax (unwind-protect unless when))
+
+;;; Author: Ludovic Courtès
+;;;
+;;; Commentary:
+;;;
+;;; A reader for the Skribe syntax, i.e. roughly R5RS Scheme plus DSSSL-style
+;;; keywords and sk-exps (expressions introduced using a square bracket).
+;;;
+;;; Code:
+
+(define %skribilo-module-reader
+ ;; The syntax used to read Skribilo modules.
+ (make-alternate-guile-reader '(colon-keywords
+ no-scsh-block-comments
+ srfi30-block-comments
+ srfi62-sexp-comments)
+ (lambda (chr port read)
+ (error "unexpected character in Skribilo module"
+ chr))
+ 'reader/record-positions))
+
+(define %skribe-reader
+ ;; The Skribe syntax reader.
+ (make-reader 'skribe))
+
+
+(define-macro (unwind-protect expr1 expr2)
+ ;; This is no completely correct.
+ `(dynamic-wind
+ (lambda () #f)
+ (lambda () ,expr1)
+ (lambda () ,expr2)))
+
+(define-macro (unless condition . exprs)
+ `(if (not ,condition) (begin ,@exprs)))
+
+(define-macro (when condition . exprs)
+ `(if ,condition (begin ,@exprs)))
+
+;;; arch-tag: 9a0e0638-64f0-480a-ab19-49e8bfcbcd9b
+
+;;; syntax.scm ends here
diff --git a/src/guile/skribilo/writer.scm b/src/guile/skribilo/writer.scm
index b393c5c..db36509 100644
--- a/src/guile/skribilo/writer.scm
+++ b/src/guile/skribilo/writer.scm
@@ -32,6 +32,7 @@
invoke markup-writer markup-writer-get markup-writer-get*
lookup-markup-writer copy-markup-writer)
+ :use-module (skribilo utils syntax)
:autoload (skribilo engine) (engine? engine-ident? default-engine))
@@ -44,6 +45,9 @@
(ice-9 optargs))
+(set-current-reader %skribilo-module-reader)
+
+
;;;
;;; Class definition.