XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

8  Readtable


The behavior of the reader is controlled by a data structure called a 'readtable'. The reader uses the symbol *readtable* to locate the current readtable. This table controls the interpretation of input characters. It is an array with 128 entries, one for each of the ASCII character codes. Each entry contains one of the following things:

 NIL   -   indicating an invalid character    [see nil]
:CONSTITUENT   -   indicating a symbol constituent    [see :constituent]
:WHITE-SPACE   -   indicating a whitespace character    [see :white-space]
(:TMACRO . fun)   -   terminating readmacro    [see :tmacro]
(:NMACRO . fun)   -   non-terminating readmacro    [see :nmacro]
:SESCAPE   -   single escape character '\'    [see :sescape]
:MESCAPE   -   multiple escape character '|'    [see :mescape]

In the case of :tmacro and :nmacro, the 'fun' component is a function. This can either be a built-in readmacro function or a lambda expression. The function should take two parameters. The first is the input stream and the second is the character that caused the invocation of the readmacro. The readmacro function should return NIL to indicate that the character should be treated as white space or a value consed with NIL to indicate that the readmacro should be treated as an occurence of the specified value. Of course, the readmacro code is free to read additional characters from the input stream.

XLISP defines several useful read macros:

'expr   =   (quote expr)
#'expr   =   (function expr)
#(expr...)   =   an array of the specified expressions
#xdigits   =   a hexadecimal number [0-9,A-F]
#odigits   =   an octal number [0-7]
#bdigits   =   a binary number [0-1]
#\char   =   a single character
#| ... |#   =   a comment
#:symbol   =   an uninterned symbol
`expr   =   (backquote expr)
,expr   =   (comma expr)
,@expr   =   (comma-at expr)

Characters names handled by the reader:

#\Tab   =    horiz. tab    (ASCII decimal value 9)
#\Newline   =    newline    (ASCII decimal value 10)
#\Space   =    space    (ASCII decimal value 32)

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next