Mercurial > emacs
comparison src/syntax.h @ 5441:0af9674da850
(enum syntaxcode): Add Sinherit.
(RAW_SYNTAX, RAW_SYNTAX_MATCH, SYNTAX_CHOOSE_TABLE): New macros.
(SYNTAX, SYNTAX_MATCH, SYNTAX_COMSTART_FIRST, SYNTAX_COMSTART_SECOND)
(SYNTAX_COMEND_FIRST, SYNTAX_COMEND_SECOND, SYNTAX_PREFIX)
(SYNTAX_COMMENT_STYLE): Handle Sinherit.
Alternative definitions if __GNUC__.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 05 Jan 1994 20:33:02 +0000 |
parents | e94a593c3952 |
children | 45d91f2b3810 |
comparison
equal
deleted
inserted
replaced
5440:856ecdc5228a | 5441:0af9674da850 |
---|---|
43 Smath, /* for delimiters like $ in Tex. */ | 43 Smath, /* for delimiters like $ in Tex. */ |
44 Sescape, /* for a character that begins a C-style escape */ | 44 Sescape, /* for a character that begins a C-style escape */ |
45 Scharquote, /* for a character that quotes the following character */ | 45 Scharquote, /* for a character that quotes the following character */ |
46 Scomment, /* for a comment-starting character */ | 46 Scomment, /* for a comment-starting character */ |
47 Sendcomment, /* for a comment-ending character */ | 47 Sendcomment, /* for a comment-ending character */ |
48 Sinherit, /* use the standard syntax table for this character */ | |
48 Smax /* Upper bound on codes that are meaningful */ | 49 Smax /* Upper bound on codes that are meaningful */ |
49 }; | 50 }; |
50 | 51 |
51 #define SYNTAX(c) \ | 52 #define RAW_SYNTAX(table, c) \ |
52 ((enum syntaxcode) (XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) & 0377)) | 53 ((enum syntaxcode) (XINT (XVECTOR (table)->contents[(unsigned char) (c)]) & 0377)) |
54 | |
55 #ifdef __GNUC__ | |
56 #define SYNTAX(c) \ | |
57 ({ unsigned char character = c; \ | |
58 enum syntaxcode syntax \ | |
59 = RAW_SYNTAX (current_buffer->syntax_table, character); \ | |
60 if (syntax == Sinherit) \ | |
61 syntax = RAW_SYNTAX (Vstandard_syntax_table, character); \ | |
62 syntax; }) | |
63 #else | |
64 #define SYNTAX(c) \ | |
65 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \ | |
66 ? RAW_SYNTAX (Vstandard_syntax_table, c) \ | |
67 : RAW_SYNTAX (c)) | |
68 #endif | |
53 | 69 |
54 /* The next 8 bits of the number is a character, | 70 /* The next 8 bits of the number is a character, |
55 the matching delimiter in the case of Sopen or Sclose. */ | 71 the matching delimiter in the case of Sopen or Sclose. */ |
56 | 72 |
57 #define SYNTAX_MATCH(c) \ | 73 #define RAW_SYNTAX_MATCH(table, c) \ |
58 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 8) & 0377) | 74 ((XINT (XVECTOR (table)->contents[(unsigned char) (c)]) >> 8) & 0377) |
75 | |
76 #ifdef __GNUC__ | |
77 #define SYNTAX_MATCH(c) \ | |
78 ({ unsigned char character = c; \ | |
79 enum syntaxcode syntax \ | |
80 = RAW_SYNTAX (current_buffer->syntax_table, character); \ | |
81 int matcher; \ | |
82 if (syntax == Sinherit) \ | |
83 matcher = RAW_SYNTAX_MATCH (Vstandard_syntax_table, character); \ | |
84 else \ | |
85 matcher = RAW_SYNTAX_MATCH (current_buffer->syntax_table, character); \ | |
86 syntax; }) | |
87 #else | |
88 #define SYNTAX_MATCH(c) \ | |
89 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \ | |
90 ? RAW_SYNTAX_MATCH (Vstandard_syntax_table, c) \ | |
91 : RAW_SYNTAX_MATCH (c)) | |
92 #endif | |
59 | 93 |
60 /* Then there are six single-bit flags that have the following meanings: | 94 /* Then there are six single-bit flags that have the following meanings: |
61 1. This character is the first of a two-character comment-start sequence. | 95 1. This character is the first of a two-character comment-start sequence. |
62 2. This character is the second of a two-character comment-start sequence. | 96 2. This character is the second of a two-character comment-start sequence. |
63 3. This character is the first of a two-character comment-end sequence. | 97 3. This character is the first of a two-character comment-end sequence. |
71 and bit 6 is used to determine whether a comment-end or Scommentend | 105 and bit 6 is used to determine whether a comment-end or Scommentend |
72 ends style a or b. Comment start sequences can start style a or b. | 106 ends style a or b. Comment start sequences can start style a or b. |
73 Style a is always the default. | 107 Style a is always the default. |
74 */ | 108 */ |
75 | 109 |
76 #define SYNTAX_COMSTART_FIRST(c) \ | 110 #define SYNTAX_CHOOSE_TABLE(c) \ |
77 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 16) & 1) | 111 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \ |
112 ? Vstandard_syntax_table : current_buffer->syntax_table) | |
113 | |
114 #ifdef __GNUC__ | |
115 | |
116 #define SYNTAX_COMSTART_FIRST(c) \ | |
117 ({ unsigned char ch = c; \ | |
118 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ | |
119 (XINT (XVECTOR (table)->contents[ch]) >> 16) & 1; \ | |
120 }) | |
78 | 121 |
79 #define SYNTAX_COMSTART_SECOND(c) \ | 122 #define SYNTAX_COMSTART_SECOND(c) \ |
80 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 17) & 1) | 123 ({ unsigned char ch = c; \ |
124 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ | |
125 (XINT (XVECTOR (table)->contents[ch]) >> 17) & 1; \ | |
126 }) | |
81 | 127 |
82 #define SYNTAX_COMEND_FIRST(c) \ | 128 #define SYNTAX_COMEND_FIRST(c) \ |
83 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 18) & 1) | 129 ({ unsigned char ch = c; \ |
130 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ | |
131 (XINT (XVECTOR (table)->contents[ch]) >> 18) & 1; \ | |
132 }) | |
84 | 133 |
85 #define SYNTAX_COMEND_SECOND(c) \ | 134 #define SYNTAX_COMEND_SECOND(c) \ |
86 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 19) & 1) | 135 ({ unsigned char ch = c; \ |
136 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ | |
137 (XINT (XVECTOR (table)->contents[ch]) >> 19) & 1; \ | |
138 }) | |
87 | 139 |
88 #define SYNTAX_PREFIX(c) \ | 140 #define SYNTAX_PREFIX(c) \ |
89 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 20) & 1) | 141 ({ unsigned char ch = c; \ |
142 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ | |
143 (XINT (XVECTOR (table)->contents[ch]) >> 20) & 1; \ | |
144 }) | |
90 | 145 |
91 /* extract the comment style bit from the syntax table entry */ | 146 /* extract the comment style bit from the syntax table entry */ |
92 #define SYNTAX_COMMENT_STYLE(c) \ | 147 #define SYNTAX_COMMENT_STYLE(c) \ |
93 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 21) & 1) | 148 ({ unsigned char ch = c; \ |
149 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \ | |
150 (XINT (XVECTOR (table)->contents[ch]) >> 21) & 1; \ | |
151 }) | |
152 | |
153 #else | |
154 | |
155 #define SYNTAX_COMSTART_FIRST(c) \ | |
156 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 16) & 1) | |
157 | |
158 #define SYNTAX_COMSTART_SECOND(c) \ | |
159 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 17) & 1) | |
160 | |
161 #define SYNTAX_COMEND_FIRST(c) \ | |
162 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 18) & 1) | |
163 | |
164 #define SYNTAX_COMEND_SECOND(c) \ | |
165 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 19) & 1) | |
166 | |
167 #define SYNTAX_PREFIX(c) \ | |
168 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 20) & 1) | |
169 | |
170 /* extract the comment style bit from the syntax table entry */ | |
171 #define SYNTAX_COMMENT_STYLE(c) \ | |
172 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 21) & 1) | |
173 | |
174 #endif | |
94 | 175 |
95 /* This array, indexed by a character, contains the syntax code which that | 176 /* This array, indexed by a character, contains the syntax code which that |
96 character signifies (as a char). For example, | 177 character signifies (as a char). For example, |
97 (enum syntaxcode) syntax_spec_code['w'] is Sword. */ | 178 (enum syntaxcode) syntax_spec_code['w'] is Sword. */ |
98 | 179 |
99 extern unsigned char syntax_spec_code[0400]; | 180 extern unsigned char syntax_spec_code[0400]; |
100 | 181 |
101 /* Indexed by syntax code, give the letter that describes it. */ | 182 /* Indexed by syntax code, give the letter that describes it. */ |
102 | 183 |
103 extern char syntax_code_spec[13]; | 184 extern char syntax_code_spec[14]; |