]>
Commit | Line | Data |
---|---|---|
861bb6c1 | 1 | |
c3bcf315 | 2 | /* A Bison parser, made from cexp.y |
956d6950 | 3 | by GNU Bison version 1.25 |
861bb6c1 JL |
4 | */ |
5 | ||
6 | #define YYBISON 1 /* Identify Bison output. */ | |
7 | ||
8 | #define INT 258 | |
9 | #define CHAR 259 | |
10 | #define NAME 260 | |
11 | #define ERROR 261 | |
12 | #define OR 262 | |
13 | #define AND 263 | |
14 | #define EQUAL 264 | |
15 | #define NOTEQUAL 265 | |
16 | #define LEQ 266 | |
17 | #define GEQ 267 | |
18 | #define LSH 268 | |
19 | #define RSH 269 | |
20 | #define UNARY 270 | |
21 | ||
22 | #line 27 "cexp.y" | |
23 | ||
24 | #include "config.h" | |
25 | #include <setjmp.h> | |
26 | /* #define YYDEBUG 1 */ | |
27 | ||
861bb6c1 | 28 | |
27b6b158 | 29 | #ifdef HAVE_STRING_H |
861bb6c1 JL |
30 | # include <string.h> |
31 | #endif | |
32 | ||
27b6b158 | 33 | #ifdef HAVE_STDLIB_H |
861bb6c1 JL |
34 | # include <stdlib.h> |
35 | #endif | |
36 | ||
27b6b158 | 37 | #ifdef HAVE_LIMITS_H |
c3bcf315 JL |
38 | # include <limits.h> |
39 | #endif | |
40 | ||
861bb6c1 JL |
41 | #ifdef MULTIBYTE_CHARS |
42 | #include <locale.h> | |
43 | #endif | |
44 | ||
45 | #include <stdio.h> | |
46 | ||
47 | typedef unsigned char U_CHAR; | |
48 | ||
49 | /* This is used for communicating lists of keywords with cccp.c. */ | |
50 | struct arglist { | |
51 | struct arglist *next; | |
52 | U_CHAR *name; | |
53 | int length; | |
54 | int argno; | |
55 | }; | |
56 | ||
57 | /* Define a generic NULL if one hasn't already been defined. */ | |
58 | ||
59 | #ifndef NULL | |
60 | #define NULL 0 | |
61 | #endif | |
62 | ||
63 | #ifndef GENERIC_PTR | |
64 | #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) | |
65 | #define GENERIC_PTR void * | |
66 | #else | |
67 | #define GENERIC_PTR char * | |
68 | #endif | |
69 | #endif | |
70 | ||
71 | #ifndef NULL_PTR | |
72 | #define NULL_PTR ((GENERIC_PTR) 0) | |
73 | #endif | |
74 | ||
75 | /* Find the largest host integer type and set its size and type. | |
c3bcf315 | 76 | Watch out: on some crazy hosts `long' is shorter than `int'. */ |
861bb6c1 | 77 | |
c3bcf315 JL |
78 | #ifndef HOST_WIDE_INT |
79 | # if HAVE_INTTYPES_H | |
80 | # include <inttypes.h> | |
81 | # define HOST_WIDE_INT intmax_t | |
82 | # define unsigned_HOST_WIDE_INT uintmax_t | |
83 | # else | |
27b6b158 | 84 | # if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT) |
c3bcf315 JL |
85 | # define HOST_WIDE_INT int |
86 | # else | |
27b6b158 | 87 | # if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG || ! (defined LONG_LONG_MAX || defined LLONG_MAX)) |
c3bcf315 JL |
88 | # define HOST_WIDE_INT long |
89 | # else | |
90 | # define HOST_WIDE_INT long long | |
91 | # endif | |
92 | # endif | |
93 | # endif | |
94 | #endif | |
861bb6c1 | 95 | |
c3bcf315 JL |
96 | #ifndef unsigned_HOST_WIDE_INT |
97 | #define unsigned_HOST_WIDE_INT unsigned HOST_WIDE_INT | |
861bb6c1 JL |
98 | #endif |
99 | ||
c3bcf315 JL |
100 | #ifndef CHAR_BIT |
101 | #define CHAR_BIT 8 | |
102 | #endif | |
103 | ||
104 | #ifndef HOST_BITS_PER_WIDE_INT | |
105 | #define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT)) | |
861bb6c1 JL |
106 | #endif |
107 | ||
108 | #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) | |
109 | # define __attribute__(x) | |
110 | #endif | |
111 | ||
112 | #ifndef PROTO | |
113 | # if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) | |
114 | # define PROTO(ARGS) ARGS | |
115 | # else | |
116 | # define PROTO(ARGS) () | |
117 | # endif | |
118 | #endif | |
119 | ||
120 | #if defined (__STDC__) && defined (HAVE_VPRINTF) | |
121 | # include <stdarg.h> | |
122 | # define VA_START(va_list, var) va_start (va_list, var) | |
123 | # define PRINTF_ALIST(msg) char *msg, ... | |
124 | # define PRINTF_DCL(msg) | |
125 | # define PRINTF_PROTO(ARGS, m, n) PROTO (ARGS) __attribute__ ((format (__printf__, m, n))) | |
126 | #else | |
127 | # include <varargs.h> | |
128 | # define VA_START(va_list, var) va_start (va_list) | |
129 | # define PRINTF_ALIST(msg) msg, va_alist | |
130 | # define PRINTF_DCL(msg) char *msg; va_dcl | |
131 | # define PRINTF_PROTO(ARGS, m, n) () __attribute__ ((format (__printf__, m, n))) | |
132 | # define vfprintf(file, msg, args) \ | |
133 | { \ | |
134 | char *a0 = va_arg(args, char *); \ | |
135 | char *a1 = va_arg(args, char *); \ | |
136 | char *a2 = va_arg(args, char *); \ | |
137 | char *a3 = va_arg(args, char *); \ | |
138 | fprintf (file, msg, a0, a1, a2, a3); \ | |
139 | } | |
140 | #endif | |
141 | ||
142 | #define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2) | |
143 | ||
27b6b158 | 144 | HOST_WIDE_INT parse_c_expression PROTO((char *, int)); |
861bb6c1 JL |
145 | |
146 | static int yylex PROTO((void)); | |
147 | static void yyerror PROTO((char *)) __attribute__ ((noreturn)); | |
148 | static HOST_WIDE_INT expression_value; | |
27b6b158 JL |
149 | #ifdef TEST_EXP_READER |
150 | static int expression_signedp; | |
151 | #endif | |
861bb6c1 JL |
152 | |
153 | static jmp_buf parse_return_error; | |
154 | ||
155 | /* Nonzero means count most punctuation as part of a name. */ | |
156 | static int keyword_parsing = 0; | |
157 | ||
158 | /* Nonzero means do not evaluate this expression. | |
159 | This is a count, since unevaluated expressions can nest. */ | |
160 | static int skip_evaluation; | |
161 | ||
27b6b158 JL |
162 | /* Nonzero means warn if undefined identifiers are evaluated. */ |
163 | static int warn_undef; | |
164 | ||
861bb6c1 JL |
165 | /* some external tables of character types */ |
166 | extern unsigned char is_idstart[], is_idchar[], is_space[]; | |
167 | ||
168 | /* Flag for -pedantic. */ | |
169 | extern int pedantic; | |
170 | ||
171 | /* Flag for -traditional. */ | |
172 | extern int traditional; | |
173 | ||
174 | /* Flag for -lang-c89. */ | |
175 | extern int c89; | |
176 | ||
861bb6c1 JL |
177 | #ifndef CHAR_TYPE_SIZE |
178 | #define CHAR_TYPE_SIZE BITS_PER_UNIT | |
179 | #endif | |
180 | ||
181 | #ifndef INT_TYPE_SIZE | |
182 | #define INT_TYPE_SIZE BITS_PER_WORD | |
183 | #endif | |
184 | ||
185 | #ifndef LONG_TYPE_SIZE | |
186 | #define LONG_TYPE_SIZE BITS_PER_WORD | |
187 | #endif | |
188 | ||
189 | #ifndef WCHAR_TYPE_SIZE | |
190 | #define WCHAR_TYPE_SIZE INT_TYPE_SIZE | |
191 | #endif | |
192 | ||
193 | #ifndef MAX_CHAR_TYPE_SIZE | |
194 | #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE | |
195 | #endif | |
196 | ||
197 | #ifndef MAX_INT_TYPE_SIZE | |
198 | #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE | |
199 | #endif | |
200 | ||
201 | #ifndef MAX_LONG_TYPE_SIZE | |
202 | #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE | |
203 | #endif | |
204 | ||
205 | #ifndef MAX_WCHAR_TYPE_SIZE | |
206 | #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE | |
207 | #endif | |
208 | ||
c3bcf315 JL |
209 | #define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \ |
210 | ? (~ (~ (HOST_WIDE_INT) 0 << MAX_CHAR_TYPE_SIZE)) \ | |
211 | : ~ (HOST_WIDE_INT) 0) | |
861bb6c1 | 212 | |
c3bcf315 JL |
213 | #define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \ |
214 | ? ~ (~ (HOST_WIDE_INT) 0 << MAX_WCHAR_TYPE_SIZE) \ | |
215 | : ~ (HOST_WIDE_INT) 0) | |
861bb6c1 JL |
216 | |
217 | /* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow. | |
218 | Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1. | |
219 | Suppose SIGNEDP is negative if the result is signed, zero if unsigned. | |
220 | Then this yields nonzero if overflow occurred during the addition. | |
221 | Overflow occurs if A and B have the same sign, but A and SUM differ in sign, | |
222 | and SIGNEDP is negative. | |
223 | Use `^' to test whether signs differ, and `< 0' to isolate the sign. */ | |
224 | #define overflow_sum_sign(a, b, sum, signedp) \ | |
225 | ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0) | |
226 | ||
227 | struct constant; | |
228 | ||
229 | GENERIC_PTR xmalloc PROTO((size_t)); | |
230 | HOST_WIDE_INT parse_escape PROTO((char **, HOST_WIDE_INT)); | |
231 | int check_assertion PROTO((U_CHAR *, int, int, struct arglist *)); | |
232 | struct hashnode *lookup PROTO((U_CHAR *, int, int)); | |
233 | void error PRINTF_PROTO_1((char *, ...)); | |
234 | void pedwarn PRINTF_PROTO_1((char *, ...)); | |
235 | void warning PRINTF_PROTO_1((char *, ...)); | |
236 | ||
237 | static int parse_number PROTO((int)); | |
c3bcf315 JL |
238 | static HOST_WIDE_INT left_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT)); |
239 | static HOST_WIDE_INT right_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT)); | |
861bb6c1 JL |
240 | static void integer_overflow PROTO((void)); |
241 | ||
242 | /* `signedp' values */ | |
243 | #define SIGNED (~0) | |
244 | #define UNSIGNED 0 | |
245 | ||
27b6b158 | 246 | #line 251 "cexp.y" |
861bb6c1 JL |
247 | typedef union { |
248 | struct constant {HOST_WIDE_INT value; int signedp;} integer; | |
249 | struct name {U_CHAR *address; int length;} name; | |
250 | struct arglist *keywords; | |
251 | } YYSTYPE; | |
861bb6c1 JL |
252 | #include <stdio.h> |
253 | ||
254 | #ifndef __cplusplus | |
255 | #ifndef __STDC__ | |
256 | #define const | |
257 | #endif | |
258 | #endif | |
259 | ||
260 | ||
261 | ||
262 | #define YYFINAL 77 | |
263 | #define YYFLAG -32768 | |
264 | #define YYNTBASE 34 | |
265 | ||
266 | #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43) | |
267 | ||
268 | static const char yytranslate[] = { 0, | |
269 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
270 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
271 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
272 | 2, 2, 29, 2, 31, 2, 27, 14, 2, 32, | |
273 | 33, 25, 23, 9, 24, 2, 26, 2, 2, 2, | |
274 | 2, 2, 2, 2, 2, 2, 2, 8, 2, 17, | |
275 | 2, 18, 7, 2, 2, 2, 2, 2, 2, 2, | |
276 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
277 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
278 | 2, 2, 2, 13, 2, 2, 2, 2, 2, 2, | |
279 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
280 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
281 | 2, 2, 2, 12, 2, 30, 2, 2, 2, 2, | |
282 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
283 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
284 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
285 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
286 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
287 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
288 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
289 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
290 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
291 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
292 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
293 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
294 | 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, | |
295 | 6, 10, 11, 15, 16, 19, 20, 21, 22, 28 | |
296 | }; | |
297 | ||
298 | #if YYDEBUG != 0 | |
299 | static const short yyprhs[] = { 0, | |
300 | 0, 2, 4, 8, 11, 14, 17, 20, 23, 24, | |
301 | 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, | |
302 | 71, 75, 79, 83, 87, 91, 95, 99, 100, 105, | |
303 | 106, 111, 112, 113, 121, 123, 125, 127, 128, 133 | |
304 | }; | |
305 | ||
306 | static const short yyrhs[] = { 35, | |
307 | 0, 36, 0, 35, 9, 36, 0, 24, 36, 0, | |
308 | 29, 36, 0, 23, 36, 0, 30, 36, 0, 31, | |
309 | 5, 0, 0, 31, 5, 37, 32, 42, 33, 0, | |
310 | 32, 35, 33, 0, 36, 25, 36, 0, 36, 26, | |
311 | 36, 0, 36, 27, 36, 0, 36, 23, 36, 0, | |
312 | 36, 24, 36, 0, 36, 21, 36, 0, 36, 22, | |
313 | 36, 0, 36, 15, 36, 0, 36, 16, 36, 0, | |
314 | 36, 19, 36, 0, 36, 20, 36, 0, 36, 17, | |
315 | 36, 0, 36, 18, 36, 0, 36, 14, 36, 0, | |
316 | 36, 13, 36, 0, 36, 12, 36, 0, 0, 36, | |
317 | 11, 38, 36, 0, 0, 36, 10, 39, 36, 0, | |
318 | 0, 0, 36, 7, 40, 36, 8, 41, 36, 0, | |
319 | 3, 0, 4, 0, 5, 0, 0, 32, 42, 33, | |
320 | 42, 0, 5, 42, 0 | |
321 | }; | |
322 | ||
323 | #endif | |
324 | ||
325 | #if YYDEBUG != 0 | |
326 | static const short yyrline[] = { 0, | |
27b6b158 JL |
327 | 281, 291, 292, 299, 304, 307, 309, 312, 316, 318, |
328 | 323, 328, 341, 358, 371, 377, 383, 389, 395, 398, | |
329 | 401, 408, 415, 422, 429, 432, 435, 438, 441, 444, | |
330 | 447, 450, 452, 455, 458, 460, 462, 470, 472, 485 | |
861bb6c1 | 331 | }; |
c3bcf315 JL |
332 | #endif |
333 | ||
334 | ||
956d6950 | 335 | #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) |
861bb6c1 JL |
336 | |
337 | static const char * const yytname[] = { "$","error","$undefined.","INT","CHAR", | |
338 | "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL", | |
339 | "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'", | |
c3bcf315 | 340 | "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL |
861bb6c1 JL |
341 | }; |
342 | #endif | |
343 | ||
344 | static const short yyr1[] = { 0, | |
345 | 34, 35, 35, 36, 36, 36, 36, 36, 37, 36, | |
346 | 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, | |
347 | 36, 36, 36, 36, 36, 36, 36, 38, 36, 39, | |
348 | 36, 40, 41, 36, 36, 36, 36, 42, 42, 42 | |
349 | }; | |
350 | ||
351 | static const short yyr2[] = { 0, | |
352 | 1, 1, 3, 2, 2, 2, 2, 2, 0, 6, | |
353 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
354 | 3, 3, 3, 3, 3, 3, 3, 0, 4, 0, | |
355 | 4, 0, 0, 7, 1, 1, 1, 0, 4, 2 | |
356 | }; | |
357 | ||
358 | static const short yydefact[] = { 0, | |
359 | 35, 36, 37, 0, 0, 0, 0, 0, 0, 1, | |
360 | 2, 6, 4, 5, 7, 8, 0, 0, 32, 30, | |
361 | 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
362 | 0, 0, 0, 0, 0, 0, 0, 0, 11, 3, | |
363 | 0, 0, 0, 27, 26, 25, 19, 20, 23, 24, | |
364 | 21, 22, 17, 18, 15, 16, 12, 13, 14, 38, | |
365 | 0, 31, 29, 38, 38, 0, 33, 40, 0, 10, | |
366 | 0, 38, 34, 39, 0, 0, 0 | |
367 | }; | |
368 | ||
369 | static const short yydefgoto[] = { 75, | |
370 | 10, 11, 38, 43, 42, 41, 71, 66 | |
371 | }; | |
372 | ||
373 | static const short yypact[] = { 12, | |
374 | -32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4, | |
375 | 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768, | |
376 | -32768, 12, 12, 12, 12, 12, 12, 12, 12, 12, | |
377 | 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79, | |
378 | 12, 12, 12, 110, 124, 137, 148, 148, 155, 155, | |
379 | 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2, | |
380 | 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768, | |
381 | 12, 2, 79,-32768, 63, 188,-32768 | |
382 | }; | |
383 | ||
384 | static const short yypgoto[] = {-32768, | |
385 | 180, -4,-32768,-32768,-32768,-32768,-32768, -60 | |
386 | }; | |
387 | ||
388 | ||
389 | #define YYLAST 189 | |
390 | ||
391 | ||
392 | static const short yytable[] = { 12, | |
393 | 13, 14, 15, 68, 69, 16, 64, 35, 36, 37, | |
394 | -9, 74, 18, 40, 1, 2, 3, 44, 45, 46, | |
395 | 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, | |
396 | 57, 58, 59, 65, 4, 5, 61, 62, 63, 18, | |
397 | 6, 7, 8, 9, 21, 22, 23, 24, 25, 26, | |
398 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, | |
399 | 37, 60, 76, 39, 19, 67, 73, 20, 21, 22, | |
400 | 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, | |
401 | 33, 34, 35, 36, 37, 19, 70, 72, 20, 21, | |
402 | 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, | |
403 | 32, 33, 34, 35, 36, 37, 22, 23, 24, 25, | |
404 | 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, | |
405 | 36, 37, 23, 24, 25, 26, 27, 28, 29, 30, | |
406 | 31, 32, 33, 34, 35, 36, 37, 24, 25, 26, | |
407 | 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, | |
408 | 37, 25, 26, 27, 28, 29, 30, 31, 32, 33, | |
409 | 34, 35, 36, 37, 27, 28, 29, 30, 31, 32, | |
410 | 33, 34, 35, 36, 37, 31, 32, 33, 34, 35, | |
411 | 36, 37, 33, 34, 35, 36, 37, 77, 17 | |
412 | }; | |
413 | ||
414 | static const short yycheck[] = { 4, | |
415 | 5, 6, 7, 64, 65, 5, 5, 25, 26, 27, | |
416 | 32, 72, 9, 18, 3, 4, 5, 22, 23, 24, | |
417 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, | |
418 | 35, 36, 37, 32, 23, 24, 41, 42, 43, 9, | |
419 | 29, 30, 31, 32, 11, 12, 13, 14, 15, 16, | |
420 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, | |
421 | 27, 32, 0, 33, 7, 8, 71, 10, 11, 12, | |
422 | 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, | |
423 | 23, 24, 25, 26, 27, 7, 33, 33, 10, 11, | |
424 | 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, | |
425 | 22, 23, 24, 25, 26, 27, 12, 13, 14, 15, | |
426 | 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, | |
427 | 26, 27, 13, 14, 15, 16, 17, 18, 19, 20, | |
428 | 21, 22, 23, 24, 25, 26, 27, 14, 15, 16, | |
429 | 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, | |
430 | 27, 15, 16, 17, 18, 19, 20, 21, 22, 23, | |
431 | 24, 25, 26, 27, 17, 18, 19, 20, 21, 22, | |
432 | 23, 24, 25, 26, 27, 21, 22, 23, 24, 25, | |
433 | 26, 27, 23, 24, 25, 26, 27, 0, 9 | |
434 | }; | |
435 | /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ | |
c3bcf315 | 436 | #line 3 "/usr/share/bison.simple" |
861bb6c1 JL |
437 | |
438 | /* Skeleton output parser for bison, | |
439 | Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. | |
440 | ||
441 | This program is free software; you can redistribute it and/or modify | |
442 | it under the terms of the GNU General Public License as published by | |
443 | the Free Software Foundation; either version 2, or (at your option) | |
444 | any later version. | |
445 | ||
446 | This program is distributed in the hope that it will be useful, | |
447 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
448 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
449 | GNU General Public License for more details. | |
450 | ||
451 | You should have received a copy of the GNU General Public License | |
452 | along with this program; if not, write to the Free Software | |
453 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
454 | ||
455 | /* As a special exception, when this file is copied by Bison into a | |
456 | Bison output file, you may use that output file without restriction. | |
457 | This special exception was added by the Free Software Foundation | |
458 | in version 1.24 of Bison. */ | |
459 | ||
460 | #ifndef alloca | |
461 | #ifdef __GNUC__ | |
462 | #define alloca __builtin_alloca | |
463 | #else /* not GNU C. */ | |
464 | #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) | |
465 | #include <alloca.h> | |
466 | #else /* not sparc */ | |
467 | #if defined (MSDOS) && !defined (__TURBOC__) | |
468 | #include <malloc.h> | |
469 | #else /* not MSDOS, or __TURBOC__ */ | |
470 | #if defined(_AIX) | |
471 | #include <malloc.h> | |
472 | #pragma alloca | |
473 | #else /* not MSDOS, __TURBOC__, or _AIX */ | |
474 | #ifdef __hpux | |
475 | #ifdef __cplusplus | |
476 | extern "C" { | |
477 | void *alloca (unsigned int); | |
478 | }; | |
479 | #else /* not __cplusplus */ | |
480 | void *alloca (); | |
481 | #endif /* not __cplusplus */ | |
482 | #endif /* __hpux */ | |
483 | #endif /* not _AIX */ | |
484 | #endif /* not MSDOS, or __TURBOC__ */ | |
485 | #endif /* not sparc. */ | |
486 | #endif /* not GNU C. */ | |
487 | #endif /* alloca not defined. */ | |
488 | ||
489 | /* This is the parser code that is written into each bison parser | |
490 | when the %semantic_parser declaration is not specified in the grammar. | |
491 | It was written by Richard Stallman by simplifying the hairy parser | |
492 | used when %semantic_parser is specified. */ | |
493 | ||
494 | /* Note: there must be only one dollar sign in this file. | |
495 | It is replaced by the list of actions, each action | |
496 | as one case of the switch. */ | |
497 | ||
498 | #define yyerrok (yyerrstatus = 0) | |
499 | #define yyclearin (yychar = YYEMPTY) | |
500 | #define YYEMPTY -2 | |
501 | #define YYEOF 0 | |
502 | #define YYACCEPT return(0) | |
503 | #define YYABORT return(1) | |
504 | #define YYERROR goto yyerrlab1 | |
505 | /* Like YYERROR except do call yyerror. | |
506 | This remains here temporarily to ease the | |
507 | transition to the new meaning of YYERROR, for GCC. | |
508 | Once GCC version 2 has supplanted version 1, this can go. */ | |
509 | #define YYFAIL goto yyerrlab | |
510 | #define YYRECOVERING() (!!yyerrstatus) | |
511 | #define YYBACKUP(token, value) \ | |
512 | do \ | |
513 | if (yychar == YYEMPTY && yylen == 1) \ | |
514 | { yychar = (token), yylval = (value); \ | |
515 | yychar1 = YYTRANSLATE (yychar); \ | |
516 | YYPOPSTACK; \ | |
517 | goto yybackup; \ | |
518 | } \ | |
519 | else \ | |
520 | { yyerror ("syntax error: cannot back up"); YYERROR; } \ | |
521 | while (0) | |
522 | ||
523 | #define YYTERROR 1 | |
524 | #define YYERRCODE 256 | |
525 | ||
526 | #ifndef YYPURE | |
527 | #define YYLEX yylex() | |
528 | #endif | |
529 | ||
530 | #ifdef YYPURE | |
531 | #ifdef YYLSP_NEEDED | |
532 | #ifdef YYLEX_PARAM | |
533 | #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) | |
534 | #else | |
535 | #define YYLEX yylex(&yylval, &yylloc) | |
536 | #endif | |
537 | #else /* not YYLSP_NEEDED */ | |
538 | #ifdef YYLEX_PARAM | |
539 | #define YYLEX yylex(&yylval, YYLEX_PARAM) | |
540 | #else | |
541 | #define YYLEX yylex(&yylval) | |
542 | #endif | |
543 | #endif /* not YYLSP_NEEDED */ | |
544 | #endif | |
545 | ||
546 | /* If nonreentrant, generate the variables here */ | |
547 | ||
548 | #ifndef YYPURE | |
549 | ||
550 | int yychar; /* the lookahead symbol */ | |
551 | YYSTYPE yylval; /* the semantic value of the */ | |
552 | /* lookahead symbol */ | |
553 | ||
554 | #ifdef YYLSP_NEEDED | |
555 | YYLTYPE yylloc; /* location data for the lookahead */ | |
556 | /* symbol */ | |
557 | #endif | |
558 | ||
559 | int yynerrs; /* number of parse errors so far */ | |
560 | #endif /* not YYPURE */ | |
561 | ||
562 | #if YYDEBUG != 0 | |
563 | int yydebug; /* nonzero means print parse trace */ | |
564 | /* Since this is uninitialized, it does not stop multiple parsers | |
565 | from coexisting. */ | |
566 | #endif | |
567 | ||
568 | /* YYINITDEPTH indicates the initial size of the parser's stacks */ | |
569 | ||
570 | #ifndef YYINITDEPTH | |
571 | #define YYINITDEPTH 200 | |
572 | #endif | |
573 | ||
574 | /* YYMAXDEPTH is the maximum size the stacks can grow to | |
575 | (effective only if the built-in stack extension method is used). */ | |
576 | ||
577 | #if YYMAXDEPTH == 0 | |
578 | #undef YYMAXDEPTH | |
579 | #endif | |
580 | ||
581 | #ifndef YYMAXDEPTH | |
582 | #define YYMAXDEPTH 10000 | |
583 | #endif | |
584 | ||
585 | /* Prevent warning if -Wstrict-prototypes. */ | |
586 | #ifdef __GNUC__ | |
587 | int yyparse (void); | |
588 | #endif | |
589 | \f | |
590 | #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ | |
956d6950 | 591 | #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) |
861bb6c1 JL |
592 | #else /* not GNU C or C++ */ |
593 | #ifndef __cplusplus | |
594 | ||
595 | /* This is the most reliable way to avoid incompatibilities | |
596 | in available built-in functions on various systems. */ | |
597 | static void | |
956d6950 | 598 | __yy_memcpy (to, from, count) |
861bb6c1 | 599 | char *to; |
956d6950 | 600 | char *from; |
861bb6c1 JL |
601 | int count; |
602 | { | |
603 | register char *f = from; | |
604 | register char *t = to; | |
605 | register int i = count; | |
606 | ||
607 | while (i-- > 0) | |
608 | *t++ = *f++; | |
609 | } | |
610 | ||
611 | #else /* __cplusplus */ | |
612 | ||
613 | /* This is the most reliable way to avoid incompatibilities | |
614 | in available built-in functions on various systems. */ | |
615 | static void | |
956d6950 | 616 | __yy_memcpy (char *to, char *from, int count) |
861bb6c1 JL |
617 | { |
618 | register char *f = from; | |
619 | register char *t = to; | |
620 | register int i = count; | |
621 | ||
622 | while (i-- > 0) | |
623 | *t++ = *f++; | |
624 | } | |
625 | ||
626 | #endif | |
627 | #endif | |
628 | \f | |
956d6950 | 629 | #line 196 "/usr/share/bison.simple" |
861bb6c1 JL |
630 | |
631 | /* The user can define YYPARSE_PARAM as the name of an argument to be passed | |
632 | into yyparse. The argument should have type void *. | |
633 | It should actually point to an object. | |
634 | Grammar actions can access the variable by casting it | |
635 | to the proper pointer type. */ | |
636 | ||
637 | #ifdef YYPARSE_PARAM | |
956d6950 JL |
638 | #ifdef __cplusplus |
639 | #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM | |
640 | #define YYPARSE_PARAM_DECL | |
641 | #else /* not __cplusplus */ | |
642 | #define YYPARSE_PARAM_ARG YYPARSE_PARAM | |
861bb6c1 | 643 | #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; |
956d6950 JL |
644 | #endif /* not __cplusplus */ |
645 | #else /* not YYPARSE_PARAM */ | |
646 | #define YYPARSE_PARAM_ARG | |
861bb6c1 | 647 | #define YYPARSE_PARAM_DECL |
956d6950 | 648 | #endif /* not YYPARSE_PARAM */ |
861bb6c1 JL |
649 | |
650 | int | |
956d6950 | 651 | yyparse(YYPARSE_PARAM_ARG) |
861bb6c1 JL |
652 | YYPARSE_PARAM_DECL |
653 | { | |
654 | register int yystate; | |
655 | register int yyn; | |
656 | register short *yyssp; | |
657 | register YYSTYPE *yyvsp; | |
658 | int yyerrstatus; /* number of tokens to shift before error messages enabled */ | |
659 | int yychar1 = 0; /* lookahead token as an internal (translated) token number */ | |
660 | ||
661 | short yyssa[YYINITDEPTH]; /* the state stack */ | |
662 | YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ | |
663 | ||
664 | short *yyss = yyssa; /* refer to the stacks thru separate pointers */ | |
665 | YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ | |
666 | ||
667 | #ifdef YYLSP_NEEDED | |
668 | YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ | |
669 | YYLTYPE *yyls = yylsa; | |
670 | YYLTYPE *yylsp; | |
671 | ||
672 | #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) | |
673 | #else | |
674 | #define YYPOPSTACK (yyvsp--, yyssp--) | |
675 | #endif | |
676 | ||
677 | int yystacksize = YYINITDEPTH; | |
678 | ||
679 | #ifdef YYPURE | |
680 | int yychar; | |
681 | YYSTYPE yylval; | |
682 | int yynerrs; | |
683 | #ifdef YYLSP_NEEDED | |
684 | YYLTYPE yylloc; | |
685 | #endif | |
686 | #endif | |
687 | ||
688 | YYSTYPE yyval; /* the variable used to return */ | |
689 | /* semantic values from the action */ | |
690 | /* routines */ | |
691 | ||
692 | int yylen; | |
693 | ||
694 | #if YYDEBUG != 0 | |
695 | if (yydebug) | |
696 | fprintf(stderr, "Starting parse\n"); | |
697 | #endif | |
698 | ||
699 | yystate = 0; | |
700 | yyerrstatus = 0; | |
701 | yynerrs = 0; | |
702 | yychar = YYEMPTY; /* Cause a token to be read. */ | |
703 | ||
704 | /* Initialize stack pointers. | |
705 | Waste one element of value and location stack | |
706 | so that they stay on the same level as the state stack. | |
707 | The wasted elements are never initialized. */ | |
708 | ||
709 | yyssp = yyss - 1; | |
710 | yyvsp = yyvs; | |
711 | #ifdef YYLSP_NEEDED | |
712 | yylsp = yyls; | |
713 | #endif | |
714 | ||
715 | /* Push a new state, which is found in yystate . */ | |
716 | /* In all cases, when you get here, the value and location stacks | |
717 | have just been pushed. so pushing a state here evens the stacks. */ | |
718 | yynewstate: | |
719 | ||
720 | *++yyssp = yystate; | |
721 | ||
722 | if (yyssp >= yyss + yystacksize - 1) | |
723 | { | |
724 | /* Give user a chance to reallocate the stack */ | |
725 | /* Use copies of these so that the &'s don't force the real ones into memory. */ | |
726 | YYSTYPE *yyvs1 = yyvs; | |
727 | short *yyss1 = yyss; | |
728 | #ifdef YYLSP_NEEDED | |
729 | YYLTYPE *yyls1 = yyls; | |
730 | #endif | |
731 | ||
732 | /* Get the current used size of the three stacks, in elements. */ | |
733 | int size = yyssp - yyss + 1; | |
734 | ||
735 | #ifdef yyoverflow | |
736 | /* Each stack pointer address is followed by the size of | |
737 | the data in use in that stack, in bytes. */ | |
738 | #ifdef YYLSP_NEEDED | |
739 | /* This used to be a conditional around just the two extra args, | |
740 | but that might be undefined if yyoverflow is a macro. */ | |
741 | yyoverflow("parser stack overflow", | |
742 | &yyss1, size * sizeof (*yyssp), | |
743 | &yyvs1, size * sizeof (*yyvsp), | |
744 | &yyls1, size * sizeof (*yylsp), | |
745 | &yystacksize); | |
746 | #else | |
747 | yyoverflow("parser stack overflow", | |
748 | &yyss1, size * sizeof (*yyssp), | |
749 | &yyvs1, size * sizeof (*yyvsp), | |
750 | &yystacksize); | |
751 | #endif | |
752 | ||
753 | yyss = yyss1; yyvs = yyvs1; | |
754 | #ifdef YYLSP_NEEDED | |
755 | yyls = yyls1; | |
756 | #endif | |
757 | #else /* no yyoverflow */ | |
758 | /* Extend the stack our own way. */ | |
759 | if (yystacksize >= YYMAXDEPTH) | |
760 | { | |
761 | yyerror("parser stack overflow"); | |
762 | return 2; | |
763 | } | |
764 | yystacksize *= 2; | |
765 | if (yystacksize > YYMAXDEPTH) | |
766 | yystacksize = YYMAXDEPTH; | |
767 | yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); | |
956d6950 | 768 | __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); |
861bb6c1 | 769 | yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); |
956d6950 | 770 | __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); |
861bb6c1 JL |
771 | #ifdef YYLSP_NEEDED |
772 | yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); | |
956d6950 | 773 | __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); |
861bb6c1 JL |
774 | #endif |
775 | #endif /* no yyoverflow */ | |
776 | ||
777 | yyssp = yyss + size - 1; | |
778 | yyvsp = yyvs + size - 1; | |
779 | #ifdef YYLSP_NEEDED | |
780 | yylsp = yyls + size - 1; | |
781 | #endif | |
782 | ||
783 | #if YYDEBUG != 0 | |
784 | if (yydebug) | |
785 | fprintf(stderr, "Stack size increased to %d\n", yystacksize); | |
786 | #endif | |
787 | ||
788 | if (yyssp >= yyss + yystacksize - 1) | |
789 | YYABORT; | |
790 | } | |
791 | ||
792 | #if YYDEBUG != 0 | |
793 | if (yydebug) | |
794 | fprintf(stderr, "Entering state %d\n", yystate); | |
795 | #endif | |
796 | ||
797 | goto yybackup; | |
798 | yybackup: | |
799 | ||
800 | /* Do appropriate processing given the current state. */ | |
801 | /* Read a lookahead token if we need one and don't already have one. */ | |
802 | /* yyresume: */ | |
803 | ||
804 | /* First try to decide what to do without reference to lookahead token. */ | |
805 | ||
806 | yyn = yypact[yystate]; | |
807 | if (yyn == YYFLAG) | |
808 | goto yydefault; | |
809 | ||
810 | /* Not known => get a lookahead token if don't already have one. */ | |
811 | ||
812 | /* yychar is either YYEMPTY or YYEOF | |
813 | or a valid token in external form. */ | |
814 | ||
815 | if (yychar == YYEMPTY) | |
816 | { | |
817 | #if YYDEBUG != 0 | |
818 | if (yydebug) | |
819 | fprintf(stderr, "Reading a token: "); | |
820 | #endif | |
821 | yychar = YYLEX; | |
822 | } | |
823 | ||
824 | /* Convert token to internal form (in yychar1) for indexing tables with */ | |
825 | ||
826 | if (yychar <= 0) /* This means end of input. */ | |
827 | { | |
828 | yychar1 = 0; | |
829 | yychar = YYEOF; /* Don't call YYLEX any more */ | |
830 | ||
831 | #if YYDEBUG != 0 | |
832 | if (yydebug) | |
833 | fprintf(stderr, "Now at end of input.\n"); | |
834 | #endif | |
835 | } | |
836 | else | |
837 | { | |
838 | yychar1 = YYTRANSLATE(yychar); | |
839 | ||
840 | #if YYDEBUG != 0 | |
841 | if (yydebug) | |
842 | { | |
843 | fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); | |
844 | /* Give the individual parser a way to print the precise meaning | |
845 | of a token, for further debugging info. */ | |
846 | #ifdef YYPRINT | |
847 | YYPRINT (stderr, yychar, yylval); | |
848 | #endif | |
849 | fprintf (stderr, ")\n"); | |
850 | } | |
851 | #endif | |
852 | } | |
853 | ||
854 | yyn += yychar1; | |
855 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) | |
856 | goto yydefault; | |
857 | ||
858 | yyn = yytable[yyn]; | |
859 | ||
860 | /* yyn is what to do for this token type in this state. | |
861 | Negative => reduce, -yyn is rule number. | |
862 | Positive => shift, yyn is new state. | |
863 | New state is final state => don't bother to shift, | |
864 | just return success. | |
865 | 0, or most negative number => error. */ | |
866 | ||
867 | if (yyn < 0) | |
868 | { | |
869 | if (yyn == YYFLAG) | |
870 | goto yyerrlab; | |
871 | yyn = -yyn; | |
872 | goto yyreduce; | |
873 | } | |
874 | else if (yyn == 0) | |
875 | goto yyerrlab; | |
876 | ||
877 | if (yyn == YYFINAL) | |
878 | YYACCEPT; | |
879 | ||
880 | /* Shift the lookahead token. */ | |
881 | ||
882 | #if YYDEBUG != 0 | |
883 | if (yydebug) | |
884 | fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); | |
885 | #endif | |
886 | ||
887 | /* Discard the token being shifted unless it is eof. */ | |
888 | if (yychar != YYEOF) | |
889 | yychar = YYEMPTY; | |
890 | ||
891 | *++yyvsp = yylval; | |
892 | #ifdef YYLSP_NEEDED | |
893 | *++yylsp = yylloc; | |
894 | #endif | |
895 | ||
896 | /* count tokens shifted since error; after three, turn off error status. */ | |
897 | if (yyerrstatus) yyerrstatus--; | |
898 | ||
899 | yystate = yyn; | |
900 | goto yynewstate; | |
901 | ||
902 | /* Do the default action for the current state. */ | |
903 | yydefault: | |
904 | ||
905 | yyn = yydefact[yystate]; | |
906 | if (yyn == 0) | |
907 | goto yyerrlab; | |
908 | ||
909 | /* Do a reduction. yyn is the number of a rule to reduce with. */ | |
910 | yyreduce: | |
911 | yylen = yyr2[yyn]; | |
912 | if (yylen > 0) | |
913 | yyval = yyvsp[1-yylen]; /* implement default value of the action */ | |
914 | ||
915 | #if YYDEBUG != 0 | |
916 | if (yydebug) | |
917 | { | |
918 | int i; | |
919 | ||
920 | fprintf (stderr, "Reducing via rule %d (line %d), ", | |
921 | yyn, yyrline[yyn]); | |
922 | ||
923 | /* Print the symbols being reduced, and their result. */ | |
924 | for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) | |
925 | fprintf (stderr, "%s ", yytname[yyrhs[i]]); | |
926 | fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); | |
927 | } | |
928 | #endif | |
929 | ||
930 | ||
931 | switch (yyn) { | |
932 | ||
933 | case 1: | |
27b6b158 JL |
934 | #line 282 "cexp.y" |
935 | { | |
936 | expression_value = yyvsp[0].integer.value; | |
937 | #ifdef TEST_EXP_READER | |
938 | expression_signedp = yyvsp[0].integer.signedp; | |
939 | #endif | |
940 | ; | |
861bb6c1 JL |
941 | break;} |
942 | case 3: | |
27b6b158 | 943 | #line 293 "cexp.y" |
861bb6c1 JL |
944 | { if (pedantic) |
945 | pedwarn ("comma operator in operand of `#if'"); | |
946 | yyval.integer = yyvsp[0].integer; ; | |
947 | break;} | |
948 | case 4: | |
27b6b158 | 949 | #line 300 "cexp.y" |
861bb6c1 JL |
950 | { yyval.integer.value = - yyvsp[0].integer.value; |
951 | yyval.integer.signedp = yyvsp[0].integer.signedp; | |
952 | if ((yyval.integer.value & yyvsp[0].integer.value & yyval.integer.signedp) < 0) | |
953 | integer_overflow (); ; | |
954 | break;} | |
955 | case 5: | |
27b6b158 | 956 | #line 305 "cexp.y" |
861bb6c1 JL |
957 | { yyval.integer.value = ! yyvsp[0].integer.value; |
958 | yyval.integer.signedp = SIGNED; ; | |
959 | break;} | |
960 | case 6: | |
27b6b158 | 961 | #line 308 "cexp.y" |
861bb6c1 JL |
962 | { yyval.integer = yyvsp[0].integer; ; |
963 | break;} | |
964 | case 7: | |
27b6b158 | 965 | #line 310 "cexp.y" |
861bb6c1 JL |
966 | { yyval.integer.value = ~ yyvsp[0].integer.value; |
967 | yyval.integer.signedp = yyvsp[0].integer.signedp; ; | |
968 | break;} | |
969 | case 8: | |
27b6b158 | 970 | #line 313 "cexp.y" |
861bb6c1 JL |
971 | { yyval.integer.value = check_assertion (yyvsp[0].name.address, yyvsp[0].name.length, |
972 | 0, NULL_PTR); | |
973 | yyval.integer.signedp = SIGNED; ; | |
974 | break;} | |
975 | case 9: | |
27b6b158 | 976 | #line 317 "cexp.y" |
861bb6c1 JL |
977 | { keyword_parsing = 1; ; |
978 | break;} | |
979 | case 10: | |
27b6b158 | 980 | #line 319 "cexp.y" |
861bb6c1 JL |
981 | { yyval.integer.value = check_assertion (yyvsp[-4].name.address, yyvsp[-4].name.length, |
982 | 1, yyvsp[-1].keywords); | |
983 | keyword_parsing = 0; | |
984 | yyval.integer.signedp = SIGNED; ; | |
985 | break;} | |
986 | case 11: | |
27b6b158 | 987 | #line 324 "cexp.y" |
861bb6c1 JL |
988 | { yyval.integer = yyvsp[-1].integer; ; |
989 | break;} | |
990 | case 12: | |
27b6b158 | 991 | #line 329 "cexp.y" |
861bb6c1 JL |
992 | { yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; |
993 | if (yyval.integer.signedp) | |
994 | { | |
995 | yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value; | |
996 | if (yyvsp[-2].integer.value | |
997 | && (yyval.integer.value / yyvsp[-2].integer.value != yyvsp[0].integer.value | |
998 | || (yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0)) | |
999 | integer_overflow (); | |
1000 | } | |
1001 | else | |
c3bcf315 | 1002 | yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value |
861bb6c1 JL |
1003 | * yyvsp[0].integer.value); ; |
1004 | break;} | |
1005 | case 13: | |
27b6b158 | 1006 | #line 342 "cexp.y" |
861bb6c1 JL |
1007 | { if (yyvsp[0].integer.value == 0) |
1008 | { | |
1009 | if (!skip_evaluation) | |
1010 | error ("division by zero in #if"); | |
1011 | yyvsp[0].integer.value = 1; | |
1012 | } | |
1013 | yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; | |
1014 | if (yyval.integer.signedp) | |
1015 | { | |
1016 | yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value; | |
1017 | if ((yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0) | |
1018 | integer_overflow (); | |
1019 | } | |
1020 | else | |
c3bcf315 | 1021 | yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value |
861bb6c1 JL |
1022 | / yyvsp[0].integer.value); ; |
1023 | break;} | |
1024 | case 14: | |
27b6b158 | 1025 | #line 359 "cexp.y" |
861bb6c1 JL |
1026 | { if (yyvsp[0].integer.value == 0) |
1027 | { | |
1028 | if (!skip_evaluation) | |
1029 | error ("division by zero in #if"); | |
1030 | yyvsp[0].integer.value = 1; | |
1031 | } | |
1032 | yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; | |
1033 | if (yyval.integer.signedp) | |
1034 | yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value; | |
1035 | else | |
c3bcf315 | 1036 | yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value |
861bb6c1 JL |
1037 | % yyvsp[0].integer.value); ; |
1038 | break;} | |
1039 | case 15: | |
27b6b158 | 1040 | #line 372 "cexp.y" |
861bb6c1 JL |
1041 | { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value; |
1042 | yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; | |
1043 | if (overflow_sum_sign (yyvsp[-2].integer.value, yyvsp[0].integer.value, | |
1044 | yyval.integer.value, yyval.integer.signedp)) | |
1045 | integer_overflow (); ; | |
1046 | break;} | |
1047 | case 16: | |
27b6b158 | 1048 | #line 378 "cexp.y" |
861bb6c1 JL |
1049 | { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value; |
1050 | yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; | |
1051 | if (overflow_sum_sign (yyval.integer.value, yyvsp[0].integer.value, | |
1052 | yyvsp[-2].integer.value, yyval.integer.signedp)) | |
1053 | integer_overflow (); ; | |
1054 | break;} | |
1055 | case 17: | |
27b6b158 | 1056 | #line 384 "cexp.y" |
861bb6c1 JL |
1057 | { yyval.integer.signedp = yyvsp[-2].integer.signedp; |
1058 | if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) | |
1059 | yyval.integer.value = right_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); | |
1060 | else | |
1061 | yyval.integer.value = left_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; | |
1062 | break;} | |
1063 | case 18: | |
27b6b158 | 1064 | #line 390 "cexp.y" |
861bb6c1 JL |
1065 | { yyval.integer.signedp = yyvsp[-2].integer.signedp; |
1066 | if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0) | |
1067 | yyval.integer.value = left_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value); | |
1068 | else | |
1069 | yyval.integer.value = right_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ; | |
1070 | break;} | |
1071 | case 19: | |
27b6b158 | 1072 | #line 396 "cexp.y" |
861bb6c1 JL |
1073 | { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value); |
1074 | yyval.integer.signedp = SIGNED; ; | |
1075 | break;} | |
1076 | case 20: | |
27b6b158 | 1077 | #line 399 "cexp.y" |
861bb6c1 JL |
1078 | { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value); |
1079 | yyval.integer.signedp = SIGNED; ; | |
1080 | break;} | |
1081 | case 21: | |
27b6b158 | 1082 | #line 402 "cexp.y" |
861bb6c1 JL |
1083 | { yyval.integer.signedp = SIGNED; |
1084 | if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) | |
1085 | yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; | |
1086 | else | |
c3bcf315 | 1087 | yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value |
861bb6c1 JL |
1088 | <= yyvsp[0].integer.value); ; |
1089 | break;} | |
1090 | case 22: | |
27b6b158 | 1091 | #line 409 "cexp.y" |
861bb6c1 JL |
1092 | { yyval.integer.signedp = SIGNED; |
1093 | if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) | |
1094 | yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; | |
1095 | else | |
c3bcf315 | 1096 | yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value |
861bb6c1 JL |
1097 | >= yyvsp[0].integer.value); ; |
1098 | break;} | |
1099 | case 23: | |
27b6b158 | 1100 | #line 416 "cexp.y" |
861bb6c1 JL |
1101 | { yyval.integer.signedp = SIGNED; |
1102 | if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) | |
1103 | yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; | |
1104 | else | |
c3bcf315 | 1105 | yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value |
861bb6c1 JL |
1106 | < yyvsp[0].integer.value); ; |
1107 | break;} | |
1108 | case 24: | |
27b6b158 | 1109 | #line 423 "cexp.y" |
861bb6c1 JL |
1110 | { yyval.integer.signedp = SIGNED; |
1111 | if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp) | |
1112 | yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; | |
1113 | else | |
c3bcf315 | 1114 | yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value |
861bb6c1 JL |
1115 | > yyvsp[0].integer.value); ; |
1116 | break;} | |
1117 | case 25: | |
27b6b158 | 1118 | #line 430 "cexp.y" |
861bb6c1 JL |
1119 | { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value; |
1120 | yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; | |
1121 | break;} | |
1122 | case 26: | |
27b6b158 | 1123 | #line 433 "cexp.y" |
861bb6c1 JL |
1124 | { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value; |
1125 | yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; | |
1126 | break;} | |
1127 | case 27: | |
27b6b158 | 1128 | #line 436 "cexp.y" |
861bb6c1 JL |
1129 | { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value; |
1130 | yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ; | |
1131 | break;} | |
1132 | case 28: | |
27b6b158 | 1133 | #line 439 "cexp.y" |
861bb6c1 JL |
1134 | { skip_evaluation += !yyvsp[-1].integer.value; ; |
1135 | break;} | |
1136 | case 29: | |
27b6b158 | 1137 | #line 441 "cexp.y" |
861bb6c1 JL |
1138 | { skip_evaluation -= !yyvsp[-3].integer.value; |
1139 | yyval.integer.value = (yyvsp[-3].integer.value && yyvsp[0].integer.value); | |
1140 | yyval.integer.signedp = SIGNED; ; | |
1141 | break;} | |
1142 | case 30: | |
27b6b158 | 1143 | #line 445 "cexp.y" |
861bb6c1 JL |
1144 | { skip_evaluation += !!yyvsp[-1].integer.value; ; |
1145 | break;} | |
1146 | case 31: | |
27b6b158 | 1147 | #line 447 "cexp.y" |
861bb6c1 JL |
1148 | { skip_evaluation -= !!yyvsp[-3].integer.value; |
1149 | yyval.integer.value = (yyvsp[-3].integer.value || yyvsp[0].integer.value); | |
1150 | yyval.integer.signedp = SIGNED; ; | |
1151 | break;} | |
1152 | case 32: | |
27b6b158 | 1153 | #line 451 "cexp.y" |
861bb6c1 JL |
1154 | { skip_evaluation += !yyvsp[-1].integer.value; ; |
1155 | break;} | |
1156 | case 33: | |
27b6b158 | 1157 | #line 453 "cexp.y" |
861bb6c1 JL |
1158 | { skip_evaluation += !!yyvsp[-4].integer.value - !yyvsp[-4].integer.value; ; |
1159 | break;} | |
1160 | case 34: | |
27b6b158 | 1161 | #line 455 "cexp.y" |
861bb6c1 JL |
1162 | { skip_evaluation -= !!yyvsp[-6].integer.value; |
1163 | yyval.integer.value = yyvsp[-6].integer.value ? yyvsp[-3].integer.value : yyvsp[0].integer.value; | |
1164 | yyval.integer.signedp = yyvsp[-3].integer.signedp & yyvsp[0].integer.signedp; ; | |
1165 | break;} | |
1166 | case 35: | |
27b6b158 | 1167 | #line 459 "cexp.y" |
861bb6c1 JL |
1168 | { yyval.integer = yylval.integer; ; |
1169 | break;} | |
1170 | case 36: | |
27b6b158 | 1171 | #line 461 "cexp.y" |
861bb6c1 JL |
1172 | { yyval.integer = yylval.integer; ; |
1173 | break;} | |
1174 | case 37: | |
27b6b158 | 1175 | #line 463 "cexp.y" |
861bb6c1 JL |
1176 | { if (warn_undef && !skip_evaluation) |
1177 | warning ("`%.*s' is not defined", | |
1178 | yyvsp[0].name.length, yyvsp[0].name.address); | |
1179 | yyval.integer.value = 0; | |
1180 | yyval.integer.signedp = SIGNED; ; | |
1181 | break;} | |
1182 | case 38: | |
27b6b158 | 1183 | #line 471 "cexp.y" |
861bb6c1 JL |
1184 | { yyval.keywords = 0; ; |
1185 | break;} | |
1186 | case 39: | |
27b6b158 | 1187 | #line 473 "cexp.y" |
861bb6c1 JL |
1188 | { struct arglist *temp; |
1189 | yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); | |
1190 | yyval.keywords->next = yyvsp[-2].keywords; | |
1191 | yyval.keywords->name = (U_CHAR *) "("; | |
1192 | yyval.keywords->length = 1; | |
1193 | temp = yyval.keywords; | |
1194 | while (temp != 0 && temp->next != 0) | |
1195 | temp = temp->next; | |
1196 | temp->next = (struct arglist *) xmalloc (sizeof (struct arglist)); | |
1197 | temp->next->next = yyvsp[0].keywords; | |
1198 | temp->next->name = (U_CHAR *) ")"; | |
1199 | temp->next->length = 1; ; | |
1200 | break;} | |
1201 | case 40: | |
27b6b158 | 1202 | #line 486 "cexp.y" |
861bb6c1 JL |
1203 | { yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist)); |
1204 | yyval.keywords->name = yyvsp[-1].name.address; | |
1205 | yyval.keywords->length = yyvsp[-1].name.length; | |
1206 | yyval.keywords->next = yyvsp[0].keywords; ; | |
1207 | break;} | |
1208 | } | |
1209 | /* the action file gets copied in in place of this dollarsign */ | |
956d6950 | 1210 | #line 498 "/usr/share/bison.simple" |
861bb6c1 JL |
1211 | \f |
1212 | yyvsp -= yylen; | |
1213 | yyssp -= yylen; | |
1214 | #ifdef YYLSP_NEEDED | |
1215 | yylsp -= yylen; | |
1216 | #endif | |
1217 | ||
1218 | #if YYDEBUG != 0 | |
1219 | if (yydebug) | |
1220 | { | |
1221 | short *ssp1 = yyss - 1; | |
1222 | fprintf (stderr, "state stack now"); | |
1223 | while (ssp1 != yyssp) | |
1224 | fprintf (stderr, " %d", *++ssp1); | |
1225 | fprintf (stderr, "\n"); | |
1226 | } | |
1227 | #endif | |
1228 | ||
1229 | *++yyvsp = yyval; | |
1230 | ||
1231 | #ifdef YYLSP_NEEDED | |
1232 | yylsp++; | |
1233 | if (yylen == 0) | |
1234 | { | |
1235 | yylsp->first_line = yylloc.first_line; | |
1236 | yylsp->first_column = yylloc.first_column; | |
1237 | yylsp->last_line = (yylsp-1)->last_line; | |
1238 | yylsp->last_column = (yylsp-1)->last_column; | |
1239 | yylsp->text = 0; | |
1240 | } | |
1241 | else | |
1242 | { | |
1243 | yylsp->last_line = (yylsp+yylen-1)->last_line; | |
1244 | yylsp->last_column = (yylsp+yylen-1)->last_column; | |
1245 | } | |
1246 | #endif | |
1247 | ||
1248 | /* Now "shift" the result of the reduction. | |
1249 | Determine what state that goes to, | |
1250 | based on the state we popped back to | |
1251 | and the rule number reduced by. */ | |
1252 | ||
1253 | yyn = yyr1[yyn]; | |
1254 | ||
1255 | yystate = yypgoto[yyn - YYNTBASE] + *yyssp; | |
1256 | if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) | |
1257 | yystate = yytable[yystate]; | |
1258 | else | |
1259 | yystate = yydefgoto[yyn - YYNTBASE]; | |
1260 | ||
1261 | goto yynewstate; | |
1262 | ||
1263 | yyerrlab: /* here on detecting error */ | |
1264 | ||
1265 | if (! yyerrstatus) | |
1266 | /* If not already recovering from an error, report this error. */ | |
1267 | { | |
1268 | ++yynerrs; | |
1269 | ||
1270 | #ifdef YYERROR_VERBOSE | |
1271 | yyn = yypact[yystate]; | |
1272 | ||
1273 | if (yyn > YYFLAG && yyn < YYLAST) | |
1274 | { | |
1275 | int size = 0; | |
1276 | char *msg; | |
1277 | int x, count; | |
1278 | ||
1279 | count = 0; | |
1280 | /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ | |
1281 | for (x = (yyn < 0 ? -yyn : 0); | |
1282 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
1283 | if (yycheck[x + yyn] == x) | |
1284 | size += strlen(yytname[x]) + 15, count++; | |
1285 | msg = (char *) malloc(size + 15); | |
1286 | if (msg != 0) | |
1287 | { | |
1288 | strcpy(msg, "parse error"); | |
1289 | ||
1290 | if (count < 5) | |
1291 | { | |
1292 | count = 0; | |
1293 | for (x = (yyn < 0 ? -yyn : 0); | |
1294 | x < (sizeof(yytname) / sizeof(char *)); x++) | |
1295 | if (yycheck[x + yyn] == x) | |
1296 | { | |
1297 | strcat(msg, count == 0 ? ", expecting `" : " or `"); | |
1298 | strcat(msg, yytname[x]); | |
1299 | strcat(msg, "'"); | |
1300 | count++; | |
1301 | } | |
1302 | } | |
1303 | yyerror(msg); | |
1304 | free(msg); | |
1305 | } | |
1306 | else | |
1307 | yyerror ("parse error; also virtual memory exceeded"); | |
1308 | } | |
1309 | else | |
1310 | #endif /* YYERROR_VERBOSE */ | |
1311 | yyerror("parse error"); | |
1312 | } | |
1313 | ||
1314 | goto yyerrlab1; | |
1315 | yyerrlab1: /* here on error raised explicitly by an action */ | |
1316 | ||
1317 | if (yyerrstatus == 3) | |
1318 | { | |
1319 | /* if just tried and failed to reuse lookahead token after an error, discard it. */ | |
1320 | ||
1321 | /* return failure if at end of input */ | |
1322 | if (yychar == YYEOF) | |
1323 | YYABORT; | |
1324 | ||
1325 | #if YYDEBUG != 0 | |
1326 | if (yydebug) | |
1327 | fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); | |
1328 | #endif | |
1329 | ||
1330 | yychar = YYEMPTY; | |
1331 | } | |
1332 | ||
1333 | /* Else will try to reuse lookahead token | |
1334 | after shifting the error token. */ | |
1335 | ||
1336 | yyerrstatus = 3; /* Each real token shifted decrements this */ | |
1337 | ||
1338 | goto yyerrhandle; | |
1339 | ||
1340 | yyerrdefault: /* current state does not do anything special for the error token. */ | |
1341 | ||
1342 | #if 0 | |
1343 | /* This is wrong; only states that explicitly want error tokens | |
1344 | should shift them. */ | |
1345 | yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ | |
1346 | if (yyn) goto yydefault; | |
1347 | #endif | |
1348 | ||
1349 | yyerrpop: /* pop the current state because it cannot handle the error token */ | |
1350 | ||
1351 | if (yyssp == yyss) YYABORT; | |
1352 | yyvsp--; | |
1353 | yystate = *--yyssp; | |
1354 | #ifdef YYLSP_NEEDED | |
1355 | yylsp--; | |
1356 | #endif | |
1357 | ||
1358 | #if YYDEBUG != 0 | |
1359 | if (yydebug) | |
1360 | { | |
1361 | short *ssp1 = yyss - 1; | |
1362 | fprintf (stderr, "Error: state stack now"); | |
1363 | while (ssp1 != yyssp) | |
1364 | fprintf (stderr, " %d", *++ssp1); | |
1365 | fprintf (stderr, "\n"); | |
1366 | } | |
1367 | #endif | |
1368 | ||
1369 | yyerrhandle: | |
1370 | ||
1371 | yyn = yypact[yystate]; | |
1372 | if (yyn == YYFLAG) | |
1373 | goto yyerrdefault; | |
1374 | ||
1375 | yyn += YYTERROR; | |
1376 | if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) | |
1377 | goto yyerrdefault; | |
1378 | ||
1379 | yyn = yytable[yyn]; | |
1380 | if (yyn < 0) | |
1381 | { | |
1382 | if (yyn == YYFLAG) | |
1383 | goto yyerrpop; | |
1384 | yyn = -yyn; | |
1385 | goto yyreduce; | |
1386 | } | |
1387 | else if (yyn == 0) | |
1388 | goto yyerrpop; | |
1389 | ||
1390 | if (yyn == YYFINAL) | |
1391 | YYACCEPT; | |
1392 | ||
1393 | #if YYDEBUG != 0 | |
1394 | if (yydebug) | |
1395 | fprintf(stderr, "Shifting error token, "); | |
1396 | #endif | |
1397 | ||
1398 | *++yyvsp = yylval; | |
1399 | #ifdef YYLSP_NEEDED | |
1400 | *++yylsp = yylloc; | |
1401 | #endif | |
1402 | ||
1403 | yystate = yyn; | |
1404 | goto yynewstate; | |
1405 | } | |
27b6b158 | 1406 | #line 491 "cexp.y" |
861bb6c1 JL |
1407 | |
1408 | \f | |
1409 | /* During parsing of a C expression, the pointer to the next character | |
1410 | is in this variable. */ | |
1411 | ||
1412 | static char *lexptr; | |
1413 | ||
1414 | /* Take care of parsing a number (anything that starts with a digit). | |
1415 | Set yylval and return the token type; update lexptr. | |
1416 | LEN is the number of characters in it. */ | |
1417 | ||
1418 | /* maybe needs to actually deal with floating point numbers */ | |
1419 | ||
1420 | static int | |
1421 | parse_number (olen) | |
1422 | int olen; | |
1423 | { | |
1424 | register char *p = lexptr; | |
1425 | register int c; | |
c3bcf315 | 1426 | register unsigned_HOST_WIDE_INT n = 0, nd, max_over_base; |
861bb6c1 JL |
1427 | register int base = 10; |
1428 | register int len = olen; | |
1429 | register int overflow = 0; | |
1430 | register int digit, largest_digit = 0; | |
1431 | int spec_long = 0; | |
1432 | ||
1433 | yylval.integer.signedp = SIGNED; | |
1434 | ||
1435 | if (*p == '0') { | |
1436 | base = 8; | |
1437 | if (len >= 3 && (p[1] == 'x' || p[1] == 'X')) { | |
1438 | p += 2; | |
1439 | base = 16; | |
1440 | len -= 2; | |
1441 | } | |
1442 | } | |
1443 | ||
c3bcf315 | 1444 | max_over_base = (unsigned_HOST_WIDE_INT) -1 / base; |
861bb6c1 JL |
1445 | |
1446 | for (; len > 0; len--) { | |
1447 | c = *p++; | |
1448 | ||
1449 | if (c >= '0' && c <= '9') | |
1450 | digit = c - '0'; | |
1451 | else if (base == 16 && c >= 'a' && c <= 'f') | |
1452 | digit = c - 'a' + 10; | |
1453 | else if (base == 16 && c >= 'A' && c <= 'F') | |
1454 | digit = c - 'A' + 10; | |
1455 | else { | |
1456 | /* `l' means long, and `u' means unsigned. */ | |
1457 | while (1) { | |
1458 | if (c == 'l' || c == 'L') | |
1459 | { | |
1460 | if (!pedantic < spec_long) | |
1461 | yyerror ("too many `l's in integer constant"); | |
1462 | spec_long++; | |
1463 | } | |
1464 | else if (c == 'u' || c == 'U') | |
1465 | { | |
1466 | if (! yylval.integer.signedp) | |
1467 | yyerror ("two `u's in integer constant"); | |
1468 | yylval.integer.signedp = UNSIGNED; | |
1469 | } | |
1470 | else { | |
1471 | if (c == '.' || c == 'e' || c == 'E' || c == 'p' || c == 'P') | |
1472 | yyerror ("Floating point numbers not allowed in #if expressions"); | |
1473 | else { | |
1474 | char *buf = (char *) alloca (p - lexptr + 40); | |
1475 | sprintf (buf, "missing white space after number `%.*s'", | |
1476 | (int) (p - lexptr - 1), lexptr); | |
1477 | yyerror (buf); | |
1478 | } | |
1479 | } | |
1480 | ||
1481 | if (--len == 0) | |
1482 | break; | |
1483 | c = *p++; | |
1484 | } | |
1485 | /* Don't look for any more digits after the suffixes. */ | |
1486 | break; | |
1487 | } | |
1488 | if (largest_digit < digit) | |
1489 | largest_digit = digit; | |
1490 | nd = n * base + digit; | |
1491 | overflow |= (max_over_base < n) | (nd < n); | |
1492 | n = nd; | |
1493 | } | |
1494 | ||
1495 | if (base <= largest_digit) | |
1496 | pedwarn ("integer constant contains digits beyond the radix"); | |
1497 | ||
1498 | if (overflow) | |
1499 | pedwarn ("integer constant out of range"); | |
1500 | ||
1501 | /* If too big to be signed, consider it unsigned. */ | |
1502 | if (((HOST_WIDE_INT) n & yylval.integer.signedp) < 0) | |
1503 | { | |
1504 | if (base == 10) | |
1505 | warning ("integer constant is so large that it is unsigned"); | |
1506 | yylval.integer.signedp = UNSIGNED; | |
1507 | } | |
1508 | ||
1509 | lexptr = p; | |
1510 | yylval.integer.value = n; | |
1511 | return INT; | |
1512 | } | |
1513 | ||
1514 | struct token { | |
1515 | char *operator; | |
1516 | int token; | |
1517 | }; | |
1518 | ||
1519 | static struct token tokentab2[] = { | |
1520 | {"&&", AND}, | |
1521 | {"||", OR}, | |
1522 | {"<<", LSH}, | |
1523 | {">>", RSH}, | |
1524 | {"==", EQUAL}, | |
1525 | {"!=", NOTEQUAL}, | |
1526 | {"<=", LEQ}, | |
1527 | {">=", GEQ}, | |
1528 | {"++", ERROR}, | |
1529 | {"--", ERROR}, | |
1530 | {NULL, ERROR} | |
1531 | }; | |
1532 | ||
1533 | /* Read one token, getting characters through lexptr. */ | |
1534 | ||
1535 | static int | |
1536 | yylex () | |
1537 | { | |
1538 | register int c; | |
1539 | register int namelen; | |
1540 | register unsigned char *tokstart; | |
1541 | register struct token *toktab; | |
1542 | int wide_flag; | |
1543 | HOST_WIDE_INT mask; | |
1544 | ||
1545 | retry: | |
1546 | ||
1547 | tokstart = (unsigned char *) lexptr; | |
1548 | c = *tokstart; | |
1549 | /* See if it is a special token of length 2. */ | |
1550 | if (! keyword_parsing) | |
1551 | for (toktab = tokentab2; toktab->operator != NULL; toktab++) | |
1552 | if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) { | |
1553 | lexptr += 2; | |
1554 | if (toktab->token == ERROR) | |
1555 | { | |
1556 | char *buf = (char *) alloca (40); | |
1557 | sprintf (buf, "`%s' not allowed in operand of `#if'", toktab->operator); | |
1558 | yyerror (buf); | |
1559 | } | |
1560 | return toktab->token; | |
1561 | } | |
1562 | ||
1563 | switch (c) { | |
1564 | case '\n': | |
1565 | return 0; | |
1566 | ||
1567 | case ' ': | |
1568 | case '\t': | |
1569 | case '\r': | |
1570 | lexptr++; | |
1571 | goto retry; | |
1572 | ||
1573 | case 'L': | |
1574 | /* Capital L may start a wide-string or wide-character constant. */ | |
1575 | if (lexptr[1] == '\'') | |
1576 | { | |
1577 | lexptr++; | |
1578 | wide_flag = 1; | |
1579 | mask = MAX_WCHAR_TYPE_MASK; | |
1580 | goto char_constant; | |
1581 | } | |
1582 | if (lexptr[1] == '"') | |
1583 | { | |
1584 | lexptr++; | |
1585 | wide_flag = 1; | |
1586 | mask = MAX_WCHAR_TYPE_MASK; | |
1587 | goto string_constant; | |
1588 | } | |
1589 | break; | |
1590 | ||
1591 | case '\'': | |
1592 | wide_flag = 0; | |
1593 | mask = MAX_CHAR_TYPE_MASK; | |
1594 | char_constant: | |
1595 | lexptr++; | |
1596 | if (keyword_parsing) { | |
1597 | char *start_ptr = lexptr - 1; | |
1598 | while (1) { | |
1599 | c = *lexptr++; | |
1600 | if (c == '\\') | |
1601 | c = parse_escape (&lexptr, mask); | |
1602 | else if (c == '\'') | |
1603 | break; | |
1604 | } | |
1605 | yylval.name.address = tokstart; | |
1606 | yylval.name.length = lexptr - start_ptr; | |
1607 | return NAME; | |
1608 | } | |
1609 | ||
1610 | /* This code for reading a character constant | |
1611 | handles multicharacter constants and wide characters. | |
1612 | It is mostly copied from c-lex.c. */ | |
1613 | { | |
1614 | register HOST_WIDE_INT result = 0; | |
27b6b158 | 1615 | register int num_chars = 0; |
861bb6c1 JL |
1616 | unsigned width = MAX_CHAR_TYPE_SIZE; |
1617 | int max_chars; | |
1618 | char *token_buffer; | |
1619 | ||
1620 | if (wide_flag) | |
1621 | { | |
1622 | width = MAX_WCHAR_TYPE_SIZE; | |
1623 | #ifdef MULTIBYTE_CHARS | |
1624 | max_chars = MB_CUR_MAX; | |
1625 | #else | |
1626 | max_chars = 1; | |
1627 | #endif | |
1628 | } | |
1629 | else | |
1630 | max_chars = MAX_LONG_TYPE_SIZE / width; | |
1631 | ||
1632 | token_buffer = (char *) alloca (max_chars + 1); | |
1633 | ||
1634 | while (1) | |
1635 | { | |
1636 | c = *lexptr++; | |
1637 | ||
1638 | if (c == '\'' || c == EOF) | |
1639 | break; | |
1640 | ||
1641 | if (c == '\\') | |
1642 | { | |
1643 | c = parse_escape (&lexptr, mask); | |
1644 | } | |
1645 | ||
1646 | num_chars++; | |
1647 | ||
1648 | /* Merge character into result; ignore excess chars. */ | |
1649 | if (num_chars <= max_chars) | |
1650 | { | |
1651 | if (width < HOST_BITS_PER_WIDE_INT) | |
1652 | result = (result << width) | c; | |
1653 | else | |
1654 | result = c; | |
1655 | token_buffer[num_chars - 1] = c; | |
1656 | } | |
1657 | } | |
1658 | ||
1659 | token_buffer[num_chars] = 0; | |
1660 | ||
1661 | if (c != '\'') | |
1662 | error ("malformatted character constant"); | |
1663 | else if (num_chars == 0) | |
1664 | error ("empty character constant"); | |
1665 | else if (num_chars > max_chars) | |
1666 | { | |
1667 | num_chars = max_chars; | |
1668 | error ("character constant too long"); | |
1669 | } | |
1670 | else if (num_chars != 1 && ! traditional) | |
1671 | warning ("multi-character character constant"); | |
1672 | ||
1673 | /* If char type is signed, sign-extend the constant. */ | |
1674 | if (! wide_flag) | |
1675 | { | |
1676 | int num_bits = num_chars * width; | |
1677 | ||
1678 | if (lookup ((U_CHAR *) "__CHAR_UNSIGNED__", | |
1679 | sizeof ("__CHAR_UNSIGNED__") - 1, -1) | |
1680 | || ((result >> (num_bits - 1)) & 1) == 0) | |
1681 | yylval.integer.value | |
c3bcf315 | 1682 | = result & (~ (unsigned_HOST_WIDE_INT) 0 |
861bb6c1 JL |
1683 | >> (HOST_BITS_PER_WIDE_INT - num_bits)); |
1684 | else | |
1685 | yylval.integer.value | |
c3bcf315 | 1686 | = result | ~(~ (unsigned_HOST_WIDE_INT) 0 |
861bb6c1 JL |
1687 | >> (HOST_BITS_PER_WIDE_INT - num_bits)); |
1688 | } | |
1689 | else | |
1690 | { | |
1691 | #ifdef MULTIBYTE_CHARS | |
1692 | /* Set the initial shift state and convert the next sequence. */ | |
1693 | result = 0; | |
1694 | /* In all locales L'\0' is zero and mbtowc will return zero, | |
1695 | so don't use it. */ | |
1696 | if (num_chars > 1 | |
1697 | || (num_chars == 1 && token_buffer[0] != '\0')) | |
1698 | { | |
1699 | wchar_t wc; | |
1700 | (void) mbtowc (NULL_PTR, NULL_PTR, 0); | |
1701 | if (mbtowc (& wc, token_buffer, num_chars) == num_chars) | |
1702 | result = wc; | |
1703 | else | |
1704 | pedwarn ("Ignoring invalid multibyte character"); | |
1705 | } | |
1706 | #endif | |
1707 | yylval.integer.value = result; | |
1708 | } | |
1709 | } | |
1710 | ||
1711 | /* This is always a signed type. */ | |
1712 | yylval.integer.signedp = SIGNED; | |
1713 | ||
1714 | return CHAR; | |
1715 | ||
1716 | /* some of these chars are invalid in constant expressions; | |
1717 | maybe do something about them later */ | |
1718 | case '/': | |
1719 | case '+': | |
1720 | case '-': | |
1721 | case '*': | |
1722 | case '%': | |
1723 | case '|': | |
1724 | case '&': | |
1725 | case '^': | |
1726 | case '~': | |
1727 | case '!': | |
1728 | case '@': | |
1729 | case '<': | |
1730 | case '>': | |
1731 | case '[': | |
1732 | case ']': | |
1733 | case '.': | |
1734 | case '?': | |
1735 | case ':': | |
1736 | case '=': | |
1737 | case '{': | |
1738 | case '}': | |
1739 | case ',': | |
1740 | case '#': | |
1741 | if (keyword_parsing) | |
1742 | break; | |
1743 | case '(': | |
1744 | case ')': | |
1745 | lexptr++; | |
1746 | return c; | |
1747 | ||
1748 | case '"': | |
1749 | mask = MAX_CHAR_TYPE_MASK; | |
1750 | string_constant: | |
1751 | if (keyword_parsing) { | |
1752 | char *start_ptr = lexptr; | |
1753 | lexptr++; | |
1754 | while (1) { | |
1755 | c = *lexptr++; | |
1756 | if (c == '\\') | |
1757 | c = parse_escape (&lexptr, mask); | |
1758 | else if (c == '"') | |
1759 | break; | |
1760 | } | |
1761 | yylval.name.address = tokstart; | |
1762 | yylval.name.length = lexptr - start_ptr; | |
1763 | return NAME; | |
1764 | } | |
1765 | yyerror ("string constants not allowed in #if expressions"); | |
1766 | return ERROR; | |
1767 | } | |
1768 | ||
1769 | if (c >= '0' && c <= '9' && !keyword_parsing) { | |
1770 | /* It's a number */ | |
1771 | for (namelen = 1; ; namelen++) { | |
1772 | int d = tokstart[namelen]; | |
1773 | if (! ((is_idchar[d] || d == '.') | |
1774 | || ((d == '-' || d == '+') | |
1775 | && (c == 'e' || c == 'E' | |
1776 | || ((c == 'p' || c == 'P') && ! c89)) | |
1777 | && ! traditional))) | |
1778 | break; | |
1779 | c = d; | |
1780 | } | |
1781 | return parse_number (namelen); | |
1782 | } | |
1783 | ||
1784 | /* It is a name. See how long it is. */ | |
1785 | ||
1786 | if (keyword_parsing) { | |
1787 | for (namelen = 0;; namelen++) { | |
1788 | if (is_space[tokstart[namelen]]) | |
1789 | break; | |
1790 | if (tokstart[namelen] == '(' || tokstart[namelen] == ')') | |
1791 | break; | |
1792 | if (tokstart[namelen] == '"' || tokstart[namelen] == '\'') | |
1793 | break; | |
1794 | } | |
1795 | } else { | |
1796 | if (!is_idstart[c]) { | |
1797 | yyerror ("Invalid token in expression"); | |
1798 | return ERROR; | |
1799 | } | |
1800 | ||
1801 | for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++) | |
1802 | ; | |
1803 | } | |
1804 | ||
1805 | lexptr += namelen; | |
1806 | yylval.name.address = tokstart; | |
1807 | yylval.name.length = namelen; | |
1808 | return NAME; | |
1809 | } | |
1810 | ||
1811 | ||
1812 | /* Parse a C escape sequence. STRING_PTR points to a variable | |
1813 | containing a pointer to the string to parse. That pointer | |
1814 | is updated past the characters we use. The value of the | |
1815 | escape sequence is returned. | |
1816 | ||
1817 | RESULT_MASK is used to mask out the result; | |
1818 | an error is reported if bits are lost thereby. | |
1819 | ||
1820 | A negative value means the sequence \ newline was seen, | |
1821 | which is supposed to be equivalent to nothing at all. | |
1822 | ||
1823 | If \ is followed by a null character, we return a negative | |
1824 | value and leave the string pointer pointing at the null character. | |
1825 | ||
1826 | If \ is followed by 000, we return 0 and leave the string pointer | |
1827 | after the zeros. A value of 0 does not mean end of string. */ | |
1828 | ||
1829 | HOST_WIDE_INT | |
1830 | parse_escape (string_ptr, result_mask) | |
1831 | char **string_ptr; | |
1832 | HOST_WIDE_INT result_mask; | |
1833 | { | |
1834 | register int c = *(*string_ptr)++; | |
1835 | switch (c) | |
1836 | { | |
1837 | case 'a': | |
1838 | return TARGET_BELL; | |
1839 | case 'b': | |
1840 | return TARGET_BS; | |
1841 | case 'e': | |
1842 | case 'E': | |
1843 | if (pedantic) | |
1844 | pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c); | |
1845 | return 033; | |
1846 | case 'f': | |
1847 | return TARGET_FF; | |
1848 | case 'n': | |
1849 | return TARGET_NEWLINE; | |
1850 | case 'r': | |
1851 | return TARGET_CR; | |
1852 | case 't': | |
1853 | return TARGET_TAB; | |
1854 | case 'v': | |
1855 | return TARGET_VT; | |
1856 | case '\n': | |
1857 | return -2; | |
1858 | case 0: | |
1859 | (*string_ptr)--; | |
1860 | return 0; | |
1861 | ||
1862 | case '0': | |
1863 | case '1': | |
1864 | case '2': | |
1865 | case '3': | |
1866 | case '4': | |
1867 | case '5': | |
1868 | case '6': | |
1869 | case '7': | |
1870 | { | |
1871 | register HOST_WIDE_INT i = c - '0'; | |
1872 | register int count = 0; | |
1873 | while (++count < 3) | |
1874 | { | |
1875 | c = *(*string_ptr)++; | |
1876 | if (c >= '0' && c <= '7') | |
1877 | i = (i << 3) + c - '0'; | |
1878 | else | |
1879 | { | |
1880 | (*string_ptr)--; | |
1881 | break; | |
1882 | } | |
1883 | } | |
1884 | if (i != (i & result_mask)) | |
1885 | { | |
1886 | i &= result_mask; | |
1887 | pedwarn ("octal escape sequence out of range"); | |
1888 | } | |
1889 | return i; | |
1890 | } | |
1891 | case 'x': | |
1892 | { | |
c3bcf315 | 1893 | register unsigned_HOST_WIDE_INT i = 0, overflow = 0; |
861bb6c1 JL |
1894 | register int digits_found = 0, digit; |
1895 | for (;;) | |
1896 | { | |
1897 | c = *(*string_ptr)++; | |
1898 | if (c >= '0' && c <= '9') | |
1899 | digit = c - '0'; | |
1900 | else if (c >= 'a' && c <= 'f') | |
1901 | digit = c - 'a' + 10; | |
1902 | else if (c >= 'A' && c <= 'F') | |
1903 | digit = c - 'A' + 10; | |
1904 | else | |
1905 | { | |
1906 | (*string_ptr)--; | |
1907 | break; | |
1908 | } | |
1909 | overflow |= i ^ (i << 4 >> 4); | |
1910 | i = (i << 4) + digit; | |
1911 | digits_found = 1; | |
1912 | } | |
1913 | if (!digits_found) | |
1914 | yyerror ("\\x used with no following hex digits"); | |
1915 | if (overflow | (i != (i & result_mask))) | |
1916 | { | |
1917 | i &= result_mask; | |
1918 | pedwarn ("hex escape sequence out of range"); | |
1919 | } | |
1920 | return i; | |
1921 | } | |
1922 | default: | |
1923 | return c; | |
1924 | } | |
1925 | } | |
1926 | ||
1927 | static void | |
1928 | yyerror (s) | |
1929 | char *s; | |
1930 | { | |
1931 | error ("%s", s); | |
1932 | skip_evaluation = 0; | |
1933 | longjmp (parse_return_error, 1); | |
1934 | } | |
1935 | ||
1936 | static void | |
1937 | integer_overflow () | |
1938 | { | |
1939 | if (!skip_evaluation && pedantic) | |
1940 | pedwarn ("integer overflow in preprocessor expression"); | |
1941 | } | |
1942 | ||
1943 | static HOST_WIDE_INT | |
1944 | left_shift (a, b) | |
1945 | struct constant *a; | |
c3bcf315 | 1946 | unsigned_HOST_WIDE_INT b; |
861bb6c1 JL |
1947 | { |
1948 | /* It's unclear from the C standard whether shifts can overflow. | |
1949 | The following code ignores overflow; perhaps a C standard | |
1950 | interpretation ruling is needed. */ | |
1951 | if (b >= HOST_BITS_PER_WIDE_INT) | |
1952 | return 0; | |
1953 | else | |
c3bcf315 | 1954 | return (unsigned_HOST_WIDE_INT) a->value << b; |
861bb6c1 JL |
1955 | } |
1956 | ||
1957 | static HOST_WIDE_INT | |
1958 | right_shift (a, b) | |
1959 | struct constant *a; | |
c3bcf315 | 1960 | unsigned_HOST_WIDE_INT b; |
861bb6c1 JL |
1961 | { |
1962 | if (b >= HOST_BITS_PER_WIDE_INT) | |
1963 | return a->signedp ? a->value >> (HOST_BITS_PER_WIDE_INT - 1) : 0; | |
1964 | else if (a->signedp) | |
1965 | return a->value >> b; | |
1966 | else | |
c3bcf315 | 1967 | return (unsigned_HOST_WIDE_INT) a->value >> b; |
861bb6c1 JL |
1968 | } |
1969 | \f | |
1970 | /* This page contains the entry point to this file. */ | |
1971 | ||
1972 | /* Parse STRING as an expression, and complain if this fails | |
27b6b158 JL |
1973 | to use up all of the contents of STRING. |
1974 | STRING may contain '\0' bytes; it is terminated by the first '\n' | |
1975 | outside a string constant, so that we can diagnose '\0' properly. | |
1976 | If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated. | |
1977 | We do not support C comments. They should be removed before | |
861bb6c1 JL |
1978 | this function is called. */ |
1979 | ||
1980 | HOST_WIDE_INT | |
27b6b158 | 1981 | parse_c_expression (string, warn_undefined) |
861bb6c1 | 1982 | char *string; |
27b6b158 | 1983 | int warn_undefined; |
861bb6c1 JL |
1984 | { |
1985 | lexptr = string; | |
27b6b158 | 1986 | warn_undef = warn_undefined; |
861bb6c1 JL |
1987 | |
1988 | /* if there is some sort of scanning error, just return 0 and assume | |
1989 | the parsing routine has printed an error message somewhere. | |
1990 | there is surely a better thing to do than this. */ | |
1991 | if (setjmp (parse_return_error)) | |
1992 | return 0; | |
1993 | ||
1994 | if (yyparse () != 0) | |
1995 | abort (); | |
1996 | ||
1997 | if (*lexptr != '\n') | |
1998 | error ("Junk after end of expression."); | |
1999 | ||
2000 | return expression_value; /* set by yyparse () */ | |
2001 | } | |
2002 | \f | |
2003 | #ifdef TEST_EXP_READER | |
2004 | ||
2005 | #if YYDEBUG | |
2006 | extern int yydebug; | |
2007 | #endif | |
2008 | ||
2009 | int pedantic; | |
2010 | int traditional; | |
2011 | ||
2012 | int main PROTO((int, char **)); | |
2013 | static void initialize_random_junk PROTO((void)); | |
27b6b158 | 2014 | static void print_unsigned_host_wide_int PROTO((unsigned_HOST_WIDE_INT)); |
861bb6c1 JL |
2015 | |
2016 | /* Main program for testing purposes. */ | |
2017 | int | |
2018 | main (argc, argv) | |
2019 | int argc; | |
2020 | char **argv; | |
2021 | { | |
2022 | int n, c; | |
2023 | char buf[1024]; | |
27b6b158 | 2024 | unsigned_HOST_WIDE_INT u; |
861bb6c1 JL |
2025 | |
2026 | pedantic = 1 < argc; | |
2027 | traditional = 2 < argc; | |
2028 | #if YYDEBUG | |
2029 | yydebug = 3 < argc; | |
2030 | #endif | |
2031 | initialize_random_junk (); | |
2032 | ||
2033 | for (;;) { | |
2034 | printf ("enter expression: "); | |
2035 | n = 0; | |
2036 | while ((buf[n] = c = getchar ()) != '\n' && c != EOF) | |
2037 | n++; | |
2038 | if (c == EOF) | |
2039 | break; | |
27b6b158 JL |
2040 | parse_c_expression (buf, 1); |
2041 | printf ("parser returned "); | |
2042 | u = (unsigned_HOST_WIDE_INT) expression_value; | |
2043 | if (expression_value < 0 && expression_signedp) { | |
2044 | u = -u; | |
2045 | printf ("-"); | |
2046 | } | |
2047 | if (u == 0) | |
2048 | printf ("0"); | |
2049 | else | |
2050 | print_unsigned_host_wide_int (u); | |
2051 | if (! expression_signedp) | |
2052 | printf("u"); | |
2053 | printf ("\n"); | |
861bb6c1 JL |
2054 | } |
2055 | ||
2056 | return 0; | |
2057 | } | |
2058 | ||
27b6b158 JL |
2059 | static void |
2060 | print_unsigned_host_wide_int (u) | |
2061 | unsigned_HOST_WIDE_INT u; | |
2062 | { | |
2063 | if (u) { | |
2064 | print_unsigned_host_wide_int (u / 10); | |
2065 | putchar ('0' + (int) (u % 10)); | |
2066 | } | |
2067 | } | |
2068 | ||
861bb6c1 JL |
2069 | /* table to tell if char can be part of a C identifier. */ |
2070 | unsigned char is_idchar[256]; | |
2071 | /* table to tell if char can be first char of a c identifier. */ | |
2072 | unsigned char is_idstart[256]; | |
2073 | /* table to tell if c is horizontal or vertical space. */ | |
2074 | unsigned char is_space[256]; | |
2075 | ||
2076 | /* | |
2077 | * initialize random junk in the hash table and maybe other places | |
2078 | */ | |
2079 | static void | |
2080 | initialize_random_junk () | |
2081 | { | |
2082 | register int i; | |
2083 | ||
2084 | /* | |
2085 | * Set up is_idchar and is_idstart tables. These should be | |
2086 | * faster than saying (is_alpha (c) || c == '_'), etc. | |
2087 | * Must do set up these things before calling any routines tthat | |
2088 | * refer to them. | |
2089 | */ | |
2090 | for (i = 'a'; i <= 'z'; i++) { | |
2091 | ++is_idchar[i - 'a' + 'A']; | |
2092 | ++is_idchar[i]; | |
2093 | ++is_idstart[i - 'a' + 'A']; | |
2094 | ++is_idstart[i]; | |
2095 | } | |
2096 | for (i = '0'; i <= '9'; i++) | |
2097 | ++is_idchar[i]; | |
2098 | ++is_idchar['_']; | |
2099 | ++is_idstart['_']; | |
2100 | ++is_idchar['$']; | |
2101 | ++is_idstart['$']; | |
2102 | ||
2103 | ++is_space[' ']; | |
2104 | ++is_space['\t']; | |
2105 | ++is_space['\v']; | |
2106 | ++is_space['\f']; | |
2107 | ++is_space['\n']; | |
2108 | ++is_space['\r']; | |
2109 | } | |
2110 | ||
2111 | void | |
2112 | error (PRINTF_ALIST (msg)) | |
2113 | PRINTF_DCL (msg) | |
2114 | { | |
2115 | va_list args; | |
2116 | ||
2117 | VA_START (args, msg); | |
2118 | fprintf (stderr, "error: "); | |
2119 | vfprintf (stderr, msg, args); | |
2120 | fprintf (stderr, "\n"); | |
2121 | va_end (args); | |
2122 | } | |
2123 | ||
2124 | void | |
2125 | pedwarn (PRINTF_ALIST (msg)) | |
2126 | PRINTF_DCL (msg) | |
2127 | { | |
2128 | va_list args; | |
2129 | ||
2130 | VA_START (args, msg); | |
2131 | fprintf (stderr, "pedwarn: "); | |
2132 | vfprintf (stderr, msg, args); | |
2133 | fprintf (stderr, "\n"); | |
2134 | va_end (args); | |
2135 | } | |
2136 | ||
2137 | void | |
2138 | warning (PRINTF_ALIST (msg)) | |
2139 | PRINTF_DCL (msg) | |
2140 | { | |
2141 | va_list args; | |
2142 | ||
2143 | VA_START (args, msg); | |
2144 | fprintf (stderr, "warning: "); | |
2145 | vfprintf (stderr, msg, args); | |
2146 | fprintf (stderr, "\n"); | |
2147 | va_end (args); | |
2148 | } | |
2149 | ||
2150 | int | |
2151 | check_assertion (name, sym_length, tokens_specified, tokens) | |
2152 | U_CHAR *name; | |
2153 | int sym_length; | |
2154 | int tokens_specified; | |
2155 | struct arglist *tokens; | |
2156 | { | |
2157 | return 0; | |
2158 | } | |
2159 | ||
2160 | struct hashnode * | |
2161 | lookup (name, len, hash) | |
2162 | U_CHAR *name; | |
2163 | int len; | |
2164 | int hash; | |
2165 | { | |
2166 | return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1); | |
2167 | } | |
2168 | ||
2169 | GENERIC_PTR | |
2170 | xmalloc (size) | |
2171 | size_t size; | |
2172 | { | |
2173 | return (GENERIC_PTR) malloc (size); | |
2174 | } | |
2175 | #endif |