Mercurial > hg > xemacs-beta
annotate src/syntax.h @ 5475:248176c74e6b
Merge with trunk.
author | Mats Lidell <matsl@xemacs.org> |
---|---|
date | Sat, 23 Apr 2011 23:47:13 +0200 |
parents | 308d34e9f07d |
children | dab422055bab |
rev | line source |
---|---|
428 | 1 /* Declarations having to do with XEmacs syntax tables. |
2 Copyright (C) 1985, 1992, 1993 Free Software Foundation, Inc. | |
1296 | 3 Copyright (C) 2002, 2003 Ben Wing. |
428 | 4 |
5 This file is part of XEmacs. | |
6 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
428 | 8 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
10 option) any later version. |
428 | 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 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5127
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 19 |
20 /* Synched up with: FSF 19.28. */ | |
21 | |
440 | 22 #ifndef INCLUDED_syntax_h_ |
23 #define INCLUDED_syntax_h_ | |
428 | 24 |
25 #include "chartab.h" | |
26 | |
27 /* A syntax table is a type of char table. | |
28 | |
29 The low 7 bits of the integer is a code, as follows. The 8th bit is | |
30 used as the prefix bit flag (see below). | |
31 | |
32 The values in a syntax table are either integers or conses of | |
33 integers and chars. The lowest 7 bits of the integer are the syntax | |
34 class. If this is Sinherit, then the actual syntax value needs to | |
35 be retrieved from the standard syntax table. | |
36 | |
37 Since the logic involved in finding the actual integer isn't very | |
38 complex, you'd think the time required to retrieve it is not a | |
39 factor. If you thought that, however, you'd be wrong, due to the | |
40 high number of times (many per character) that the syntax value is | |
41 accessed in functions such as scan_lists(). To speed this up, | |
42 we maintain a mirror syntax table that contains the actual | |
43 integers. We can do this successfully because syntax tables are | |
44 now an abstract type, where we control all access. | |
45 */ | |
46 | |
47 enum syntaxcode | |
48 { | |
49 Swhitespace, /* whitespace character */ | |
50 Spunct, /* random punctuation character */ | |
51 Sword, /* word constituent */ | |
52 Ssymbol, /* symbol constituent but not word constituent */ | |
53 Sopen, /* a beginning delimiter */ | |
54 Sclose, /* an ending delimiter */ | |
55 Squote, /* a prefix character like Lisp ' */ | |
56 Sstring, /* a string-grouping character like Lisp " */ | |
57 Smath, /* delimiters like $ in TeX. */ | |
58 Sescape, /* a character that begins a C-style escape */ | |
59 Scharquote, /* a character that quotes the following character */ | |
60 Scomment, /* a comment-starting character */ | |
61 Sendcomment, /* a comment-ending character */ | |
62 Sinherit, /* use the standard syntax table for this character */ | |
460 | 63 Scomment_fence, /* Starts/ends comment which is delimited on the |
64 other side by a char with the same syntaxcode. */ | |
65 Sstring_fence, /* Starts/ends string which is delimited on the | |
66 other side by a char with the same syntaxcode. */ | |
428 | 67 Smax /* Upper bound on codes that are meaningful */ |
68 }; | |
69 | |
70 enum syntaxcode charset_syntax (struct buffer *buf, Lisp_Object charset, | |
71 int *multi_p_out); | |
72 | |
1296 | 73 void update_syntax_table (Lisp_Object table); |
74 | |
75 DECLARE_INLINE_HEADER ( | |
76 void | |
77 update_mirror_syntax_if_dirty (Lisp_Object table) | |
78 ) | |
79 { | |
80 if (XCHAR_TABLE (table)->dirty) | |
81 update_syntax_table (table); | |
82 } | |
83 | |
428 | 84 /* Return the syntax code for a particular character and mirror table. */ |
85 | |
1296 | 86 DECLARE_INLINE_HEADER ( |
1315 | 87 int |
1296 | 88 SYNTAX_CODE (Lisp_Object table, Ichar c) |
89 ) | |
90 { | |
91 type_checking_assert (XCHAR_TABLE (table)->mirror_table_p); | |
92 update_mirror_syntax_if_dirty (table); | |
1315 | 93 return XINT (get_char_table_1 (c, table)); |
1296 | 94 } |
95 | |
96 #ifdef NOT_WORTH_THE_EFFORT | |
97 | |
98 /* Same but skip the dirty check. */ | |
99 | |
100 DECLARE_INLINE_HEADER ( | |
1315 | 101 int |
1296 | 102 SYNTAX_CODE_1 (Lisp_Object table, Ichar c) |
103 ) | |
104 { | |
105 type_checking_assert (XCHAR_TABLE (table)->mirror_table_p); | |
106 return (enum syntaxcode) XINT (get_char_table_1 (c, table)); | |
107 } | |
108 | |
109 #endif /* NOT_WORTH_THE_EFFORT */ | |
428 | 110 |
111 #define SYNTAX_FROM_CODE(code) ((enum syntaxcode) ((code) & 0177)) | |
826 | 112 |
428 | 113 #define SYNTAX(table, c) SYNTAX_FROM_CODE (SYNTAX_CODE (table, c)) |
114 | |
826 | 115 DECLARE_INLINE_HEADER ( |
116 int | |
867 | 117 WORD_SYNTAX_P (Lisp_Object table, Ichar c) |
826 | 118 ) |
428 | 119 { |
120 return SYNTAX (table, c) == Sword; | |
121 } | |
122 | |
123 /* OK, here's a graphic diagram of the format of the syntax values: | |
124 | |
125 Bit number: | |
126 | |
127 [ 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 ] | |
128 [ 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 ] | |
129 | |
130 <-----> <-----> <-------------> <-------------> ^ <-----------> | |
131 ELisp unused |comment bits | unused | syntax code | |
132 tag | | | | | | | | | | |
133 stuff | | | | | | | | | | |
134 | | | | | | | | | | |
135 | | | | | | | | `--> prefix flag | |
136 | | | | | | | | | |
137 | | | | | | | `--> comment end style B, second char | |
138 | | | | | | `----> comment end style A, second char | |
139 | | | | | `------> comment end style B, first char | |
140 | | | | `--------> comment end style A, first char | |
141 | | | `----------> comment start style B, second char | |
142 | | `------------> comment start style A, second char | |
143 | `--------------> comment start style B, first char | |
144 `----------------> comment start style A, first char | |
145 | |
146 In a 64-bit integer, there would be 32 more unused bits between | |
147 the tag and the comment bits. | |
148 | |
149 Clearly, such a scheme will not work for Mule, because the matching | |
3498 | 150 paren could be any character and as such requires 21 bits, which |
428 | 151 we don't got. |
152 | |
153 Remember that under Mule we use char tables instead of vectors. | |
154 So what we do is use another char table for the matching paren | |
155 and store a pointer to it in the first char table. (This frees | |
156 code from having to worry about passing two tables around.) | |
157 */ | |
158 | |
159 | |
160 /* The prefix flag bit for backward-prefix-chars is now put into bit 7. */ | |
161 | |
162 #define SYNTAX_PREFIX(table, c) \ | |
163 ((SYNTAX_CODE (table, c) >> 7) & 1) | |
164 | |
165 /* Bits 23-16 are used to implement up to two comment styles | |
166 in a single buffer. They have the following meanings: | |
167 | |
168 1. first of a one or two character comment-start sequence of style a. | |
169 2. first of a one or two character comment-start sequence of style b. | |
170 3. second of a two-character comment-start sequence of style a. | |
171 4. second of a two-character comment-start sequence of style b. | |
172 5. first of a one or two character comment-end sequence of style a. | |
173 6. first of a one or two character comment-end sequence of style b. | |
174 7. second of a two-character comment-end sequence of style a. | |
175 8. second of a two-character comment-end sequence of style b. | |
176 */ | |
177 | |
178 #define SYNTAX_COMMENT_BITS(table, c) \ | |
179 ((SYNTAX_CODE (table, c) >> 16) &0xff) | |
180 | |
181 #define SYNTAX_FIRST_OF_START_A 0x80 | |
182 #define SYNTAX_FIRST_OF_START_B 0x40 | |
183 #define SYNTAX_SECOND_OF_START_A 0x20 | |
184 #define SYNTAX_SECOND_OF_START_B 0x10 | |
185 #define SYNTAX_FIRST_OF_END_A 0x08 | |
186 #define SYNTAX_FIRST_OF_END_B 0x04 | |
187 #define SYNTAX_SECOND_OF_END_A 0x02 | |
188 #define SYNTAX_SECOND_OF_END_B 0x01 | |
189 | |
190 #define SYNTAX_COMMENT_STYLE_A 0xaa | |
191 #define SYNTAX_COMMENT_STYLE_B 0x55 | |
192 #define SYNTAX_FIRST_CHAR_START 0xc0 | |
193 #define SYNTAX_FIRST_CHAR_END 0x0c | |
194 #define SYNTAX_FIRST_CHAR 0xcc | |
195 #define SYNTAX_SECOND_CHAR_START 0x30 | |
196 #define SYNTAX_SECOND_CHAR_END 0x03 | |
197 #define SYNTAX_SECOND_CHAR 0x33 | |
198 | |
826 | 199 #if 0 |
200 | |
201 /* #### Entirely unused. Should they be deleted? */ | |
428 | 202 |
442 | 203 /* #### These are now more or less equivalent to |
204 SYNTAX_COMMENT_MATCH_START ...*/ | |
205 /* a and b must be first and second start chars for a common type */ | |
206 #define SYNTAX_START_P(table, a, b) \ | |
207 (((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_START) >> 2) \ | |
208 & (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_START)) | |
209 | |
210 /* ... and SYNTAX_COMMENT_MATCH_END */ | |
211 /* a and b must be first and second end chars for a common type */ | |
212 #define SYNTAX_END_P(table, a, b) \ | |
213 (((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_END) >> 2) \ | |
214 & (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_END)) | |
428 | 215 |
216 #define SYNTAX_STYLES_MATCH_START_P(table, a, b, mask) \ | |
217 ((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_START & (mask)) \ | |
218 && (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_START & (mask))) | |
219 | |
220 #define SYNTAX_STYLES_MATCH_END_P(table, a, b, mask) \ | |
221 ((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_END & (mask)) \ | |
222 && (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_END & (mask))) | |
223 | |
224 #define SYNTAX_STYLES_MATCH_1CHAR_P(table, a, mask) \ | |
225 ((SYNTAX_COMMENT_BITS (table, a) & (mask))) | |
226 | |
227 #define STYLE_FOUND_P(table, a, b, startp, style) \ | |
228 ((SYNTAX_COMMENT_BITS (table, a) & \ | |
229 ((startp) ? SYNTAX_FIRST_CHAR_START : \ | |
230 SYNTAX_FIRST_CHAR_END) & (style)) \ | |
231 && (SYNTAX_COMMENT_BITS (table, b) & \ | |
232 ((startp) ? SYNTAX_SECOND_CHAR_START : \ | |
233 SYNTAX_SECOND_CHAR_END) & (style))) | |
234 | |
235 #define SYNTAX_COMMENT_MASK_START(table, a, b) \ | |
236 ((STYLE_FOUND_P (table, a, b, 1, SYNTAX_COMMENT_STYLE_A) \ | |
237 ? SYNTAX_COMMENT_STYLE_A \ | |
238 : (STYLE_FOUND_P (table, a, b, 1, SYNTAX_COMMENT_STYLE_B) \ | |
239 ? SYNTAX_COMMENT_STYLE_B \ | |
240 : 0))) | |
241 | |
242 #define SYNTAX_COMMENT_MASK_END(table, a, b) \ | |
243 ((STYLE_FOUND_P (table, a, b, 0, SYNTAX_COMMENT_STYLE_A) \ | |
244 ? SYNTAX_COMMENT_STYLE_A \ | |
245 : (STYLE_FOUND_P (table, a, b, 0, SYNTAX_COMMENT_STYLE_B) \ | |
246 ? SYNTAX_COMMENT_STYLE_B \ | |
247 : 0))) | |
248 | |
249 #define STYLE_FOUND_1CHAR_P(table, a, style) \ | |
250 ((SYNTAX_COMMENT_BITS (table, a) & (style))) | |
251 | |
252 #define SYNTAX_COMMENT_1CHAR_MASK(table, a) \ | |
253 ((STYLE_FOUND_1CHAR_P (table, a, SYNTAX_COMMENT_STYLE_A) \ | |
254 ? SYNTAX_COMMENT_STYLE_A \ | |
255 : (STYLE_FOUND_1CHAR_P (table, a, SYNTAX_COMMENT_STYLE_B) \ | |
256 ? SYNTAX_COMMENT_STYLE_B \ | |
257 : 0))) | |
258 | |
826 | 259 #endif /* 0 */ |
428 | 260 |
261 /* This array, indexed by a character, contains the syntax code which | |
262 that character signifies (as a char). | |
263 For example, (enum syntaxcode) syntax_spec_code['w'] is Sword. */ | |
264 | |
442 | 265 extern const unsigned char syntax_spec_code[0400]; |
428 | 266 |
267 /* Indexed by syntax code, give the letter that describes it. */ | |
268 | |
442 | 269 extern const unsigned char syntax_code_spec[]; |
428 | 270 |
665 | 271 Lisp_Object scan_lists (struct buffer *buf, Charbpos from, int count, |
428 | 272 int depth, int sexpflag, int no_error); |
665 | 273 int char_quoted (struct buffer *buf, Charbpos pos); |
428 | 274 |
275 /* NOTE: This does not refer to the mirror table, but to the | |
276 syntax table itself. */ | |
867 | 277 Lisp_Object syntax_match (Lisp_Object table, Ichar ch); |
428 | 278 |
279 extern int no_quit_in_re_search; | |
826 | 280 |
281 | |
282 /****************************** syntax caches ********************************/ | |
460 | 283 |
284 extern int lookup_syntax_properties; | |
285 | |
826 | 286 /* Now that the `syntax-table' property exists, and can override the syntax |
287 table or directly specify the syntax, we cache the last place we | |
288 retrieved the syntax-table property. This is because, when moving | |
289 linearly through text (e.g. in the regex routines or the scanning | |
290 routines in syntax.c), we only need to recalculate at the next place the | |
291 syntax-table property changes (i.e. not every position), and when we do | |
292 need to recalculate, we can update the info from the previous info | |
293 faster than if we did the whole calculation from scratch. */ | |
460 | 294 struct syntax_cache |
295 { | |
3092 | 296 #ifdef NEW_GC |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5120
diff
changeset
|
297 NORMAL_LISP_OBJECT_HEADER header; |
3092 | 298 #endif /* NEW_GC */ |
826 | 299 int use_code; /* Whether to use syntax_code or |
1296 | 300 syntax_table. This is set |
301 depending on whether the | |
826 | 302 syntax-table property is a |
303 syntax table or a syntax | |
304 code. */ | |
305 int no_syntax_table_prop; /* If non-zero, there was no | |
306 `syntax-table' property on the | |
307 current range, and so we're | |
308 using the buffer's syntax table. | |
309 This is important to note because | |
310 sometimes the buffer's syntax | |
311 table can be changed. */ | |
460 | 312 Lisp_Object object; /* The buffer or string the current |
826 | 313 syntax cache applies to, or |
314 Qnil for a string of text not | |
315 coming from a buffer or string. */ | |
316 struct buffer *buffer; /* The buffer that supplies the | |
317 syntax tables, or 0 for the | |
318 standard syntax table. If | |
319 OBJECT is a buffer, this will | |
320 always be the same buffer. */ | |
460 | 321 int syntax_code; /* Syntax code of current char. */ |
1296 | 322 Lisp_Object syntax_table; /* Syntax table for current pos. */ |
323 Lisp_Object mirror_table; /* Mirror table for this table. */ | |
826 | 324 Lisp_Object start, end; /* Markers to keep track of the |
325 known region in a buffer. | |
326 Formerly we used an internal | |
327 extent, but it seems that having | |
328 an extent over the entire buffer | |
329 causes serious slowdowns in | |
330 extent operations! Yuck! */ | |
331 Charxpos next_change; /* Position of the next extent | |
460 | 332 change. */ |
826 | 333 Charxpos prev_change; /* Position of the previous extent |
334 change. */ | |
460 | 335 }; |
826 | 336 |
3092 | 337 #ifdef NEW_GC |
338 typedef struct syntax_cache Lisp_Syntax_Cache; | |
339 | |
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
parents:
3498
diff
changeset
|
340 DECLARE_LISP_OBJECT (syntax_cache, Lisp_Syntax_Cache); |
3092 | 341 |
342 #define XSYNTAX_CACHE(x) \ | |
343 XRECORD (x, syntax_cache, Lisp_Syntax_Cache) | |
344 #define wrap_syntax_cache(p) wrap_record (p, syntax_cache) | |
345 #define SYNTAX_CACHE_P(x) RECORDP (x, syntax_cache) | |
346 #define CHECK_SYNTAX_CACHE(x) CHECK_RECORD (x, syntax_cache) | |
347 #define CONCHECK_SYNTAX_CACHE(x) CONCHECK_RECORD (x, syntax_cache) | |
348 #endif /* NEW_GC */ | |
349 | |
350 | |
351 | |
1296 | 352 extern const struct sized_memory_description syntax_cache_description; |
353 | |
826 | 354 /* Note that the external interface to the syntax-cache uses charpos's, but |
3250 | 355 internally we use bytepos's, for speed. */ |
460 | 356 |
826 | 357 void update_syntax_cache (struct syntax_cache *cache, Charxpos pos, int count); |
358 struct syntax_cache *setup_syntax_cache (struct syntax_cache *cache, | |
359 Lisp_Object object, | |
360 struct buffer *buffer, | |
361 Charxpos from, int count); | |
362 struct syntax_cache *setup_buffer_syntax_cache (struct buffer *buffer, | |
363 Charxpos from, int count); | |
460 | 364 |
365 /* Make syntax cache state good for CHARPOS, assuming it is | |
366 currently good for a position before CHARPOS. */ | |
826 | 367 DECLARE_INLINE_HEADER ( |
368 void | |
369 UPDATE_SYNTAX_CACHE_FORWARD (struct syntax_cache *cache, Charxpos pos) | |
370 ) | |
371 { | |
1315 | 372 /* #### Formerly this function, and the next one, had |
373 | |
374 if (pos < cache->prev_change || pos >= cache->next_change) | |
375 | |
376 just like for plain UPDATE_SYNTAX_CACHE. However, sometimes the | |
377 value of POS may be invalid (particularly, it may be 0 for a buffer). | |
378 FSF has the check at only one end, so let's try the same. */ | |
379 if (pos >= cache->next_change) | |
826 | 380 update_syntax_cache (cache, pos, 1); |
381 } | |
460 | 382 |
383 /* Make syntax cache state good for CHARPOS, assuming it is | |
384 currently good for a position after CHARPOS. */ | |
826 | 385 DECLARE_INLINE_HEADER ( |
386 void | |
387 UPDATE_SYNTAX_CACHE_BACKWARD (struct syntax_cache *cache, Charxpos pos) | |
388 ) | |
389 { | |
1315 | 390 if (pos < cache->prev_change) |
826 | 391 update_syntax_cache (cache, pos, -1); |
392 } | |
460 | 393 |
394 /* Make syntax cache state good for CHARPOS */ | |
826 | 395 DECLARE_INLINE_HEADER ( |
396 void | |
397 UPDATE_SYNTAX_CACHE (struct syntax_cache *cache, Charxpos pos) | |
398 ) | |
399 { | |
1315 | 400 if (pos < cache->prev_change || pos >= cache->next_change) |
826 | 401 update_syntax_cache (cache, pos, 0); |
402 } | |
460 | 403 |
826 | 404 #define SYNTAX_FROM_CACHE(cache, c) \ |
405 SYNTAX_FROM_CODE (SYNTAX_CODE_FROM_CACHE (cache, c)) | |
460 | 406 |
826 | 407 #define SYNTAX_CODE_FROM_CACHE(cache, c) \ |
408 ((cache)->use_code ? (cache)->syntax_code \ | |
1296 | 409 : SYNTAX_CODE ((cache)->mirror_table, c)) |
410 | |
411 #ifdef NOT_WORTH_THE_EFFORT | |
412 /* If we really cared about the theoretical performance hit of the dirty | |
413 check in SYNTAX_CODE, we could use SYNTAX_CODE_1 and endeavor to always | |
414 keep the mirror table clean, e.g. by checking for dirtiness at the time | |
415 we set up the syntax cache. There are lots of potential problems, of | |
416 course -- incomplete understanding of the possible pathways into the | |
417 code, with some that are bypassing the setups, Lisp code being executed | |
418 in the meantime that could change things (e.g. QUIT is called in many | |
419 functions and could execute arbitrary Lisp very easily), etc. The QUIT | |
420 problem is the biggest one, probably, and one of the main reasons it's | |
421 probably just not worth it. */ | |
422 #define SYNTAX_CODE_FROM_CACHE(cache, c) \ | |
423 ((cache)->use_code ? (cache)->syntax_code \ | |
424 : SYNTAX_CODE_1 ((cache)->mirror_table, c)) | |
425 #endif | |
826 | 426 |
427 | |
428 /***************************** syntax code macros ****************************/ | |
460 | 429 |
430 #define SYNTAX_CODE_PREFIX(c) \ | |
431 ((c >> 7) & 1) | |
432 | |
433 #define SYNTAX_CODE_COMMENT_BITS(c) \ | |
434 ((c >> 16) &0xff) | |
435 | |
436 #define SYNTAX_CODES_START_P(a, b) \ | |
437 (((SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_FIRST_CHAR_START) >> 2) \ | |
438 & (SYNTAX_CODE_COMMENT_BITS (b) & SYNTAX_SECOND_CHAR_START)) | |
439 | |
440 #define SYNTAX_CODES_END_P(a, b) \ | |
441 (((SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_FIRST_CHAR_END) >> 2) \ | |
442 & (SYNTAX_CODE_COMMENT_BITS (b) & SYNTAX_SECOND_CHAR_END)) | |
443 | |
444 #define SYNTAX_CODES_COMMENT_MASK_START(a, b) \ | |
445 (SYNTAX_CODES_MATCH_START_P (a, b, SYNTAX_COMMENT_STYLE_A) \ | |
446 ? SYNTAX_COMMENT_STYLE_A \ | |
447 : (SYNTAX_CODES_MATCH_START_P (a, b, SYNTAX_COMMENT_STYLE_B) \ | |
448 ? SYNTAX_COMMENT_STYLE_B \ | |
449 : 0)) | |
450 #define SYNTAX_CODES_COMMENT_MASK_END(a, b) \ | |
451 (SYNTAX_CODES_MATCH_END_P (a, b, SYNTAX_COMMENT_STYLE_A) \ | |
452 ? SYNTAX_COMMENT_STYLE_A \ | |
453 : (SYNTAX_CODES_MATCH_END_P (a, b, SYNTAX_COMMENT_STYLE_B) \ | |
454 ? SYNTAX_COMMENT_STYLE_B \ | |
455 : 0)) | |
456 | |
457 #define SYNTAX_CODE_START_FIRST_P(a) \ | |
458 (SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_FIRST_CHAR_START) | |
459 | |
460 #define SYNTAX_CODE_START_SECOND_P(a) \ | |
461 (SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_SECOND_CHAR_START) | |
462 | |
463 #define SYNTAX_CODE_END_FIRST_P(a) \ | |
464 (SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_FIRST_CHAR_END) | |
465 | |
466 #define SYNTAX_CODE_END_SECOND_P(a) \ | |
467 (SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_SECOND_CHAR_END) | |
468 | |
469 | |
470 #define SYNTAX_CODES_MATCH_START_P(a, b, mask) \ | |
471 ((SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_FIRST_CHAR_START & (mask)) \ | |
472 && (SYNTAX_CODE_COMMENT_BITS (b) \ | |
473 & SYNTAX_SECOND_CHAR_START & (mask))) | |
474 | |
475 #define SYNTAX_CODES_MATCH_END_P(a, b, mask) \ | |
476 ((SYNTAX_CODE_COMMENT_BITS (a) & SYNTAX_FIRST_CHAR_END & (mask)) \ | |
477 && (SYNTAX_CODE_COMMENT_BITS (b) & SYNTAX_SECOND_CHAR_END & (mask))) | |
478 | |
479 #define SYNTAX_CODE_MATCHES_1CHAR_P(a, mask) \ | |
480 ((SYNTAX_CODE_COMMENT_BITS (a) & (mask))) | |
481 | |
482 #define SYNTAX_CODE_COMMENT_1CHAR_MASK(a) \ | |
483 ((SYNTAX_CODE_MATCHES_1CHAR_P (a, SYNTAX_COMMENT_STYLE_A) \ | |
484 ? SYNTAX_COMMENT_STYLE_A \ | |
485 : (SYNTAX_CODE_MATCHES_1CHAR_P (a, SYNTAX_COMMENT_STYLE_B) \ | |
486 ? SYNTAX_COMMENT_STYLE_B \ | |
487 : 0))) | |
488 | |
489 | |
440 | 490 #endif /* INCLUDED_syntax_h_ */ |