Commit | Line | Data |
---|---|---|
7949960f JF |
1 | .ds e \s-2\e\s0 |
2 | .Lc The\ Reader 7 | |
3 | .pp | |
4 | The | |
5 | .Fr | |
6 | reader is controlled by a | |
7 | .i readtable. | |
8 | A readtable is an array of fixnums, one fixnum for each of the 128 | |
9 | ascii characters. | |
10 | The fixnums tell the reader what the properties of the each character | |
11 | are. | |
12 | The initial readtable is described below. | |
13 | The user may create new readtables using the | |
14 | .i makereadtable | |
15 | function. | |
16 | The current readtable is the value of the lisp | |
17 | symbol | |
18 | .i readtable | |
19 | which, like any lisp symbol, may be | |
20 | lambda bound to allow the user to change the | |
21 | reader syntax very quickly. | |
22 | The values which may appear in the readtable are: | |
23 | .TS | |
24 | center box; | |
25 | c | c | c | c | |
26 | ab | n | c | c . | |
27 | type value (decimal) meaning default | |
28 | = | |
29 | vnum 0 digit 0-9 | |
30 | _ | |
31 | vsign 1 plus or minus + - | |
32 | _ | |
33 | vchar 2 alphabetic character T{ | |
34 | A-Z a-z ^H ! $ % & * , / : ; < = > ? @ ^ _ ` { | } ~ | |
35 | T} | |
36 | _ | |
37 | vsca 66 single char atom none | |
38 | _ | |
39 | vlpara 195 left paren ( | |
40 | _ | |
41 | vrpara 196 right paren ) | |
42 | _ | |
43 | vperd 197 period . | |
44 | _ | |
45 | vlbrkt 198 left bracket [ | |
46 | _ | |
47 | vrbrkt 199 right bracket ] | |
48 | _ | |
49 | veof 200 end of file rubout | |
50 | _ | |
51 | vsq 201 single quote \' | |
52 | _ | |
53 | vdq 138 T{ | |
54 | double quote, all characters between matching double | |
55 | quotes are escaped (i.e. treated as \fBvchar\fP) | |
56 | T} " | |
57 | _ | |
58 | vsd 137 T{ | |
59 | string delimiter, all characters between matching | |
60 | delimiters are concated into an object of type string | |
61 | T} none | |
62 | _ | |
63 | verr 203 illegal character T{ | |
64 | null ^A-^I ^N-^Z ^\*e-^_ | |
65 | T} | |
66 | _ | |
67 | vsep 204 separator ^I-^M esc space | |
68 | _ | |
69 | vspl 205 splicing macro character none | |
70 | _ | |
71 | vmac 206 macro character none | |
72 | _ | |
73 | vesc 143 escape character \*e | |
74 | .TE | |
75 | .pp | |
76 | The names in the type column are not known to Franz, we are just using them | |
77 | to tag the various classes. You must use the value in the second column. | |
78 | The default column shows the syntax values of characters in the raw lisp, | |
79 | i.e., the lisp which contains only machine language functions. The lisp | |
80 | which you get when you give the lisp command to the shell is an augmented | |
81 | version of the raw lisp, with additional lisp coded functions and changes | |
82 | in the readtable. | |
83 | The syntax changes in the lisp may differ from installation to installation | |
84 | but will probably include making one character be a comment character. | |
85 | In the lisp at Berkeley, semicolon is the comment character. This | |
86 | was done by declaring it to be a splicing macro character which | |
87 | invokes the function | |
88 | .i zapline | |
89 | when seen. | |
90 | .pp | |
91 | To read the syntax of a character, you may use | |
92 | (\fBstatus\ syntax\fP\ 's_char). | |
93 | .pp | |
94 | To change the syntax bits of a character, use the | |
95 | .i setsyntax | |
96 | function. | |
97 | There are two forms, one when you just want to change the syntax bits, | |
98 | and the other when you want to define a character macro. | |
99 | The first form is: | |
100 | .sp 1v | |
101 | .tl ''(\fBsetsyntax\fP \fI\'s_c \'x_value\fP)'' | |
102 | .sp 1v | |
103 | Here | |
104 | .i s_c | |
105 | may be the character itself or it may be the fixnum representation | |
106 | of that character. | |
107 | .i x_value | |
108 | is one of the values given above in the second column. | |
109 | You should be careful when you change the syntax of a character | |
110 | as the change lasts until you explicitly change it back or until you | |
111 | begin with a new lisp. | |
112 | Also, some syntax changes are silly and will probably cause system | |
113 | errors (e.g. changing the syntax of an alphabetic character to be | |
114 | a | |
115 | .b vnum | |
116 | ). | |
117 | The only syntax values you will probably ever use are: | |
118 | .b vdq | |
119 | and | |
120 | .b vesc. | |
121 | You should not change the syntax to | |
122 | .b vspl | |
123 | or | |
124 | .b vmac | |
125 | using the above form, | |
126 | instead it will be done automatically when you use the form below. | |
127 | .pp | |
128 | To declare a character macro use: | |
129 | .sp 1v | |
130 | .tl ''(\fBsetsyntax\fP \fI\'s_c \'s_type \'s_fcn\fP)'' | |
131 | .sp 1v | |
132 | Where | |
133 | .i s_c | |
134 | is again either the character itself or its fixnum equivalent, | |
135 | type is | |
136 | .i splicing | |
137 | or | |
138 | .i macro, | |
139 | and | |
140 | .i s_fcn | |
141 | is either the name of | |
142 | a function expecting no arguments or is a lambda expression. | |
143 | The result of the setsyntax function is twofold: the readtable value | |
144 | for that character is changed to | |
145 | .b vspl | |
146 | or | |
147 | .b vmac, | |
148 | and the function | |
149 | is put on the property list of the character under the indicator "macro". | |
150 | The difference between a splicing macro and a macro is this: the value | |
151 | returned by a splicing macro is | |
152 | .i nconc ed | |
153 | to what has been read so far | |
154 | (i.e. (\fBnconc\fP\ sofar\ justreturned)), | |
155 | while the value returned by a macro is added to what has been read, | |
156 | (i.e (\fBnconc\fP\ sofar\ (\fBlist\fP justread)). | |
157 | Thus if a splicing macro returns nil, then it isn't seen since | |
158 | (\fBnconc\fP any nil)\ ==>\ any. | |
159 | In particular splicing macros are useful for conditional loading of | |
160 | lisp expressions. | |
161 | .pp | |
162 | .Fr | |
163 | treats left and right square brackets in a special way when | |
164 | building lists. | |
165 | A left bracket is just like a left parenthesis, and a right bracket | |
166 | matches a left bracket or all open left parentheses, whichever comes | |
167 | first. | |
168 | .pp | |
169 | When building atoms, a character with the syntax code | |
170 | .b vesc | |
171 | will cause the next character to be read in and treated as a | |
172 | .b vchar. | |
173 | To escape an entire string of characters, you surround them with matching | |
174 | characters | |
175 | having the | |
176 | .b vdq | |
177 | syntax code. | |
178 | To escape the | |
179 | .b vdq | |
180 | character within the string of characters you use any character of class | |
181 | .b vesc. | |
182 | The standard | |
183 | UNIX | |
184 | escape character, backslash (`\*e'), is in this class by default. |