aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-04-15 04:56:10 +0000
committerRichard M. Stallman1997-04-15 04:56:10 +0000
commit5eea1c5ad6e6f3636feb09b6f7c693b11958ed31 (patch)
treed14be41289d1ee762251a7a5416f3504a8b472e5 /src
parent195d13612d320503ec7efe4fbf8acbaa114114db (diff)
downloademacs-5eea1c5ad6e6f3636feb09b6f7c693b11958ed31.tar.gz
emacs-5eea1c5ad6e6f3636feb09b6f7c693b11958ed31.zip
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
(SYNTAX_ENTRY): Depending on the value of SYNTAX_ENTRY_VIA_PROPERTY may do a lookup for syntax table in gl_state. (UPDATE_SYNTAX_TABLE_FORWARD, UPDATE_SYNTAX_TABLE_BACKWARD, UPDATE_SYNTAX_TABLE, SETUP_SYNTAX_TABLE, SETUP_SYNTAX_TABLE_FOR_OBJECT): New macros. (struct gl_state_s): New struct.
Diffstat (limited to 'src')
-rw-r--r--src/syntax.h132
1 files changed, 118 insertions, 14 deletions
diff --git a/src/syntax.h b/src/syntax.h
index 5d78462174f..61cb4fa9668 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -1,5 +1,5 @@
1/* Declarations having to do with GNU Emacs syntax tables. 1/* Declarations having to do with GNU Emacs syntax tables.
2 Copyright (C) 1985, 1993, 1994 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1993, 1994, 1997 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -21,6 +21,7 @@ Boston, MA 02111-1307, USA. */
21 21
22extern Lisp_Object Qsyntax_table_p; 22extern Lisp_Object Qsyntax_table_p;
23extern Lisp_Object Fsyntax_table_p (), Fsyntax_table (), Fset_syntax_table (); 23extern Lisp_Object Fsyntax_table_p (), Fsyntax_table (), Fset_syntax_table ();
24extern void update_syntax_table ();
24 25
25/* The standard syntax table is stored where it will automatically 26/* The standard syntax table is stored where it will automatically
26 be used in all new buffers. */ 27 be used in all new buffers. */
@@ -42,12 +43,16 @@ enum syntaxcode
42 Sclose, /* for an ending delimiter */ 43 Sclose, /* for an ending delimiter */
43 Squote, /* for a prefix character like Lisp ' */ 44 Squote, /* for a prefix character like Lisp ' */
44 Sstring, /* for a string-grouping character like Lisp " */ 45 Sstring, /* for a string-grouping character like Lisp " */
45 Smath, /* for delimiters like $ in Tex. */ 46 Smath, /* for delimiters like $ in Tex. */
46 Sescape, /* for a character that begins a C-style escape */ 47 Sescape, /* for a character that begins a C-style escape */
47 Scharquote, /* for a character that quotes the following character */ 48 Scharquote, /* for a character that quotes the following character */
48 Scomment, /* for a comment-starting character */ 49 Scomment, /* for a comment-starting character */
49 Sendcomment, /* for a comment-ending character */ 50 Sendcomment, /* for a comment-ending character */
50 Sinherit, /* use the standard syntax table for this character */ 51 Sinherit, /* use the standard syntax table for this character */
52 Scomment_fence, /* Starts/ends comment which is delimited on the
53 other side by a char with the same syntaxcode. */
54 Sstring_fence, /* Starts/ends string which is delimited on the
55 other side by a char with the same syntaxcode. */
51 Smax /* Upper bound on codes that are meaningful */ 56 Smax /* Upper bound on codes that are meaningful */
52 }; 57 };
53 58
@@ -85,16 +90,27 @@ extern Lisp_Object syntax_parent_lookup ();
85 : syntax_temp)) 90 : syntax_temp))
86#endif 91#endif
87 92
88/* Fetch the syntax entry for char C in the current syntax table. 93/* SYNTAX_ENTRY fetches the information from the entry for character C
89 This returns the whole entry (normally a cons cell). 94 in syntax table TABLE, or from globally kept data (gl_state).
90 Do Inheritance. */ 95 Does inheritance. */
96/* CURRENT_SYNTAX_TABLE gives the syntax table valid for current
97 position, it is either the buffer's syntax table, or syntax table
98 found in text properties. */
99
100#ifdef SYNTAX_ENTRY_VIA_PROPERTY
101# define SYNTAX_ENTRY(c) \
102 (gl_state.use_global ? gl_state.global_code : SYNTAX_ENTRY_INT (c))
103# define CURRENT_SYNTAX_TABLE gl_state.current_syntax_table
104#else
105# define SYNTAX_ENTRY SYNTAX_ENTRY_INT
106# define CURRENT_SYNTAX_TABLE current_buffer->syntax_table
107#endif
91 108
92#define SYNTAX_ENTRY(c) \ 109#define SYNTAX_ENTRY_INT(c) \
93 ((c) < CHAR_TABLE_SINGLE_BYTE_SLOTS \ 110 ((c) < CHAR_TABLE_SINGLE_BYTE_SLOTS \
94 ? SYNTAX_ENTRY_FOLLOW_PARENT (current_buffer->syntax_table, \ 111 ? SYNTAX_ENTRY_FOLLOW_PARENT (CURRENT_SYNTAX_TABLE, \
95 (unsigned char) (c)) \ 112 (unsigned char) (c)) \
96 : Faref (current_buffer->syntax_table, make_number ((c)))) 113 : Faref (CURRENT_SYNTAX_TABLE, make_number ((c))))
97
98 114
99/* Extract the information from the entry for character C 115/* Extract the information from the entry for character C
100 in the current syntax table. */ 116 in the current syntax table. */
@@ -152,7 +168,7 @@ extern Lisp_Object syntax_parent_lookup ();
152 bit 6 is used to discriminate between two different comment styles. 168 bit 6 is used to discriminate between two different comment styles.
153 Languages such as C++ allow two orthogonal syntax start/end pairs 169 Languages such as C++ allow two orthogonal syntax start/end pairs
154 and bit 6 is used to determine whether a comment-end or Scommentend 170 and bit 6 is used to determine whether a comment-end or Scommentend
155 ends style a or b. Comment start sequences can start style a or b. 171 ends style a or b. Comment start sequences can start style a or b.
156 Style a is always the default. 172 Style a is always the default.
157 */ 173 */
158 174
@@ -171,10 +187,98 @@ extern Lisp_Object syntax_parent_lookup ();
171 187
172/* This array, indexed by a character, contains the syntax code which that 188/* This array, indexed by a character, contains the syntax code which that
173 character signifies (as a char). For example, 189 character signifies (as a char). For example,
174 (enum syntaxcode) syntax_spec_code['w'] is Sword. */ 190 (enum syntaxcode) syntax_spec_code['w'] is Sword. */
175 191
176extern unsigned char syntax_spec_code[0400]; 192extern unsigned char syntax_spec_code[0400];
177 193
178/* Indexed by syntax code, give the letter that describes it. */ 194/* Indexed by syntax code, give the letter that describes it. */
179 195
180extern char syntax_code_spec[14]; 196extern char syntax_code_spec[16];
197
198/* Make syntax table state (gl_state) good for POS, assuming it is
199 currently good for a position before POS. */
200#define UPDATE_SYNTAX_TABLE_FORWARD(pos) \
201 ((pos) >= gl_state.e_property ? \
202 ( update_syntax_table ((pos), 1, 0), 1 ) : 0)
203
204
205/* Make syntax table state (gl_state) good for POS, assuming it is
206 currently good for a position after POS. */
207#define UPDATE_SYNTAX_TABLE_BACKWARD(pos) \
208 ((pos) <= gl_state.b_property ? \
209 ( update_syntax_table ((pos), -1, 0), 1 ) : 0)
210
211/* Make syntax table good for POS. */
212#define UPDATE_SYNTAX_TABLE(pos) \
213 ((pos) <= gl_state.b_property ? \
214 ( update_syntax_table ((pos), -1, 0), 1 ) : \
215 ( (pos) >= gl_state.e_property ? \
216 ( update_syntax_table ((pos), 1, 0), 1 ) : 0))
217
218/* This macro should be called with FROM at the start of forward
219 search, or after the last position of the backward search. It
220 makes sure that the first char is picked up with correct table, so
221 one does not need to call UPDATE_SYNTAX_TABLE immediately after the
222 call.
223 Sign of COUNT gives the direction of the search.
224 */
225
226#define SETUP_SYNTAX_TABLE(from,count) \
227 gl_state.b_property = BEGV - 1; \
228 gl_state.e_property = ZV + 1; \
229 gl_state.use_global = 0; \
230 gl_state.current_syntax_table = current_buffer->syntax_table; \
231 if (parse_sexp_lookup_properties) \
232 update_syntax_table ((count) > 0 ? (from) : (from) - 1, (count), 1, Qnil);
233
234/* Same as above, but in OBJECT. If OBJECT is nil, use current buffer.
235 If it is t, ignore properties altogether. */
236
237#define SETUP_SYNTAX_TABLE_FOR_OBJECT(object, from, count) \
238 if (BUFFERP (object)) \
239 { \
240 gl_state.b_property = BEGV - 1; \
241 gl_state.e_property = ZV; \
242 } \
243 else if (EQ (object, Qt)) \
244 { \
245 gl_state.b_property = - 1; \
246 gl_state.e_property = 1500000000; \
247 } \
248 else \
249 { \
250 gl_state.b_property = -1; \
251 gl_state.e_property = 1 + XSTRING (object)->size; \
252 } \
253 gl_state.use_global = 0; \
254 gl_state.current_syntax_table = current_buffer->syntax_table; \
255 if (parse_sexp_lookup_properties) \
256 update_syntax_table (count > 0 ? (from) : (from) - 1, count, 1, object);
257
258struct gl_state_s
259{
260 int start; /* Where to stop. */
261 int stop; /* Where to stop. */
262 int use_global; /* Whether to use global_code
263 or c_s_t. */
264 Lisp_Object global_code; /* Syntax code of current char. */
265 Lisp_Object current_syntax_table; /* Syntax table for current pos. */
266 Lisp_Object old_prop; /* Syntax-table prop at prev pos. */
267 int b_property; /* Last index where c_s_t is
268 not valid. */
269 int e_property; /* First index where c_s_t is
270 not valid. */
271 INTERVAL forward_i; /* Where to start lookup on forward */
272 INTERVAL backward_i; /* or backward movement. The
273 data in c_s_t is valid
274 between these intervals,
275 and possibly at the
276 intervals too, depending
277 on: */
278 char left_ok;
279 char right_ok;
280};
281
282extern struct gl_state_s gl_state;
283extern int parse_sexp_lookup_properties;
284extern INTERVAL interval_of();