The Reader Module

The reader module provides functions to read and write lisp forms as bytevectors. It is intended to be reasonably machine independent, although at the current time it falls a little short. The module currently deals with reading and writing lisp forms for the pvm, socket and dbm modules.

The module exports the following interface (for use in user modules):

indentation

/ *
* obread.h
* interface for obread
* /


/ * class of the reader * /

extern LispObject object_reader;

/ * functions * /

extern void write_obj(LispObject *,LispObject, unsigned char **,
LispObject);
extern LispObject read_obj(LispObject *,unsigned char I>ast*, LispObject);

#define EUBUG(x)

The reader in its default form can read any 'simple' lisp expression that is: integers, floats, strings, symbols8, lists and vectors. The extensibility is provided via an extra argument which may be supplied to control the reader's behaviour on complex lisp types. A type here means a group of classes which can be read in the same way. The type of an object is given by the integer identifier passed to add-writer and add-reader.

make-obj-readerCompiler Makes a new reader object. The class and internals of this object are left unspecified.

add-writerCompiler
\begin{arguments}
\item[reader] A reader
\item[class] A class
\item [type-ide...
...o be called when an object of class
{\tt class} is encountered.
\end{arguments}
This function adds a new writer function, function to the given reader. The function is called when an object of class class (or one of its subclasses) is encountered by a write process. It is called with three arguments: the object to be written, a value representing write buffer and the reader which called the function. The function should call write-next with any data associated with the object.

add-readerCompiler
\begin{arguments}
\item[reader] A reader
\item [type-ident] An identifier
\item [function] A function.
\end{arguments}
This function adds a new reader function function to the given reader. The function is called whenever an object of type type-ident is encountered by a read process. It is called with two arguments: a value representing the read buffer plus the reader supplied by the caller of the read. The function then calls read-next to obtain any data associated with the object. If the function fails to consume all the data written by its corresponding write, an unhandled error condition results9.

read-nextCompiler
\begin{arguments}
\item[ptr] A pointer value
\item [reader] A reader
\end{arguments}
This function returns the next object in the read-buffer specified by ptr, using reader as the reader object. It can only be called inside the dynamic scope of a read function.

write-nextCompiler
\begin{arguments}
\item [object] the object to be written
\item [ptr] A pointer value
\item [reader] A reader
\end{arguments}
This function writes the object object onto the write-buffer specified by ptr, using reader as the reader object.



Subsections