Embedding Scribe into Bigloo
|
|
Scribe is implemented by the means of Bigloo
libraries. It is possible to use this library into Bigloo programs. These
programs will be able to compile Scribe expression into all the supported
Scribe back-ends.
In order to enable Scribe programming into Bigloo, the only
requirement is to use the Scribe libraries into the Bigloo module
clause of the application. Here is a non exhaustive list of Scribe
libraries:
- scribeapi
- The mandatory library that is used by all other Scribe
library. Bigloo embedding applications must always use this library.
- scribehtml
- The HTML back-end. This library provides a html
function that compiles Scribe to HTML. The HTML back-end back-end supports
various customizations.
- scribehtmlgui
- The HTML GUI back-end.
- scribetext
- The text back-ends. That is, the ASCII and INFO
back-ends. This library provides two functions: ascii and
info.
- scribetex
- The TeX back-end. This library provides the function
tex that compiles from Scribe to TeX.
- scribeman
- The MAN (nroff) back-end. This library provides
the function man that compiles from Scribe to man.
12.2 Example of Bigloo application
|
In this Section we present an example of Bigloo application
that compiles Scribe expressions to various Scribe supported formats.
;*=====================================================================*/
;* serrano/prgm/project/scribe/examples/embedded/embedded.scm */
;* ------------------------------------------------------------- */
;* Author : Manuel Serrano */
;* Creation : Tue Nov 6 14:58:46 2001 */
;* Last change : Sat Dec 8 08:22:24 2001 (serrano) */
;* Copyright : 2001 Manuel Serrano */
;* ------------------------------------------------------------- */
;* An example of embedded Scribe program. */
;*=====================================================================*/
;*---------------------------------------------------------------------*/
;* The module */
;*---------------------------------------------------------------------*/
(module scribe_embedded
(library scribeapi
scribehtml
scribetext
scribetex
scribeman)
(main main))
;*---------------------------------------------------------------------*/
;* main ... */
;*---------------------------------------------------------------------*/
(define (main argv)
(let ((doc (document :title "A generated electronic document"
:author (string-append (car argv) " -- scribeapi")
(body))))
;; the html file
(with-output-to-file (string-append (car argv) ".html")
(lambda () (html doc)))
;; the text file
(with-output-to-file (string-append (car argv) ".ascii")
(lambda () (ascii doc)))
;; the tex file
(with-output-to-file (string-append (car argv) ".tex")
(lambda () (tex doc)))
;; the man file
(with-output-to-file (string-append (car argv) ".man")
(lambda () (man doc)))))
;*---------------------------------------------------------------------*/
;* body ... */
;*---------------------------------------------------------------------*/
(define (body)
(list
(section :title "Fibonacci"
(let ((n 20))
(string-append "fib("
(number->string n)
") : "
(number->string (fib n)))))
(section :title "Bigloo compiler options: "
(color :bg "#eebbbb"
(pre (let ((port (open-input-file "| bigloo -help")))
(let loop ((exp (read-line port))
(res '()))
(if (eof-object? exp)
(apply string-append (reverse! res))
(loop (read-line port)
(cons* exp "\n" res))))))))))
;*---------------------------------------------------------------------*/
;* fib ... */
;*---------------------------------------------------------------------*/
(define (fib x)
(if (< x 2)
1
(+ (fib (- x 1)) (fib (- x 2)))))
|
|