0.6.11.13:
[sbcl.git] / src / code / readtable.lisp
1 ;;;; READTABLEs
2
3 ;;;; This software is part of the SBCL system. See the README file for
4 ;;;; more information.
5 ;;;;
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
11
12 (in-package "SB!IMPL")
13
14 (sb!xc:deftype attribute-table ()
15   '(simple-array (unsigned-byte 8) (#.char-code-limit)))
16
17 (sb!xc:defstruct (readtable (:conc-name nil)
18                             (:predicate readtablep))
19   #!+sb-doc
20   "Readtable is a data structure that maps characters into syntax
21    types for the Common Lisp expression reader."
22   ;; The CHARACTER-ATTRIBUTE-TABLE is a vector of CHAR-CODE-LIMIT
23   ;; integers for describing the character type. Conceptually, there
24   ;; are 4 distinct "primary" character attributes: WHITESPACE,
25   ;; TERMINATING-MACRO, ESCAPE, and CONSTITUENT. Non-terminating
26   ;; macros (such as the symbol reader) have the attribute
27   ;; CONSTITUENT.
28   ;;
29   ;; In order to make the READ-TOKEN fast, all this information is
30   ;; stored in the character attribute table by having different
31   ;; varieties of constituents.
32   (character-attribute-table
33    (make-array char-code-limit
34                :element-type '(unsigned-byte 8)
35                :initial-element constituent)
36    :type attribute-table)
37   ;; The CHARACTER-MACRO-TABLE is a vector of CHAR-CODE-LIMIT
38   ;; functions. One of these functions called with appropriate
39   ;; arguments whenever any non-WHITESPACE character is encountered
40   ;; inside READ-PRESERVING-WHITESPACE. These functions are used to
41   ;; implement user-defined read-macros, system read-macros, and the
42   ;; number-symbol reader.
43   (character-macro-table
44    (make-array char-code-limit :initial-element #'undefined-macro-char)
45    :type (simple-vector #.char-code-limit))
46   ;; DISPATCH-TABLES entry, which is an alist from dispatch characters
47   ;; to vectors of CHAR-CODE-LIMIT functions, for use in defining
48   ;; dispatching macros (like #-macro).
49   (dispatch-tables () :type list)
50   (readtable-case :upcase :type (member :upcase :downcase :preserve :invert)))