aboutsummaryrefslogtreecommitdiffstats
path: root/src/syntax.h
diff options
context:
space:
mode:
authorRichard M. Stallman1994-01-05 20:33:02 +0000
committerRichard M. Stallman1994-01-05 20:33:02 +0000
commitc8cdcb16ad52a122fc28fa4ddc3a62e1e0654e22 (patch)
tree63c9ecf1a652c91550a785f3c21198a4ad52eebf /src/syntax.h
parent12c7071c31ee37d908f4e3f2b104332e3b543784 (diff)
downloademacs-c8cdcb16ad52a122fc28fa4ddc3a62e1e0654e22.tar.gz
emacs-c8cdcb16ad52a122fc28fa4ddc3a62e1e0654e22.zip
(enum syntaxcode): Add Sinherit.
(RAW_SYNTAX, RAW_SYNTAX_MATCH, SYNTAX_CHOOSE_TABLE): New macros. (SYNTAX, SYNTAX_MATCH, SYNTAX_COMSTART_FIRST, SYNTAX_COMSTART_SECOND) (SYNTAX_COMEND_FIRST, SYNTAX_COMEND_SECOND, SYNTAX_PREFIX) (SYNTAX_COMMENT_STYLE): Handle Sinherit. Alternative definitions if __GNUC__.
Diffstat (limited to 'src/syntax.h')
-rw-r--r--src/syntax.h103
1 files changed, 92 insertions, 11 deletions
diff --git a/src/syntax.h b/src/syntax.h
index 6ccafff64be..b3c92ca9979 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -45,17 +45,51 @@ enum syntaxcode
45 Scharquote, /* for a character that quotes the following character */ 45 Scharquote, /* for a character that quotes the following character */
46 Scomment, /* for a comment-starting character */ 46 Scomment, /* for a comment-starting character */
47 Sendcomment, /* for a comment-ending character */ 47 Sendcomment, /* for a comment-ending character */
48 Sinherit, /* use the standard syntax table for this character */
48 Smax /* Upper bound on codes that are meaningful */ 49 Smax /* Upper bound on codes that are meaningful */
49 }; 50 };
50 51
51#define SYNTAX(c) \ 52#define RAW_SYNTAX(table, c) \
52 ((enum syntaxcode) (XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) & 0377)) 53 ((enum syntaxcode) (XINT (XVECTOR (table)->contents[(unsigned char) (c)]) & 0377))
54
55#ifdef __GNUC__
56#define SYNTAX(c) \
57 ({ unsigned char character = c; \
58 enum syntaxcode syntax \
59 = RAW_SYNTAX (current_buffer->syntax_table, character); \
60 if (syntax == Sinherit) \
61 syntax = RAW_SYNTAX (Vstandard_syntax_table, character); \
62 syntax; })
63#else
64#define SYNTAX(c) \
65 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \
66 ? RAW_SYNTAX (Vstandard_syntax_table, c) \
67 : RAW_SYNTAX (c))
68#endif
53 69
54/* The next 8 bits of the number is a character, 70/* The next 8 bits of the number is a character,
55 the matching delimiter in the case of Sopen or Sclose. */ 71 the matching delimiter in the case of Sopen or Sclose. */
56 72
57#define SYNTAX_MATCH(c) \ 73#define RAW_SYNTAX_MATCH(table, c) \
58 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 8) & 0377) 74 ((XINT (XVECTOR (table)->contents[(unsigned char) (c)]) >> 8) & 0377)
75
76#ifdef __GNUC__
77#define SYNTAX_MATCH(c) \
78 ({ unsigned char character = c; \
79 enum syntaxcode syntax \
80 = RAW_SYNTAX (current_buffer->syntax_table, character); \
81 int matcher; \
82 if (syntax == Sinherit) \
83 matcher = RAW_SYNTAX_MATCH (Vstandard_syntax_table, character); \
84 else \
85 matcher = RAW_SYNTAX_MATCH (current_buffer->syntax_table, character); \
86 syntax; })
87#else
88#define SYNTAX_MATCH(c) \
89 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \
90 ? RAW_SYNTAX_MATCH (Vstandard_syntax_table, c) \
91 : RAW_SYNTAX_MATCH (c))
92#endif
59 93
60/* Then there are six single-bit flags that have the following meanings: 94/* Then there are six single-bit flags that have the following meanings:
61 1. This character is the first of a two-character comment-start sequence. 95 1. This character is the first of a two-character comment-start sequence.
@@ -73,24 +107,71 @@ enum syntaxcode
73 Style a is always the default. 107 Style a is always the default.
74 */ 108 */
75 109
110#define SYNTAX_CHOOSE_TABLE(c) \
111 (RAW_SYNTAX (current_buffer->syntax_table, c) == Sinherit \
112 ? Vstandard_syntax_table : current_buffer->syntax_table)
113
114#ifdef __GNUC__
115
116#define SYNTAX_COMSTART_FIRST(c) \
117 ({ unsigned char ch = c; \
118 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \
119 (XINT (XVECTOR (table)->contents[ch]) >> 16) & 1; \
120 })
121
122#define SYNTAX_COMSTART_SECOND(c) \
123 ({ unsigned char ch = c; \
124 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \
125 (XINT (XVECTOR (table)->contents[ch]) >> 17) & 1; \
126 })
127
128#define SYNTAX_COMEND_FIRST(c) \
129 ({ unsigned char ch = c; \
130 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \
131 (XINT (XVECTOR (table)->contents[ch]) >> 18) & 1; \
132 })
133
134#define SYNTAX_COMEND_SECOND(c) \
135 ({ unsigned char ch = c; \
136 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \
137 (XINT (XVECTOR (table)->contents[ch]) >> 19) & 1; \
138 })
139
140#define SYNTAX_PREFIX(c) \
141 ({ unsigned char ch = c; \
142 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \
143 (XINT (XVECTOR (table)->contents[ch]) >> 20) & 1; \
144 })
145
146/* extract the comment style bit from the syntax table entry */
147#define SYNTAX_COMMENT_STYLE(c) \
148 ({ unsigned char ch = c; \
149 Lisp_Object table = SYNTAX_CHOOSE_TABLE (ch); \
150 (XINT (XVECTOR (table)->contents[ch]) >> 21) & 1; \
151 })
152
153#else
154
76#define SYNTAX_COMSTART_FIRST(c) \ 155#define SYNTAX_COMSTART_FIRST(c) \
77 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 16) & 1) 156 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 16) & 1)
78 157
79#define SYNTAX_COMSTART_SECOND(c) \ 158#define SYNTAX_COMSTART_SECOND(c) \
80 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 17) & 1) 159 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 17) & 1)
81 160
82#define SYNTAX_COMEND_FIRST(c) \ 161#define SYNTAX_COMEND_FIRST(c) \
83 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 18) & 1) 162 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 18) & 1)
84 163
85#define SYNTAX_COMEND_SECOND(c) \ 164#define SYNTAX_COMEND_SECOND(c) \
86 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 19) & 1) 165 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 19) & 1)
87 166
88#define SYNTAX_PREFIX(c) \ 167#define SYNTAX_PREFIX(c) \
89 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[(unsigned char) (c)]) >> 20) & 1) 168 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 20) & 1)
90 169
91/* extract the comment style bit from the syntax table entry */ 170/* extract the comment style bit from the syntax table entry */
92#define SYNTAX_COMMENT_STYLE(c) \ 171#define SYNTAX_COMMENT_STYLE(c) \
93 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 21) & 1) 172 ((XINT (XVECTOR (SYNTAX_CHOOSE_TABLE (c))->contents[(unsigned char) (c)]) >> 21) & 1)
173
174#endif
94 175
95/* This array, indexed by a character, contains the syntax code which that 176/* This array, indexed by a character, contains the syntax code which that
96 character signifies (as a char). For example, 177 character signifies (as a char). For example,
@@ -100,4 +181,4 @@ extern unsigned char syntax_spec_code[0400];
100 181
101/* Indexed by syntax code, give the letter that describes it. */ 182/* Indexed by syntax code, give the letter that describes it. */
102 183
103extern char syntax_code_spec[13]; 184extern char syntax_code_spec[14];