10. Scribe Programming Manual -- Embedding Scribe into Bigloo

10. Scribe Programming Manual -- Embedding Scribe into Bigloo

Browsing

Home: Scribe Programming Manual

Previous chapter: Bibliography
Next chapter: Scribe Apache module


Embedding Scribe into Bigloo

Scribe libraries
Example of Bigloo application


Chapters

Defining new functions
Fontification
Common Classes
Scribe Library
Container numbering
Target format
Programming Back-ends
The HTML back end
Bibliography
Embedding Scribe into Bigloo
Scribe Apache module
Classes, Functions and Variables
Bibliography


Scribe

Home page:Scribe

Documentation:user
expert


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.

10.1 Scribe libraries

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.


10.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)))))          

    



This
Scribe page is generated by scribeinfo.
Last update Sun Feb 17 12:09:41 2002