Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

*readtable*

*readtable*

type: system variable
location: built-in
source file: xlread.c
Common LISP compatible: related
supported on: all machines

SYNTAX

*readtable*

DESCRIPTION

The *READTABLE* is a system variable that contains XLISP's data structures relating to the processing of characters from the user (or files) and read-macro expansions. The table is 128 entries (0..127) for each of the 7-bit ASCII characters that XLISP can read. Each entry in the *READTABLE* array must be one of NIL, :CONSTITUENT, :WHITE-SPACE, :SESCAPE, :MESCAPE, a :TMACRO dotted pair or a :NMACRO dotted pair.

Table entry             Meaning
--------------------------------------------------------
NIL                     Invalid character
:CONSTITUENT            The character is valid, as is.
:WHITE-SPACE            The character may be skipped over.
:SESCAPE                The single escape character ('\');
:MESCAPE                The multiple escape character ('|');
(:TMACRO . <f> )        A terminating read-macro
(:NMACRO . <f> )        A non-terminating read-macro

In the case of :NMACRO and :TMACRO, the form of the *READTABLE* entry is a list like (:TMACRO . <function> ) or (:NMACRO . <function> ). The <function> can be a built-in read-macro function or a user defined lambda expression. The <function> takes two parameters, an input stream specification, and an integer that is the character value. The <function> should return NIL if the character is 'white-space' or a value CONSed with NIL to return the value.

EXAMPLES

*readtable*                             ; returns the current table
                                        ;
(defun look-at (table)                  ; define a function to 
 (dotimes (ch 127)                      ;   look in a table
  (prog ( (entry (aref table ch)) )     ;   and print out any     
    (case entry                         ;   entries with a function
      (NIL          NIL)                ;
      (:CONSTITUENT NIL)                ;
      (:WHITE-SPACE NIL)                ;
      (:SESCAPE     NIL)                ;
      (:MESCAPE     NIL)                ;
      (T          (princ (int-char ch)));
      )))                               ;
 (terpri))                              ;
                                        ;
(look-at *readtable*)                   ;  prints  "#'(),;`

CAUTION: If you experiment with *READTABLE*, it is useful to save the old value in a variable, so that you can restore the system state.


Go to the first, previous, next, last section, table of contents.