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 |
|||
:CONSTITUENT |
|||
:WHITE-SPACE |
|||
(:TMACRO . fun) |
|||
(:NMACRO . fun) |
|||
:SESCAPE |
|||
: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 |
||
#'expr |
||
#(expr...) |
||
#xdigits |
||
#odigits |
||
#bdigits |
||
#\char |
||
#| ... |# |
||
#:symbol |
||
`expr |
||
,expr |
||
,@expr |
Characters names handled by the reader:
#\Tab |
|||
#\Newline |
|||
#\Space |