annotate src/syntax.h @ 112408:04c350138c72

* man.el (Man-highlight-references0): Use make-button (Bug#7881).
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 21 Jan 2011 22:53:06 -0500
parents 42e22c4f06b7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Declarations having to do with GNU Emacs syntax tables.
75227
e90d04cd455a Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents: 68651
diff changeset
2 Copyright (C) 1985, 1993, 1994, 1997, 1998, 2001, 2002, 2003, 2004,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
3 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 This file is part of GNU Emacs.
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
94994
29adfc9354e7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91618
diff changeset
7 GNU Emacs is free software: you can redistribute it and/or modify
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
94994
29adfc9354e7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91618
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
29adfc9354e7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91618
diff changeset
10 (at your option) any later version.
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 GNU Emacs is distributed in the hope that it will be useful,
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 GNU General Public License for more details.
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
94994
29adfc9354e7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 91618
diff changeset
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 extern Lisp_Object Qsyntax_table_p;
110551
f28cc7ff91f9 Fix int/EMACS_INT use in casefiddle.c and syntax.c.
Eli Zaretskii <eliz@gnu.org>
parents: 109757
diff changeset
22 extern void update_syntax_table (EMACS_INT, int, int, Lisp_Object);
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 /* The standard syntax table is stored where it will automatically
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 be used in all new buffers. */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 #define Vstandard_syntax_table buffer_defaults.syntax_table
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 enum syntaxcode
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 {
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 Swhitespace, /* for a whitespace character */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 Spunct, /* for random punctuation characters */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 Sword, /* for a word constituent */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 Ssymbol, /* symbol constituent but not word constituent */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 Sopen, /* for a beginning delimiter */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 Sclose, /* for an ending delimiter */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 Squote, /* for a prefix character like Lisp ' */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 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
44 Smath, /* for delimiters like $ in Tex. */
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 Sescape, /* for a character that begins a C-style escape */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 Scharquote, /* for a character that quotes the following character */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 Scomment, /* for a comment-starting character */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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 */
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
50 Scomment_fence, /* Starts/ends comment which is delimited on the
20487
c9224a343630 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 20349
diff changeset
51 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
52 Sstring_fence, /* Starts/ends string which is delimited on the
20487
c9224a343630 Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 20349
diff changeset
53 other side by any char with the same syntaxcode. */
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 Smax /* Upper bound on codes that are meaningful */
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 };
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
57 /* 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
58
88390
ee2122ab4d5b (SET_RAW_SYNTAX_ENTRY): Call CHAR_TABLE_SET.
Kenichi Handa <handa@m17n.org>
parents: 39795
diff changeset
59 #define SET_RAW_SYNTAX_ENTRY(table, c, val) \
88432
9302a313a37b (SET_RAW_SYNTAX_ENTRY): Don't call make_number.
Kenichi Handa <handa@m17n.org>
parents: 88390
diff changeset
60 CHAR_TABLE_SET ((table), c, (val))
5441
0af9674da850 (enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
61
88390
ee2122ab4d5b (SET_RAW_SYNTAX_ENTRY): Call CHAR_TABLE_SET.
Kenichi Handa <handa@m17n.org>
parents: 39795
diff changeset
62 /* Set the syntax entry VAL for char-range RANGE in table TABLE.
ee2122ab4d5b (SET_RAW_SYNTAX_ENTRY): Call CHAR_TABLE_SET.
Kenichi Handa <handa@m17n.org>
parents: 39795
diff changeset
63 RANGE is a cons (FROM . TO) specifying the range of characters. */
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
64
88390
ee2122ab4d5b (SET_RAW_SYNTAX_ENTRY): Call CHAR_TABLE_SET.
Kenichi Handa <handa@m17n.org>
parents: 39795
diff changeset
65 #define SET_RAW_SYNTAX_ENTRY_RANGE(table, range, val) \
ee2122ab4d5b (SET_RAW_SYNTAX_ENTRY): Call CHAR_TABLE_SET.
Kenichi Handa <handa@m17n.org>
parents: 39795
diff changeset
66 Fset_char_table_range ((table), (range), (val))
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
67
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
68 /* 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
69 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
70 Does inheritance. */
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
71 /* 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
72 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
73 found in text properties. */
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
74
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
75 #ifdef SYNTAX_ENTRY_VIA_PROPERTY
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
76 # define SYNTAX_ENTRY(c) \
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
77 (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
78 # 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
79 #else
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
80 # 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
81 # 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
82 #endif
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
83
88852
9a7268b7a742 (SYNTAX_ENTRY_INT): Don't use make_number.
Dave Love <fx@gnu.org>
parents: 88471
diff changeset
84 #define SYNTAX_ENTRY_INT(c) CHAR_TABLE_REF (CURRENT_SYNTAX_TABLE, (c))
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
85
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
86 /* 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
87 in the current syntax table. */
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
88
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
89 #ifdef __GNUC__
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
90 #define SYNTAX(c) \
56068
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
91 ({ Lisp_Object _syntax_temp; \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
92 _syntax_temp = SYNTAX_ENTRY (c); \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
93 (CONSP (_syntax_temp) \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
94 ? (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
95 : Swhitespace); })
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
96
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
97 #define SYNTAX_WITH_FLAGS(c) \
56068
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
98 ({ Lisp_Object _syntax_temp; \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
99 _syntax_temp = SYNTAX_ENTRY (c); \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
100 (CONSP (_syntax_temp) \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
101 ? XINT (XCAR (_syntax_temp)) \
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
102 : (int) Swhitespace); })
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
103
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
104 #define SYNTAX_MATCH(c) \
56068
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
105 ({ Lisp_Object _syntax_temp; \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
106 _syntax_temp = SYNTAX_ENTRY (c); \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
107 (CONSP (_syntax_temp) \
f6fab60742ca (SYNTAX_ENTRY_FOLLOW_PARENT): Rename local variable to
Andreas Schwab <schwab@suse.de>
parents: 55319
diff changeset
108 ? XCDR (_syntax_temp) \
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
109 : Qnil); })
5441
0af9674da850 (enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
110 #else
88471
9729ea16acd8 (syntax_temp) [!__GNUC__]: Declare.
Dave Love <fx@gnu.org>
parents: 88432
diff changeset
111 extern Lisp_Object syntax_temp;
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
112 #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
113 (syntax_temp = SYNTAX_ENTRY ((c)), \
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
114 (CONSP (syntax_temp) \
25640
69c2d34eb25c Use XCAR and XCDR.
Ken Raeburn <raeburn@raeburn.org>
parents: 25446
diff changeset
115 ? (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
116 : Swhitespace))
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
117
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
118 #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
119 (syntax_temp = SYNTAX_ENTRY ((c)), \
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
120 (CONSP (syntax_temp) \
25640
69c2d34eb25c Use XCAR and XCDR.
Ken Raeburn <raeburn@raeburn.org>
parents: 25446
diff changeset
121 ? XINT (XCAR (syntax_temp)) \
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
122 : (int) Swhitespace))
13143
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_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
125 (syntax_temp = SYNTAX_ENTRY ((c)), \
13143
ba670977cceb Use char tables as syntax tables.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
126 (CONSP (syntax_temp) \
25640
69c2d34eb25c Use XCAR and XCDR.
Ken Raeburn <raeburn@raeburn.org>
parents: 25446
diff changeset
127 ? XCDR (syntax_temp) \
17045
1dfa84b25d3b (SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte
Karl Heuer <kwzh@gnu.org>
parents: 14186
diff changeset
128 : Qnil))
5441
0af9674da850 (enum syntaxcode): Add Sinherit.
Richard M. Stallman <rms@gnu.org>
parents: 2961
diff changeset
129 #endif
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
1073
721e4f57c8b0 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 720
diff changeset
131
109757
818e325e0469 Introduce a new comment style "c" flag.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109099
diff changeset
132 /* Whether the syntax of the character C has the prefix flag set. */
818e325e0469 Introduce a new comment style "c" flag.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109099
diff changeset
133 extern int syntax_prefix_flag_p (int c);
25446
2a2d7ebaa018 (SYNTAX_COMMENT_NESTED, SYNTAX_FLAGS_COMMENT_NESTED):
Richard M. Stallman <rms@gnu.org>
parents: 23713
diff changeset
134
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 /* This array, indexed by a character, contains the syntax code which that
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 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
137 (enum syntaxcode) syntax_spec_code['w'] is Sword. */
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 extern unsigned char syntax_spec_code[0400];
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
141 /* 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
142
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
143 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
144
20649
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
145 /* 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
146 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
147
9f8f791762a8 (UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents: 20957
diff changeset
148 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
149 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
150 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
151
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
152 #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
153 (! 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
154 ? 0 \
9f8f791762a8 (UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents: 20957
diff changeset
155 : STRINGP (gl_state.object) \
20649
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
156 ? 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
157 : BUFFERP (gl_state.object) \
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
158 ? 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
159 (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
160 : NILP (gl_state.object) \
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
161 ? 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
162 : (bytepos))
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
163
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
164 /* 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
165 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
166
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
167 #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
168 (parse_sexp_lookup_properties \
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
169 && (charpos) >= gl_state.e_property \
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
170 ? (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
171 gl_state.object), \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
172 1) \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
173 : 0)
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
174
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
175 /* 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
176 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
177
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
178 #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
179 (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
180 && (charpos) < gl_state.b_property \
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
181 ? (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
182 gl_state.object), \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
183 1) \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
184 : 0)
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
185
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
186 /* 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
187
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
188 #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
189 (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
190 && (charpos) < gl_state.b_property \
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
191 ? (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
192 gl_state.object), \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
193 1) \
21015
9f8f791762a8 (UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents: 20957
diff changeset
194 : (parse_sexp_lookup_properties \
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
195 && (charpos) >= gl_state.e_property \
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
196 ? (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
197 gl_state.object), \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
198 1) \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
199 : 0))
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
200
107366
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
201 /* This macro sets up the buffer-global syntax table. */
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
202 #define SETUP_BUFFER_SYNTAX_TABLE() \
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
203 do \
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
204 { \
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
205 gl_state.use_global = 0; \
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
206 gl_state.current_syntax_table = current_buffer->syntax_table; \
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
207 } while (0)
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
208
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
209 /* 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
210 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
211 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
212 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
213 call.
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
214 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
215 */
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
216
20649
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
217 #define SETUP_SYNTAX_TABLE(FROM, COUNT) \
91618
400a54e167c9 Use "do...while (0)", not "if (1)..else" in macro definitions.
Jan Djärv <jan.h.d@swipnet.se>
parents: 91327
diff changeset
218 do \
21015
9f8f791762a8 (UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents: 20957
diff changeset
219 { \
107366
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
220 SETUP_BUFFER_SYNTAX_TABLE (); \
39795
b945bdff4f96 (struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26870
diff changeset
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 1, Qnil); \
21015
9f8f791762a8 (UPDATE_SYNTAX_TABLE): Do nothing unless parse_sexp_lookup_properties.
Richard M. Stallman <rms@gnu.org>
parents: 20957
diff changeset
229 } \
91618
400a54e167c9 Use "do...while (0)", not "if (1)..else" in macro definitions.
Jan Djärv <jan.h.d@swipnet.se>
parents: 91327
diff changeset
230 while (0)
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
231
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
232 /* 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
233 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
234
d26f9720e55f (struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents: 18625
diff changeset
235 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
236 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
237 So if it is a buffer, we set the offset field to BEGV. */
486
80cdb2387043 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238
20649
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
239 #define SETUP_SYNTAX_TABLE_FOR_OBJECT(OBJECT, FROM, COUNT) \
91618
400a54e167c9 Use "do...while (0)", not "if (1)..else" in macro definitions.
Jan Djärv <jan.h.d@swipnet.se>
parents: 91327
diff changeset
240 do \
20544
a884f0426ab9 (SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20487
diff changeset
241 { \
107366
14ff9accfbd3 Cleanup setup of gl_state in various parts of the code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
242 SETUP_BUFFER_SYNTAX_TABLE (); \
20649
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
243 gl_state.object = (OBJECT); \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
244 if (BUFFERP (gl_state.object)) \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
245 { \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
246 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
247 gl_state.b_property = 1; \
20957
25bb3da85d05 (UPDATE_SYNTAX_TABLE_FORWARD): Fix condition.
Karl Heuer <kwzh@gnu.org>
parents: 20708
diff changeset
248 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
249 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
250 } \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
251 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
252 { \
39795
b945bdff4f96 (struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26870
diff changeset
253 gl_state.b_property = 1; \
20957
25bb3da85d05 (UPDATE_SYNTAX_TABLE_FORWARD): Fix condition.
Karl Heuer <kwzh@gnu.org>
parents: 20708
diff changeset
254 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
255 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
256 } \
20649
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
257 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
258 { \
39795
b945bdff4f96 (struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26870
diff changeset
259 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
260 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
261 gl_state.offset = 0; \
a884f0426ab9 (SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20487
diff changeset
262 } \
a884f0426ab9 (SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20487
diff changeset
263 else \
a884f0426ab9 (SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20487
diff changeset
264 { \
39795
b945bdff4f96 (struct gl_state_s): Change the meaning of b_property.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 26870
diff changeset
265 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
266 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
267 gl_state.offset = 0; \
a884f0426ab9 (SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20487
diff changeset
268 } \
a884f0426ab9 (SETUP_SYNTAX_TABLE_FOR_OBJECT): Call bytepos_to_charpos.
Richard M. Stallman <rms@gnu.org>
parents: 20487
diff changeset
269 if (parse_sexp_lookup_properties) \
21481
e53c0d01cf31 (SETUP_SYNTAX_TABLE_FOR_OBJECT): FROM counts chars.
Karl Heuer <kwzh@gnu.org>
parents: 21206
diff changeset
270 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
271 + (COUNT > 0 ? 0 : -1)), \
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
272 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
273 } \
91618
400a54e167c9 Use "do...while (0)", not "if (1)..else" in macro definitions.
Jan Djärv <jan.h.d@swipnet.se>
parents: 91327
diff changeset
274 while (0)
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
275
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
276 struct gl_state_s
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
277 {
20649
388cedeebb88 (SYNTAX_TABLE_BYTE_TO_CHAR): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20544
diff changeset
278 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
279 int start; /* Where to stop. */
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
280 int stop; /* Where to stop. */
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
281 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
282 or c_s_t. */
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
283 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
284 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
285 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
286 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
287 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
288 not valid. */
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
289 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
290 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
291 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
292 between these intervals,
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
293 and possibly at the
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
294 intervals too, depending
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
295 on: */
18678
d26f9720e55f (struct gl_state_s): New field `offset'.
Richard M. Stallman <rms@gnu.org>
parents: 18625
diff changeset
296 /* 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
297 int offset;
17465
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
298 };
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
299
8a008f65c8d4 (enum syntaxcode): New members Scomment_fence, Sstring_fence.
Richard M. Stallman <rms@gnu.org>
parents: 17181
diff changeset
300 extern struct gl_state_s gl_state;
110551
f28cc7ff91f9 Fix int/EMACS_INT use in casefiddle.c and syntax.c.
Eli Zaretskii <eliz@gnu.org>
parents: 109757
diff changeset
301 extern EMACS_INT scan_words (EMACS_INT, EMACS_INT);
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
302