0
|
1 /* XEmacs routines to deal with syntax tables; also word and list parsing.
|
|
2 Copyright (C) 1985-1994 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: FSF 19.28. */
|
|
23
|
70
|
24 /* This file has been Mule-ized. */
|
|
25
|
0
|
26 #include <config.h>
|
|
27 #include "lisp.h"
|
|
28
|
|
29 #include "buffer.h"
|
|
30 #include "commands.h"
|
|
31 #include "insdel.h"
|
|
32 #include "syntax.h"
|
|
33
|
70
|
34 /* Here is a comment from Ken'ichi HANDA <handa@etl.go.jp>
|
|
35 explaining the purpose of the Sextword syntax category:
|
|
36
|
|
37 Japanese words are not separated by spaces, which makes finding word
|
|
38 boundaries very difficult. Theoretically it's impossible without
|
|
39 using natural language processing techniques. But, by defining
|
|
40 pseudo-words as below (much simplified for letting you understand it
|
|
41 easily) for Japanese, we can have a convenient forward-word function
|
|
42 for Japanese.
|
|
43
|
|
44 A Japanese word is a sequence of characters that consists of
|
|
45 zero or more Kanji characters followed by zero or more
|
|
46 Hiragana characters.
|
|
47
|
|
48 Then, the problem is that now we can't say that a sequence of
|
|
49 word-constituents makes up a WORD. For instance, both Hiragana "A"
|
|
50 and Kanji "KAN" are word-constituents but the sequence of these two
|
|
51 letters can't be a single word.
|
|
52
|
|
53 So, we introduced Sextword for Japanese letters. A character of
|
|
54 Sextword is a word-constituent but a word boundary may exist between
|
|
55 two such characters. */
|
|
56
|
|
57 /* Mule 2.4 doesn't seem to have Sextword - I'm removing it -- mrb */
|
|
58
|
0
|
59 Lisp_Object Qsyntax_table_p;
|
|
60
|
|
61 int words_include_escapes;
|
|
62
|
|
63 int parse_sexp_ignore_comments;
|
|
64
|
|
65 /* The following two variables are provided to tell additional information
|
|
66 to the regex routines. We do it this way rather than change the
|
|
67 arguments to re_search_2() in an attempt to maintain some call
|
|
68 compatibility with other versions of the regex code. */
|
|
69
|
|
70 /* Tell the regex routines not to QUIT. Normally there is a QUIT
|
|
71 each iteration in re_search_2(). */
|
|
72 int no_quit_in_re_search;
|
|
73
|
|
74 /* Tell the regex routines which buffer to access for SYNTAX() lookups
|
|
75 and the like. */
|
|
76 struct buffer *regex_emacs_buffer;
|
|
77
|
|
78 Lisp_Object Vstandard_syntax_table;
|
|
79
|
|
80 Lisp_Object Vsyntax_designator_chars_string;
|
|
81
|
|
82 /* This is the internal form of the parse state used in parse-partial-sexp. */
|
|
83
|
|
84 struct lisp_parse_state
|
2
|
85 {
|
|
86 int depth; /* Depth at end of parsing */
|
|
87 Emchar instring; /* -1 if not within string, else desired terminator */
|
|
88 int incomment; /* Nonzero if within a comment at end of parsing */
|
|
89 int comstyle; /* comment style a=0, or b=1 */
|
|
90 int quoted; /* Nonzero if just after an escape char at end of
|
0
|
91 parsing */
|
2
|
92 Bufpos thislevelstart;/* Char number of most recent start-of-expression
|
|
93 at current level */
|
|
94 Bufpos prevlevelstart;/* Char number of start of containing expression */
|
|
95 Bufpos location; /* Char number at which parsing stopped */
|
|
96 int mindepth; /* Minimum depth seen while scanning */
|
|
97 Bufpos comstart; /* Position just after last comment starter */
|
|
98 };
|
0
|
99
|
|
100 /* These variables are a cache for finding the start of a defun.
|
2
|
101 find_start_pos is the place for which the defun start was found.
|
|
102 find_start_value is the defun start position found for it.
|
0
|
103 find_start_buffer is the buffer it was found in.
|
2
|
104 find_start_begv is the BEGV value when it was found.
|
0
|
105 find_start_modiff is the value of MODIFF when it was found. */
|
|
106
|
|
107 static Bufpos find_start_pos;
|
|
108 static Bufpos find_start_value;
|
|
109 static struct buffer *find_start_buffer;
|
|
110 static Bufpos find_start_begv;
|
|
111 static int find_start_modiff;
|
|
112
|
|
113 /* Find a defun-start that is the last one before POS (or nearly the last).
|
|
114 We record what we find, so that another call in the same area
|
|
115 can return the same value right away. */
|
|
116
|
|
117 static Bufpos
|
|
118 find_defun_start (struct buffer *buf, Bufpos pos)
|
|
119 {
|
|
120 Bufpos tem;
|
70
|
121 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
122
|
|
123 /* Use previous finding, if it's valid and applies to this inquiry. */
|
|
124 if (buf == find_start_buffer
|
|
125 /* Reuse the defun-start even if POS is a little farther on.
|
|
126 POS might be in the next defun, but that's ok.
|
|
127 Our value may not be the best possible, but will still be usable. */
|
|
128 && pos <= find_start_pos + 1000
|
|
129 && pos >= find_start_value
|
|
130 && BUF_BEGV (buf) == find_start_begv
|
|
131 && BUF_MODIFF (buf) == find_start_modiff)
|
|
132 return find_start_value;
|
|
133
|
|
134 /* Back up to start of line. */
|
|
135 tem = find_next_newline (buf, pos, -1);
|
|
136
|
|
137 while (tem > BUF_BEGV (buf))
|
|
138 {
|
|
139 /* Open-paren at start of line means we found our defun-start. */
|
70
|
140 if (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, tem)) == Sopen)
|
0
|
141 break;
|
|
142 /* Move to beg of previous line. */
|
|
143 tem = find_next_newline (buf, tem, -2);
|
|
144 }
|
|
145
|
|
146 /* Record what we found, for the next try. */
|
2
|
147 find_start_value = tem;
|
0
|
148 find_start_buffer = buf;
|
|
149 find_start_modiff = BUF_MODIFF (buf);
|
2
|
150 find_start_begv = BUF_BEGV (buf);
|
|
151 find_start_pos = pos;
|
0
|
152
|
|
153 return find_start_value;
|
|
154 }
|
|
155
|
20
|
156 DEFUN ("syntax-table-p", Fsyntax_table_p, 1, 1, 0, /*
|
0
|
157 Return t if ARG is a syntax table.
|
|
158 Any vector of 256 elements will do.
|
20
|
159 */
|
|
160 (obj))
|
0
|
161 {
|
70
|
162 if (CHAR_TABLEP (obj) && XCHAR_TABLE_TYPE (obj) == CHAR_TABLE_TYPE_SYNTAX)
|
0
|
163 return Qt;
|
|
164 return Qnil;
|
|
165 }
|
|
166
|
|
167 static Lisp_Object
|
|
168 check_syntax_table (Lisp_Object obj, Lisp_Object def)
|
|
169 {
|
|
170 if (NILP (obj))
|
|
171 obj = def;
|
|
172 while (NILP (Fsyntax_table_p (obj)))
|
|
173 obj = wrong_type_argument (Qsyntax_table_p, obj);
|
|
174 return (obj);
|
|
175 }
|
|
176
|
20
|
177 DEFUN ("syntax-table", Fsyntax_table, 0, 1, 0, /*
|
0
|
178 Return the current syntax table.
|
|
179 This is the one specified by the current buffer, or by BUFFER if it
|
|
180 is non-nil.
|
20
|
181 */
|
|
182 (buffer))
|
0
|
183 {
|
|
184 return decode_buffer (buffer, 0)->syntax_table;
|
|
185 }
|
|
186
|
20
|
187 DEFUN ("standard-syntax-table", Fstandard_syntax_table, 0, 0, 0, /*
|
0
|
188 Return the standard syntax table.
|
|
189 This is the one used for new buffers.
|
20
|
190 */
|
|
191 ())
|
0
|
192 {
|
|
193 return Vstandard_syntax_table;
|
|
194 }
|
|
195
|
20
|
196 DEFUN ("copy-syntax-table", Fcopy_syntax_table, 0, 1, 0, /*
|
0
|
197 Construct a new syntax table and return it.
|
|
198 It is a copy of the TABLE, which defaults to the standard syntax table.
|
20
|
199 */
|
|
200 (table))
|
0
|
201 {
|
|
202 if (NILP (Vstandard_syntax_table))
|
70
|
203 return Fmake_char_table (Qsyntax);
|
0
|
204
|
|
205 table = check_syntax_table (table, Vstandard_syntax_table);
|
70
|
206 return Fcopy_char_table (table);
|
0
|
207 }
|
|
208
|
20
|
209 DEFUN ("set-syntax-table", Fset_syntax_table, 1, 2, 0, /*
|
0
|
210 Select a new syntax table for BUFFER.
|
|
211 One argument, a syntax table.
|
|
212 BUFFER defaults to the current buffer if omitted.
|
20
|
213 */
|
|
214 (table, buffer))
|
0
|
215 {
|
|
216 struct buffer *buf = decode_buffer (buffer, 0);
|
|
217 table = check_syntax_table (table, Qnil);
|
|
218 buf->syntax_table = table;
|
70
|
219 buf->mirror_syntax_table = XCHAR_TABLE (table)->mirror_table;
|
0
|
220 /* Indicate that this buffer now has a specified syntax table. */
|
|
221 buf->local_var_flags |= XINT (buffer_local_flags.syntax_table);
|
|
222 return table;
|
|
223 }
|
|
224
|
|
225 /* Convert a letter which signifies a syntax code
|
2
|
226 into the code it signifies.
|
|
227 This is used by modify-syntax-entry, and other things. */
|
0
|
228
|
|
229 CONST unsigned char syntax_spec_code[0400] =
|
70
|
230 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
|
|
231 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
|
|
232 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
|
|
233 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
|
|
234 (char) Swhitespace, 0377, (char) Sstring, 0377,
|
|
235 (char) Smath, 0377, 0377, (char) Squote,
|
|
236 (char) Sopen, (char) Sclose, 0377, 0377,
|
0
|
237 0377, (char) Swhitespace, (char) Spunct, (char) Scharquote,
|
70
|
238 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
|
|
239 0377, 0377, 0377, 0377,
|
0
|
240 (char) Scomment, 0377, (char) Sendcomment, 0377,
|
70
|
241 (char) Sinherit, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */
|
|
242 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
|
|
243 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
|
|
244 0377, 0377, 0377, 0377, (char) Sescape, 0377, 0377, (char) Ssymbol,
|
|
245 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */
|
|
246 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
|
|
247 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
|
|
248 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377
|
|
249 };
|
0
|
250
|
70
|
251 CONST unsigned char syntax_code_spec[] = " .w_()'\"$\\/<>@";
|
0
|
252
|
20
|
253 DEFUN ("syntax-designator-chars", Fsyntax_designator_chars, 0, 0, 0, /*
|
0
|
254 Return a string of the recognized syntax designator chars.
|
|
255 The chars are ordered by their internal syntax codes, which are
|
|
256 numbered starting at 0.
|
20
|
257 */
|
|
258 ())
|
0
|
259 {
|
|
260 return Vsyntax_designator_chars_string;
|
|
261 }
|
|
262
|
20
|
263 DEFUN ("char-syntax", Fchar_syntax, 1, 2, 0, /*
|
0
|
264 Return the syntax code of CHAR, described by a character.
|
|
265 For example, if CHAR is a word constituent, the character `?w' is returned.
|
|
266 The characters that correspond to various syntax codes
|
|
267 are listed in the documentation of `modify-syntax-entry'.
|
|
268 Optional second argument TABLE defaults to the current buffer's
|
|
269 syntax table.
|
20
|
270 */
|
|
271 (ch, table))
|
0
|
272 {
|
70
|
273 struct Lisp_Char_Table *mirrortab;
|
|
274
|
159
|
275 if (NILP(ch))
|
|
276 {
|
|
277 return Qnil;
|
|
278 }
|
0
|
279 CHECK_CHAR_COERCE_INT (ch);
|
|
280 table = check_syntax_table (table, current_buffer->syntax_table);
|
70
|
281 mirrortab = XCHAR_TABLE (XCHAR_TABLE (table)->mirror_table);
|
|
282 return make_char (syntax_code_spec[(int) SYNTAX (mirrortab, XCHAR (ch))]);
|
0
|
283 }
|
|
284
|
70
|
285 #ifdef MULE
|
|
286
|
|
287 enum syntaxcode
|
|
288 charset_syntax (struct buffer *buf, Lisp_Object charset, int *multi_p_out)
|
|
289 {
|
|
290 *multi_p_out = 1;
|
|
291 /* #### get this right */
|
|
292 return Spunct;
|
|
293 }
|
|
294
|
|
295 #endif
|
0
|
296
|
|
297 Lisp_Object
|
|
298 syntax_match (Lisp_Object table, Emchar ch)
|
|
299 {
|
70
|
300 Lisp_Object code = CHAR_TABLE_VALUE_UNSAFE (XCHAR_TABLE (table), ch);
|
|
301 Lisp_Object code2 = code;
|
0
|
302
|
70
|
303 if (CONSP (code))
|
|
304 code2 = XCAR (code);
|
|
305 if (SYNTAX_FROM_CODE (XINT (code2)) == Sinherit)
|
|
306 code = CHAR_TABLE_VALUE_UNSAFE (XCHAR_TABLE (Vstandard_syntax_table),
|
|
307 ch);
|
|
308 if (CONSP (code))
|
|
309 return XCDR (code);
|
|
310 else
|
0
|
311 return Qnil;
|
|
312 }
|
|
313
|
20
|
314 DEFUN ("matching-paren", Fmatching_paren, 1, 2, 0, /*
|
0
|
315 Return the matching parenthesis of CHAR, or nil if none.
|
|
316 Optional second argument TABLE defaults to the current buffer's
|
|
317 syntax table.
|
20
|
318 */
|
|
319 (ch, table))
|
0
|
320 {
|
70
|
321 struct Lisp_Char_Table *mirrortab;
|
0
|
322 int code;
|
|
323
|
70
|
324 CHECK_CHAR_COERCE_INT (ch);
|
0
|
325 table = check_syntax_table (table, current_buffer->syntax_table);
|
70
|
326 mirrortab = XCHAR_TABLE (XCHAR_TABLE (table)->mirror_table);
|
|
327 code = SYNTAX (mirrortab, XCHAR (ch));
|
0
|
328 if (code == Sopen || code == Sclose || code == Sstring)
|
|
329 return syntax_match (table, XCHAR (ch));
|
|
330 return Qnil;
|
|
331 }
|
|
332
|
|
333
|
70
|
334
|
78
|
335 static int
|
70
|
336 word_constituent_p (struct buffer *buf, Bufpos pos,
|
|
337 struct Lisp_Char_Table *tab)
|
|
338 {
|
|
339 enum syntaxcode code = SYNTAX_UNSAFE (tab, BUF_FETCH_CHAR (buf, pos));
|
|
340 return ((words_include_escapes &&
|
|
341 (code == Sescape || code == Scharquote))
|
|
342 || (code == Sword));
|
|
343 }
|
|
344
|
0
|
345 /* Return the position across COUNT words from FROM.
|
|
346 If that many words cannot be found before the end of the buffer, return 0.
|
|
347 COUNT negative means scan backward and stop at word beginning. */
|
|
348
|
|
349 Bufpos
|
|
350 scan_words (struct buffer *buf, Bufpos from, int count)
|
|
351 {
|
70
|
352 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
|
|
353 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
354 while (count > 0)
|
|
355 {
|
|
356 QUIT;
|
|
357
|
|
358 while (1)
|
|
359 {
|
70
|
360 if (from == limit)
|
|
361 return 0;
|
|
362 if (word_constituent_p (buf, from, mirrortab))
|
0
|
363 break;
|
|
364 from++;
|
|
365 }
|
|
366
|
|
367 QUIT;
|
|
368
|
70
|
369 while ((from != limit) && word_constituent_p (buf, from, mirrortab))
|
0
|
370 {
|
|
371 from++;
|
|
372 }
|
|
373 count--;
|
|
374 }
|
70
|
375
|
0
|
376 while (count < 0)
|
|
377 {
|
|
378 QUIT;
|
|
379
|
|
380 while (1)
|
|
381 {
|
70
|
382 if (from == limit)
|
|
383 return 0;
|
|
384 if (word_constituent_p (buf, from - 1, mirrortab))
|
0
|
385 break;
|
|
386 from--;
|
|
387 }
|
|
388
|
|
389 QUIT;
|
|
390
|
70
|
391 while ((from != limit) && word_constituent_p (buf, from - 1, mirrortab))
|
0
|
392 {
|
|
393 from--;
|
|
394 }
|
|
395 count++;
|
|
396 }
|
|
397
|
|
398 return from;
|
|
399 }
|
|
400
|
20
|
401 DEFUN ("forward-word", Fforward_word, 1, 2, "_p", /*
|
0
|
402 Move point forward ARG words (backward if ARG is negative).
|
|
403 Normally returns t.
|
|
404 If an edge of the buffer is reached, point is left there
|
|
405 and nil is returned.
|
20
|
406 */
|
|
407 (count, buffer))
|
0
|
408 {
|
|
409 Bufpos val;
|
|
410 struct buffer *buf = decode_buffer (buffer, 0);
|
|
411 CHECK_INT (count);
|
|
412
|
|
413 if (!(val = scan_words (buf, BUF_PT (buf), XINT (count))))
|
|
414 {
|
|
415 BUF_SET_PT (buf, XINT (count) > 0 ? BUF_ZV (buf) : BUF_BEGV (buf));
|
|
416 return Qnil;
|
|
417 }
|
|
418 BUF_SET_PT (buf, val);
|
|
419 return Qt;
|
|
420 }
|
|
421
|
|
422 static void scan_sexps_forward (struct buffer *buf,
|
|
423 struct lisp_parse_state *,
|
|
424 Bufpos from, Bufpos end,
|
|
425 int targetdepth, int stopbefore,
|
|
426 Lisp_Object oldstate,
|
|
427 int commentstop);
|
|
428
|
|
429 static int
|
|
430 find_start_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask)
|
|
431 {
|
|
432 Emchar c;
|
|
433 enum syntaxcode code;
|
70
|
434 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
435
|
|
436 /* Look back, counting the parity of string-quotes,
|
|
437 and recording the comment-starters seen.
|
|
438 When we reach a safe place, assume that's not in a string;
|
|
439 then step the main scan to the earliest comment-starter seen
|
|
440 an even number of string quotes away from the safe place.
|
|
441
|
|
442 OFROM[I] is position of the earliest comment-starter seen
|
|
443 which is I+2X quotes from the comment-end.
|
|
444 PARITY is current parity of quotes from the comment end. */
|
|
445 int parity = 0;
|
|
446 Emchar my_stringend = 0;
|
|
447 int string_lossage = 0;
|
|
448 Bufpos comment_end = from;
|
|
449 Bufpos comstart_pos = 0;
|
|
450 int comstart_parity = 0;
|
|
451 int styles_match_p = 0;
|
|
452
|
|
453 /* At beginning of range to scan, we're outside of strings;
|
|
454 that determines quote parity to the comment-end. */
|
|
455 while (from != stop)
|
|
456 {
|
|
457 /* Move back and examine a character. */
|
|
458 from--;
|
|
459
|
|
460 c = BUF_FETCH_CHAR (buf, from);
|
70
|
461 code = SYNTAX_UNSAFE (mirrortab, c);
|
0
|
462
|
|
463 /* is this a 1-char comment end sequence? if so, try
|
|
464 to see if style matches previously extracted mask */
|
|
465 if (code == Sendcomment)
|
|
466 {
|
70
|
467 styles_match_p = SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask);
|
0
|
468 }
|
|
469
|
|
470 /* otherwise, is this a 2-char comment end sequence? */
|
|
471 else if (from >= stop
|
70
|
472 && SYNTAX_END_P (mirrortab, c, BUF_FETCH_CHAR (buf, from+1)))
|
0
|
473 {
|
|
474 code = Sendcomment;
|
|
475 styles_match_p =
|
70
|
476 SYNTAX_STYLES_MATCH_END_P (mirrortab, c,
|
0
|
477 BUF_FETCH_CHAR (buf, from+1),
|
|
478 mask);
|
|
479 }
|
|
480
|
|
481 /* or are we looking at a 1-char comment start sequence
|
|
482 of the style matching mask? */
|
|
483 else if (code == Scomment
|
70
|
484 && SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask))
|
0
|
485 {
|
|
486 styles_match_p = 1;
|
|
487 }
|
|
488
|
|
489 /* or possibly, a 2-char comment start sequence */
|
|
490 else if (from >= stop
|
70
|
491 && SYNTAX_STYLES_MATCH_START_P (mirrortab, c,
|
0
|
492 BUF_FETCH_CHAR (buf, from+1),
|
|
493 mask))
|
|
494 {
|
|
495 code = Scomment;
|
|
496 styles_match_p = 1;
|
|
497 }
|
|
498
|
|
499 /* Ignore escaped characters. */
|
|
500 if (char_quoted (buf, from))
|
|
501 continue;
|
|
502
|
|
503 /* Track parity of quotes. */
|
|
504 if (code == Sstring)
|
|
505 {
|
|
506 parity ^= 1;
|
|
507 if (my_stringend == 0)
|
|
508 my_stringend = c;
|
|
509 /* If we have two kinds of string delimiters.
|
|
510 There's no way to grok this scanning backwards. */
|
|
511 else if (my_stringend != c)
|
|
512 string_lossage = 1;
|
|
513 }
|
|
514
|
|
515 /* Record comment-starters according to that
|
|
516 quote-parity to the comment-end. */
|
|
517 if (code == Scomment && styles_match_p)
|
|
518 {
|
|
519 comstart_parity = parity;
|
|
520 comstart_pos = from;
|
|
521 }
|
|
522
|
|
523 /* If we find another earlier comment-ender,
|
|
524 any comment-starts earlier than that don't count
|
|
525 (because they go with the earlier comment-ender). */
|
|
526 if (code == Sendcomment && styles_match_p)
|
|
527 break;
|
|
528
|
|
529 /* Assume a defun-start point is outside of strings. */
|
|
530 if (code == Sopen
|
|
531 && (from == stop || BUF_FETCH_CHAR (buf, from - 1) == '\n'))
|
|
532 break;
|
|
533 }
|
|
534
|
|
535 if (comstart_pos == 0)
|
|
536 from = comment_end;
|
|
537 /* If the earliest comment starter
|
|
538 is followed by uniform paired string quotes or none,
|
|
539 we know it can't be inside a string
|
|
540 since if it were then the comment ender would be inside one.
|
|
541 So it does start a comment. Skip back to it. */
|
|
542 else if (comstart_parity == 0 && !string_lossage)
|
|
543 from = comstart_pos;
|
|
544 else
|
|
545 {
|
|
546 /* We had two kinds of string delimiters mixed up
|
|
547 together. Decode this going forwards.
|
|
548 Scan fwd from the previous comment ender
|
|
549 to the one in question; this records where we
|
|
550 last passed a comment starter. */
|
|
551
|
|
552 struct lisp_parse_state state;
|
|
553 scan_sexps_forward (buf, &state, find_defun_start (buf, comment_end),
|
|
554 comment_end - 1, -10000, 0, Qnil, 0);
|
|
555 if (state.incomment)
|
|
556 from = state.comstart;
|
|
557 else
|
|
558 /* We can't grok this as a comment; scan it normally. */
|
|
559 from = comment_end;
|
|
560 }
|
|
561 return from;
|
|
562 }
|
|
563
|
|
564 static Bufpos
|
|
565 find_end_of_comment (struct buffer *buf, Bufpos from, Bufpos stop, int mask)
|
|
566 {
|
|
567 int c;
|
70
|
568 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
569
|
|
570 while (1)
|
|
571 {
|
|
572 if (from == stop)
|
|
573 {
|
|
574 return -1;
|
|
575 }
|
|
576 c = BUF_FETCH_CHAR (buf, from);
|
70
|
577 if (SYNTAX_UNSAFE (mirrortab, c) == Sendcomment
|
|
578 && SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask))
|
0
|
579 /* we have encountered a comment end of the same style
|
|
580 as the comment sequence which began this comment
|
|
581 section */
|
|
582 break;
|
|
583
|
|
584 from++;
|
|
585 if (from < stop
|
70
|
586 && SYNTAX_STYLES_MATCH_END_P (mirrortab, c,
|
0
|
587 BUF_FETCH_CHAR (buf, from), mask))
|
|
588 /* we have encountered a comment end of the same style
|
|
589 as the comment sequence which began this comment
|
|
590 section */
|
|
591 { from++; break; }
|
|
592 }
|
|
593 return from;
|
|
594 }
|
|
595
|
|
596
|
|
597 /* #### between FSF 19.23 and 19.28 there are some changes to the logic
|
|
598 in this function (and minor changes to find_start_of_comment(),
|
|
599 above, which is part of Fforward_comment() in FSF). Attempts to port
|
|
600 that logic made this function break, so I'm leaving it out. If anyone
|
|
601 ever complains about this function not working properly, take a look
|
|
602 at those changes. --ben */
|
|
603
|
20
|
604 DEFUN ("forward-comment", Fforward_comment, 1, 2, 0, /*
|
0
|
605 Move forward across up to N comments. If N is negative, move backward.
|
|
606 Stop scanning if we find something other than a comment or whitespace.
|
|
607 Set point to where scanning stops.
|
|
608 If N comments are found as expected, with nothing except whitespace
|
|
609 between them, return t; otherwise return nil.
|
|
610 Point is set in either case.
|
|
611 Optional argument BUFFER defaults to the current buffer.
|
20
|
612 */
|
|
613 (n, buffer))
|
0
|
614 {
|
|
615 Bufpos from;
|
|
616 Bufpos stop;
|
|
617 Emchar c;
|
|
618 enum syntaxcode code;
|
|
619 int count;
|
|
620 struct buffer *buf = decode_buffer (buffer, 0);
|
70
|
621 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
622
|
|
623 CHECK_INT (n);
|
|
624 count = XINT (n);
|
|
625
|
|
626 from = BUF_PT (buf);
|
|
627
|
|
628 while (count > 0)
|
|
629 {
|
|
630 QUIT;
|
|
631
|
|
632 stop = BUF_ZV (buf);
|
|
633 while (from < stop)
|
|
634 {
|
|
635 int mask = 0; /* mask for finding matching comment style */
|
|
636
|
|
637 if (char_quoted (buf, from))
|
|
638 {
|
|
639 from++;
|
|
640 continue;
|
|
641 }
|
|
642
|
|
643 c = BUF_FETCH_CHAR (buf, from);
|
70
|
644 code = SYNTAX (mirrortab, c);
|
0
|
645
|
|
646 if (code == Scomment)
|
|
647 {
|
|
648 /* we have encountered a single character comment start
|
|
649 sequence, and we are ignoring all text inside comments.
|
|
650 we must record the comment style this character begins
|
|
651 so that later, only a comment end of the same style actually
|
|
652 ends the comment section */
|
70
|
653 mask = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c);
|
0
|
654 }
|
|
655
|
|
656 else if (from < stop
|
70
|
657 && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from+1)))
|
0
|
658 {
|
|
659 /* we have encountered a 2char comment start sequence and we
|
|
660 are ignoring all text inside comments. we must record
|
|
661 the comment style this sequence begins so that later,
|
|
662 only a comment end of the same style actually ends
|
|
663 the comment section */
|
|
664 code = Scomment;
|
70
|
665 mask = SYNTAX_COMMENT_MASK_START (mirrortab, c,
|
0
|
666 BUF_FETCH_CHAR (buf, from+1));
|
|
667 from++;
|
|
668 }
|
|
669
|
|
670 if (code == Scomment)
|
|
671 {
|
|
672 Bufpos newfrom;
|
|
673
|
|
674 newfrom = find_end_of_comment (buf, from, stop, mask);
|
|
675 if (newfrom < 0)
|
|
676 {
|
|
677 /* we stopped because from==stop */
|
|
678 BUF_SET_PT (buf, stop);
|
|
679 return Qnil;
|
|
680 }
|
|
681 from = newfrom;
|
|
682
|
|
683 /* We have skipped one comment. */
|
|
684 break;
|
|
685 }
|
|
686 else if (code != Swhitespace
|
|
687 && code != Sendcomment
|
|
688 && code != Scomment )
|
|
689 {
|
|
690 BUF_SET_PT (buf, from);
|
|
691 return Qnil;
|
|
692 }
|
|
693 from++;
|
|
694 }
|
|
695
|
|
696 /* End of comment reached */
|
|
697 count--;
|
|
698 }
|
|
699
|
|
700 while (count < 0)
|
|
701 {
|
|
702 QUIT;
|
|
703
|
|
704 stop = BUF_BEGV (buf);
|
|
705 while (from > stop)
|
|
706 {
|
|
707 int mask = 0; /* mask for finding matching comment style */
|
|
708
|
|
709 from--;
|
|
710 if (char_quoted (buf, from))
|
|
711 {
|
|
712 from--;
|
|
713 continue;
|
|
714 }
|
|
715
|
|
716 c = BUF_FETCH_CHAR (buf, from);
|
70
|
717 code = SYNTAX (mirrortab, c);
|
0
|
718
|
|
719 if (code == Sendcomment)
|
|
720 {
|
|
721 /* we have found a single char end comment. we must record
|
|
722 the comment style encountered so that later, we can match
|
|
723 only the proper comment begin sequence of the same style */
|
70
|
724 mask = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c);
|
0
|
725 }
|
|
726
|
|
727 else if (from > stop
|
70
|
728 && SYNTAX_END_P (mirrortab, BUF_FETCH_CHAR (buf, from - 1), c)
|
0
|
729 && !char_quoted (buf, from - 1))
|
|
730 {
|
|
731 /* We must record the comment style encountered so that
|
|
732 later, we can match only the proper comment begin
|
|
733 sequence of the same style. */
|
|
734 code = Sendcomment;
|
70
|
735 mask = SYNTAX_COMMENT_MASK_END (mirrortab,
|
0
|
736 BUF_FETCH_CHAR (buf, from - 1),
|
|
737 c);
|
|
738 from--;
|
|
739 }
|
|
740
|
|
741 if (code == Sendcomment)
|
|
742 {
|
|
743 from = find_start_of_comment (buf, from, stop, mask);
|
|
744 break;
|
|
745 }
|
|
746
|
|
747 else if (code != Swhitespace
|
70
|
748 && SYNTAX (mirrortab, c) != Scomment
|
|
749 && SYNTAX (mirrortab, c) != Sendcomment)
|
0
|
750 {
|
|
751 BUF_SET_PT (buf, from + 1);
|
|
752 return Qnil;
|
|
753 }
|
|
754 }
|
|
755
|
|
756 count++;
|
|
757 }
|
|
758
|
|
759 BUF_SET_PT (buf, from);
|
|
760 return Qt;
|
|
761 }
|
|
762
|
|
763
|
|
764 Lisp_Object
|
|
765 scan_lists (struct buffer *buf, Bufpos from, int count, int depth,
|
|
766 int sexpflag, int no_error)
|
|
767 {
|
|
768 Bufpos stop;
|
|
769 Emchar c;
|
|
770 int quoted;
|
|
771 int mathexit = 0;
|
|
772 enum syntaxcode code;
|
|
773 int min_depth = depth; /* Err out if depth gets less than this. */
|
70
|
774 Lisp_Object syntaxtab = buf->syntax_table;
|
|
775 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
776
|
|
777 if (depth > 0) min_depth = 0;
|
|
778
|
|
779 while (count > 0)
|
|
780 {
|
|
781 QUIT;
|
|
782
|
|
783 stop = BUF_ZV (buf);
|
|
784 while (from < stop)
|
|
785 {
|
|
786 int mask = 0; /* mask for finding matching comment style */
|
|
787
|
|
788 c = BUF_FETCH_CHAR (buf, from);
|
70
|
789 code = SYNTAX_UNSAFE (mirrortab, c);
|
0
|
790 from++;
|
|
791
|
|
792 /* a 1-char comment start sequence */
|
|
793 if (code == Scomment && parse_sexp_ignore_comments)
|
|
794 {
|
70
|
795 mask = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c);
|
0
|
796 }
|
|
797
|
|
798 /* else, a 2-char comment start sequence? */
|
|
799 else if (from < stop
|
70
|
800 && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from))
|
0
|
801 && parse_sexp_ignore_comments)
|
|
802 {
|
|
803 /* we have encountered a comment start sequence and we
|
|
804 are ignoring all text inside comments. we must record
|
|
805 the comment style this sequence begins so that later,
|
|
806 only a comment end of the same style actually ends
|
|
807 the comment section */
|
|
808 code = Scomment;
|
70
|
809 mask = SYNTAX_COMMENT_MASK_START (mirrortab, c,
|
0
|
810 BUF_FETCH_CHAR (buf, from));
|
|
811 from++;
|
|
812 }
|
|
813
|
70
|
814 if (SYNTAX_PREFIX_UNSAFE (mirrortab, c))
|
0
|
815 continue;
|
|
816
|
|
817 switch (code)
|
|
818 {
|
|
819 case Sescape:
|
|
820 case Scharquote:
|
|
821 if (from == stop) goto lose;
|
|
822 from++;
|
|
823 /* treat following character as a word constituent */
|
|
824 case Sword:
|
|
825 case Ssymbol:
|
|
826 if (depth || !sexpflag) break;
|
|
827 /* This word counts as a sexp; return at end of it. */
|
|
828 while (from < stop)
|
|
829 {
|
70
|
830 switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
|
0
|
831 {
|
|
832 case Scharquote:
|
|
833 case Sescape:
|
|
834 from++;
|
|
835 if (from == stop) goto lose;
|
|
836 break;
|
|
837 case Sword:
|
|
838 case Ssymbol:
|
|
839 case Squote:
|
|
840 break;
|
|
841 default:
|
|
842 goto done;
|
|
843 }
|
|
844 from++;
|
|
845 }
|
|
846 goto done;
|
|
847
|
|
848 case Scomment:
|
|
849 if (!parse_sexp_ignore_comments)
|
|
850 break;
|
|
851 {
|
|
852 Bufpos newfrom = find_end_of_comment (buf, from, stop, mask);
|
|
853 if (newfrom < 0)
|
|
854 {
|
|
855 /* we stopped because from == stop in search forward */
|
|
856 from = stop;
|
|
857 if (depth == 0)
|
|
858 goto done;
|
|
859 goto lose;
|
|
860 }
|
|
861 from = newfrom;
|
|
862 }
|
|
863 break;
|
|
864
|
|
865 case Smath:
|
|
866 if (!sexpflag)
|
|
867 break;
|
|
868 if (from != stop && c == BUF_FETCH_CHAR (buf, from))
|
|
869 from++;
|
|
870 if (mathexit)
|
|
871 {
|
|
872 mathexit = 0;
|
|
873 goto close1;
|
|
874 }
|
|
875 mathexit = 1;
|
|
876
|
|
877 case Sopen:
|
|
878 if (!++depth) goto done;
|
|
879 break;
|
|
880
|
|
881 case Sclose:
|
|
882 close1:
|
|
883 if (!--depth) goto done;
|
|
884 if (depth < min_depth)
|
|
885 {
|
|
886 if (no_error)
|
|
887 return Qnil;
|
|
888 error ("Containing expression ends prematurely");
|
|
889 }
|
|
890 break;
|
|
891
|
|
892 case Sstring:
|
|
893 {
|
|
894 /* XEmacs change: call syntax_match on character */
|
|
895 Emchar ch = BUF_FETCH_CHAR (buf, from - 1);
|
70
|
896 Lisp_Object stermobj = syntax_match (syntaxtab, ch);
|
0
|
897 Emchar stringterm;
|
|
898
|
|
899 if (CHARP (stermobj))
|
|
900 stringterm = XCHAR (stermobj);
|
|
901 else
|
|
902 stringterm = ch;
|
|
903
|
|
904 while (1)
|
|
905 {
|
|
906 if (from >= stop)
|
|
907 goto lose;
|
|
908 if (BUF_FETCH_CHAR (buf, from) == stringterm)
|
|
909 break;
|
70
|
910 switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
|
0
|
911 {
|
|
912 case Scharquote:
|
|
913 case Sescape:
|
|
914 from++;
|
|
915 break;
|
|
916 default:
|
|
917 break;
|
|
918 }
|
|
919 from++;
|
|
920 }
|
|
921 from++;
|
|
922 if (!depth && sexpflag) goto done;
|
|
923 break;
|
|
924 }
|
|
925
|
|
926 default:
|
|
927 break;
|
|
928 }
|
|
929 }
|
|
930
|
|
931 /* Reached end of buffer. Error if within object,
|
|
932 return nil if between */
|
|
933 if (depth) goto lose;
|
|
934
|
|
935 return Qnil;
|
|
936
|
|
937 /* End of object reached */
|
|
938 done:
|
|
939 count--;
|
|
940 }
|
|
941
|
|
942 while (count < 0)
|
|
943 {
|
|
944 QUIT;
|
|
945
|
|
946 stop = BUF_BEGV (buf);
|
|
947 while (from > stop)
|
|
948 {
|
|
949 int mask = 0; /* mask for finding matching comment style */
|
|
950
|
|
951 from--;
|
|
952 quoted = char_quoted (buf, from);
|
|
953 if (quoted)
|
|
954 from--;
|
|
955
|
|
956 c = BUF_FETCH_CHAR (buf, from);
|
70
|
957 code = SYNTAX_UNSAFE (mirrortab, c);
|
0
|
958
|
|
959 if (code == Sendcomment && parse_sexp_ignore_comments)
|
|
960 {
|
|
961 /* we have found a single char end comment. we must record
|
|
962 the comment style encountered so that later, we can match
|
|
963 only the proper comment begin sequence of the same style */
|
70
|
964 mask = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, c);
|
0
|
965 }
|
|
966
|
|
967 else if (from > stop
|
70
|
968 && SYNTAX_END_P (mirrortab, BUF_FETCH_CHAR (buf, from-1), c)
|
0
|
969 && !char_quoted (buf, from - 1)
|
|
970 && parse_sexp_ignore_comments)
|
|
971 {
|
|
972 /* we must record the comment style encountered so that
|
|
973 later, we can match only the proper comment begin
|
|
974 sequence of the same style */
|
|
975 code = Sendcomment;
|
70
|
976 mask = SYNTAX_COMMENT_MASK_END (mirrortab,
|
0
|
977 BUF_FETCH_CHAR (buf, from - 1),
|
|
978 c);
|
|
979 from--;
|
|
980 }
|
|
981
|
70
|
982 if (SYNTAX_PREFIX_UNSAFE (mirrortab, c))
|
0
|
983 continue;
|
|
984
|
|
985 switch (((quoted) ? Sword : code))
|
|
986 {
|
|
987 case Sword:
|
|
988 case Ssymbol:
|
|
989 if (depth || !sexpflag) break;
|
|
990 /* This word counts as a sexp; count object finished after
|
|
991 passing it. */
|
|
992 while (from > stop)
|
|
993 {
|
|
994 enum syntaxcode syncode;
|
|
995 quoted = char_quoted (buf, from - 1);
|
|
996
|
|
997 if (quoted)
|
|
998 from--;
|
|
999 if (! (quoted
|
|
1000 || (syncode =
|
70
|
1001 SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from - 1)))
|
0
|
1002 == Sword
|
|
1003 || syncode == Ssymbol
|
|
1004 || syncode == Squote))
|
|
1005 goto done2;
|
|
1006 from--;
|
|
1007 }
|
|
1008 goto done2;
|
|
1009
|
|
1010 case Smath:
|
|
1011 if (!sexpflag)
|
|
1012 break;
|
|
1013 if (from != stop && c == BUF_FETCH_CHAR (buf, from - 1))
|
|
1014 from--;
|
|
1015 if (mathexit)
|
|
1016 {
|
|
1017 mathexit = 0;
|
|
1018 goto open2;
|
|
1019 }
|
|
1020 mathexit = 1;
|
|
1021
|
|
1022 case Sclose:
|
|
1023 if (!++depth) goto done2;
|
|
1024 break;
|
|
1025
|
|
1026 case Sopen:
|
|
1027 open2:
|
|
1028 if (!--depth) goto done2;
|
|
1029 if (depth < min_depth)
|
|
1030 {
|
|
1031 if (no_error)
|
|
1032 return Qnil;
|
|
1033 error ("Containing expression ends prematurely");
|
|
1034 }
|
|
1035 break;
|
|
1036
|
|
1037 case Sendcomment:
|
|
1038 if (parse_sexp_ignore_comments)
|
|
1039 from = find_start_of_comment (buf, from, stop, mask);
|
|
1040 break;
|
|
1041
|
|
1042 case Sstring:
|
|
1043 {
|
|
1044 /* XEmacs change: call syntax_match() on character */
|
|
1045 Emchar ch = BUF_FETCH_CHAR (buf, from);
|
70
|
1046 Lisp_Object stermobj = syntax_match (syntaxtab, ch);
|
0
|
1047 Emchar stringterm;
|
|
1048
|
|
1049 if (CHARP (stermobj))
|
|
1050 stringterm = XCHAR (stermobj);
|
|
1051 else
|
|
1052 stringterm = ch;
|
|
1053
|
|
1054 while (1)
|
|
1055 {
|
|
1056 if (from == stop) goto lose;
|
|
1057 if (!char_quoted (buf, from - 1)
|
|
1058 && stringterm == BUF_FETCH_CHAR (buf, from - 1))
|
|
1059 break;
|
|
1060 from--;
|
|
1061 }
|
|
1062 from--;
|
|
1063 if (!depth && sexpflag) goto done2;
|
|
1064 break;
|
|
1065 }
|
|
1066 }
|
|
1067 }
|
|
1068
|
|
1069 /* Reached start of buffer. Error if within object,
|
|
1070 return nil if between */
|
|
1071 if (depth) goto lose;
|
|
1072
|
|
1073 return Qnil;
|
|
1074
|
|
1075 done2:
|
|
1076 count++;
|
|
1077 }
|
|
1078
|
|
1079
|
|
1080 return (make_int (from));
|
|
1081
|
|
1082 lose:
|
|
1083 if (!no_error)
|
|
1084 error ("Unbalanced parentheses");
|
|
1085 return Qnil;
|
|
1086 }
|
|
1087
|
|
1088 int
|
|
1089 char_quoted (struct buffer *buf, Bufpos pos)
|
|
1090 {
|
|
1091 enum syntaxcode code;
|
|
1092 Bufpos beg = BUF_BEGV (buf);
|
|
1093 int quoted = 0;
|
70
|
1094 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
1095
|
|
1096 while (pos > beg
|
70
|
1097 && ((code = SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)))
|
0
|
1098 == Scharquote
|
|
1099 || code == Sescape))
|
|
1100 pos--, quoted = !quoted;
|
|
1101 return quoted;
|
|
1102 }
|
|
1103
|
20
|
1104 DEFUN ("scan-lists", Fscan_lists, 3, 5, 0, /*
|
0
|
1105 Scan from character number FROM by COUNT lists.
|
|
1106 Returns the character number of the position thus found.
|
|
1107
|
|
1108 If DEPTH is nonzero, paren depth begins counting from that value,
|
|
1109 only places where the depth in parentheses becomes zero
|
|
1110 are candidates for stopping; COUNT such places are counted.
|
|
1111 Thus, a positive value for DEPTH means go out levels.
|
|
1112
|
|
1113 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
|
|
1114
|
|
1115 If the beginning or end of (the accessible part of) the buffer is reached
|
|
1116 and the depth is wrong, an error is signaled.
|
|
1117 If the depth is right but the count is not used up, nil is returned.
|
|
1118
|
|
1119 If optional arg BUFFER is non-nil, scanning occurs in that buffer instead
|
|
1120 of in the current buffer.
|
|
1121
|
|
1122 If optional arg NOERROR is non-nil, scan-lists will return nil instead of
|
|
1123 signalling an error.
|
20
|
1124 */
|
|
1125 (from, count, depth, buffer, no_error))
|
0
|
1126 {
|
|
1127 struct buffer *buf;
|
|
1128
|
|
1129 CHECK_INT (from);
|
|
1130 CHECK_INT (count);
|
|
1131 CHECK_INT (depth);
|
|
1132 buf = decode_buffer (buffer, 0);
|
|
1133
|
|
1134 return scan_lists (buf, XINT (from), XINT (count), XINT (depth), 0,
|
|
1135 !NILP (no_error));
|
|
1136 }
|
|
1137
|
20
|
1138 DEFUN ("scan-sexps", Fscan_sexps, 2, 4, 0, /*
|
0
|
1139 Scan from character number FROM by COUNT balanced expressions.
|
|
1140 If COUNT is negative, scan backwards.
|
|
1141 Returns the character number of the position thus found.
|
|
1142
|
|
1143 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.
|
|
1144
|
|
1145 If the beginning or end of (the accessible part of) the buffer is reached
|
|
1146 in the middle of a parenthetical grouping, an error is signaled.
|
|
1147 If the beginning or end is reached between groupings
|
|
1148 but before count is used up, nil is returned.
|
|
1149
|
|
1150 If optional arg BUFFER is non-nil, scanning occurs in that buffer instead
|
|
1151 of in the current buffer.
|
|
1152
|
|
1153 If optional arg NOERROR is non-nil, scan-sexps will return nil instead of
|
|
1154 signalling an error.
|
20
|
1155 */
|
|
1156 (from, count, buffer, no_error))
|
0
|
1157 {
|
|
1158 struct buffer *buf = decode_buffer (buffer, 0);
|
|
1159 CHECK_INT (from);
|
|
1160 CHECK_INT (count);
|
|
1161
|
|
1162 return scan_lists (buf, XINT (from), XINT (count), 0, 1, !NILP (no_error));
|
|
1163 }
|
|
1164
|
20
|
1165 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, 0, 1, 0, /*
|
0
|
1166 Move point backward over any number of chars with prefix syntax.
|
|
1167 This includes chars with \"quote\" or \"prefix\" syntax (' or p).
|
|
1168
|
|
1169 Optional arg BUFFER defaults to the current buffer.
|
20
|
1170 */
|
|
1171 (buffer))
|
0
|
1172 {
|
|
1173 struct buffer *buf = decode_buffer (buffer, 0);
|
|
1174 Bufpos beg = BUF_BEGV (buf);
|
|
1175 Bufpos pos = BUF_PT (buf);
|
70
|
1176 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
1177
|
|
1178 while (pos > beg && !char_quoted (buf, pos - 1)
|
70
|
1179 && (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1)) == Squote
|
|
1180 || SYNTAX_PREFIX (mirrortab, BUF_FETCH_CHAR (buf, pos - 1))))
|
0
|
1181 pos--;
|
|
1182
|
|
1183 BUF_SET_PT (buf, pos);
|
|
1184
|
|
1185 return Qnil;
|
|
1186 }
|
|
1187
|
|
1188 /* Parse forward from FROM to END,
|
|
1189 assuming that FROM has state OLDSTATE (nil means FROM is start of function),
|
|
1190 and return a description of the state of the parse at END.
|
|
1191 If STOPBEFORE is nonzero, stop at the start of an atom.
|
|
1192 If COMMENTSTOP is nonzero, stop at the start of a comment. */
|
|
1193
|
|
1194 static void
|
|
1195 scan_sexps_forward (struct buffer *buf, struct lisp_parse_state *stateptr,
|
|
1196 Bufpos from, Bufpos end,
|
|
1197 int targetdepth, int stopbefore,
|
|
1198 Lisp_Object oldstate,
|
|
1199 int commentstop)
|
|
1200 {
|
|
1201 struct lisp_parse_state state;
|
|
1202
|
|
1203 enum syntaxcode code;
|
|
1204 struct level { int last, prev; };
|
|
1205 struct level levelstart[100];
|
|
1206 struct level *curlevel = levelstart;
|
|
1207 struct level *endlevel = levelstart + 100;
|
|
1208 int depth; /* Paren depth of current scanning location.
|
|
1209 level - levelstart equals this except
|
|
1210 when the depth becomes negative. */
|
|
1211 int mindepth; /* Lowest DEPTH value seen. */
|
|
1212 int start_quoted = 0; /* Nonzero means starting after a char quote */
|
|
1213 Lisp_Object tem;
|
|
1214 int mask; /* comment mask */
|
70
|
1215 Lisp_Object syntaxtab = buf->syntax_table;
|
|
1216 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
|
0
|
1217
|
|
1218 if (NILP (oldstate))
|
|
1219 {
|
|
1220 depth = 0;
|
|
1221 state.instring = -1;
|
|
1222 state.incomment = 0;
|
|
1223 state.comstyle = 0; /* comment style a by default */
|
|
1224 mask = SYNTAX_COMMENT_STYLE_A;
|
|
1225 }
|
|
1226 else
|
|
1227 {
|
|
1228 tem = Fcar (oldstate); /* elt 0, depth */
|
|
1229 if (!NILP (tem))
|
|
1230 depth = XINT (tem);
|
|
1231 else
|
|
1232 depth = 0;
|
|
1233
|
|
1234 oldstate = Fcdr (oldstate);
|
|
1235 oldstate = Fcdr (oldstate);
|
|
1236 oldstate = Fcdr (oldstate);
|
|
1237 tem = Fcar (oldstate); /* elt 3, instring */
|
|
1238 state.instring = !NILP (tem) ? XINT (tem) : -1;
|
|
1239
|
|
1240 oldstate = Fcdr (oldstate); /* elt 4, incomment */
|
|
1241 tem = Fcar (oldstate);
|
|
1242 state.incomment = !NILP (tem);
|
|
1243
|
|
1244 oldstate = Fcdr (oldstate);
|
|
1245 tem = Fcar (oldstate); /* elt 5, follows-quote */
|
|
1246 start_quoted = !NILP (tem);
|
|
1247
|
|
1248 /* if the eighth element of the list is nil, we are in comment style
|
|
1249 a. if it is non-nil, we are in comment style b */
|
|
1250 oldstate = Fcdr (oldstate);
|
|
1251 oldstate = Fcdr (oldstate);
|
|
1252 oldstate = Fcdr (oldstate);
|
|
1253 tem = Fcar (oldstate); /* elt 8, comment style a */
|
|
1254 state.comstyle = !NILP (tem);
|
|
1255 mask = state.comstyle ? SYNTAX_COMMENT_STYLE_B : SYNTAX_COMMENT_STYLE_A;
|
|
1256 }
|
|
1257 state.quoted = 0;
|
|
1258 mindepth = depth;
|
|
1259
|
|
1260 curlevel->prev = -1;
|
|
1261 curlevel->last = -1;
|
|
1262
|
|
1263 /* Enter the loop at a place appropriate for initial state. */
|
|
1264
|
|
1265 if (state.incomment) goto startincomment;
|
|
1266 if (state.instring >= 0)
|
|
1267 {
|
|
1268 if (start_quoted) goto startquotedinstring;
|
|
1269 goto startinstring;
|
|
1270 }
|
|
1271 if (start_quoted) goto startquoted;
|
|
1272
|
|
1273 while (from < end)
|
|
1274 {
|
|
1275 QUIT;
|
|
1276
|
70
|
1277 code = SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from));
|
0
|
1278 from++;
|
|
1279
|
|
1280 if (code == Scomment)
|
|
1281 {
|
|
1282 /* record the comment style we have entered so that only the
|
|
1283 comment-ender sequence (or single char) of the same style
|
|
1284 actually terminates the comment section. */
|
70
|
1285 mask = SYNTAX_COMMENT_1CHAR_MASK (mirrortab,
|
0
|
1286 BUF_FETCH_CHAR (buf, from-1));
|
|
1287 state.comstyle = (mask == SYNTAX_COMMENT_STYLE_B);
|
|
1288 state.comstart = from - 1;
|
|
1289 }
|
|
1290
|
|
1291 else if (from < end &&
|
70
|
1292 SYNTAX_START_P (mirrortab, BUF_FETCH_CHAR (buf, from-1),
|
0
|
1293 BUF_FETCH_CHAR (buf, from)))
|
|
1294 {
|
|
1295 /* Record the comment style we have entered so that only
|
|
1296 the comment-end sequence of the same style actually
|
|
1297 terminates the comment section. */
|
|
1298 code = Scomment;
|
70
|
1299 mask = SYNTAX_COMMENT_MASK_START (mirrortab,
|
0
|
1300 BUF_FETCH_CHAR (buf, from-1),
|
|
1301 BUF_FETCH_CHAR (buf, from));
|
|
1302 state.comstyle = (mask == SYNTAX_COMMENT_STYLE_B);
|
|
1303 state.comstart = from-1;
|
|
1304 from++;
|
|
1305 }
|
|
1306
|
70
|
1307 if (SYNTAX_PREFIX (mirrortab, BUF_FETCH_CHAR (buf, from - 1)))
|
0
|
1308 continue;
|
|
1309 switch (code)
|
|
1310 {
|
|
1311 case Sescape:
|
|
1312 case Scharquote:
|
|
1313 if (stopbefore) goto stop; /* this arg means stop at sexp start */
|
|
1314 curlevel->last = from - 1;
|
|
1315 startquoted:
|
|
1316 if (from == end) goto endquoted;
|
|
1317 from++;
|
|
1318 goto symstarted;
|
|
1319 /* treat following character as a word constituent */
|
|
1320 case Sword:
|
|
1321 case Ssymbol:
|
|
1322 if (stopbefore) goto stop; /* this arg means stop at sexp start */
|
|
1323 curlevel->last = from - 1;
|
|
1324 symstarted:
|
|
1325 while (from < end)
|
|
1326 {
|
70
|
1327 switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
|
0
|
1328 {
|
|
1329 case Scharquote:
|
|
1330 case Sescape:
|
|
1331 from++;
|
|
1332 if (from == end) goto endquoted;
|
|
1333 break;
|
|
1334 case Sword:
|
|
1335 case Ssymbol:
|
|
1336 case Squote:
|
|
1337 break;
|
|
1338 default:
|
|
1339 goto symdone;
|
|
1340 }
|
|
1341 from++;
|
|
1342 }
|
|
1343 symdone:
|
|
1344 curlevel->prev = curlevel->last;
|
|
1345 break;
|
|
1346
|
|
1347 case Scomment:
|
|
1348 state.incomment = 1;
|
|
1349 startincomment:
|
|
1350 if (commentstop)
|
|
1351 goto done;
|
|
1352 {
|
|
1353 Bufpos newfrom = find_end_of_comment (buf, from, end, mask);
|
|
1354 if (newfrom < 0)
|
|
1355 {
|
|
1356 /* we terminated search because from == end */
|
|
1357 from = end;
|
|
1358 goto done;
|
|
1359 }
|
|
1360 from = newfrom;
|
|
1361 }
|
|
1362 state.incomment = 0;
|
|
1363 state.comstyle = 0; /* reset the comment style */
|
|
1364 mask = 0;
|
|
1365 break;
|
|
1366
|
|
1367 case Sopen:
|
|
1368 if (stopbefore) goto stop; /* this arg means stop at sexp start */
|
|
1369 depth++;
|
|
1370 /* curlevel++->last ran into compiler bug on Apollo */
|
|
1371 curlevel->last = from - 1;
|
|
1372 if (++curlevel == endlevel)
|
|
1373 error ("Nesting too deep for parser");
|
|
1374 curlevel->prev = -1;
|
|
1375 curlevel->last = -1;
|
88
|
1376 if (targetdepth == depth) goto done;
|
0
|
1377 break;
|
|
1378
|
|
1379 case Sclose:
|
|
1380 depth--;
|
|
1381 if (depth < mindepth)
|
|
1382 mindepth = depth;
|
|
1383 if (curlevel != levelstart)
|
|
1384 curlevel--;
|
|
1385 curlevel->prev = curlevel->last;
|
88
|
1386 if (targetdepth == depth) goto done;
|
0
|
1387 break;
|
|
1388
|
|
1389 case Sstring:
|
|
1390 {
|
|
1391 Emchar ch;
|
|
1392 if (stopbefore) goto stop; /* this arg means stop at sexp start */
|
|
1393 curlevel->last = from - 1;
|
|
1394 /* XEmacs change: call syntax_match() on character */
|
|
1395 ch = BUF_FETCH_CHAR (buf, from - 1);
|
|
1396 {
|
70
|
1397 Lisp_Object stermobj = syntax_match (syntaxtab, ch);
|
0
|
1398
|
|
1399 if (CHARP (stermobj))
|
|
1400 state.instring = XCHAR (stermobj);
|
|
1401 else
|
|
1402 state.instring = ch;
|
|
1403 }
|
|
1404 }
|
|
1405 startinstring:
|
|
1406 while (1)
|
|
1407 {
|
|
1408 if (from >= end) goto done;
|
|
1409 if (BUF_FETCH_CHAR (buf, from) == state.instring) break;
|
70
|
1410 switch (SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from)))
|
0
|
1411 {
|
|
1412 case Scharquote:
|
|
1413 case Sescape:
|
|
1414 {
|
|
1415 from++;
|
|
1416 startquotedinstring:
|
|
1417 if (from >= end) goto endquoted;
|
|
1418 break;
|
|
1419 }
|
|
1420 default:
|
|
1421 break;
|
|
1422 }
|
|
1423 from++;
|
|
1424 }
|
|
1425 state.instring = -1;
|
|
1426 curlevel->prev = curlevel->last;
|
|
1427 from++;
|
|
1428 break;
|
|
1429
|
|
1430 case Smath:
|
|
1431 break;
|
|
1432
|
|
1433 case Swhitespace:
|
|
1434 case Spunct:
|
|
1435 case Squote:
|
|
1436 case Sendcomment:
|
|
1437 case Sinherit:
|
|
1438 case Smax:
|
|
1439 break;
|
|
1440 }
|
|
1441 }
|
|
1442 goto done;
|
|
1443
|
|
1444 stop: /* Here if stopping before start of sexp. */
|
|
1445 from--; /* We have just fetched the char that starts it; */
|
|
1446 goto done; /* but return the position before it. */
|
|
1447
|
|
1448 endquoted:
|
|
1449 state.quoted = 1;
|
|
1450 done:
|
|
1451 state.depth = depth;
|
|
1452 state.mindepth = mindepth;
|
|
1453 state.thislevelstart = curlevel->prev;
|
|
1454 state.prevlevelstart
|
|
1455 = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
|
|
1456 state.location = from;
|
|
1457
|
|
1458 *stateptr = state;
|
|
1459 }
|
|
1460
|
20
|
1461 DEFUN ("parse-partial-sexp", Fparse_partial_sexp, 2, 7, 0, /*
|
0
|
1462 Parse Lisp syntax starting at FROM until TO; return status of parse at TO.
|
|
1463 Parsing stops at TO or when certain criteria are met;
|
|
1464 point is set to where parsing stops.
|
|
1465 If fifth arg STATE is omitted or nil,
|
|
1466 parsing assumes that FROM is the beginning of a function.
|
|
1467 Value is a list of eight elements describing final state of parsing:
|
|
1468 0. depth in parens.
|
|
1469 1. character address of start of innermost containing list; nil if none.
|
|
1470 2. character address of start of last complete sexp terminated.
|
|
1471 3. non-nil if inside a string.
|
|
1472 (It is the character that will terminate the string.)
|
|
1473 4. t if inside a comment.
|
|
1474 5. t if following a quote character.
|
|
1475 6. the minimum paren-depth encountered during this scan.
|
|
1476 7. nil if in comment style a, or not in a comment; t if in comment style b
|
|
1477 If third arg TARGETDEPTH is non-nil, parsing stops if the depth
|
|
1478 in parentheses becomes equal to TARGETDEPTH.
|
|
1479 Fourth arg STOPBEFORE non-nil means stop when come to
|
|
1480 any character that starts a sexp.
|
|
1481 Fifth arg STATE is an eight-element list like what this function returns.
|
|
1482 It is used to initialize the state of the parse. Its second and third
|
|
1483 elements are ignored.
|
|
1484 Sixth arg COMMENTSTOP non-nil means stop at the start of a comment.
|
20
|
1485 */
|
|
1486 (from, to, targetdepth, stopbefore, oldstate, commentstop, buffer))
|
0
|
1487 {
|
|
1488 struct lisp_parse_state state;
|
|
1489 int target;
|
|
1490 Bufpos start, end;
|
|
1491 struct buffer *buf = decode_buffer (buffer, 0);
|
|
1492
|
|
1493 if (!NILP (targetdepth))
|
|
1494 {
|
|
1495 CHECK_INT (targetdepth);
|
|
1496 target = XINT (targetdepth);
|
|
1497 }
|
|
1498 else
|
|
1499 target = -100000; /* We won't reach this depth */
|
|
1500
|
|
1501 get_buffer_range_char (buf, from, to, &start, &end, 0);
|
|
1502 scan_sexps_forward (buf, &state, start, end,
|
|
1503 target, !NILP (stopbefore), oldstate,
|
|
1504 !NILP (commentstop));
|
|
1505
|
|
1506 BUF_SET_PT (buf, state.location);
|
|
1507
|
|
1508 {
|
|
1509 /*
|
|
1510 * This junk is necessary because of a bug in SparcWorks cc 2.0.1. It
|
|
1511 * doesn't handle functions as arguments to other functions very well.
|
|
1512 */
|
|
1513 Lisp_Object retval[8];
|
|
1514
|
|
1515 retval[0] = make_int (state.depth);
|
|
1516 retval[1] = ((state.prevlevelstart < 0) ? Qnil :
|
|
1517 make_int (state.prevlevelstart));
|
|
1518 retval[2] = ((state.thislevelstart < 0) ? Qnil :
|
|
1519 make_int (state.thislevelstart));
|
|
1520 retval[3] = ((state.instring >= 0) ? make_int (state.instring) : Qnil);
|
|
1521 retval[4] = ((state.incomment) ? Qt : Qnil);
|
|
1522 retval[5] = ((state.quoted) ? Qt : Qnil);
|
|
1523 retval[6] = make_int (state.mindepth);
|
|
1524 retval[7] = ((state.comstyle) ? Qt : Qnil);
|
|
1525
|
|
1526 return (Flist (8, retval));
|
|
1527 }
|
|
1528 }
|
|
1529
|
70
|
1530
|
|
1531 /* Updating of the mirror syntax table.
|
|
1532
|
|
1533 Each syntax table has a corresponding mirror table in it.
|
|
1534 Whenever we make a change to a syntax table, we call
|
|
1535 update_syntax_table() on it.
|
|
1536
|
|
1537 #### We really only need to map over the changed range.
|
|
1538
|
|
1539 If we change the standard syntax table, we need to map over
|
|
1540 all tables because any of them could be inheriting from the
|
|
1541 standard syntax table.
|
|
1542
|
|
1543 When `set-syntax-table' is called, we set the buffer's mirror
|
|
1544 syntax table as well.
|
|
1545 */
|
|
1546
|
|
1547 struct cmst_arg
|
|
1548 {
|
|
1549 Lisp_Object mirrortab;
|
|
1550 int check_inherit;
|
|
1551 };
|
|
1552
|
|
1553 static int
|
|
1554 cmst_mapfun (struct chartab_range *range, Lisp_Object val, void *arg)
|
|
1555 {
|
|
1556 struct cmst_arg *closure = (struct cmst_arg *) arg;
|
|
1557
|
|
1558 if (CONSP (val))
|
|
1559 val = XCAR (val);
|
|
1560 if (SYNTAX_FROM_CODE (XINT (val)) == Sinherit
|
|
1561 && closure->check_inherit)
|
|
1562 {
|
|
1563 struct cmst_arg recursive;
|
|
1564
|
|
1565 recursive.mirrortab = closure->mirrortab;
|
|
1566 recursive.check_inherit = 0;
|
|
1567 map_char_table (XCHAR_TABLE (Vstandard_syntax_table), range,
|
|
1568 cmst_mapfun, &recursive);
|
|
1569 }
|
|
1570 else
|
|
1571 put_char_table (XCHAR_TABLE (closure->mirrortab), range, val);
|
|
1572 return 0;
|
|
1573 }
|
|
1574
|
|
1575 static void
|
|
1576 update_just_this_syntax_table (struct Lisp_Char_Table *ct)
|
|
1577 {
|
|
1578 struct chartab_range range;
|
|
1579 struct cmst_arg arg;
|
|
1580
|
|
1581 arg.mirrortab = ct->mirror_table;
|
|
1582 arg.check_inherit = (CHAR_TABLEP (Vstandard_syntax_table)
|
|
1583 && ct != XCHAR_TABLE (Vstandard_syntax_table));
|
|
1584 range.type = CHARTAB_RANGE_ALL;
|
|
1585 map_char_table (ct, &range, cmst_mapfun, &arg);
|
|
1586 }
|
|
1587
|
|
1588 /* Called from chartab.c when a change is made to a syntax table.
|
|
1589 If this is the standard syntax table, we need to recompute
|
|
1590 *all* syntax tables (yuck). Otherwise we just recompute this
|
|
1591 one. */
|
|
1592
|
|
1593 void
|
|
1594 update_syntax_table (struct Lisp_Char_Table *ct)
|
|
1595 {
|
|
1596 /* Don't be stymied at startup. */
|
|
1597 if (CHAR_TABLEP (Vstandard_syntax_table)
|
|
1598 && ct == XCHAR_TABLE (Vstandard_syntax_table))
|
|
1599 {
|
|
1600 Lisp_Object syntab;
|
|
1601
|
|
1602 for (syntab = Vall_syntax_tables; !NILP (syntab);
|
|
1603 syntab = XCHAR_TABLE (syntab)->next_table)
|
|
1604 update_just_this_syntax_table (XCHAR_TABLE (syntab));
|
|
1605 }
|
|
1606 else
|
|
1607 update_just_this_syntax_table (ct);
|
|
1608 }
|
|
1609
|
0
|
1610
|
|
1611 /************************************************************************/
|
|
1612 /* initialization */
|
|
1613 /************************************************************************/
|
|
1614
|
|
1615 void
|
|
1616 syms_of_syntax (void)
|
|
1617 {
|
|
1618 defsymbol (&Qsyntax_table_p, "syntax-table-p");
|
|
1619
|
20
|
1620 DEFSUBR (Fsyntax_table_p);
|
|
1621 DEFSUBR (Fsyntax_table);
|
|
1622 DEFSUBR (Fstandard_syntax_table);
|
|
1623 DEFSUBR (Fcopy_syntax_table);
|
|
1624 DEFSUBR (Fset_syntax_table);
|
|
1625 DEFSUBR (Fsyntax_designator_chars);
|
|
1626 DEFSUBR (Fchar_syntax);
|
|
1627 DEFSUBR (Fmatching_paren);
|
|
1628 /* DEFSUBR (Fmodify_syntax_entry); now in Lisp. */
|
|
1629 /* DEFSUBR (Fdescribe_syntax); now in Lisp. */
|
0
|
1630
|
20
|
1631 DEFSUBR (Fforward_word);
|
0
|
1632
|
20
|
1633 DEFSUBR (Fforward_comment);
|
|
1634 DEFSUBR (Fscan_lists);
|
|
1635 DEFSUBR (Fscan_sexps);
|
|
1636 DEFSUBR (Fbackward_prefix_chars);
|
|
1637 DEFSUBR (Fparse_partial_sexp);
|
0
|
1638 }
|
|
1639
|
|
1640 void
|
|
1641 vars_of_syntax (void)
|
|
1642 {
|
|
1643 DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments /*
|
|
1644 Non-nil means `forward-sexp', etc., should treat comments as whitespace.
|
|
1645 */ );
|
|
1646
|
|
1647 words_include_escapes = 0;
|
|
1648 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes /*
|
|
1649 Non-nil means `forward-word', etc., should treat escape chars part of words.
|
|
1650 */ );
|
|
1651
|
|
1652 no_quit_in_re_search = 0;
|
|
1653 }
|
|
1654
|
|
1655 void
|
|
1656 complex_vars_of_syntax (void)
|
|
1657 {
|
|
1658 /* Set this now, so first buffer creation can refer to it. */
|
|
1659 /* Make it nil before calling copy-syntax-table
|
|
1660 so that copy-syntax-table will know not to try to copy from garbage */
|
|
1661 Vstandard_syntax_table = Qnil;
|
|
1662 Vstandard_syntax_table = Fcopy_syntax_table (Qnil);
|
|
1663 staticpro (&Vstandard_syntax_table);
|
|
1664
|
|
1665 Vsyntax_designator_chars_string = make_pure_string (syntax_code_spec,
|
|
1666 Smax, Qnil, 1);
|
|
1667 staticpro (&Vsyntax_designator_chars_string);
|
|
1668
|
70
|
1669 fill_char_table (XCHAR_TABLE (Vstandard_syntax_table),
|
|
1670 make_int (Spunct));
|
|
1671
|
0
|
1672 {
|
70
|
1673 Emchar i;
|
|
1674
|
|
1675 for (i = 0; i <= 32; i++)
|
|
1676 Fput_char_table (make_char (i), make_int ((int) Swhitespace),
|
|
1677 Vstandard_syntax_table);
|
|
1678 for (i = 127; i <= 159; i++)
|
|
1679 Fput_char_table (make_char (i), make_int ((int) Swhitespace),
|
|
1680 Vstandard_syntax_table);
|
|
1681
|
|
1682 for (i = 'a'; i <= 'z'; i++)
|
|
1683 Fput_char_table (make_char (i), make_int ((int) Sword),
|
|
1684 Vstandard_syntax_table);
|
|
1685 for (i = 'A'; i <= 'Z'; i++)
|
|
1686 Fput_char_table (make_char (i), make_int ((int) Sword),
|
|
1687 Vstandard_syntax_table);
|
|
1688 for (i = '0'; i <= '9'; i++)
|
|
1689 Fput_char_table (make_char (i), make_int ((int) Sword),
|
|
1690 Vstandard_syntax_table);
|
|
1691 Fput_char_table (make_char ('$'), make_int ((int) Sword),
|
|
1692 Vstandard_syntax_table);
|
|
1693 Fput_char_table (make_char ('%'), make_int ((int) Sword),
|
|
1694 Vstandard_syntax_table);
|
0
|
1695
|
70
|
1696 {
|
|
1697 Fput_char_table (make_char ('('), Fcons (make_int ((int) Sopen),
|
|
1698 make_char (')')),
|
|
1699 Vstandard_syntax_table);
|
|
1700 Fput_char_table (make_char (')'), Fcons (make_int ((int) Sclose),
|
|
1701 make_char ('(')),
|
|
1702 Vstandard_syntax_table);
|
|
1703 Fput_char_table (make_char ('['), Fcons (make_int ((int) Sopen),
|
|
1704 make_char (']')),
|
|
1705 Vstandard_syntax_table);
|
|
1706 Fput_char_table (make_char (']'), Fcons (make_int ((int) Sclose),
|
|
1707 make_char ('[')),
|
|
1708 Vstandard_syntax_table);
|
|
1709 Fput_char_table (make_char ('{'), Fcons (make_int ((int) Sopen),
|
|
1710 make_char ('}')),
|
|
1711 Vstandard_syntax_table);
|
|
1712 Fput_char_table (make_char ('}'), Fcons (make_int ((int) Sclose),
|
|
1713 make_char ('{')),
|
|
1714 Vstandard_syntax_table);
|
|
1715 }
|
|
1716
|
|
1717 Fput_char_table (make_char ('"'), make_int ((int) Sstring),
|
|
1718 Vstandard_syntax_table);
|
|
1719 Fput_char_table (make_char ('\\'), make_int ((int) Sescape),
|
|
1720 Vstandard_syntax_table);
|
0
|
1721
|
70
|
1722 {
|
|
1723 CONST char *p;
|
|
1724 for (p = "_-+*/&|<>="; *p; p++)
|
|
1725 Fput_char_table (make_char (*p), make_int ((int) Ssymbol),
|
|
1726 Vstandard_syntax_table);
|
|
1727
|
|
1728 for (p = ".,;:?!#@~^'`"; *p; p++)
|
|
1729 Fput_char_table (make_char (*p), make_int ((int) Spunct),
|
|
1730 Vstandard_syntax_table);
|
|
1731 }
|
0
|
1732 }
|
|
1733 }
|