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