3 ;;;; This software is part of the SBCL system. See the README file for
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.
12 (in-package "SB!IMPL")
17 (sb!xc:deftype attribute-table ()
18 '(simple-array (unsigned-byte 8) (#.char-code-limit)))
20 (sb!xc:defstruct (readtable (:conc-name nil)
21 (:predicate readtablep)
24 "Readtable is a data structure that maps characters into syntax
25 types for the Common Lisp expression reader."
26 ;; The CHARACTER-ATTRIBUTE-TABLE is a vector of CHAR-CODE-LIMIT
27 ;; integers for describing the character type. Conceptually, there
28 ;; are 4 distinct "primary" character attributes: WHITESPACE,
29 ;; TERMINATING-MACRO, ESCAPE, and CONSTITUENT. Non-terminating
30 ;; macros (such as the symbol reader) have the attribute
33 ;; In order to make the READ-TOKEN fast, all this information is
34 ;; stored in the character attribute table by having different
35 ;; varieties of constituents.
36 (character-attribute-table
37 (make-array char-code-limit :element-type '(unsigned-byte 8)
38 :initial-element constituent)
39 :type attribute-table)
40 ;; The CHARACTER-MACRO-TABLE is a vector of CHAR-CODE-LIMIT
41 ;; functions. One of these functions called with appropriate
42 ;; arguments whenever any non-WHITESPACE character is encountered
43 ;; inside READ-PRESERVING-WHITESPACE. These functions are used to
44 ;; implement user-defined read-macros, system read-macros, and the
45 ;; number-symbol reader.
46 (character-macro-table
47 (make-array char-code-limit :initial-element #'undefined-macro-char)
48 :type (simple-vector #.char-code-limit))
49 ;; DISPATCH-TABLES entry, which is an alist from dispatch characters
50 ;; to vectors of CHAR-CODE-LIMIT functions, for use in defining
51 ;; dispatching macros (like #-macro).
52 (dispatch-tables () :type list)
53 (readtable-case :upcase :type (member :upcase :downcase :preserve :invert)))