REDUCE

10.11 Scan Table Internals

The scan table controls the behaviour of the reader. It can be modified to extend the syntax of PSL or to aid the writing of other parsers. This table contains information about the syntax of each character. It is possible to have several tables describing different syntaxes and to switch from one to another by binding the variable lispscantable*.

The table is a vector of 129 entries, indexed by 0 through 128. The first 128 entries correspond to ASCII character code. Each entry contains an integer between 0 and 21. The meaning of these numbers is given below.

0 …9

DIGIT: indicates the character is a digit and gives the corresponding numeric value.

10

LETTER: indicates the character is alphabetic.

11

DELIMITER: indicates the character is a delimiter, the first character of a diphthong should not be classified as a delimiter.

12

COMMENT: indicates the character begins a comment, terminated by an end of line.

13

DIPHTHONG: indicates the character is a delimiter which may be the starting character of a diphthong. A diphthong is a two character sequence read as one token.

14

IDESCAPE: indicates that the character is an escape character, this character is used within id names to reference a character which is not a digit or alphabetic.

15

STRINGQUOTE: indicates that the character is used to delimit strings.

16

PACKAGE: indicates that the character is used to introduce explicit package names.

17

IGNORE: indicates that the character is to be ignored.

18

MINUS: indicates that the character represents a minus sign.

19

PLUS: indicates that the character represents a plus sign.

20

DECIMAL: indicates that the character represents a decimal point.

21

IDSURROUND: indicates that the character is to act for identifiers as a string quote for strings.

It may be tedious to insert an idescape character (!), before every delimiter character in the name of an id. By setting the type of a character (for example —), to idsurround this can be avoided. Every character between the vertical bars is taken as part of the ids name, as if ! were written before each. Note that !! corresponds to ! and !— to —.

  (PUTV LISPSCANTABLE⋆ (CHAR '|) IDSURROUND)  
 
|"|     % the same as !"  
|dave|  % the name of the id is dave not DAVE  
|!|!!|  % the name is |!, the same effect is gotten  
        % by writing !|!!

lispscantable* = [Initially: as described below] global
   
Lispscantable* associates a type with each character. It is a vector of 129 entries. The type for a character C is stored at index (CHAR C). The table below lists each character under its type. The 128’th entry is the diphthong indicator, LISPDIPHTHONG.
    DIGIT        0 through 9  
    LETTER       a through z, A through Z, #, $, &, ⋆, /,  
                 @, ;, :, <, >, =, ^, _, {, }, |, ~, ?,  
                 ^A through ^H, ^K, ^N through ^Y, ^\,^],  
                 ^^, ^_, rubout  
    DELIMITER    (, ), ', ‘, ^Z, [, ]  
    COMMENT      %  
    DIPHTHONG    ,  
    IDESCAPE     !  
    STRINGQUOTE  "  
    PACKAGE      \  
    IGNORE       null, tab, line-feed, ^L,  
                 carriage-return and space  
    MINUS        -  
    PLUS         +  
    DECIMAL      .