Mercurial > emacs
annotate src/syntax.h @ 67012:6b634736fd83
(read-passwd): Fontify the prompt as we do with other prompts.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sat, 19 Nov 2005 12:49:30 +0000 |
parents | a0d1312ede66 |
children | 3bd95f4f2941 2d92f5c9d6ae |
rev | line source |
---|---|
486 | 1 /* Declarations having to do with GNU Emacs syntax tables. |
64770
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
2 Copyright (C) 1985, 1993, 1994, 1997, 1998, 2002, 2003, 2004, |
a0d1312ede66
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64084
diff
changeset
|
3 2005 Free Software Foundation, Inc. |
486 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
12244 | 9 the Free Software Foundation; either version 2, or (at your option) |
486 | 10 any later version. |
11 | |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
64084 | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. */ | |
486 | 21 |
22 | |
23 extern Lisp_Object Qsyntax_table_p; | |
20349 | 24 extern void update_syntax_table P_ ((int, int, int, Lisp_Object)); |
486 | 25 |
26 /* The standard syntax table is stored where it will automatically | |
27 be used in all new buffers. */ | |
28 #define Vstandard_syntax_table buffer_defaults.syntax_table | |
29 | |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
30 /* 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
|
31 (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
|
32 is not a kind of parenthesis. |
486 | 33 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
34 The low 8 bits of CODE+FLAGS is a code, as follows: */ |
486 | 35 |
36 enum syntaxcode | |
37 { | |
38 Swhitespace, /* for a whitespace character */ | |
39 Spunct, /* for random punctuation characters */ | |
40 Sword, /* for a word constituent */ | |
41 Ssymbol, /* symbol constituent but not word constituent */ | |
42 Sopen, /* for a beginning delimiter */ | |
43 Sclose, /* for an ending delimiter */ | |
44 Squote, /* for a prefix character like Lisp ' */ | |
45 Sstring, /* for a string-grouping character like Lisp " */ | |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
46 Smath, /* for delimiters like $ in Tex. */ |
486 | 47 Sescape, /* for a character that begins a C-style escape */ |
48 Scharquote, /* for a character that quotes the following character */ | |
49 Scomment, /* for a comment-starting character */ | |
50 Sendcomment, /* for a comment-ending character */ | |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
51 Sinherit, /* use the standard syntax table for this character */ |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
52 Scomment_fence, /* Starts/ends comment which is delimited on the |
20487 | 53 other side by any char with the same syntaxcode. */ |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
54 Sstring_fence, /* Starts/ends string which is delimited on the |
20487 | 55 other side by any char with the same syntaxcode. */ |
486 | 56 Smax /* Upper bound on codes that are meaningful */ |
57 }; | |
58 | |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
59 /* Set the syntax entry VAL for char C in table TABLE. */ |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
60 |
17127
ab43d13fdfd5
(SET_RAW_SYNTAX_ENTRY, SYNTAX_ENTRY): Cast arg C to
Kenichi Handa <handa@m17n.org>
parents:
17045
diff
changeset
|
61 #define SET_RAW_SYNTAX_ENTRY(table, c, val) \ |
55319
75e1ea70fb3d
(SET_RAW_SYNTAX_ENTRY, SYNTAX_ENTRY_INT): Avoid
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
62 ((((c) & 0xFF) == (c)) \ |
17127
ab43d13fdfd5
(SET_RAW_SYNTAX_ENTRY, SYNTAX_ENTRY): Cast arg C to
Kenichi Handa <handa@m17n.org>
parents:
17045
diff
changeset
|
63 ? (XCHAR_TABLE (table)->contents[(unsigned char) (c)] = (val)) \ |
ab43d13fdfd5
(SET_RAW_SYNTAX_ENTRY, SYNTAX_ENTRY): Cast arg C to
Kenichi Handa <handa@m17n.org>
parents:
17045
diff
changeset
|
64 : Faset ((table), make_number (c), (val))) |
486 | 65 |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
66 /* Fetch the syntax entry for char C in syntax table TABLE. |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
67 This macro is called only when C is less than CHAR_TABLE_ORDINARY_SLOTS. |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
68 Do inheritance. */ |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
69 |
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
70 #ifdef __GNUC__ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
71 #define SYNTAX_ENTRY_FOLLOW_PARENT(table, c) \ |
56068
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
72 ({ Lisp_Object _syntax_tbl = (table); \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
73 Lisp_Object _syntax_temp = XCHAR_TABLE (_syntax_tbl)->contents[(c)]; \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
74 while (NILP (_syntax_temp)) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
75 { \ |
56068
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
76 _syntax_tbl = XCHAR_TABLE (_syntax_tbl)->parent; \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
77 if (NILP (_syntax_tbl)) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
78 break; \ |
56068
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
79 _syntax_temp = XCHAR_TABLE (_syntax_tbl)->contents[(c)]; \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
80 } \ |
56068
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
81 _syntax_temp; }) |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
82 #else |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
83 extern Lisp_Object syntax_temp; |
20349 | 84 extern Lisp_Object syntax_parent_lookup P_ ((Lisp_Object, int)); |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
85 |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
86 #define SYNTAX_ENTRY_FOLLOW_PARENT(table, c) \ |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
87 (syntax_temp = XCHAR_TABLE (table)->contents[(c)], \ |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
88 (NILP (syntax_temp) \ |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
89 ? syntax_parent_lookup (table, (c)) \ |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
90 : syntax_temp)) |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
91 #endif |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
92 |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
93 /* SYNTAX_ENTRY fetches the information from the entry for character C |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
94 in syntax table TABLE, or from globally kept data (gl_state). |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
95 Does inheritance. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
96 /* CURRENT_SYNTAX_TABLE gives the syntax table valid for current |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
97 position, it is either the buffer's syntax table, or syntax table |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
98 found in text properties. */ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
99 |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
100 #ifdef SYNTAX_ENTRY_VIA_PROPERTY |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
101 # define SYNTAX_ENTRY(c) \ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
102 (gl_state.use_global ? gl_state.global_code : SYNTAX_ENTRY_INT (c)) |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
103 # define CURRENT_SYNTAX_TABLE gl_state.current_syntax_table |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
104 #else |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
105 # define SYNTAX_ENTRY SYNTAX_ENTRY_INT |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
106 # define CURRENT_SYNTAX_TABLE current_buffer->syntax_table |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
107 #endif |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
108 |
26870
9ecd0716cf8a
(SYNTAX_ENTRY_INT): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25640
diff
changeset
|
109 #define SYNTAX_ENTRY_INT(c) \ |
55319
75e1ea70fb3d
(SET_RAW_SYNTAX_ENTRY, SYNTAX_ENTRY_INT): Avoid
Eli Zaretskii <eliz@gnu.org>
parents:
52401
diff
changeset
|
110 ((((c) & 0xFF) == (c)) \ |
26870
9ecd0716cf8a
(SYNTAX_ENTRY_INT): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25640
diff
changeset
|
111 ? SYNTAX_ENTRY_FOLLOW_PARENT (CURRENT_SYNTAX_TABLE, \ |
9ecd0716cf8a
(SYNTAX_ENTRY_INT): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25640
diff
changeset
|
112 (unsigned char) (c)) \ |
9ecd0716cf8a
(SYNTAX_ENTRY_INT): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25640
diff
changeset
|
113 : Faref (CURRENT_SYNTAX_TABLE, \ |
9ecd0716cf8a
(SYNTAX_ENTRY_INT): Delete codes for a composite
Kenichi Handa <handa@m17n.org>
parents:
25640
diff
changeset
|
114 make_number (c))) |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
115 |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
116 /* Extract the information from the entry for character C |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
117 in the current syntax table. */ |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
118 |
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
119 #ifdef __GNUC__ |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
120 #define SYNTAX(c) \ |
56068
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
121 ({ Lisp_Object _syntax_temp; \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
122 _syntax_temp = SYNTAX_ENTRY (c); \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
123 (CONSP (_syntax_temp) \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
124 ? (enum syntaxcode) (XINT (XCAR (_syntax_temp)) & 0xff) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
125 : Swhitespace); }) |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
126 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
127 #define SYNTAX_WITH_FLAGS(c) \ |
56068
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
128 ({ Lisp_Object _syntax_temp; \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
129 _syntax_temp = SYNTAX_ENTRY (c); \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
130 (CONSP (_syntax_temp) \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
131 ? XINT (XCAR (_syntax_temp)) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
132 : (int) Swhitespace); }) |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
133 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
134 #define SYNTAX_MATCH(c) \ |
56068
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
135 ({ Lisp_Object _syntax_temp; \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
136 _syntax_temp = SYNTAX_ENTRY (c); \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
137 (CONSP (_syntax_temp) \ |
f6fab60742ca
(SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents:
55319
diff
changeset
|
138 ? XCDR (_syntax_temp) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
139 : Qnil); }) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
140 #else |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
141 #define SYNTAX(c) \ |
13318
94a4b6e9d310
(SYNTAX, SYNTAX_WITH_FLAGS, SYNTAX_MATCH): Fix the non-GCC definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13143
diff
changeset
|
142 (syntax_temp = SYNTAX_ENTRY ((c)), \ |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
143 (CONSP (syntax_temp) \ |
25640 | 144 ? (enum syntaxcode) (XINT (XCAR (syntax_temp)) & 0xff) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
145 : Swhitespace)) |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
146 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
147 #define SYNTAX_WITH_FLAGS(c) \ |
13318
94a4b6e9d310
(SYNTAX, SYNTAX_WITH_FLAGS, SYNTAX_MATCH): Fix the non-GCC definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13143
diff
changeset
|
148 (syntax_temp = SYNTAX_ENTRY ((c)), \ |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
149 (CONSP (syntax_temp) \ |
25640 | 150 ? XINT (XCAR (syntax_temp)) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
151 : (int) Swhitespace)) |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
152 |
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
153 #define SYNTAX_MATCH(c) \ |
13318
94a4b6e9d310
(SYNTAX, SYNTAX_WITH_FLAGS, SYNTAX_MATCH): Fix the non-GCC definitions.
Richard M. Stallman <rms@gnu.org>
parents:
13143
diff
changeset
|
154 (syntax_temp = SYNTAX_ENTRY ((c)), \ |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
155 (CONSP (syntax_temp) \ |
25640 | 156 ? XCDR (syntax_temp) \ |
17045
1dfa84b25d3b
(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents:
14186
diff
changeset
|
157 : Qnil)) |
5441
0af9674da850
(enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents:
2961
diff
changeset
|
158 #endif |
486 | 159 |
25446
2a2d7ebaa018
(SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents:
23713
diff
changeset
|
160 /* Then there are seven single-bit flags that have the following meanings: |
486 | 161 1. This character is the first of a two-character comment-start sequence. |
162 2. This character is the second of a two-character comment-start sequence. | |
163 3. This character is the first of a two-character comment-end sequence. | |
164 4. This character is the second of a two-character comment-end sequence. | |
165 5. This character is a prefix, for backward-prefix-chars. | |
25446
2a2d7ebaa018
(SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents:
23713
diff
changeset
|
166 6. see below |
2a2d7ebaa018
(SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents:
23713
diff
changeset
|
167 7. This character is part of a nestable comment sequence. |
1073 | 168 Note that any two-character sequence whose first character has flag 1 |
169 and whose second character has flag 2 will be interpreted as a comment start. | |
170 | |
171 bit 6 is used to discriminate between two different comment styles. | |
172 Languages such as C++ allow two orthogonal syntax start/end pairs | |
173 and bit 6 is used to determine whether a comment-end or Scommentend | |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
174 ends style a or b. Comment start sequences can start style a or b. |
1073 | 175 Style a is always the default. |
176 */ | |
486 | 177 |
21206
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
178 /* These macros extract a particular flag for a given character. */ |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
179 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
180 #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
|
181 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
182 #define SYNTAX_COMSTART_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 17) & 1) |
486 | 183 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
184 #define SYNTAX_COMEND_FIRST(c) ((SYNTAX_WITH_FLAGS (c) >> 18) & 1) |
486 | 185 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
186 #define SYNTAX_COMEND_SECOND(c) ((SYNTAX_WITH_FLAGS (c) >> 19) & 1) |
486 | 187 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
188 #define SYNTAX_PREFIX(c) ((SYNTAX_WITH_FLAGS (c) >> 20) & 1) |
486 | 189 |
13143
ba670977cceb
Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents:
12244
diff
changeset
|
190 #define SYNTAX_COMMENT_STYLE(c) ((SYNTAX_WITH_FLAGS (c) >> 21) & 1) |
1073 | 191 |
25446
2a2d7ebaa018
(SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents:
23713
diff
changeset
|
192 #define SYNTAX_COMMENT_NESTED(c) ((SYNTAX_WITH_FLAGS (c) >> 22) & 1) |
2a2d7ebaa018
(SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents:
23713
diff
changeset
|
193 |
21206
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
194 /* These macros extract specific flags from an integer |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
195 that holds the syntax code and the flags. */ |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
196 |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
197 #define SYNTAX_FLAGS_COMSTART_FIRST(flags) (((flags) >> 16) & 1) |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
198 |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
199 #define SYNTAX_FLAGS_COMSTART_SECOND(flags) (((flags) >> 17) & 1) |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
200 |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
201 #define SYNTAX_FLAGS_COMEND_FIRST(flags) (((flags) >> 18) & 1) |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
202 |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
203 #define SYNTAX_FLAGS_COMEND_SECOND(flags) (((flags) >> 19) & 1) |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
204 |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
205 #define SYNTAX_FLAGS_PREFIX(flags) (((flags) >> 20) & 1) |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
206 |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
207 #define SYNTAX_FLAGS_COMMENT_STYLE(flags) (((flags) >> 21) & 1) |
dac44ee5f772
(SYNTAX_FLAGS_COMSTART_FIRST): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
21015
diff
changeset
|
208 |
25446
2a2d7ebaa018
(SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents:
23713
diff
changeset
|
209 #define SYNTAX_FLAGS_COMMENT_NESTED(flags) (((flags) >> 22) & 1) |
2a2d7ebaa018
(SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents:
23713
diff
changeset
|
210 |
486 | 211 /* This array, indexed by a character, contains the syntax code which that |
212 character signifies (as a char). For example, | |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
213 (enum syntaxcode) syntax_spec_code['w'] is Sword. */ |
486 | 214 |
215 extern unsigned char syntax_spec_code[0400]; | |
216 | |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
217 /* Indexed by syntax code, give the letter that describes it. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
218 |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
219 extern char syntax_code_spec[16]; |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
220 |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
221 /* Convert the byte offset BYTEPOS into a character position, |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
222 for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT. |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
223 |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
224 The value is meant for use in the UPDATE_SYNTAX_TABLE... macros. |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
225 These macros do nothing when parse_sexp_lookup_properties is 0, |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
226 so we return 0 in that case, for speed. */ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
227 |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
228 #define SYNTAX_TABLE_BYTE_TO_CHAR(bytepos) \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
229 (! parse_sexp_lookup_properties \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
230 ? 0 \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
231 : STRINGP (gl_state.object) \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
232 ? string_byte_to_char (gl_state.object, (bytepos)) \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
233 : BUFFERP (gl_state.object) \ |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
234 ? buf_bytepos_to_charpos (XBUFFER (gl_state.object), \ |
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
235 (bytepos) + BUF_BEGV_BYTE (XBUFFER (gl_state.object)) - 1) - BUF_BEGV (XBUFFER (gl_state.object)) + 1 \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
236 : NILP (gl_state.object) \ |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
237 ? BYTE_TO_CHAR ((bytepos) + BEGV_BYTE - 1) - BEGV + 1 \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
238 : (bytepos)) |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
239 |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
240 /* Make syntax table state (gl_state) good for CHARPOS, assuming it is |
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
241 currently good for a position before CHARPOS. */ |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
242 |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
243 #define UPDATE_SYNTAX_TABLE_FORWARD(charpos) \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
244 (parse_sexp_lookup_properties \ |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
245 && (charpos) >= gl_state.e_property \ |
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
246 ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0, \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
247 gl_state.object), \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
248 1) \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
249 : 0) |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
250 |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
251 /* Make syntax table state (gl_state) good for CHARPOS, assuming it is |
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
252 currently good for a position after CHARPOS. */ |
18678
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
253 |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
254 #define UPDATE_SYNTAX_TABLE_BACKWARD(charpos) \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
255 (parse_sexp_lookup_properties \ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
256 && (charpos) < gl_state.b_property \ |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
257 ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
258 gl_state.object), \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
259 1) \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
260 : 0) |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
261 |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
262 /* Make syntax table good for CHARPOS. */ |
18678
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
263 |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
264 #define UPDATE_SYNTAX_TABLE(charpos) \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
265 (parse_sexp_lookup_properties \ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
266 && (charpos) < gl_state.b_property \ |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
267 ? (update_syntax_table ((charpos) + gl_state.offset, -1, 0, \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
268 gl_state.object), \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
269 1) \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
270 : (parse_sexp_lookup_properties \ |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
271 && (charpos) >= gl_state.e_property \ |
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
272 ? (update_syntax_table ((charpos) + gl_state.offset, 1, 0,\ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
273 gl_state.object), \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
274 1) \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
275 : 0)) |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
276 |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
277 /* This macro should be called with FROM at the start of forward |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
278 search, or after the last position of the backward search. It |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
279 makes sure that the first char is picked up with correct table, so |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
280 one does not need to call UPDATE_SYNTAX_TABLE immediately after the |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
46370
diff
changeset
|
281 call. |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
282 Sign of COUNT gives the direction of the search. |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
283 */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
284 |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
285 #define SETUP_SYNTAX_TABLE(FROM, COUNT) \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
286 if (1) \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
287 { \ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
288 gl_state.b_property = BEGV; \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
289 gl_state.e_property = ZV + 1; \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
290 gl_state.object = Qnil; \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
291 gl_state.use_global = 0; \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
292 gl_state.offset = 0; \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
293 gl_state.current_syntax_table = current_buffer->syntax_table; \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
294 if (parse_sexp_lookup_properties) \ |
22438
917424c9c149
(SETUP_SYNTAX_TABLE): Don't call update_syntax_table
Richard M. Stallman <rms@gnu.org>
parents:
21481
diff
changeset
|
295 if ((COUNT) > 0 || (FROM) > BEGV) \ |
917424c9c149
(SETUP_SYNTAX_TABLE): Don't call update_syntax_table
Richard M. Stallman <rms@gnu.org>
parents:
21481
diff
changeset
|
296 update_syntax_table ((COUNT) > 0 ? (FROM) : (FROM) - 1, (COUNT),\ |
917424c9c149
(SETUP_SYNTAX_TABLE): Don't call update_syntax_table
Richard M. Stallman <rms@gnu.org>
parents:
21481
diff
changeset
|
297 1, Qnil); \ |
21015
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
298 } \ |
9f8f791762a8
(UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents:
20957
diff
changeset
|
299 else |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
300 |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
301 /* Same as above, but in OBJECT. If OBJECT is nil, use current buffer. |
18678
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
302 If it is t, ignore properties altogether. |
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
303 |
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
304 This is meant for regex.c to use. For buffers, regex.c passes arguments |
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
305 to the UPDATE_SYNTAX_TABLE macros which are relative to BEGV. |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
306 So if it is a buffer, we set the offset field to BEGV. */ |
486 | 307 |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
308 #define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \ |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
309 if (1) \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
310 { \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
311 gl_state.object = (OBJECT); \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
312 if (BUFFERP (gl_state.object)) \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
313 { \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
314 struct buffer *buf = XBUFFER (gl_state.object); \ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
315 gl_state.b_property = 1; \ |
20957
25bb3da85d05
(UPDATE_SYNTAX_TABLE_FORWARD): Fix condition.
Karl Heuer <kwzh@gnu.org>
parents:
20708
diff
changeset
|
316 gl_state.e_property = BUF_ZV (buf) - BUF_BEGV (buf) + 1; \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
317 gl_state.offset = BUF_BEGV (buf) - 1; \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
318 } \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
319 else if (NILP (gl_state.object)) \ |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
320 { \ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
321 gl_state.b_property = 1; \ |
20957
25bb3da85d05
(UPDATE_SYNTAX_TABLE_FORWARD): Fix condition.
Karl Heuer <kwzh@gnu.org>
parents:
20708
diff
changeset
|
322 gl_state.e_property = ZV - BEGV + 1; \ |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
323 gl_state.offset = BEGV - 1; \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
324 } \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
325 else if (EQ (gl_state.object, Qt)) \ |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
326 { \ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
327 gl_state.b_property = 0; \ |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
328 gl_state.e_property = 1500000000; \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
329 gl_state.offset = 0; \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
330 } \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
331 else \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
332 { \ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
333 gl_state.b_property = 0; \ |
46370
40db0673e6f0
Most uses of XSTRING combined with STRING_BYTES or indirection changed to
Ken Raeburn <raeburn@raeburn.org>
parents:
39795
diff
changeset
|
334 gl_state.e_property = 1 + SCHARS (gl_state.object); \ |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
335 gl_state.offset = 0; \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
336 } \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
337 gl_state.use_global = 0; \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
338 gl_state.current_syntax_table = current_buffer->syntax_table; \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
339 if (parse_sexp_lookup_properties) \ |
21481
e53c0d01cf31
(SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents:
21206
diff
changeset
|
340 update_syntax_table (((FROM) + gl_state.offset \ |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
341 + (COUNT > 0 ? 0 : -1)), \ |
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
342 COUNT, 1, gl_state.object); \ |
20544
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
343 } \ |
a884f0426ab9
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents:
20487
diff
changeset
|
344 else |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
345 |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
346 struct gl_state_s |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
347 { |
20649
388cedeebb88
(SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20544
diff
changeset
|
348 Lisp_Object object; /* The object we are scanning. */ |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
349 int start; /* Where to stop. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
350 int stop; /* Where to stop. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
351 int use_global; /* Whether to use global_code |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
352 or c_s_t. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
353 Lisp_Object global_code; /* Syntax code of current char. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
354 Lisp_Object current_syntax_table; /* Syntax table for current pos. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
355 Lisp_Object old_prop; /* Syntax-table prop at prev pos. */ |
39795
b945bdff4f96
(struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
26870
diff
changeset
|
356 int b_property; /* First index where c_s_t is valid. */ |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
357 int e_property; /* First index where c_s_t is |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
358 not valid. */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
359 INTERVAL forward_i; /* Where to start lookup on forward */ |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
360 INTERVAL backward_i; /* or backward movement. The |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
361 data in c_s_t is valid |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
362 between these intervals, |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
363 and possibly at the |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
364 intervals too, depending |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
365 on: */ |
18678
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
366 /* Offset for positions specified to UPDATE_SYNTAX_TABLE. */ |
d26f9720e55f
(struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents:
18625
diff
changeset
|
367 int offset; |
17465
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
368 }; |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
369 |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
370 extern struct gl_state_s gl_state; |
8a008f65c8d4
(enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents:
17181
diff
changeset
|
371 extern int parse_sexp_lookup_properties; |
20349 | 372 extern INTERVAL interval_of P_ ((int, Lisp_Object)); |
373 | |
374 extern int scan_words P_ ((int, int)); | |
52401 | 375 |
376 /* arch-tag: 28833cca-cd73-4741-8c85-a3111166a0e0 | |
377 (do not change this comment) */ |