ToC DocOverview CGDoc RelNotes Index PermutedIndex
Allegro CL
Home Previous Up Next Table of Contents Index
  ANSI Common Lisp   2 Syntax   2.1 Character Syntax

2.1.4 Character Syntax Types

The Lisp reader constructs an object from the input text by interpreting each character according to its syntax type. The Lisp reader cannot accept as input everything that the Lisp printer produces, and the Lisp reader has features that are not used by the Lisp printer. The Lisp reader can be used as a lexical analyzer for a more general user-written parser.

When the Lisp reader is invoked, it reads a single character from the input stream and dispatches according to the syntax type of that character. Every character that can appear in the input stream is of one of the syntax types shown in Figure 2.1.4 Character Syntax Types.

Possible Character Syntax Types
constituent macro character single escape
invalid multiple escape whitespace2

The syntax type of a character in a readtable determines how that character is interpreted by the Lisp reader while that readtable is the current readtable. At any given time, every character has exactly one syntax type.

Figure 2.1.4 Character Syntax Types  lists the syntax type of each character in standard syntax.

Character Syntax Types in Standard Syntax
character syntax type character syntax type
Backspace constituent 0--9 constituent
Tab whitespace2 : constituent
Newline whitespace2 ; terminating macro char
Linefeed whitespace2 < constituent
Page whitespace2 = constituent
Return whitespace2 > constituent
Space whitespace2 ? constituent*
! constituent* @ constituent
" terminating macro char A--Z constituent
# non-terminating macro char [ constituent*
$ constituent \ single escape
% constituent ] constituent*
& constituent ^ constituent
' terminating macro char _ constituent
( terminating macro char ` terminating macro char
) terminating macro char a--z constituent
* constituent { constituent*
+ constituent | multiple escape
, terminating macro char } constituent*
- constituent ~ constituent
. constituent Rubout constituent
/ constituent

The characters marked with an asterisk (*) are initially constituents, but they are not used in any standard Common Lisp notations. These characters are explicitly reserved to the programmer. ~ is not used in Common Lisp, and reserved to implementors. $ and % are alphabetic2 characters, but are not used in the names of any standard Common Lisp defined names.

Whitespace2 characters serve as separators but are otherwise ignored. Constituent and escape characters are accumulated to make a token, which is then interpreted as a number or symbol. Macro characters trigger the invocation of functions (possibly user-supplied) that can perform arbitrary parsing actions. Macro characters are divided into two kinds, terminating and non-terminating, depending on whether or not they terminate a token. The following are descriptions of each kind of syntax type.

2.1.4.1  Constituent Characters
2.1.4.2  Constituent Traits
2.1.4.3  Invalid Characters
2.1.4.4  Macro Characters
2.1.4.5  Multiple Escape Characters
2.1.4.6  Single Escape Character
2.1.4.7  Whitespace Characters


Home Previous Up Next Table of Contents Index
© Franz Inc. 1998-2019 - File last updated 02-07-2019