comparison src/syntax.h @ 17045:1dfa84b25d3b

(SET_RAW_SYNTAX_ENTRY): Handle syntax of multibyte characters. (SYNTAX_ENTRY_FOLLOW_PARENT): New macro. (SYNTAX_ENTRY): Handle syntax of multibyte characters. (SYNTAX, SYNTAX_WITH_FLAGS, SYNTAX_MATCH): Don't signal error even if a syntax entry is not cons.
author Karl Heuer <kwzh@gnu.org>
date Thu, 20 Feb 1997 06:57:02 +0000
parents ee40177f6c68
children ab43d13fdfd5
comparison
equal deleted inserted replaced
17044:f07c36097f33 17045:1dfa84b25d3b
49 Sendcomment, /* for a comment-ending character */ 49 Sendcomment, /* for a comment-ending character */
50 Sinherit, /* use the standard syntax table for this character */ 50 Sinherit, /* use the standard syntax table for this character */
51 Smax /* Upper bound on codes that are meaningful */ 51 Smax /* Upper bound on codes that are meaningful */
52 }; 52 };
53 53
54 /* Fetch the syntax entry for char C from table TABLE. 54 /* Set the syntax entry VAL for char C in table TABLE. */
55 This returns the whole entry (normally a cons cell)
56 and does not do any kind of inheritance. */
57
58 #if 1
59 #define RAW_SYNTAX_ENTRY(table, c) \
60 (XCHAR_TABLE (table)->contents[(unsigned char) (c)])
61 55
62 #define SET_RAW_SYNTAX_ENTRY(table, c, val) \ 56 #define SET_RAW_SYNTAX_ENTRY(table, c, val) \
63 (XCHAR_TABLE (table)->contents[(unsigned char) (c)] = (val)) 57 ((unsigned)(c) < 128 \
58 ? (XCHAR_TABLE (table)->contents[(unsigned) (c)] = (val)) \
59 : Faset ((table), (unsigned) (c), (val)))
60
61 /* Fetch the syntax entry for char C in syntax table TABLE.
62 This macro is called only when C is less than CHAR_TABLE_ORDINARY_SLOTS.
63 Do inheritance. */
64
65 #ifdef __GNUC__
66 #define SYNTAX_ENTRY_FOLLOW_PARENT(table, c) \
67 ({ Lisp_Object tbl = table; \
68 Lisp_Object temp = XCHAR_TABLE (tbl)->contents[(c)]; \
69 while (NILP (temp)) \
70 { \
71 tbl = XCHAR_TABLE (tbl)->parent; \
72 if (NILP (tbl)) \
73 break; \
74 temp = XCHAR_TABLE (tbl)->contents[(c)]; \
75 } \
76 temp; })
64 #else 77 #else
65 #define RAW_SYNTAX_ENTRY(table, c) \ 78 extern Lisp_Object syntax_temp;
66 ((c) >= 128 \ 79 extern Lisp_Object syntax_parent_lookup ();
67 ? raw_syntax_table_lookup (table, c) \
68 : XCHAR_TABLE (table)->contents[(unsigned char) (c)])
69 80
70 #define SET_RAW_SYNTAX_ENTRY(table, c, val) \ 81 #define SYNTAX_ENTRY_FOLLOW_PARENT(table, c) \
71 ((c) >= 128 \ 82 (syntax_temp = XCHAR_TABLE (table)->contents[(c)], \
72 ? set_raw_syntax_table_lookup (table, c, (val)) \ 83 (NILP (syntax_temp) \
73 : XCHAR_TABLE (table)->contents[(unsigned char) (c)] = (val)) 84 ? syntax_parent_lookup (table, (c)) \
85 : syntax_temp))
74 #endif 86 #endif
75 87
88 /* Fetch the syntax entry for char C in the current syntax table.
89 This returns the whole entry (normally a cons cell).
90 Do Inheritance. */
91
92 #define SYNTAX_ENTRY(c) \
93 ((unsigned) (c) < CHAR_TABLE_ORDINARY_SLOTS \
94 ? SYNTAX_ENTRY_FOLLOW_PARENT (current_buffer->syntax_table, (unsigned) (c))\
95 : Faref (current_buffer->syntax_table, make_number (c)))
96
76 /* Extract the information from the entry for character C 97 /* Extract the information from the entry for character C
77 in syntax table TABLE. Do inheritance. */ 98 in the current syntax table. */
78 99
79 #ifdef __GNUC__ 100 #ifdef __GNUC__
80 #define SYNTAX_ENTRY(c) \
81 ({ Lisp_Object temp, table; \
82 unsigned char cc = (c); \
83 table = current_buffer->syntax_table; \
84 while (!NILP (table)) \
85 { \
86 temp = RAW_SYNTAX_ENTRY (table, cc); \
87 if (!NILP (temp)) \
88 break; \
89 table = XCHAR_TABLE (table)->parent; \
90 } \
91 temp; })
92
93 #define SYNTAX(c) \ 101 #define SYNTAX(c) \
94 ({ Lisp_Object temp; \ 102 ({ Lisp_Object temp; \
95 temp = SYNTAX_ENTRY (c); \ 103 temp = SYNTAX_ENTRY (c); \
96 (CONSP (temp) \ 104 (CONSP (temp) \
97 ? (enum syntaxcode) (XINT (XCONS (temp)->car) & 0xff) \ 105 ? (enum syntaxcode) (XINT (XCONS (temp)->car) & 0xff) \
98 : wrong_type_argument (Qconsp, temp)); }) 106 : Swhitespace); })
99 107
100 #define SYNTAX_WITH_FLAGS(c) \ 108 #define SYNTAX_WITH_FLAGS(c) \
101 ({ Lisp_Object temp; \ 109 ({ Lisp_Object temp; \
102 temp = SYNTAX_ENTRY (c); \ 110 temp = SYNTAX_ENTRY (c); \
103 (CONSP (temp) \ 111 (CONSP (temp) \
104 ? XINT (XCONS (temp)->car) \ 112 ? XINT (XCONS (temp)->car) \
105 : wrong_type_argument (Qconsp, temp)); }) 113 : (int) Swhitespace); })
106 114
107 #define SYNTAX_MATCH(c) \ 115 #define SYNTAX_MATCH(c) \
108 ({ Lisp_Object temp; \ 116 ({ Lisp_Object temp; \
109 temp = SYNTAX_ENTRY (c); \ 117 temp = SYNTAX_ENTRY (c); \
110 (CONSP (temp) \ 118 (CONSP (temp) \
111 ? XINT (XCONS (temp)->cdr) \ 119 ? XINT (XCONS (temp)->cdr) \
112 : wrong_type_argument (Qconsp, temp)); }) 120 : Qnil); })
113 #else 121 #else
114 extern Lisp_Object syntax_temp;
115 extern Lisp_Object syntax_parent_lookup ();
116
117 #define SYNTAX_ENTRY(c) \
118 (syntax_temp \
119 = RAW_SYNTAX_ENTRY (current_buffer->syntax_table, (c)), \
120 (NILP (syntax_temp) \
121 ? (syntax_temp \
122 = syntax_parent_lookup (current_buffer->syntax_table, \
123 (unsigned char) (c))) \
124 : syntax_temp))
125
126 #define SYNTAX(c) \ 122 #define SYNTAX(c) \
127 (syntax_temp = SYNTAX_ENTRY ((c)), \ 123 (syntax_temp = SYNTAX_ENTRY ((c)), \
128 (CONSP (syntax_temp) \ 124 (CONSP (syntax_temp) \
129 ? (enum syntaxcode) (XINT (XCONS (syntax_temp)->car) & 0xff) \ 125 ? (enum syntaxcode) (XINT (XCONS (syntax_temp)->car) & 0xff) \
130 : wrong_type_argument (Qconsp, syntax_temp))) 126 : Swhitespace))
131 127
132 #define SYNTAX_WITH_FLAGS(c) \ 128 #define SYNTAX_WITH_FLAGS(c) \
133 (syntax_temp = SYNTAX_ENTRY ((c)), \ 129 (syntax_temp = SYNTAX_ENTRY ((c)), \
134 (CONSP (syntax_temp) \ 130 (CONSP (syntax_temp) \
135 ? XINT (XCONS (syntax_temp)->car) \ 131 ? XINT (XCONS (syntax_temp)->car) \
136 : wrong_type_argument (Qconsp, syntax_temp))) 132 : (int) Swhitespace))
137 133
138 #define SYNTAX_MATCH(c) \ 134 #define SYNTAX_MATCH(c) \
139 (syntax_temp = SYNTAX_ENTRY ((c)), \ 135 (syntax_temp = SYNTAX_ENTRY ((c)), \
140 (CONSP (syntax_temp) \ 136 (CONSP (syntax_temp) \
141 ? XINT (XCONS (syntax_temp)->cdr) \ 137 ? XINT (XCONS (syntax_temp)->cdr) \
142 : wrong_type_argument (Qconsp, syntax_temp))) 138 : Qnil))
143 #endif 139 #endif
144 140
145 /* Then there are six single-bit flags that have the following meanings: 141 /* Then there are six single-bit flags that have the following meanings:
146 1. This character is the first of a two-character comment-start sequence. 142 1. This character is the first of a two-character comment-start sequence.
147 2. This character is the second of a two-character comment-start sequence. 143 2. This character is the second of a two-character comment-start sequence.