diff options
author | Ludovic Courtes | 2005-12-03 11:35:47 +0000 |
---|---|---|
committer | Ludovic Courtes | 2005-12-03 11:35:47 +0000 |
commit | 9d4199ce1494a0c2a328fa51424acc29ae9dc91f (patch) | |
tree | 0e9e8ed316ed3a4a996b3a42c769282eb842c7bd /src | |
parent | 3d3ef9b5ad8687d6e5119cdcd7f86260a79fd697 (diff) | |
parent | c4c942f265f9cd7730155ecb978eb1b98051e764 (diff) | |
download | skribilo-9d4199ce1494a0c2a328fa51424acc29ae9dc91f.tar.gz skribilo-9d4199ce1494a0c2a328fa51424acc29ae9dc91f.tar.lz skribilo-9d4199ce1494a0c2a328fa51424acc29ae9dc91f.zip |
Merge from lcourtes@laas.fr--2004-libre
Patches applied:
* lcourtes@laas.fr--2004-libre/skribilo--devel--1.2 (patch 12-16)
- Fixed and updated the installation process.
- Created a canonical module for Skribilo syntactic sugar.
- More `%skribilo-module-reader' fixes.
- Fixed `ref' and bibliography-related things.
- Fixed Lout-related thingies.
git-archimport-id: lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2--patch-14
Diffstat (limited to 'src')
27 files changed, 434 insertions, 760 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 1d3db1f..4a83f1a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1 +1,4 @@ SUBDIRS = guile + +EXTRA_DIST = skribilo.in +bin_SCRIPTS = skribilo diff --git a/src/guile/Makefile.am b/src/guile/Makefile.am index afe4667..e410a87 100644 --- a/src/guile/Makefile.am +++ b/src/guile/Makefile.am @@ -1,4 +1,5 @@ SUBDIRS = skribilo -bin_SCRIPTS = skribilo.scm +guilemoduledir = $(GUILE_SITE) +dist_guilemodule_DATA = skribilo.scm EXTRA_DIST = README diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm index c4a5eac..a560b46 100755..100644 --- 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,8 @@ 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)) (use-modules (skribilo evaluator) (skribilo debug) @@ -74,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) @@ -180,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'. @@ -216,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))) @@ -370,18 +374,26 @@ 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))))) + ;;;; ====================================================================== ;;;; ;;;; M A I N @@ -392,7 +404,9 @@ 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")) + (warning-level (option-ref options 'warning "2")) (load-path (option-ref options 'load-path ".")) (bib-path (option-ref options 'bib-path ".")) (preload '()) @@ -405,7 +419,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 +435,11 @@ 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))) + (*warning* (string->number warning-level)) + (*verbose* (let ((v (option-ref options + 'verbose 0))) + (if (number? v) v + (if v 1 0))))) ;; Load the user rc file ;;(load-rc) @@ -443,26 +460,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/Makefile.am b/src/guile/skribilo/Makefile.am index c86f2f3..c6765f5 100644 --- a/src/guile/skribilo/Makefile.am +++ b/src/guile/skribilo/Makefile.am @@ -1,9 +1,10 @@ guilemoduledir = $(GUILE_SITE)/skribilo -dist_guilemodule_DATA = biblio.scm color.scm config.scm \ - debug.scm engine.scm evaluator.scm \ - lib.scm module.scm output.scm prog.scm \ - reader.scm resolve.scm runtime.scm \ - source.scm types.scm vars.scm verify.scm \ - writer.scm +dist_guilemodule_DATA = biblio.scm color.scm config.scm \ + debug.scm engine.scm evaluator.scm \ + lib.scm module.scm output.scm prog.scm \ + reader.scm resolve.scm runtime.scm \ + source.scm parameters.scm verify.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/Makefile.in b/src/guile/skribilo/Makefile.in deleted file mode 100644 index add7d0e..0000000 --- a/src/guile/skribilo/Makefile.in +++ /dev/null @@ -1,463 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = ../../.. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -subdir = src/guile/skribilo -DIST_COMMON = $(dist_guilemodule_DATA) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in $(srcdir)/config.scm.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_CLEAN_FILES = config.scm -SOURCES = -DIST_SOURCES = -RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ - html-recursive info-recursive install-data-recursive \ - install-exec-recursive install-info-recursive \ - install-recursive installcheck-recursive installdirs-recursive \ - pdf-recursive ps-recursive uninstall-info-recursive \ - uninstall-recursive -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; -am__installdirs = "$(DESTDIR)$(guilemoduledir)" -dist_guilemoduleDATA_INSTALL = $(INSTALL_DATA) -DATA = $(dist_guilemodule_DATA) -ETAGS = etags -CTAGS = ctags -DIST_SUBDIRS = $(SUBDIRS) -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -GUILE = @GUILE@ -GUILE_CONFIG = @GUILE_CONFIG@ -GUILE_SITE = @GUILE_SITE@ -GUILE_TOOLS = @GUILE_TOOLS@ -HAVE_LOUT_FALSE = @HAVE_LOUT_FALSE@ -HAVE_LOUT_TRUE = @HAVE_LOUT_TRUE@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LOUT = @LOUT@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -SKRIBILO_DOC_DIR = @SKRIBILO_DOC_DIR@ -SKRIBILO_EXT_DIR = @SKRIBILO_EXT_DIR@ -SKRIBILO_SKR_PATH = @SKRIBILO_SKR_PATH@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_STRIP = @ac_ct_STRIP@ -am__leading_dot = @am__leading_dot@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build_alias = @build_alias@ -datadir = @datadir@ -exec_prefix = @exec_prefix@ -host_alias = @host_alias@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -guilemoduledir = $(GUILE_SITE)/skribilo -dist_guilemodule_DATA = biblio.scm color.scm config.scm \ - debug.scm engine.scm evaluator.scm \ - lib.scm module.scm output.scm prog.scm \ - reader.scm resolve.scm runtime.scm \ - source.scm types.scm vars.scm verify.scm \ - writer.scm - -SUBDIRS = reader engine package skribe coloring -all: all-recursive - -.SUFFIXES: -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/guile/skribilo/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/guile/skribilo/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -config.scm: $(top_builddir)/config.status $(srcdir)/config.scm.in - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ -uninstall-info-am: -install-dist_guilemoduleDATA: $(dist_guilemodule_DATA) - @$(NORMAL_INSTALL) - test -z "$(guilemoduledir)" || $(mkdir_p) "$(DESTDIR)$(guilemoduledir)" - @list='$(dist_guilemodule_DATA)'; for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - f=$(am__strip_dir) \ - echo " $(dist_guilemoduleDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(guilemoduledir)/$$f'"; \ - $(dist_guilemoduleDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(guilemoduledir)/$$f"; \ - done - -uninstall-dist_guilemoduleDATA: - @$(NORMAL_UNINSTALL) - @list='$(dist_guilemodule_DATA)'; for p in $$list; do \ - f=$(am__strip_dir) \ - echo " rm -f '$(DESTDIR)$(guilemoduledir)/$$f'"; \ - rm -f "$(DESTDIR)$(guilemoduledir)/$$f"; \ - done - -# This directory's subdirectories are mostly independent; you can cd -# into them and run `make' without going through this Makefile. -# To change the values of `make' variables: instead of editing Makefiles, -# (1) if the variable is set in `config.status', edit `config.status' -# (which will cause the Makefiles to be regenerated when you run `make'); -# (2) otherwise, pass the desired values on the `make' command line. -$(RECURSIVE_TARGETS): - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -mostlyclean-recursive clean-recursive distclean-recursive \ -maintainer-clean-recursive: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - dot_seen=no; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - rev=''; for subdir in $$list; do \ - if test "$$subdir" = "."; then :; else \ - rev="$$subdir $$rev"; \ - fi; \ - done; \ - rev="$$rev ."; \ - target=`echo $@ | sed s/-recursive//`; \ - for subdir in $$rev; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done && test -z "$$fail" -tags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ - done -ctags-recursive: - list='$(SUBDIRS)'; for subdir in $$list; do \ - test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ - done - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done - list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(mkdir_p) "$(distdir)/$$subdir" \ - || exit 1; \ - distdir=`$(am__cd) $(distdir) && pwd`; \ - top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ - (cd $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$top_distdir" \ - distdir="$$distdir/$$subdir" \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile $(DATA) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(guilemoduledir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f Makefile -distclean-am: clean-am distclean-generic distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -info: info-recursive - -info-am: - -install-data-am: install-dist_guilemoduleDATA - -install-exec-am: - -install-info: install-info-recursive - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-dist_guilemoduleDATA uninstall-info-am - -uninstall-info: uninstall-info-recursive - -.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \ - clean clean-generic clean-recursive ctags ctags-recursive \ - distclean distclean-generic distclean-recursive distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-data install-data-am \ - install-dist_guilemoduleDATA install-exec install-exec-am \ - install-info install-info-am install-man install-strip \ - installcheck installcheck-am installdirs installdirs-am \ - maintainer-clean maintainer-clean-generic \ - maintainer-clean-recursive mostlyclean mostlyclean-generic \ - mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ - uninstall uninstall-am uninstall-dist_guilemoduleDATA \ - uninstall-info-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: 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..cbb9202 100644 --- a/src/guile/skribilo/biblio.scm +++ b/src/guile/skribilo/biblio.scm @@ -22,14 +22,17 @@ (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 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) ;; FIXME: Should be a fluid? @@ -91,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/coloring/Makefile.am b/src/guile/skribilo/coloring/Makefile.am index d518553..c8f9242 100644 --- a/src/guile/skribilo/coloring/Makefile.am +++ b/src/guile/skribilo/coloring/Makefile.am @@ -1,2 +1,2 @@ -guilemoduledir = $(GUILE_SITE)/skribilo +guilemoduledir = $(GUILE_SITE)/skribilo/coloring dist_guilemodule_DATA = c.scm lisp.scm xml.scm 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/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 64a3c5d..6d3dbfa 100644 --- a/src/guile/skribilo/engine/lout.scm +++ b/src/guile/skribilo/engine/lout.scm @@ -1,30 +1,30 @@ -;*=====================================================================*/ -;* Lout Skribe engine */ -;* ------------------------------------------------------------- */ -;* (C) Copyright 2004, 2005 Ludovic Courtès */ -;* */ -;* Taken from `lcourtes@laas.fr--2004-libre/ */ -;* skribe-lout--main--0.2--patch-15' */ -;* Based on `latex.skr', copyright 2003,2004 Manuel Serrano. */ -;*=====================================================================*/ - -(define-skribe-module (skribilo engine lout)) - -;* This is the Lout engine, part of Skribilo. -;* -;* Skribe 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. -;* -;* Skribe 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 Skribe; if not, write to the Free Software -;* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +;;; lout.scm -- A Lout engine. +;;; +;;; Copyright 2004, 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. + +;;; Taken from `lcourtes@laas.fr--2004-libre', +;;; `skribe-lout--main--0.2--patch-15'. +;;; Based on `latex.skr', copyright 2003, 2004 Manuel Serrano. + + +(define-skribe-module (skribilo engine lout) + :autoload (ice-9 rdelim) (read-line)) ;*---------------------------------------------------------------------*/ @@ -1277,8 +1277,10 @@ "`document-type' should be one of `book', `report' or `doc'" doc-type))))) -(define (lout-structure-number-string markup) +(define-public (lout-structure-number-string markup) ;; Return a structure number string such as "1.2". + ;; FIXME: External code has started to rely on this. This should be + ;; generalized and moved elsewhere. (let loop ((struct markup)) (if (document? struct) "" @@ -1496,7 +1498,7 @@ ;* footnote ... */ ;*---------------------------------------------------------------------*/ (markup-writer 'footnote - :options '(:number) + :options '(:label) :before (lambda (n e) (let ((number (markup-option n :number)) (use-number? @@ -2777,7 +2779,7 @@ ;*---------------------------------------------------------------------*/ ;* Illustrations */ ;*---------------------------------------------------------------------*/ -(define (lout-illustration . args) +(define-public (lout-illustration . args) ;; Introduce a Lout illustration (such as a diagram) whose code is either ;; the body of `lout-illustration' or the contents of `file'. For engines ;; other than Lout, an EPS file is produced and then converted if needed. @@ -2879,7 +2881,7 @@ ;* At some point, we might want to move this to `slide.scm'. */ ;*---------------------------------------------------------------------*/ -(use-modules (skribilo packages slide)) +(use-modules (skribilo package slide)) (markup-writer 'slide :options '(:title :number :toc :ident) ;; '(:bg :vspace :image) @@ -2941,8 +2943,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..e4ef208 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 @@ -54,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 <location> :file file :line line :pos column)))) + result)) @@ -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) @@ -92,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)) @@ -112,7 +111,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 +119,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 +158,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..b88c3b7 100644 --- a/src/guile/skribilo/module.scm +++ b/src/guile/skribilo/module.scm @@ -19,10 +19,14 @@ ;;; 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)) + :use-module (ice-9 optargs) + :use-module (skribilo utils syntax)) + +(set-current-reader %skribilo-module-reader) ;;; Author: Ludovic Courtès ;;; @@ -41,11 +45,9 @@ '((srfi srfi-1) ;; lists (srfi srfi-13) ;; strings (ice-9 optargs) ;; `define*' - (ice-9 and-let-star) ;; `and-let*' - (ice-9 receive) ;; `receive' + (skribilo utils syntax) ;; `unless', `when', etc. (skribilo module) - (skribilo parameters) ;; run-time parameters (skribilo compat) ;; `skribe-load-path', etc. (skribilo ast) ;; `<document>', `document?', etc. (skribilo config) @@ -57,25 +59,46 @@ (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 engine lout) . (lout-illustration + ;; FIXME: The following should eventually be + ;; removed from here. + lout-structure-number-string)) + ((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")) + + +;; 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 - #: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 +106,12 @@ ,(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))) ;; Make it available to the top-level module. @@ -122,38 +150,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/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/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/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/skribe/Makefile.am b/src/guile/skribilo/skribe/Makefile.am index 2850c4d..e005313 100644 --- a/src/guile/skribilo/skribe/Makefile.am +++ b/src/guile/skribilo/skribe/Makefile.am @@ -1,2 +1,2 @@ -guilemoduledir = $(GUILE_SITE)/skribilo +guilemoduledir = $(GUILE_SITE)/skribilo/skribe dist_guilemodule_DATA = api.scm bib.scm index.scm param.scm sui.scm utils.scm 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: 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..810ee48 --- /dev/null +++ b/src/guile/skribilo/utils/Makefile.am @@ -0,0 +1,4 @@ +guilemoduledir = $(GUILE_SITE)/skribilo/utils +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/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 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. diff --git a/src/skribilo.in b/src/skribilo.in new file mode 100644 index 0000000..5508e10 --- /dev/null +++ b/src/skribilo.in @@ -0,0 +1,7 @@ +#!/bin/sh +# The `skribilo' executable. + +main='(module-ref (resolve-module '\''(skribilo)) '\'main')' +exec ${GUILE-@GUILE@} --debug \ + -c "(apply $main (cdr (command-line)))" "$@" + |