2 /* A Bison parser, made from cexp.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
31 #define PRINTF_PROTO(ARGS, m, n) PVPROTO (ARGS) ATTRIBUTE_PRINTF(m, n)
33 #define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)
37 /* #define YYDEBUG 1 */
39 #ifdef MULTIBYTE_CHARS
43 #include "gansidecl.h"
45 typedef unsigned char U_CHAR;
47 /* This is used for communicating lists of keywords with cccp.c. */
55 /* Find the largest host integer type and set its size and type.
56 Watch out: on some crazy hosts `long' is shorter than `int'. */
60 # include <inttypes.h>
61 # define HOST_WIDE_INT intmax_t
62 # define unsigned_HOST_WIDE_INT uintmax_t
64 # if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT)
65 # define HOST_WIDE_INT int
67 # if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG || ! (defined LONG_LONG_MAX || defined LLONG_MAX))
68 # define HOST_WIDE_INT long
70 # define HOST_WIDE_INT long long
76 #ifndef unsigned_HOST_WIDE_INT
77 #define unsigned_HOST_WIDE_INT unsigned HOST_WIDE_INT
84 #ifndef HOST_BITS_PER_WIDE_INT
85 #define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
88 HOST_WIDE_INT parse_c_expression PROTO((char *, int));
90 static int yylex PROTO((void));
91 static void yyerror PROTO((char *)) __attribute__ ((noreturn));
92 static HOST_WIDE_INT expression_value;
93 #ifdef TEST_EXP_READER
94 static int expression_signedp;
97 static jmp_buf parse_return_error;
99 /* Nonzero means count most punctuation as part of a name. */
100 static int keyword_parsing = 0;
102 /* Nonzero means do not evaluate this expression.
103 This is a count, since unevaluated expressions can nest. */
104 static int skip_evaluation;
106 /* Nonzero means warn if undefined identifiers are evaluated. */
107 static int warn_undef;
109 /* some external tables of character types */
110 extern unsigned char is_idstart[], is_idchar[], is_space[];
112 /* Flag for -pedantic. */
115 /* Flag for -traditional. */
116 extern int traditional;
118 /* Flag for -lang-c89. */
121 #ifndef CHAR_TYPE_SIZE
122 #define CHAR_TYPE_SIZE BITS_PER_UNIT
125 #ifndef INT_TYPE_SIZE
126 #define INT_TYPE_SIZE BITS_PER_WORD
129 #ifndef LONG_TYPE_SIZE
130 #define LONG_TYPE_SIZE BITS_PER_WORD
133 #ifndef WCHAR_TYPE_SIZE
134 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
137 #ifndef MAX_CHAR_TYPE_SIZE
138 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
141 #ifndef MAX_INT_TYPE_SIZE
142 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
145 #ifndef MAX_LONG_TYPE_SIZE
146 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
149 #ifndef MAX_WCHAR_TYPE_SIZE
150 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
153 #define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
154 ? (~ (~ (HOST_WIDE_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
155 : ~ (HOST_WIDE_INT) 0)
157 #define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
158 ? ~ (~ (HOST_WIDE_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
159 : ~ (HOST_WIDE_INT) 0)
161 /* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
162 Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
163 Suppose SIGNEDP is negative if the result is signed, zero if unsigned.
164 Then this yields nonzero if overflow occurred during the addition.
165 Overflow occurs if A and B have the same sign, but A and SUM differ in sign,
166 and SIGNEDP is negative.
167 Use `^' to test whether signs differ, and `< 0' to isolate the sign. */
168 #define overflow_sum_sign(a, b, sum, signedp) \
169 ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0)
173 GENERIC_PTR xmalloc PROTO((size_t));
174 HOST_WIDE_INT parse_escape PROTO((char **, HOST_WIDE_INT));
175 int check_assertion PROTO((U_CHAR *, int, int, struct arglist *));
176 struct hashnode *lookup PROTO((U_CHAR *, int, int));
177 void error PRINTF_PROTO_1((char *, ...));
178 void pedwarn PRINTF_PROTO_1((char *, ...));
179 void warning PRINTF_PROTO_1((char *, ...));
181 static int parse_number PROTO((int));
182 static HOST_WIDE_INT left_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT));
183 static HOST_WIDE_INT right_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT));
184 static void integer_overflow PROTO((void));
186 /* `signedp' values */
192 struct constant {HOST_WIDE_INT value; int signedp;} integer;
193 struct name {U_CHAR *address; int length;} name;
194 struct arglist *keywords;
207 #define YYFLAG -32768
210 #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)
212 static const char yytranslate[] = { 0,
213 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
214 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
215 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
216 2, 2, 29, 2, 31, 2, 27, 14, 2, 32,
217 33, 25, 23, 9, 24, 2, 26, 2, 2, 2,
218 2, 2, 2, 2, 2, 2, 2, 8, 2, 17,
219 2, 18, 7, 2, 2, 2, 2, 2, 2, 2,
220 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
221 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
222 2, 2, 2, 13, 2, 2, 2, 2, 2, 2,
223 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
224 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
225 2, 2, 2, 12, 2, 30, 2, 2, 2, 2,
226 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
227 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
228 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
229 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
230 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
231 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
232 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
233 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
234 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
235 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
236 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
237 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
238 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
239 6, 10, 11, 15, 16, 19, 20, 21, 22, 28
243 static const short yyprhs[] = { 0,
244 0, 2, 4, 8, 11, 14, 17, 20, 23, 24,
245 31, 35, 39, 43, 47, 51, 55, 59, 63, 67,
246 71, 75, 79, 83, 87, 91, 95, 99, 100, 105,
247 106, 111, 112, 113, 121, 123, 125, 127, 128, 133
250 static const short yyrhs[] = { 35,
251 0, 36, 0, 35, 9, 36, 0, 24, 36, 0,
252 29, 36, 0, 23, 36, 0, 30, 36, 0, 31,
253 5, 0, 0, 31, 5, 37, 32, 42, 33, 0,
254 32, 35, 33, 0, 36, 25, 36, 0, 36, 26,
255 36, 0, 36, 27, 36, 0, 36, 23, 36, 0,
256 36, 24, 36, 0, 36, 21, 36, 0, 36, 22,
257 36, 0, 36, 15, 36, 0, 36, 16, 36, 0,
258 36, 19, 36, 0, 36, 20, 36, 0, 36, 17,
259 36, 0, 36, 18, 36, 0, 36, 14, 36, 0,
260 36, 13, 36, 0, 36, 12, 36, 0, 0, 36,
261 11, 38, 36, 0, 0, 36, 10, 39, 36, 0,
262 0, 0, 36, 7, 40, 36, 8, 41, 36, 0,
263 3, 0, 4, 0, 5, 0, 0, 32, 42, 33,
270 static const short yyrline[] = { 0,
271 281, 291, 292, 299, 304, 307, 309, 312, 316, 318,
272 323, 328, 341, 358, 371, 377, 383, 389, 395, 398,
273 401, 408, 415, 422, 429, 432, 435, 438, 441, 444,
274 447, 450, 452, 455, 458, 460, 462, 470, 472, 485
279 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
281 static const char * const yytname[] = { "$","error","$undefined.","INT","CHAR",
282 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
283 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
284 "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL
288 static const short yyr1[] = { 0,
289 34, 35, 35, 36, 36, 36, 36, 36, 37, 36,
290 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
291 36, 36, 36, 36, 36, 36, 36, 38, 36, 39,
292 36, 40, 41, 36, 36, 36, 36, 42, 42, 42
295 static const short yyr2[] = { 0,
296 1, 1, 3, 2, 2, 2, 2, 2, 0, 6,
297 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
298 3, 3, 3, 3, 3, 3, 3, 0, 4, 0,
299 4, 0, 0, 7, 1, 1, 1, 0, 4, 2
302 static const short yydefact[] = { 0,
303 35, 36, 37, 0, 0, 0, 0, 0, 0, 1,
304 2, 6, 4, 5, 7, 8, 0, 0, 32, 30,
305 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
306 0, 0, 0, 0, 0, 0, 0, 0, 11, 3,
307 0, 0, 0, 27, 26, 25, 19, 20, 23, 24,
308 21, 22, 17, 18, 15, 16, 12, 13, 14, 38,
309 0, 31, 29, 38, 38, 0, 33, 40, 0, 10,
310 0, 38, 34, 39, 0, 0, 0
313 static const short yydefgoto[] = { 75,
314 10, 11, 38, 43, 42, 41, 71, 66
317 static const short yypact[] = { 12,
318 -32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4,
319 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768,
320 -32768, 12, 12, 12, 12, 12, 12, 12, 12, 12,
321 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79,
322 12, 12, 12, 110, 124, 137, 148, 148, 155, 155,
323 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2,
324 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768,
325 12, 2, 79,-32768, 63, 188,-32768
328 static const short yypgoto[] = {-32768,
329 180, -4,-32768,-32768,-32768,-32768,-32768, -60
336 static const short yytable[] = { 12,
337 13, 14, 15, 68, 69, 16, 64, 35, 36, 37,
338 -9, 74, 18, 40, 1, 2, 3, 44, 45, 46,
339 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
340 57, 58, 59, 65, 4, 5, 61, 62, 63, 18,
341 6, 7, 8, 9, 21, 22, 23, 24, 25, 26,
342 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
343 37, 60, 76, 39, 19, 67, 73, 20, 21, 22,
344 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
345 33, 34, 35, 36, 37, 19, 70, 72, 20, 21,
346 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
347 32, 33, 34, 35, 36, 37, 22, 23, 24, 25,
348 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
349 36, 37, 23, 24, 25, 26, 27, 28, 29, 30,
350 31, 32, 33, 34, 35, 36, 37, 24, 25, 26,
351 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
352 37, 25, 26, 27, 28, 29, 30, 31, 32, 33,
353 34, 35, 36, 37, 27, 28, 29, 30, 31, 32,
354 33, 34, 35, 36, 37, 31, 32, 33, 34, 35,
355 36, 37, 33, 34, 35, 36, 37, 77, 17
358 static const short yycheck[] = { 4,
359 5, 6, 7, 64, 65, 5, 5, 25, 26, 27,
360 32, 72, 9, 18, 3, 4, 5, 22, 23, 24,
361 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
362 35, 36, 37, 32, 23, 24, 41, 42, 43, 9,
363 29, 30, 31, 32, 11, 12, 13, 14, 15, 16,
364 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
365 27, 32, 0, 33, 7, 8, 71, 10, 11, 12,
366 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
367 23, 24, 25, 26, 27, 7, 33, 33, 10, 11,
368 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
369 22, 23, 24, 25, 26, 27, 12, 13, 14, 15,
370 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
371 26, 27, 13, 14, 15, 16, 17, 18, 19, 20,
372 21, 22, 23, 24, 25, 26, 27, 14, 15, 16,
373 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
374 27, 15, 16, 17, 18, 19, 20, 21, 22, 23,
375 24, 25, 26, 27, 17, 18, 19, 20, 21, 22,
376 23, 24, 25, 26, 27, 21, 22, 23, 24, 25,
377 26, 27, 23, 24, 25, 26, 27, 0, 9
379 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
380 #line 3 "/usr/cygnus/latest-940103/share/bison.simple"
382 /* Skeleton output parser for bison,
383 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
385 This program is free software; you can redistribute it and/or modify
386 it under the terms of the GNU General Public License as published by
387 the Free Software Foundation; either version 2, or (at your option)
390 This program is distributed in the hope that it will be useful,
391 but WITHOUT ANY WARRANTY; without even the implied warranty of
392 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
393 GNU General Public License for more details.
395 You should have received a copy of the GNU General Public License
396 along with this program; if not, write to the Free Software
397 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
399 /* As a special exception, when this file is copied by Bison into a
400 Bison output file, you may use that output file without restriction.
401 This special exception was added by the Free Software Foundation
402 in version 1.24 of Bison. */
406 #define alloca __builtin_alloca
407 #else /* not GNU C. */
408 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
410 #else /* not sparc */
411 #if defined (MSDOS) && !defined (__TURBOC__)
413 #else /* not MSDOS, or __TURBOC__ */
417 #else /* not MSDOS, __TURBOC__, or _AIX */
421 void *alloca (unsigned int);
423 #else /* not __cplusplus */
425 #endif /* not __cplusplus */
427 #endif /* not _AIX */
428 #endif /* not MSDOS, or __TURBOC__ */
429 #endif /* not sparc. */
430 #endif /* not GNU C. */
431 #endif /* alloca not defined. */
433 /* This is the parser code that is written into each bison parser
434 when the %semantic_parser declaration is not specified in the grammar.
435 It was written by Richard Stallman by simplifying the hairy parser
436 used when %semantic_parser is specified. */
438 /* Note: there must be only one dollar sign in this file.
439 It is replaced by the list of actions, each action
440 as one case of the switch. */
442 #define yyerrok (yyerrstatus = 0)
443 #define yyclearin (yychar = YYEMPTY)
446 #define YYACCEPT return(0)
447 #define YYABORT return(1)
448 #define YYERROR goto yyerrlab1
449 /* Like YYERROR except do call yyerror.
450 This remains here temporarily to ease the
451 transition to the new meaning of YYERROR, for GCC.
452 Once GCC version 2 has supplanted version 1, this can go. */
453 #define YYFAIL goto yyerrlab
454 #define YYRECOVERING() (!!yyerrstatus)
455 #define YYBACKUP(token, value) \
457 if (yychar == YYEMPTY && yylen == 1) \
458 { yychar = (token), yylval = (value); \
459 yychar1 = YYTRANSLATE (yychar); \
464 { yyerror ("syntax error: cannot back up"); YYERROR; } \
468 #define YYERRCODE 256
471 #define YYLEX yylex()
477 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
479 #define YYLEX yylex(&yylval, &yylloc)
481 #else /* not YYLSP_NEEDED */
483 #define YYLEX yylex(&yylval, YYLEX_PARAM)
485 #define YYLEX yylex(&yylval)
487 #endif /* not YYLSP_NEEDED */
490 /* If nonreentrant, generate the variables here */
494 int yychar; /* the lookahead symbol */
495 YYSTYPE yylval; /* the semantic value of the */
496 /* lookahead symbol */
499 YYLTYPE yylloc; /* location data for the lookahead */
503 int yynerrs; /* number of parse errors so far */
504 #endif /* not YYPURE */
507 int yydebug; /* nonzero means print parse trace */
508 /* Since this is uninitialized, it does not stop multiple parsers
512 /* YYINITDEPTH indicates the initial size of the parser's stacks */
515 #define YYINITDEPTH 200
518 /* YYMAXDEPTH is the maximum size the stacks can grow to
519 (effective only if the built-in stack extension method is used). */
526 #define YYMAXDEPTH 10000
529 /* Prevent warning if -Wstrict-prototypes. */
534 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
535 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
536 #else /* not GNU C or C++ */
539 /* This is the most reliable way to avoid incompatibilities
540 in available built-in functions on various systems. */
542 __yy_memcpy (to, from, count)
547 register char *f = from;
548 register char *t = to;
549 register int i = count;
555 #else /* __cplusplus */
557 /* This is the most reliable way to avoid incompatibilities
558 in available built-in functions on various systems. */
560 __yy_memcpy (char *to, char *from, int count)
562 register char *f = from;
563 register char *t = to;
564 register int i = count;
573 #line 196 "/usr/cygnus/latest-940103/share/bison.simple"
575 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
576 into yyparse. The argument should have type void *.
577 It should actually point to an object.
578 Grammar actions can access the variable by casting it
579 to the proper pointer type. */
583 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
584 #define YYPARSE_PARAM_DECL
585 #else /* not __cplusplus */
586 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
587 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
588 #endif /* not __cplusplus */
589 #else /* not YYPARSE_PARAM */
590 #define YYPARSE_PARAM_ARG
591 #define YYPARSE_PARAM_DECL
592 #endif /* not YYPARSE_PARAM */
595 yyparse(YYPARSE_PARAM_ARG)
598 register int yystate;
600 register short *yyssp;
601 register YYSTYPE *yyvsp;
602 int yyerrstatus; /* number of tokens to shift before error messages enabled */
603 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
605 short yyssa[YYINITDEPTH]; /* the state stack */
606 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
608 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
609 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
612 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
613 YYLTYPE *yyls = yylsa;
616 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
618 #define YYPOPSTACK (yyvsp--, yyssp--)
621 int yystacksize = YYINITDEPTH;
632 YYSTYPE yyval; /* the variable used to return */
633 /* semantic values from the action */
640 fprintf(stderr, "Starting parse\n");
646 yychar = YYEMPTY; /* Cause a token to be read. */
648 /* Initialize stack pointers.
649 Waste one element of value and location stack
650 so that they stay on the same level as the state stack.
651 The wasted elements are never initialized. */
659 /* Push a new state, which is found in yystate . */
660 /* In all cases, when you get here, the value and location stacks
661 have just been pushed. so pushing a state here evens the stacks. */
666 if (yyssp >= yyss + yystacksize - 1)
668 /* Give user a chance to reallocate the stack */
669 /* Use copies of these so that the &'s don't force the real ones into memory. */
670 YYSTYPE *yyvs1 = yyvs;
673 YYLTYPE *yyls1 = yyls;
676 /* Get the current used size of the three stacks, in elements. */
677 int size = yyssp - yyss + 1;
680 /* Each stack pointer address is followed by the size of
681 the data in use in that stack, in bytes. */
683 /* This used to be a conditional around just the two extra args,
684 but that might be undefined if yyoverflow is a macro. */
685 yyoverflow("parser stack overflow",
686 &yyss1, size * sizeof (*yyssp),
687 &yyvs1, size * sizeof (*yyvsp),
688 &yyls1, size * sizeof (*yylsp),
691 yyoverflow("parser stack overflow",
692 &yyss1, size * sizeof (*yyssp),
693 &yyvs1, size * sizeof (*yyvsp),
697 yyss = yyss1; yyvs = yyvs1;
701 #else /* no yyoverflow */
702 /* Extend the stack our own way. */
703 if (yystacksize >= YYMAXDEPTH)
705 yyerror("parser stack overflow");
709 if (yystacksize > YYMAXDEPTH)
710 yystacksize = YYMAXDEPTH;
711 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
712 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
713 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
714 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
716 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
717 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
719 #endif /* no yyoverflow */
721 yyssp = yyss + size - 1;
722 yyvsp = yyvs + size - 1;
724 yylsp = yyls + size - 1;
729 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
732 if (yyssp >= yyss + yystacksize - 1)
738 fprintf(stderr, "Entering state %d\n", yystate);
744 /* Do appropriate processing given the current state. */
745 /* Read a lookahead token if we need one and don't already have one. */
748 /* First try to decide what to do without reference to lookahead token. */
750 yyn = yypact[yystate];
754 /* Not known => get a lookahead token if don't already have one. */
756 /* yychar is either YYEMPTY or YYEOF
757 or a valid token in external form. */
759 if (yychar == YYEMPTY)
763 fprintf(stderr, "Reading a token: ");
768 /* Convert token to internal form (in yychar1) for indexing tables with */
770 if (yychar <= 0) /* This means end of input. */
773 yychar = YYEOF; /* Don't call YYLEX any more */
777 fprintf(stderr, "Now at end of input.\n");
782 yychar1 = YYTRANSLATE(yychar);
787 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
788 /* Give the individual parser a way to print the precise meaning
789 of a token, for further debugging info. */
791 YYPRINT (stderr, yychar, yylval);
793 fprintf (stderr, ")\n");
799 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
804 /* yyn is what to do for this token type in this state.
805 Negative => reduce, -yyn is rule number.
806 Positive => shift, yyn is new state.
807 New state is final state => don't bother to shift,
809 0, or most negative number => error. */
824 /* Shift the lookahead token. */
828 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
831 /* Discard the token being shifted unless it is eof. */
840 /* count tokens shifted since error; after three, turn off error status. */
841 if (yyerrstatus) yyerrstatus--;
846 /* Do the default action for the current state. */
849 yyn = yydefact[yystate];
853 /* Do a reduction. yyn is the number of a rule to reduce with. */
857 yyval = yyvsp[1-yylen]; /* implement default value of the action */
864 fprintf (stderr, "Reducing via rule %d (line %d), ",
867 /* Print the symbols being reduced, and their result. */
868 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
869 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
870 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
880 expression_value = yyvsp[0].integer.value;
881 #ifdef TEST_EXP_READER
882 expression_signedp = yyvsp[0].integer.signedp;
889 pedwarn ("comma operator in operand of `#if'");
890 yyval.integer = yyvsp[0].integer; ;
894 { yyval.integer.value = - yyvsp[0].integer.value;
895 yyval.integer.signedp = yyvsp[0].integer.signedp;
896 if ((yyval.integer.value & yyvsp[0].integer.value & yyval.integer.signedp) < 0)
897 integer_overflow (); ;
901 { yyval.integer.value = ! yyvsp[0].integer.value;
902 yyval.integer.signedp = SIGNED; ;
906 { yyval.integer = yyvsp[0].integer; ;
910 { yyval.integer.value = ~ yyvsp[0].integer.value;
911 yyval.integer.signedp = yyvsp[0].integer.signedp; ;
915 { yyval.integer.value = check_assertion (yyvsp[0].name.address, yyvsp[0].name.length,
917 yyval.integer.signedp = SIGNED; ;
921 { keyword_parsing = 1; ;
925 { yyval.integer.value = check_assertion (yyvsp[-4].name.address, yyvsp[-4].name.length,
926 1, yyvsp[-1].keywords);
928 yyval.integer.signedp = SIGNED; ;
932 { yyval.integer = yyvsp[-1].integer; ;
936 { yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
937 if (yyval.integer.signedp)
939 yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value;
940 if (yyvsp[-2].integer.value
941 && (yyval.integer.value / yyvsp[-2].integer.value != yyvsp[0].integer.value
942 || (yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0))
946 yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
947 * yyvsp[0].integer.value); ;
951 { if (yyvsp[0].integer.value == 0)
953 if (!skip_evaluation)
954 error ("division by zero in #if");
955 yyvsp[0].integer.value = 1;
957 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
958 if (yyval.integer.signedp)
960 yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value;
961 if ((yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0)
965 yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
966 / yyvsp[0].integer.value); ;
970 { if (yyvsp[0].integer.value == 0)
972 if (!skip_evaluation)
973 error ("division by zero in #if");
974 yyvsp[0].integer.value = 1;
976 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
977 if (yyval.integer.signedp)
978 yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value;
980 yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
981 % yyvsp[0].integer.value); ;
985 { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value;
986 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
987 if (overflow_sum_sign (yyvsp[-2].integer.value, yyvsp[0].integer.value,
988 yyval.integer.value, yyval.integer.signedp))
989 integer_overflow (); ;
993 { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value;
994 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
995 if (overflow_sum_sign (yyval.integer.value, yyvsp[0].integer.value,
996 yyvsp[-2].integer.value, yyval.integer.signedp))
997 integer_overflow (); ;
1001 { yyval.integer.signedp = yyvsp[-2].integer.signedp;
1002 if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0)
1003 yyval.integer.value = right_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value);
1005 yyval.integer.value = left_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ;
1009 { yyval.integer.signedp = yyvsp[-2].integer.signedp;
1010 if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0)
1011 yyval.integer.value = left_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value);
1013 yyval.integer.value = right_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ;
1017 { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value);
1018 yyval.integer.signedp = SIGNED; ;
1022 { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value);
1023 yyval.integer.signedp = SIGNED; ;
1027 { yyval.integer.signedp = SIGNED;
1028 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1029 yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value;
1031 yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1032 <= yyvsp[0].integer.value); ;
1036 { yyval.integer.signedp = SIGNED;
1037 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1038 yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value;
1040 yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1041 >= yyvsp[0].integer.value); ;
1045 { yyval.integer.signedp = SIGNED;
1046 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1047 yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value;
1049 yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1050 < yyvsp[0].integer.value); ;
1054 { yyval.integer.signedp = SIGNED;
1055 if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1056 yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value;
1058 yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1059 > yyvsp[0].integer.value); ;
1063 { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value;
1064 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ;
1068 { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value;
1069 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ;
1073 { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value;
1074 yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ;
1078 { skip_evaluation += !yyvsp[-1].integer.value; ;
1082 { skip_evaluation -= !yyvsp[-3].integer.value;
1083 yyval.integer.value = (yyvsp[-3].integer.value && yyvsp[0].integer.value);
1084 yyval.integer.signedp = SIGNED; ;
1088 { skip_evaluation += !!yyvsp[-1].integer.value; ;
1092 { skip_evaluation -= !!yyvsp[-3].integer.value;
1093 yyval.integer.value = (yyvsp[-3].integer.value || yyvsp[0].integer.value);
1094 yyval.integer.signedp = SIGNED; ;
1098 { skip_evaluation += !yyvsp[-1].integer.value; ;
1102 { skip_evaluation += !!yyvsp[-4].integer.value - !yyvsp[-4].integer.value; ;
1106 { skip_evaluation -= !!yyvsp[-6].integer.value;
1107 yyval.integer.value = yyvsp[-6].integer.value ? yyvsp[-3].integer.value : yyvsp[0].integer.value;
1108 yyval.integer.signedp = yyvsp[-3].integer.signedp & yyvsp[0].integer.signedp; ;
1112 { yyval.integer = yylval.integer; ;
1116 { yyval.integer = yylval.integer; ;
1120 { if (warn_undef && !skip_evaluation)
1121 warning ("`%.*s' is not defined",
1122 yyvsp[0].name.length, yyvsp[0].name.address);
1123 yyval.integer.value = 0;
1124 yyval.integer.signedp = SIGNED; ;
1128 { yyval.keywords = 0; ;
1132 { struct arglist *temp;
1133 yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist));
1134 yyval.keywords->next = yyvsp[-2].keywords;
1135 yyval.keywords->name = (U_CHAR *) "(";
1136 yyval.keywords->length = 1;
1137 temp = yyval.keywords;
1138 while (temp != 0 && temp->next != 0)
1140 temp->next = (struct arglist *) xmalloc (sizeof (struct arglist));
1141 temp->next->next = yyvsp[0].keywords;
1142 temp->next->name = (U_CHAR *) ")";
1143 temp->next->length = 1; ;
1147 { yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist));
1148 yyval.keywords->name = yyvsp[-1].name.address;
1149 yyval.keywords->length = yyvsp[-1].name.length;
1150 yyval.keywords->next = yyvsp[0].keywords; ;
1153 /* the action file gets copied in in place of this dollarsign */
1154 #line 498 "/usr/cygnus/latest-940103/share/bison.simple"
1165 short *ssp1 = yyss - 1;
1166 fprintf (stderr, "state stack now");
1167 while (ssp1 != yyssp)
1168 fprintf (stderr, " %d", *++ssp1);
1169 fprintf (stderr, "\n");
1179 yylsp->first_line = yylloc.first_line;
1180 yylsp->first_column = yylloc.first_column;
1181 yylsp->last_line = (yylsp-1)->last_line;
1182 yylsp->last_column = (yylsp-1)->last_column;
1187 yylsp->last_line = (yylsp+yylen-1)->last_line;
1188 yylsp->last_column = (yylsp+yylen-1)->last_column;
1192 /* Now "shift" the result of the reduction.
1193 Determine what state that goes to,
1194 based on the state we popped back to
1195 and the rule number reduced by. */
1199 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1200 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1201 yystate = yytable[yystate];
1203 yystate = yydefgoto[yyn - YYNTBASE];
1207 yyerrlab: /* here on detecting error */
1210 /* If not already recovering from an error, report this error. */
1214 #ifdef YYERROR_VERBOSE
1215 yyn = yypact[yystate];
1217 if (yyn > YYFLAG && yyn < YYLAST)
1224 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1225 for (x = (yyn < 0 ? -yyn : 0);
1226 x < (sizeof(yytname) / sizeof(char *)); x++)
1227 if (yycheck[x + yyn] == x)
1228 size += strlen(yytname[x]) + 15, count++;
1229 msg = (char *) malloc(size + 15);
1232 strcpy(msg, "parse error");
1237 for (x = (yyn < 0 ? -yyn : 0);
1238 x < (sizeof(yytname) / sizeof(char *)); x++)
1239 if (yycheck[x + yyn] == x)
1241 strcat(msg, count == 0 ? ", expecting `" : " or `");
1242 strcat(msg, yytname[x]);
1251 yyerror ("parse error; also virtual memory exceeded");
1254 #endif /* YYERROR_VERBOSE */
1255 yyerror("parse error");
1259 yyerrlab1: /* here on error raised explicitly by an action */
1261 if (yyerrstatus == 3)
1263 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1265 /* return failure if at end of input */
1266 if (yychar == YYEOF)
1271 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1277 /* Else will try to reuse lookahead token
1278 after shifting the error token. */
1280 yyerrstatus = 3; /* Each real token shifted decrements this */
1284 yyerrdefault: /* current state does not do anything special for the error token. */
1287 /* This is wrong; only states that explicitly want error tokens
1288 should shift them. */
1289 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1290 if (yyn) goto yydefault;
1293 yyerrpop: /* pop the current state because it cannot handle the error token */
1295 if (yyssp == yyss) YYABORT;
1305 short *ssp1 = yyss - 1;
1306 fprintf (stderr, "Error: state stack now");
1307 while (ssp1 != yyssp)
1308 fprintf (stderr, " %d", *++ssp1);
1309 fprintf (stderr, "\n");
1315 yyn = yypact[yystate];
1320 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1339 fprintf(stderr, "Shifting error token, ");
1353 /* During parsing of a C expression, the pointer to the next character
1354 is in this variable. */
1356 static char *lexptr;
1358 /* Take care of parsing a number (anything that starts with a digit).
1359 Set yylval and return the token type; update lexptr.
1360 LEN is the number of characters in it. */
1362 /* maybe needs to actually deal with floating point numbers */
1368 register char *p = lexptr;
1370 register unsigned_HOST_WIDE_INT n = 0, nd, max_over_base;
1371 register int base = 10;
1372 register int len = olen;
1373 register int overflow = 0;
1374 register int digit, largest_digit = 0;
1377 yylval.integer.signedp = SIGNED;
1381 if (len >= 3 && (p[1] == 'x' || p[1] == 'X')) {
1388 max_over_base = (unsigned_HOST_WIDE_INT) -1 / base;
1390 for (; len > 0; len--) {
1393 if (c >= '0' && c <= '9')
1395 else if (base == 16 && c >= 'a' && c <= 'f')
1396 digit = c - 'a' + 10;
1397 else if (base == 16 && c >= 'A' && c <= 'F')
1398 digit = c - 'A' + 10;
1400 /* `l' means long, and `u' means unsigned. */
1402 if (c == 'l' || c == 'L')
1404 if (!pedantic < spec_long)
1405 yyerror ("too many `l's in integer constant");
1408 else if (c == 'u' || c == 'U')
1410 if (! yylval.integer.signedp)
1411 yyerror ("two `u's in integer constant");
1412 yylval.integer.signedp = UNSIGNED;
1415 if (c == '.' || c == 'e' || c == 'E' || c == 'p' || c == 'P')
1416 yyerror ("Floating point numbers not allowed in #if expressions");
1418 char *buf = (char *) alloca (p - lexptr + 40);
1419 sprintf (buf, "missing white space after number `%.*s'",
1420 (int) (p - lexptr - 1), lexptr);
1429 /* Don't look for any more digits after the suffixes. */
1432 if (largest_digit < digit)
1433 largest_digit = digit;
1434 nd = n * base + digit;
1435 overflow |= (max_over_base < n) | (nd < n);
1439 if (base <= largest_digit)
1440 pedwarn ("integer constant contains digits beyond the radix");
1443 pedwarn ("integer constant out of range");
1445 /* If too big to be signed, consider it unsigned. */
1446 if (((HOST_WIDE_INT) n & yylval.integer.signedp) < 0)
1449 warning ("integer constant is so large that it is unsigned");
1450 yylval.integer.signedp = UNSIGNED;
1454 yylval.integer.value = n;
1463 static struct token tokentab2[] = {
1477 /* Read one token, getting characters through lexptr. */
1483 register int namelen;
1484 register unsigned char *tokstart;
1485 register struct token *toktab;
1491 tokstart = (unsigned char *) lexptr;
1493 /* See if it is a special token of length 2. */
1494 if (! keyword_parsing)
1495 for (toktab = tokentab2; toktab->operator != NULL; toktab++)
1496 if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) {
1498 if (toktab->token == ERROR)
1500 char *buf = (char *) alloca (40);
1501 sprintf (buf, "`%s' not allowed in operand of `#if'", toktab->operator);
1504 return toktab->token;
1518 /* Capital L may start a wide-string or wide-character constant. */
1519 if (lexptr[1] == '\'')
1523 mask = MAX_WCHAR_TYPE_MASK;
1526 if (lexptr[1] == '"')
1530 mask = MAX_WCHAR_TYPE_MASK;
1531 goto string_constant;
1537 mask = MAX_CHAR_TYPE_MASK;
1540 if (keyword_parsing) {
1541 char *start_ptr = lexptr - 1;
1545 c = parse_escape (&lexptr, mask);
1549 yylval.name.address = tokstart;
1550 yylval.name.length = lexptr - start_ptr;
1554 /* This code for reading a character constant
1555 handles multicharacter constants and wide characters.
1556 It is mostly copied from c-lex.c. */
1558 register HOST_WIDE_INT result = 0;
1559 register int num_chars = 0;
1560 unsigned width = MAX_CHAR_TYPE_SIZE;
1566 width = MAX_WCHAR_TYPE_SIZE;
1567 #ifdef MULTIBYTE_CHARS
1568 max_chars = MB_CUR_MAX;
1574 max_chars = MAX_LONG_TYPE_SIZE / width;
1576 token_buffer = (char *) alloca (max_chars + 1);
1582 if (c == '\'' || c == EOF)
1587 c = parse_escape (&lexptr, mask);
1592 /* Merge character into result; ignore excess chars. */
1593 if (num_chars <= max_chars)
1595 if (width < HOST_BITS_PER_WIDE_INT)
1596 result = (result << width) | c;
1599 token_buffer[num_chars - 1] = c;
1603 token_buffer[num_chars] = 0;
1606 error ("malformatted character constant");
1607 else if (num_chars == 0)
1608 error ("empty character constant");
1609 else if (num_chars > max_chars)
1611 num_chars = max_chars;
1612 error ("character constant too long");
1614 else if (num_chars != 1 && ! traditional)
1615 warning ("multi-character character constant");
1617 /* If char type is signed, sign-extend the constant. */
1620 int num_bits = num_chars * width;
1622 if (lookup ((U_CHAR *) "__CHAR_UNSIGNED__",
1623 sizeof ("__CHAR_UNSIGNED__") - 1, -1)
1624 || ((result >> (num_bits - 1)) & 1) == 0)
1625 yylval.integer.value
1626 = result & (~ (unsigned_HOST_WIDE_INT) 0
1627 >> (HOST_BITS_PER_WIDE_INT - num_bits));
1629 yylval.integer.value
1630 = result | ~(~ (unsigned_HOST_WIDE_INT) 0
1631 >> (HOST_BITS_PER_WIDE_INT - num_bits));
1635 #ifdef MULTIBYTE_CHARS
1636 /* Set the initial shift state and convert the next sequence. */
1638 /* In all locales L'\0' is zero and mbtowc will return zero,
1641 || (num_chars == 1 && token_buffer[0] != '\0'))
1644 (void) mbtowc (NULL_PTR, NULL_PTR, 0);
1645 if (mbtowc (& wc, token_buffer, num_chars) == num_chars)
1648 pedwarn ("Ignoring invalid multibyte character");
1651 yylval.integer.value = result;
1655 /* This is always a signed type. */
1656 yylval.integer.signedp = SIGNED;
1660 /* some of these chars are invalid in constant expressions;
1661 maybe do something about them later */
1685 if (keyword_parsing)
1693 mask = MAX_CHAR_TYPE_MASK;
1695 if (keyword_parsing) {
1696 char *start_ptr = lexptr;
1701 c = parse_escape (&lexptr, mask);
1705 yylval.name.address = tokstart;
1706 yylval.name.length = lexptr - start_ptr;
1709 yyerror ("string constants not allowed in #if expressions");
1713 if (c >= '0' && c <= '9' && !keyword_parsing) {
1715 for (namelen = 1; ; namelen++) {
1716 int d = tokstart[namelen];
1717 if (! ((is_idchar[d] || d == '.')
1718 || ((d == '-' || d == '+')
1719 && (c == 'e' || c == 'E'
1720 || ((c == 'p' || c == 'P') && ! c89))
1725 return parse_number (namelen);
1728 /* It is a name. See how long it is. */
1730 if (keyword_parsing) {
1731 for (namelen = 0;; namelen++) {
1732 if (is_space[tokstart[namelen]])
1734 if (tokstart[namelen] == '(' || tokstart[namelen] == ')')
1736 if (tokstart[namelen] == '"' || tokstart[namelen] == '\'')
1740 if (!is_idstart[c]) {
1741 yyerror ("Invalid token in expression");
1745 for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++)
1750 yylval.name.address = tokstart;
1751 yylval.name.length = namelen;
1756 /* Parse a C escape sequence. STRING_PTR points to a variable
1757 containing a pointer to the string to parse. That pointer
1758 is updated past the characters we use. The value of the
1759 escape sequence is returned.
1761 RESULT_MASK is used to mask out the result;
1762 an error is reported if bits are lost thereby.
1764 A negative value means the sequence \ newline was seen,
1765 which is supposed to be equivalent to nothing at all.
1767 If \ is followed by a null character, we return a negative
1768 value and leave the string pointer pointing at the null character.
1770 If \ is followed by 000, we return 0 and leave the string pointer
1771 after the zeros. A value of 0 does not mean end of string. */
1774 parse_escape (string_ptr, result_mask)
1776 HOST_WIDE_INT result_mask;
1778 register int c = *(*string_ptr)++;
1788 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
1793 return TARGET_NEWLINE;
1815 register HOST_WIDE_INT i = c - '0';
1816 register int count = 0;
1819 c = *(*string_ptr)++;
1820 if (c >= '0' && c <= '7')
1821 i = (i << 3) + c - '0';
1828 if (i != (i & result_mask))
1831 pedwarn ("octal escape sequence out of range");
1837 register unsigned_HOST_WIDE_INT i = 0, overflow = 0;
1838 register int digits_found = 0, digit;
1841 c = *(*string_ptr)++;
1842 if (c >= '0' && c <= '9')
1844 else if (c >= 'a' && c <= 'f')
1845 digit = c - 'a' + 10;
1846 else if (c >= 'A' && c <= 'F')
1847 digit = c - 'A' + 10;
1853 overflow |= i ^ (i << 4 >> 4);
1854 i = (i << 4) + digit;
1858 yyerror ("\\x used with no following hex digits");
1859 if (overflow | (i != (i & result_mask)))
1862 pedwarn ("hex escape sequence out of range");
1876 skip_evaluation = 0;
1877 longjmp (parse_return_error, 1);
1883 if (!skip_evaluation && pedantic)
1884 pedwarn ("integer overflow in preprocessor expression");
1887 static HOST_WIDE_INT
1890 unsigned_HOST_WIDE_INT b;
1892 /* It's unclear from the C standard whether shifts can overflow.
1893 The following code ignores overflow; perhaps a C standard
1894 interpretation ruling is needed. */
1895 if (b >= HOST_BITS_PER_WIDE_INT)
1898 return (unsigned_HOST_WIDE_INT) a->value << b;
1901 static HOST_WIDE_INT
1904 unsigned_HOST_WIDE_INT b;
1906 if (b >= HOST_BITS_PER_WIDE_INT)
1907 return a->signedp ? a->value >> (HOST_BITS_PER_WIDE_INT - 1) : 0;
1908 else if (a->signedp)
1909 return a->value >> b;
1911 return (unsigned_HOST_WIDE_INT) a->value >> b;
1914 /* This page contains the entry point to this file. */
1916 /* Parse STRING as an expression, and complain if this fails
1917 to use up all of the contents of STRING.
1918 STRING may contain '\0' bytes; it is terminated by the first '\n'
1919 outside a string constant, so that we can diagnose '\0' properly.
1920 If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated.
1921 We do not support C comments. They should be removed before
1922 this function is called. */
1925 parse_c_expression (string, warn_undefined)
1930 warn_undef = warn_undefined;
1932 /* if there is some sort of scanning error, just return 0 and assume
1933 the parsing routine has printed an error message somewhere.
1934 there is surely a better thing to do than this. */
1935 if (setjmp (parse_return_error))
1938 if (yyparse () != 0)
1941 if (*lexptr != '\n')
1942 error ("Junk after end of expression.");
1944 return expression_value; /* set by yyparse () */
1947 #ifdef TEST_EXP_READER
1956 int main PROTO((int, char **));
1957 static void initialize_random_junk PROTO((void));
1958 static void print_unsigned_host_wide_int PROTO((unsigned_HOST_WIDE_INT));
1960 /* Main program for testing purposes. */
1968 unsigned_HOST_WIDE_INT u;
1970 pedantic = 1 < argc;
1971 traditional = 2 < argc;
1975 initialize_random_junk ();
1978 printf ("enter expression: ");
1980 while ((buf[n] = c = getchar ()) != '\n' && c != EOF)
1984 parse_c_expression (buf, 1);
1985 printf ("parser returned ");
1986 u = (unsigned_HOST_WIDE_INT) expression_value;
1987 if (expression_value < 0 && expression_signedp) {
1994 print_unsigned_host_wide_int (u);
1995 if (! expression_signedp)
2004 print_unsigned_host_wide_int (u)
2005 unsigned_HOST_WIDE_INT u;
2008 print_unsigned_host_wide_int (u / 10);
2009 putchar ('0' + (int) (u % 10));
2013 /* table to tell if char can be part of a C identifier. */
2014 unsigned char is_idchar[256];
2015 /* table to tell if char can be first char of a c identifier. */
2016 unsigned char is_idstart[256];
2017 /* table to tell if c is horizontal or vertical space. */
2018 unsigned char is_space[256];
2021 * initialize random junk in the hash table and maybe other places
2024 initialize_random_junk ()
2029 * Set up is_idchar and is_idstart tables. These should be
2030 * faster than saying (is_alpha (c) || c == '_'), etc.
2031 * Must do set up these things before calling any routines tthat
2034 for (i = 'a'; i <= 'z'; i++) {
2035 ++is_idchar[i - 'a' + 'A'];
2037 ++is_idstart[i - 'a' + 'A'];
2040 for (i = '0'; i <= '9'; i++)
2056 error VPROTO ((char * msg, ...))
2063 VA_START (args, msg);
2066 msg = va_arg (args, char *);
2069 fprintf (stderr, "error: ");
2070 vfprintf (stderr, msg, args);
2071 fprintf (stderr, "\n");
2076 pedwarn VPROTO ((char * msg, ...))
2083 VA_START (args, msg);
2086 msg = va_arg (args, char *);
2089 fprintf (stderr, "pedwarn: ");
2090 vfprintf (stderr, msg, args);
2091 fprintf (stderr, "\n");
2096 warning VPROTO ((char * msg, ...))
2103 VA_START (args, msg);
2106 msg = va_arg (args, char *);
2109 fprintf (stderr, "warning: ");
2110 vfprintf (stderr, msg, args);
2111 fprintf (stderr, "\n");
2116 check_assertion (name, sym_length, tokens_specified, tokens)
2119 int tokens_specified;
2120 struct arglist *tokens;
2126 lookup (name, len, hash)
2131 return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1);
2138 return (GENERIC_PTR) malloc (size);