XLISP *readtable*

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# *readtable*

Type: | - | system variable
Source: | - | xlread.c

## 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 with the meaning of:

`NIL` | - | the character is invalid | [see nil]
`:CONSTITUENT` | - | the character is valid, as is | [see :constituent]
`:WHITE-SPACE` | - | the character may be skipped over | [see :white-space]
`:SESCAPE` | - | the single escape character '\' | [see :sescape]
`:MESCAPE` | - | the multiple escape character '|' | [see :mescape]
`(:TMACRO . fun)` | - | a terminating readmacro | [see :tmacro]
`(:NMACRO . fun)` | - | a non-terminating readmacro | [see :nmacro]

In the case of :nmacro and :tmacro , the form of the *readtable* entry is a list like:

    (:tmacro . function)
    (: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

    ;; define a function to look in a table and
    ;; print out any entries with a function

    (defun look-at (table)
      (dotimes (ch 127)
        (prog ((entry (aref table ch)))
          (case entry
            (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.

See the *readtable* system variable in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference