Mercurial > emacs
annotate src/syntax.h @ 13245:2e0c4159e94b
(describe_map_tree): New arg always_title. Callers changed.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 19 Oct 1995 00:17:11 +0000 |
parents | ba670977cceb |
children | 94a4b6e9d310 |
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 | |
12244 | 8 the Free Software Foundation; either version 2, or (at your option) |
486 | 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 | |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
28 /* A syntax table is a chartable whose elements are cons cells |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
29 (CODE+FLAGS . MATCHING-CHAR). MATCHING-CHAR can be nil if the char |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
30 is not a kind of parenthesis. |
486 | 31 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
32 The low 8 bits of CODE+FLAGS is a code, as follows: */ |
486 | 33 |
34 enum syntaxcode | |
35 { | |
36 Swhitespace, /* for a whitespace character */ | |
37 Spunct, /* for random punctuation characters */ | |
38 Sword, /* for a word constituent */ | |
39 Ssymbol, /* symbol constituent but not word constituent */ | |
40 Sopen, /* for a beginning delimiter */ | |
41 Sclose, /* for an ending delimiter */ | |
42 Squote, /* for a prefix character like Lisp ' */ | |
43 Sstring, /* for a string-grouping character like Lisp " */ | |
44 Smath, /* for delimiters like $ in Tex. */ | |
45 Sescape, /* for a character that begins a C-style escape */ | |
46 Scharquote, /* for a character that quotes the following character */ | |
47 Scomment, /* for a comment-starting character */ | |
48 Sendcomment, /* for a comment-ending character */ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
49 Sinherit, /* use the standard syntax table for this character */ |
486 | 50 Smax /* Upper bound on codes that are meaningful */ |
51 }; | |
52 | |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
53 /* Fetch the syntax entry for char C from table TABLE. |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
54 This returns the whole entry (normally a cons cell) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
55 and does not do any kind of inheritance. */ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
56 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
57 #if 1 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
58 #define RAW_SYNTAX_ENTRY(table, c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
59 (XCHAR_TABLE (table)->contents[(unsigned char) (c)]) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
60 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
61 #define SET_RAW_SYNTAX_ENTRY(table, c, val) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
62 (XCHAR_TABLE (table)->contents[(unsigned char) (c)] = (val)) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
63 #else |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
64 #define RAW_SYNTAX_ENTRY(table, c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
65 ((c) >= 128 \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
66 ? raw_syntax_table_lookup (table, c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
67 : XCHAR_TABLE (table)->contents[(unsigned char) (c)]) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
68 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
69 #define SET_RAW_SYNTAX_ENTRY(table, c, val) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
70 ((c) >= 128 \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
71 ? set_raw_syntax_table_lookup (table, c, (val)) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
72 : XCHAR_TABLE (table)->contents[(unsigned char) (c)] = (val)) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
73 #endif |
486 | 74 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
75 /* Extract the information from the entry for character C |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
76 in syntax table TABLE. Do inheritance. */ |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
77 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
78 #ifdef __GNUC__ |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
79 #define SYNTAX_ENTRY(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
80 ({ Lisp_Object temp, table; \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
81 unsigned char cc = (c); \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
82 table = current_buffer->syntax_table; \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
83 while (!NILP (table)) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
84 { \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
85 temp = RAW_SYNTAX_ENTRY (table, cc); \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
86 if (!NILP (temp)) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
87 break; \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
88 table = XCHAR_TABLE (table)->parent; \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
89 } \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
90 temp; }) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
91 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
92 #define SYNTAX(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
93 ({ Lisp_Object temp; \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
94 temp = SYNTAX_ENTRY (c); \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
95 (CONSP (temp) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
96 ? (enum syntaxcode) (XINT (XCONS (temp)->car) & 0xff) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
97 : wrong_type_argument (Qconsp, temp)); }) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
98 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
99 #define SYNTAX_WITH_FLAGS(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
100 ({ Lisp_Object temp; \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
101 temp = SYNTAX_ENTRY (c); \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
102 (CONSP (temp) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
103 ? XINT (XCONS (temp)->car) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
104 : wrong_type_argument (Qconsp, temp)); }) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
105 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
106 #define SYNTAX_MATCH(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
107 ({ Lisp_Object temp; \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
108 temp = SYNTAX_ENTRY (c); \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
109 (CONSP (temp) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
110 ? XINT (XCONS (temp)->cdr) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
111 : wrong_type_argument (Qconsp, temp)); }) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
112 #else |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
113 extern Lisp_Object syntax_temp; |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
114 extern Lisp_Object syntax_parent_lookup (); |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
115 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
116 #define SYNTAX_ENTRY(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
117 (syntax_temp \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
118 = RAW_SYNTAX_ENTRY (current_buffer->syntax_table, (c)), \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
119 (NILP (syntax_temp) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
120 ? (syntax_temp \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
121 = syntax_parent_lookup (current_buffer->syntax_table, (c))) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
122 : syntax_temp)) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
123 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
124 #define SYNTAX(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
125 (syntax_temp \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
126 = SYNTAX_ENTRY (current_buffer->syntax_table, (c)), \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
127 (CONSP (syntax_temp) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
128 ? (enum syntaxcode) (XINT (XCONS (syntax_temp)->car) & 0xff) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
129 : wrong_type_argument (Qconsp, syntax_temp)) }) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
130 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
131 #define SYNTAX_WITH_FLAGS(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
132 (syntax_temp \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
133 = SYNTAX_ENTRY (current_buffer->syntax_table, (c)), \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
134 (CONSP (syntax_temp) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
135 ? XINT (XCONS (syntax_temp)->car) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
136 : wrong_type_argument (Qconsp, syntax_temp)) }) |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
137 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
138 #define SYNTAX_MATCH(c) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
139 (syntax_temp \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
140 = SYNTAX_ENTRY (current_buffer->syntax_table, (c)), \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
141 (CONSP (syntax_temp) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
142 ? XINT (XCONS (syntax_temp)->cdr) \ |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
143 : wrong_type_argument (Qconsp, syntax_temp)) }) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
144 #endif |
486 | 145 |
1073 | 146 /* Then there are six single-bit flags that have the following meanings: |
486 | 147 1. This character is the first of a two-character comment-start sequence. |
148 2. This character is the second of a two-character comment-start sequence. | |
149 3. This character is the first of a two-character comment-end sequence. | |
150 4. This character is the second of a two-character comment-end sequence. | |
151 5. This character is a prefix, for backward-prefix-chars. | |
1073 | 152 Note that any two-character sequence whose first character has flag 1 |
153 and whose second character has flag 2 will be interpreted as a comment start. | |
154 | |
155 bit 6 is used to discriminate between two different comment styles. | |
156 Languages such as C++ allow two orthogonal syntax start/end pairs | |
157 and bit 6 is used to determine whether a comment-end or Scommentend | |
158 ends style a or b. Comment start sequences can start style a or b. | |
159 Style a is always the default. | |
160 */ | |
486 | 161 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
162 #define SYNTAX_COMSTART_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 16) & 1) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
163 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
164 #define SYNTAX_COMSTART_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 17) & 1) |
486 | 165 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
166 #define SYNTAX_COMEND_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 18) & 1) |
486 | 167 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
168 #define SYNTAX_COMEND_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 19) & 1) |
486 | 169 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
170 #define SYNTAX_PREFIX(c) ((SYNTAX_WITH_FLAGS (c) >> 20) & 1) |
486 | 171 |
1073 | 172 /* extract the comment style bit from the syntax table entry */ |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
173 #define SYNTAX_COMMENT_STYLE(c) ((SYNTAX_WITH_FLAGS (c) >> 21) & 1) |
1073 | 174 |
486 | 175 /* This array, indexed by a character, contains the syntax code which that |
176 character signifies (as a char). For example, | |
177 (enum syntaxcode) syntax_spec_code['w'] is Sword. */ | |
178 | |
179 extern unsigned char syntax_spec_code[0400]; | |
180 | |
181 /* Indexed by syntax code, give the letter that describes it. */ | |
182 | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
183 extern char syntax_code_spec[14]; |