Mercurial > emacs
annotate src/syntax.h @ 9136:083a2f0f63f6
(STRING256_P): Use type test macros.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 27 Sep 1994 03:09:02 +0000 |
parents | 82a5362b244f |
children | ac7375e60931 |
rev | line source |
---|---|
486 | 1 /* Declarations having to do with GNU Emacs syntax tables. |
7307 | 2 Copyright (C) 1985, 1993, 1994 Free Software Foundation, Inc. |
486 | 3 |
4 This file is part of GNU Emacs. | |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
19 | |
20 | |
21 extern Lisp_Object Qsyntax_table_p; | |
22 extern Lisp_Object Fsyntax_table_p (), Fsyntax_table (), Fset_syntax_table (); | |
23 | |
24 /* The standard syntax table is stored where it will automatically | |
25 be used in all new buffers. */ | |
26 #define Vstandard_syntax_table buffer_defaults.syntax_table | |
27 | |
28 /* A syntax table is a Lisp vector of length 0400, whose elements are integers. | |
29 | |
30 The low 8 bits of the integer is a code, as follows: | |
31 */ | |
32 | |
33 enum syntaxcode | |
34 { | |
35 Swhitespace, /* for a whitespace character */ | |
36 Spunct, /* for random punctuation characters */ | |
37 Sword, /* for a word constituent */ | |
38 Ssymbol, /* symbol constituent but not word constituent */ | |
39 Sopen, /* for a beginning delimiter */ | |
40 Sclose, /* for an ending delimiter */ | |
41 Squote, /* for a prefix character like Lisp ' */ | |
42 Sstring, /* for a string-grouping character like Lisp " */ | |
43 Smath, /* for delimiters like $ in Tex. */ | |
44 Sescape, /* for a character that begins a C-style escape */ | |
45 Scharquote, /* for a character that quotes the following character */ | |
46 Scomment, /* for a comment-starting character */ | |
47 Sendcomment, /* for a comment-ending character */ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
48 Sinherit, /* use the standard syntax table for this character */ |
486 | 49 Smax /* Upper bound on codes that are meaningful */ |
50 }; | |
51 | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
52 #define RAW_SYNTAX(table, c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
53 ((enum syntaxcode) (XINT (XVECTOR (table)->contents[(unsigned char) (c)]) & 0377)) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
54 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
55 #ifdef __GNUC__ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
56 #define SYNTAX(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
57 ({ unsigned char character = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
58 enum syntaxcode syntax \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
59 = RAW_SYNTAX (current_buffer->syntax_table, character); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
60 if (syntax == Sinherit) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
61 syntax = RAW_SYNTAX (Vstandard_syntax_table, character); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
62 syntax; }) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
63 #else |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
64 #define SYNTAX(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
65 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
66 ? RAW_SYNTAX (Vstandard_syntax_table, c) \ |
5725
45d91f2b3810
(SYNTAX_MATCH, SYNTAX): Fix non-GNUC definitions.
Richard M. Stallman <rms@gnu.org>
parents:
5441
diff
changeset
|
67 : RAW_SYNTAX (current_buffer->syntax_table, c)) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
68 #endif |
486 | 69 |
70 /* The next 8 bits of the number is a character, | |
71 the matching delimiter in the case of Sopen or Sclose. */ | |
72 | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
73 #define RAW_SYNTAX_MATCH(table, c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
74 ((XINT (XVECTOR (table)->contents[(unsigned char) (c)]) >> 8) & 0377) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
75 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
76 #ifdef __GNUC__ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
77 #define SYNTAX_MATCH(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
78 ({ unsigned char character = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
79 enum syntaxcode syntax \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
80 = RAW_SYNTAX (current_buffer->syntax_table, character); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
81 int matcher; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
82 if (syntax == Sinherit) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
83 matcher = RAW_SYNTAX_MATCH (Vstandard_syntax_table, character); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
84 else \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
85 matcher = RAW_SYNTAX_MATCH (current_buffer->syntax_table, character); \ |
7967
82a5362b244f
(SYNTAX_MATCH): Fix typo (syntax -> matcher).
Richard M. Stallman <rms@gnu.org>
parents:
7307
diff
changeset
|
86 matcher; }) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
87 #else |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
88 #define SYNTAX_MATCH(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
89 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
90 ? RAW_SYNTAX_MATCH (Vstandard_syntax_table, c) \ |
5725
45d91f2b3810
(SYNTAX_MATCH, SYNTAX): Fix non-GNUC definitions.
Richard M. Stallman <rms@gnu.org>
parents:
5441
diff
changeset
|
91 : RAW_SYNTAX_MATCH (current_buffer->syntax_table, c)) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
92 #endif |
486 | 93 |
1073 | 94 /* Then there are six single-bit flags that have the following meanings: |
486 | 95 1. This character is the first of a two-character comment-start sequence. |
96 2. This character is the second of a two-character comment-start sequence. | |
97 3. This character is the first of a two-character comment-end sequence. | |
98 4. This character is the second of a two-character comment-end sequence. | |
99 5. This character is a prefix, for backward-prefix-chars. | |
1073 | 100 Note that any two-character sequence whose first character has flag 1 |
101 and whose second character has flag 2 will be interpreted as a comment start. | |
102 | |
103 bit 6 is used to discriminate between two different comment styles. | |
104 Languages such as C++ allow two orthogonal syntax start/end pairs | |
105 and bit 6 is used to determine whether a comment-end or Scommentend | |
106 ends style a or b. Comment start sequences can start style a or b. | |
107 Style a is always the default. | |
108 */ | |
486 | 109 |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
110 #define SYNTAX_CHOOSE_TABLE(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
111 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
112 ? Vstandard_syntax_table : current_buffer->syntax_table) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
113 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
114 #ifdef __GNUC__ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
115 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
116 #define SYNTAX_COMSTART_FIRST(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
117 ({ unsigned char ch = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
118 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
119 (XINT (XVECTOR (table)->contents[ch]) >> 16) & 1; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
120 }) |
486 | 121 |
122 #define SYNTAX_COMSTART_SECOND(c) \ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
123 ({ unsigned char ch = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
124 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
125 (XINT (XVECTOR (table)->contents[ch]) >> 17) & 1; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
126 }) |
486 | 127 |
128 #define SYNTAX_COMEND_FIRST(c) \ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
129 ({ unsigned char ch = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
130 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
131 (XINT (XVECTOR (table)->contents[ch]) >> 18) & 1; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
132 }) |
486 | 133 |
134 #define SYNTAX_COMEND_SECOND(c) \ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
135 ({ unsigned char ch = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
136 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
137 (XINT (XVECTOR (table)->contents[ch]) >> 19) & 1; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
138 }) |
486 | 139 |
140 #define SYNTAX_PREFIX(c) \ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
141 ({ unsigned char ch = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
142 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
143 (XINT (XVECTOR (table)->contents[ch]) >> 20) & 1; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
144 }) |
486 | 145 |
1073 | 146 /* extract the comment style bit from the syntax table entry */ |
147 #define SYNTAX_COMMENT_STYLE(c) \ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
148 ({ unsigned char ch = c; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
149 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
150 (XINT (XVECTOR (table)->contents[ch]) >> 21) & 1; \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
151 }) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
152 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
153 #else |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
154 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
155 #define SYNTAX_COMSTART_FIRST(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
156 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 16) & 1) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
157 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
158 #define SYNTAX_COMSTART_SECOND(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
159 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 17) & 1) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
160 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
161 #define SYNTAX_COMEND_FIRST(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
162 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 18) & 1) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
163 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
164 #define SYNTAX_COMEND_SECOND(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
165 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 19) & 1) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
166 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
167 #define SYNTAX_PREFIX(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
168 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 20) & 1) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
169 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
170 /* extract the comment style bit from the syntax table entry */ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
171 #define SYNTAX_COMMENT_STYLE(c) \ |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
172 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 21) & 1) |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
173 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
174 #endif |
1073 | 175 |
486 | 176 /* This array, indexed by a character, contains the syntax code which that |
177 character signifies (as a char). For example, | |
178 (enum syntaxcode) syntax_spec_code['w'] is Sword. */ | |
179 | |
180 extern unsigned char syntax_spec_code[0400]; | |
181 | |
182 /* Indexed by syntax code, give the letter that describes it. */ | |
183 | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
184 extern char syntax_code_spec[14]; |