A Scribe back-end is a Bigloo
library that implements a code generator for a certain
target format. The Scribe
version 1.1b provides back-ends for the
- Man (nroff)
This chapter explains how to implement new back-ends. It pre-supposes
the capacity to implement, compile and install Bigloo libraries.
7.1 Implementing a back-end
A Scribe back-end is implemented by the means of a Bigloo function
that accepts Scribe values and that write on the current
output channel the target file.
A Scribe value is either
All other values should be ignored.
- of zero argument
- It belongs to the back-end to apply the function
and re-process the result of this application.
- a text
- It belongs to the back-end to handle escape
sequences. For instance, the HTML back-end intercepts the character
"<" and replaces with the appropriate HTML characters sequence.
- of Scribe values
- The back-end must process in sequence the contained
- an instance of the
- The back-end must dispatch over
that class hierarchy in order to decide how to handle the node. For this, it
is recommended to implement the back-end by the means of a generic
For the sake of the example, here is the definition of the function
implementing the Man back-end.
And here is the implementation of the generic function man for
the instances of class %pre:
(define-generic (man obj::obj)
((and (procedure? obj) (correct-arity? obj 0))
(display (number->string obj)))
((eq? obj #unspecified)
(for-each man obj))
((or (symbol? obj) (boolean? obj))
(with-access::%node obj (loc)
"Can't find method for node"
(define-method (man obj::%pre)
(man (%pre-body obj))
7.2 Registering a back-end
Once implemented a Bigloo function implementing a back-end must
registered in order to enable Scribe to use it.
Registers the procedure under the name symbol.
That is, when Scribe is to compile a Scribe source file for a
target format, it searches a back-end has
been recorded under the name of the format.
For instance, to register the man back-end, the implementation
of the Bigloo library, contains the following top-level call:
|(register-backend! ::symbol ::procedure)||Scribe function|
(register-backend! 'man man)