2 /* A Bison parser, made from cexp.y
3 by Bison version A2.5 (Andrew Consortium)
6 #define YYBISON 1 /* Identify Bison output. */
26 /* #define YYDEBUG 1 */
41 #ifdef MULTIBYTE_CHARS
47 typedef unsigned char U_CHAR
;
49 /* This is used for communicating lists of keywords with cccp.c. */
57 /* Define a generic NULL if one hasn't already been defined. */
64 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
65 #define GENERIC_PTR void *
67 #define GENERIC_PTR char *
72 #define NULL_PTR ((GENERIC_PTR) 0)
75 /* Find the largest host integer type and set its size and type.
76 Watch out: on some crazy hosts `long' is shorter than `int'. */
80 # include <inttypes.h>
81 # define HOST_WIDE_INT intmax_t
82 # define unsigned_HOST_WIDE_INT uintmax_t
84 # if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT)
85 # define HOST_WIDE_INT int
87 # if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG || ! (defined LONG_LONG_MAX || defined LLONG_MAX))
88 # define HOST_WIDE_INT long
90 # define HOST_WIDE_INT long long
96 #ifndef unsigned_HOST_WIDE_INT
97 #define unsigned_HOST_WIDE_INT unsigned HOST_WIDE_INT
104 #ifndef HOST_BITS_PER_WIDE_INT
105 #define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
108 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
109 # define __attribute__(x)
113 # if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
114 # define PROTO(ARGS) ARGS
116 # define PROTO(ARGS) ()
120 #if defined (__STDC__) && defined (HAVE_VPRINTF)
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)))
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) \
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); \
142 #define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)
144 HOST_WIDE_INT parse_c_expression
PROTO((char *, int));
146 static int yylex
PROTO((void));
147 static void yyerror
PROTO((char *)) __attribute__ ((noreturn
));
148 static HOST_WIDE_INT expression_value
;
149 #ifdef TEST_EXP_READER
150 static int expression_signedp
;
153 static jmp_buf parse_return_error
;
155 /* Nonzero means count most punctuation as part of a name. */
156 static int keyword_parsing
= 0;
158 /* Nonzero means do not evaluate this expression.
159 This is a count, since unevaluated expressions can nest. */
160 static int skip_evaluation
;
162 /* Nonzero means warn if undefined identifiers are evaluated. */
163 static int warn_undef
;
165 /* some external tables of character types */
166 extern unsigned char is_idstart
[], is_idchar
[], is_space
[];
168 /* Flag for -pedantic. */
171 /* Flag for -traditional. */
172 extern int traditional
;
174 /* Flag for -lang-c89. */
177 #ifndef CHAR_TYPE_SIZE
178 #define CHAR_TYPE_SIZE BITS_PER_UNIT
181 #ifndef INT_TYPE_SIZE
182 #define INT_TYPE_SIZE BITS_PER_WORD
185 #ifndef LONG_TYPE_SIZE
186 #define LONG_TYPE_SIZE BITS_PER_WORD
189 #ifndef WCHAR_TYPE_SIZE
190 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
193 #ifndef MAX_CHAR_TYPE_SIZE
194 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
197 #ifndef MAX_INT_TYPE_SIZE
198 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
201 #ifndef MAX_LONG_TYPE_SIZE
202 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
205 #ifndef MAX_WCHAR_TYPE_SIZE
206 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
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)
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)
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)
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 *, ...));
237 static int parse_number
PROTO((int));
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
));
240 static void integer_overflow
PROTO((void));
242 /* `signedp' values */
248 struct constant
{HOST_WIDE_INT value
; int signedp
;} integer
;
249 struct name
{U_CHAR
*address
; int length
;} name
;
250 struct arglist
*keywords
;
263 #define YYFLAG -32768
266 #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)
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
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
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,
326 static const short yyrline
[] = { 0,
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
337 static const char * const yytname
[] = { "$","error","$undefined.","INT","CHAR",
338 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
339 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
340 "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL
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
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
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
369 static const short yydefgoto
[] = { 75,
370 10, 11, 38, 43, 42, 41, 71, 66
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
384 static const short yypgoto
[] = {-32768,
385 180, -4,-32768,-32768,-32768,-32768,-32768, -60
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
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
435 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
436 #line 3 "/usr/share/bison.simple"
438 /* Skeleton output parser for bison,
439 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
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)
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.
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. */
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. */
462 #define alloca __builtin_alloca
463 #else /* not GNU C. */
464 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
466 #else /* not sparc */
467 #if defined (MSDOS) && !defined (__TURBOC__)
469 #else /* not MSDOS, or __TURBOC__ */
473 #else /* not MSDOS, __TURBOC__, or _AIX */
477 void *alloca (unsigned int);
479 #else /* not __cplusplus */
481 #endif /* not __cplusplus */
483 #endif /* not _AIX */
484 #endif /* not MSDOS, or __TURBOC__ */
485 #endif /* not sparc. */
486 #endif /* not GNU C. */
487 #endif /* alloca not defined. */
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. */
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. */
498 #define yyerrok (yyerrstatus = 0)
499 #define yyclearin (yychar = YYEMPTY)
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) \
513 if (yychar == YYEMPTY && yylen == 1) \
514 { yychar = (token), yylval = (value); \
515 yychar1 = YYTRANSLATE (yychar); \
520 { yyerror ("syntax error: cannot back up"); YYERROR; } \
524 #define YYERRCODE 256
527 #define YYLEX yylex()
533 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
535 #define YYLEX yylex(&yylval, &yylloc)
537 #else /* not YYLSP_NEEDED */
539 #define YYLEX yylex(&yylval, YYLEX_PARAM)
541 #define YYLEX yylex(&yylval)
543 #endif /* not YYLSP_NEEDED */
546 /* If nonreentrant, generate the variables here */
550 int yychar
; /* the lookahead symbol */
551 YYSTYPE yylval
; /* the semantic value of the */
552 /* lookahead symbol */
555 YYLTYPE yylloc
; /* location data for the lookahead */
559 int yynerrs
; /* number of parse errors so far */
560 #endif /* not YYPURE */
563 int yydebug
; /* nonzero means print parse trace */
564 /* Since this is uninitialized, it does not stop multiple parsers
568 /* YYINITDEPTH indicates the initial size of the parser's stacks */
571 #define YYINITDEPTH 200
574 /* YYMAXDEPTH is the maximum size the stacks can grow to
575 (effective only if the built-in stack extension method is used). */
582 #define YYMAXDEPTH 10000
585 /* Prevent warning if -Wstrict-prototypes. */
590 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
591 #define __yy_memcpy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
592 #else /* not GNU C or C++ */
595 /* This is the most reliable way to avoid incompatibilities
596 in available built-in functions on various systems. */
598 __yy_memcpy (from
, to
, count
)
603 register char *f
= from
;
604 register char *t
= to
;
605 register int i
= count
;
611 #else /* __cplusplus */
613 /* This is the most reliable way to avoid incompatibilities
614 in available built-in functions on various systems. */
616 __yy_memcpy (char *from
, char *to
, int count
)
618 register char *f
= from
;
619 register char *t
= to
;
620 register int i
= count
;
629 #line 192 "/usr/share/bison.simple"
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. */
638 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
640 #define YYPARSE_PARAM
641 #define YYPARSE_PARAM_DECL
645 yyparse(YYPARSE_PARAM
)
648 register int yystate
;
650 register short *yyssp
;
651 register YYSTYPE
*yyvsp
;
652 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
653 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
655 short yyssa
[YYINITDEPTH
]; /* the state stack */
656 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
658 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
659 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
662 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
663 YYLTYPE
*yyls
= yylsa
;
666 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
668 #define YYPOPSTACK (yyvsp--, yyssp--)
671 int yystacksize
= YYINITDEPTH
;
682 YYSTYPE yyval
; /* the variable used to return */
683 /* semantic values from the action */
690 fprintf(stderr
, "Starting parse\n");
696 yychar
= YYEMPTY
; /* Cause a token to be read. */
698 /* Initialize stack pointers.
699 Waste one element of value and location stack
700 so that they stay on the same level as the state stack.
701 The wasted elements are never initialized. */
709 /* Push a new state, which is found in yystate . */
710 /* In all cases, when you get here, the value and location stacks
711 have just been pushed. so pushing a state here evens the stacks. */
716 if (yyssp
>= yyss
+ yystacksize
- 1)
718 /* Give user a chance to reallocate the stack */
719 /* Use copies of these so that the &'s don't force the real ones into memory. */
720 YYSTYPE
*yyvs1
= yyvs
;
723 YYLTYPE
*yyls1
= yyls
;
726 /* Get the current used size of the three stacks, in elements. */
727 int size
= yyssp
- yyss
+ 1;
730 /* Each stack pointer address is followed by the size of
731 the data in use in that stack, in bytes. */
733 /* This used to be a conditional around just the two extra args,
734 but that might be undefined if yyoverflow is a macro. */
735 yyoverflow("parser stack overflow",
736 &yyss1
, size
* sizeof (*yyssp
),
737 &yyvs1
, size
* sizeof (*yyvsp
),
738 &yyls1
, size
* sizeof (*yylsp
),
741 yyoverflow("parser stack overflow",
742 &yyss1
, size
* sizeof (*yyssp
),
743 &yyvs1
, size
* sizeof (*yyvsp
),
747 yyss
= yyss1
; yyvs
= yyvs1
;
751 #else /* no yyoverflow */
752 /* Extend the stack our own way. */
753 if (yystacksize
>= YYMAXDEPTH
)
755 yyerror("parser stack overflow");
759 if (yystacksize
> YYMAXDEPTH
)
760 yystacksize
= YYMAXDEPTH
;
761 yyss
= (short *) alloca (yystacksize
* sizeof (*yyssp
));
762 __yy_memcpy ((char *)yyss1
, (char *)yyss
, size
* sizeof (*yyssp
));
763 yyvs
= (YYSTYPE
*) alloca (yystacksize
* sizeof (*yyvsp
));
764 __yy_memcpy ((char *)yyvs1
, (char *)yyvs
, size
* sizeof (*yyvsp
));
766 yyls
= (YYLTYPE
*) alloca (yystacksize
* sizeof (*yylsp
));
767 __yy_memcpy ((char *)yyls1
, (char *)yyls
, size
* sizeof (*yylsp
));
769 #endif /* no yyoverflow */
771 yyssp
= yyss
+ size
- 1;
772 yyvsp
= yyvs
+ size
- 1;
774 yylsp
= yyls
+ size
- 1;
779 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
782 if (yyssp
>= yyss
+ yystacksize
- 1)
788 fprintf(stderr
, "Entering state %d\n", yystate
);
794 /* Do appropriate processing given the current state. */
795 /* Read a lookahead token if we need one and don't already have one. */
798 /* First try to decide what to do without reference to lookahead token. */
800 yyn
= yypact
[yystate
];
804 /* Not known => get a lookahead token if don't already have one. */
806 /* yychar is either YYEMPTY or YYEOF
807 or a valid token in external form. */
809 if (yychar
== YYEMPTY
)
813 fprintf(stderr
, "Reading a token: ");
818 /* Convert token to internal form (in yychar1) for indexing tables with */
820 if (yychar
<= 0) /* This means end of input. */
823 yychar
= YYEOF
; /* Don't call YYLEX any more */
827 fprintf(stderr
, "Now at end of input.\n");
832 yychar1
= YYTRANSLATE(yychar
);
837 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
838 /* Give the individual parser a way to print the precise meaning
839 of a token, for further debugging info. */
841 YYPRINT (stderr
, yychar
, yylval
);
843 fprintf (stderr
, ")\n");
849 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
854 /* yyn is what to do for this token type in this state.
855 Negative => reduce, -yyn is rule number.
856 Positive => shift, yyn is new state.
857 New state is final state => don't bother to shift,
859 0, or most negative number => error. */
874 /* Shift the lookahead token. */
878 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
881 /* Discard the token being shifted unless it is eof. */
890 /* count tokens shifted since error; after three, turn off error status. */
891 if (yyerrstatus
) yyerrstatus
--;
896 /* Do the default action for the current state. */
899 yyn
= yydefact
[yystate
];
903 /* Do a reduction. yyn is the number of a rule to reduce with. */
907 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
914 fprintf (stderr
, "Reducing via rule %d (line %d), ",
917 /* Print the symbols being reduced, and their result. */
918 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
919 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
920 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
930 expression_value
= yyvsp
[0].integer
.value
;
931 #ifdef TEST_EXP_READER
932 expression_signedp
= yyvsp
[0].integer
.signedp
;
939 pedwarn ("comma operator in operand of `#if'");
940 yyval
.integer
= yyvsp
[0].integer
; ;
944 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
945 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
;
946 if ((yyval
.integer
.value
& yyvsp
[0].integer
.value
& yyval
.integer
.signedp
) < 0)
947 integer_overflow (); ;
951 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
952 yyval
.integer
.signedp
= SIGNED
; ;
956 { yyval
.integer
= yyvsp
[0].integer
; ;
960 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
961 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
; ;
965 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
967 yyval
.integer
.signedp
= SIGNED
; ;
971 { keyword_parsing
= 1; ;
975 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
976 1, yyvsp
[-1].keywords
);
978 yyval
.integer
.signedp
= SIGNED
; ;
982 { yyval
.integer
= yyvsp
[-1].integer
; ;
986 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
987 if (yyval
.integer
.signedp
)
989 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
990 if (yyvsp
[-2].integer
.value
991 && (yyval
.integer
.value
/ yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
992 || (yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0))
996 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
997 * yyvsp
[0].integer
.value
); ;
1001 { if (yyvsp
[0].integer
.value
== 0)
1003 if (!skip_evaluation
)
1004 error ("division by zero in #if");
1005 yyvsp
[0].integer
.value
= 1;
1007 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
1008 if (yyval
.integer
.signedp
)
1010 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
1011 if ((yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0)
1012 integer_overflow ();
1015 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1016 / yyvsp
[0].integer
.value
); ;
1020 { if (yyvsp
[0].integer
.value
== 0)
1022 if (!skip_evaluation
)
1023 error ("division by zero in #if");
1024 yyvsp
[0].integer
.value
= 1;
1026 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
1027 if (yyval
.integer
.signedp
)
1028 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
1030 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1031 % yyvsp
[0].integer
.value
); ;
1035 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
+ yyvsp
[0].integer
.value
;
1036 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
1037 if (overflow_sum_sign (yyvsp
[-2].integer
.value
, yyvsp
[0].integer
.value
,
1038 yyval
.integer
.value
, yyval
.integer
.signedp
))
1039 integer_overflow (); ;
1043 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
1044 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
1045 if (overflow_sum_sign (yyval
.integer
.value
, yyvsp
[0].integer
.value
,
1046 yyvsp
[-2].integer
.value
, yyval
.integer
.signedp
))
1047 integer_overflow (); ;
1051 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
1052 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
1053 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1055 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1059 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
1060 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
1061 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1063 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1067 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
1068 yyval
.integer
.signedp
= SIGNED
; ;
1072 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
1073 yyval
.integer
.signedp
= SIGNED
; ;
1077 { yyval
.integer
.signedp
= SIGNED
;
1078 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1079 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
;
1081 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1082 <= yyvsp
[0].integer
.value
); ;
1086 { yyval
.integer
.signedp
= SIGNED
;
1087 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1088 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
;
1090 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1091 >= yyvsp
[0].integer
.value
); ;
1095 { yyval
.integer
.signedp
= SIGNED
;
1096 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1097 yyval
.integer
.value
= yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
;
1099 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1100 < yyvsp
[0].integer
.value
); ;
1104 { yyval
.integer
.signedp
= SIGNED
;
1105 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1106 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
;
1108 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1109 > yyvsp
[0].integer
.value
); ;
1113 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
1114 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1118 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
1119 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1123 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
1124 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1128 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1132 { skip_evaluation
-= !yyvsp
[-3].integer
.value
;
1133 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
&& yyvsp
[0].integer
.value
);
1134 yyval
.integer
.signedp
= SIGNED
; ;
1138 { skip_evaluation
+= !!yyvsp
[-1].integer
.value
; ;
1142 { skip_evaluation
-= !!yyvsp
[-3].integer
.value
;
1143 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
|| yyvsp
[0].integer
.value
);
1144 yyval
.integer
.signedp
= SIGNED
; ;
1148 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1152 { skip_evaluation
+= !!yyvsp
[-4].integer
.value
- !yyvsp
[-4].integer
.value
; ;
1156 { skip_evaluation
-= !!yyvsp
[-6].integer
.value
;
1157 yyval
.integer
.value
= yyvsp
[-6].integer
.value
? yyvsp
[-3].integer
.value
: yyvsp
[0].integer
.value
;
1158 yyval
.integer
.signedp
= yyvsp
[-3].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1162 { yyval
.integer
= yylval
.integer
; ;
1166 { yyval
.integer
= yylval
.integer
; ;
1170 { if (warn_undef
&& !skip_evaluation
)
1171 warning ("`%.*s' is not defined",
1172 yyvsp
[0].name
.length
, yyvsp
[0].name
.address
);
1173 yyval
.integer
.value
= 0;
1174 yyval
.integer
.signedp
= SIGNED
; ;
1178 { yyval
.keywords
= 0; ;
1182 { struct arglist
*temp
;
1183 yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1184 yyval
.keywords
->next
= yyvsp
[-2].keywords
;
1185 yyval
.keywords
->name
= (U_CHAR
*) "(";
1186 yyval
.keywords
->length
= 1;
1187 temp
= yyval
.keywords
;
1188 while (temp
!= 0 && temp
->next
!= 0)
1190 temp
->next
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1191 temp
->next
->next
= yyvsp
[0].keywords
;
1192 temp
->next
->name
= (U_CHAR
*) ")";
1193 temp
->next
->length
= 1; ;
1197 { yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1198 yyval
.keywords
->name
= yyvsp
[-1].name
.address
;
1199 yyval
.keywords
->length
= yyvsp
[-1].name
.length
;
1200 yyval
.keywords
->next
= yyvsp
[0].keywords
; ;
1203 /* the action file gets copied in in place of this dollarsign */
1204 #line 487 "/usr/share/bison.simple"
1215 short *ssp1
= yyss
- 1;
1216 fprintf (stderr
, "state stack now");
1217 while (ssp1
!= yyssp
)
1218 fprintf (stderr
, " %d", *++ssp1
);
1219 fprintf (stderr
, "\n");
1229 yylsp
->first_line
= yylloc
.first_line
;
1230 yylsp
->first_column
= yylloc
.first_column
;
1231 yylsp
->last_line
= (yylsp
-1)->last_line
;
1232 yylsp
->last_column
= (yylsp
-1)->last_column
;
1237 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1238 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1242 /* Now "shift" the result of the reduction.
1243 Determine what state that goes to,
1244 based on the state we popped back to
1245 and the rule number reduced by. */
1249 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1250 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1251 yystate
= yytable
[yystate
];
1253 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1257 yyerrlab
: /* here on detecting error */
1260 /* If not already recovering from an error, report this error. */
1264 #ifdef YYERROR_VERBOSE
1265 yyn
= yypact
[yystate
];
1267 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1274 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1275 for (x
= (yyn
< 0 ? -yyn
: 0);
1276 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1277 if (yycheck
[x
+ yyn
] == x
)
1278 size
+= strlen(yytname
[x
]) + 15, count
++;
1279 msg
= (char *) malloc(size
+ 15);
1282 strcpy(msg
, "parse error");
1287 for (x
= (yyn
< 0 ? -yyn
: 0);
1288 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1289 if (yycheck
[x
+ yyn
] == x
)
1291 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1292 strcat(msg
, yytname
[x
]);
1301 yyerror ("parse error; also virtual memory exceeded");
1304 #endif /* YYERROR_VERBOSE */
1305 yyerror("parse error");
1309 yyerrlab1
: /* here on error raised explicitly by an action */
1311 if (yyerrstatus
== 3)
1313 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1315 /* return failure if at end of input */
1316 if (yychar
== YYEOF
)
1321 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1327 /* Else will try to reuse lookahead token
1328 after shifting the error token. */
1330 yyerrstatus
= 3; /* Each real token shifted decrements this */
1334 yyerrdefault
: /* current state does not do anything special for the error token. */
1337 /* This is wrong; only states that explicitly want error tokens
1338 should shift them. */
1339 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1340 if (yyn
) goto yydefault
;
1343 yyerrpop
: /* pop the current state because it cannot handle the error token */
1345 if (yyssp
== yyss
) YYABORT
;
1355 short *ssp1
= yyss
- 1;
1356 fprintf (stderr
, "Error: state stack now");
1357 while (ssp1
!= yyssp
)
1358 fprintf (stderr
, " %d", *++ssp1
);
1359 fprintf (stderr
, "\n");
1365 yyn
= yypact
[yystate
];
1370 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1389 fprintf(stderr
, "Shifting error token, ");
1403 /* During parsing of a C expression, the pointer to the next character
1404 is in this variable. */
1406 static char *lexptr
;
1408 /* Take care of parsing a number (anything that starts with a digit).
1409 Set yylval and return the token type; update lexptr.
1410 LEN is the number of characters in it. */
1412 /* maybe needs to actually deal with floating point numbers */
1418 register char *p
= lexptr
;
1420 register unsigned_HOST_WIDE_INT n
= 0, nd
, max_over_base
;
1421 register int base
= 10;
1422 register int len
= olen
;
1423 register int overflow
= 0;
1424 register int digit
, largest_digit
= 0;
1427 yylval
.integer
.signedp
= SIGNED
;
1431 if (len
>= 3 && (p
[1] == 'x' || p
[1] == 'X')) {
1438 max_over_base
= (unsigned_HOST_WIDE_INT
) -1 / base
;
1440 for (; len
> 0; len
--) {
1443 if (c
>= '0' && c
<= '9')
1445 else if (base
== 16 && c
>= 'a' && c
<= 'f')
1446 digit
= c
- 'a' + 10;
1447 else if (base
== 16 && c
>= 'A' && c
<= 'F')
1448 digit
= c
- 'A' + 10;
1450 /* `l' means long, and `u' means unsigned. */
1452 if (c
== 'l' || c
== 'L')
1454 if (!pedantic
< spec_long
)
1455 yyerror ("too many `l's in integer constant");
1458 else if (c
== 'u' || c
== 'U')
1460 if (! yylval
.integer
.signedp
)
1461 yyerror ("two `u's in integer constant");
1462 yylval
.integer
.signedp
= UNSIGNED
;
1465 if (c
== '.' || c
== 'e' || c
== 'E' || c
== 'p' || c
== 'P')
1466 yyerror ("Floating point numbers not allowed in #if expressions");
1468 char *buf
= (char *) alloca (p
- lexptr
+ 40);
1469 sprintf (buf
, "missing white space after number `%.*s'",
1470 (int) (p
- lexptr
- 1), lexptr
);
1479 /* Don't look for any more digits after the suffixes. */
1482 if (largest_digit
< digit
)
1483 largest_digit
= digit
;
1484 nd
= n
* base
+ digit
;
1485 overflow
|= (max_over_base
< n
) | (nd
< n
);
1489 if (base
<= largest_digit
)
1490 pedwarn ("integer constant contains digits beyond the radix");
1493 pedwarn ("integer constant out of range");
1495 /* If too big to be signed, consider it unsigned. */
1496 if (((HOST_WIDE_INT
) n
& yylval
.integer
.signedp
) < 0)
1499 warning ("integer constant is so large that it is unsigned");
1500 yylval
.integer
.signedp
= UNSIGNED
;
1504 yylval
.integer
.value
= n
;
1513 static struct token tokentab2
[] = {
1527 /* Read one token, getting characters through lexptr. */
1533 register int namelen
;
1534 register unsigned char *tokstart
;
1535 register struct token
*toktab
;
1541 tokstart
= (unsigned char *) lexptr
;
1543 /* See if it is a special token of length 2. */
1544 if (! keyword_parsing
)
1545 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1546 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1548 if (toktab
->token
== ERROR
)
1550 char *buf
= (char *) alloca (40);
1551 sprintf (buf
, "`%s' not allowed in operand of `#if'", toktab
->operator);
1554 return toktab
->token
;
1568 /* Capital L may start a wide-string or wide-character constant. */
1569 if (lexptr
[1] == '\'')
1573 mask
= MAX_WCHAR_TYPE_MASK
;
1576 if (lexptr
[1] == '"')
1580 mask
= MAX_WCHAR_TYPE_MASK
;
1581 goto string_constant
;
1587 mask
= MAX_CHAR_TYPE_MASK
;
1590 if (keyword_parsing
) {
1591 char *start_ptr
= lexptr
- 1;
1595 c
= parse_escape (&lexptr
, mask
);
1599 yylval
.name
.address
= tokstart
;
1600 yylval
.name
.length
= lexptr
- start_ptr
;
1604 /* This code for reading a character constant
1605 handles multicharacter constants and wide characters.
1606 It is mostly copied from c-lex.c. */
1608 register HOST_WIDE_INT result
= 0;
1609 register int num_chars
= 0;
1610 unsigned width
= MAX_CHAR_TYPE_SIZE
;
1616 width
= MAX_WCHAR_TYPE_SIZE
;
1617 #ifdef MULTIBYTE_CHARS
1618 max_chars
= MB_CUR_MAX
;
1624 max_chars
= MAX_LONG_TYPE_SIZE
/ width
;
1626 token_buffer
= (char *) alloca (max_chars
+ 1);
1632 if (c
== '\'' || c
== EOF
)
1637 c
= parse_escape (&lexptr
, mask
);
1642 /* Merge character into result; ignore excess chars. */
1643 if (num_chars
<= max_chars
)
1645 if (width
< HOST_BITS_PER_WIDE_INT
)
1646 result
= (result
<< width
) | c
;
1649 token_buffer
[num_chars
- 1] = c
;
1653 token_buffer
[num_chars
] = 0;
1656 error ("malformatted character constant");
1657 else if (num_chars
== 0)
1658 error ("empty character constant");
1659 else if (num_chars
> max_chars
)
1661 num_chars
= max_chars
;
1662 error ("character constant too long");
1664 else if (num_chars
!= 1 && ! traditional
)
1665 warning ("multi-character character constant");
1667 /* If char type is signed, sign-extend the constant. */
1670 int num_bits
= num_chars
* width
;
1672 if (lookup ((U_CHAR
*) "__CHAR_UNSIGNED__",
1673 sizeof ("__CHAR_UNSIGNED__") - 1, -1)
1674 || ((result
>> (num_bits
- 1)) & 1) == 0)
1675 yylval
.integer
.value
1676 = result
& (~ (unsigned_HOST_WIDE_INT
) 0
1677 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1679 yylval
.integer
.value
1680 = result
| ~(~ (unsigned_HOST_WIDE_INT
) 0
1681 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1685 #ifdef MULTIBYTE_CHARS
1686 /* Set the initial shift state and convert the next sequence. */
1688 /* In all locales L'\0' is zero and mbtowc will return zero,
1691 || (num_chars
== 1 && token_buffer
[0] != '\0'))
1694 (void) mbtowc (NULL_PTR
, NULL_PTR
, 0);
1695 if (mbtowc (& wc
, token_buffer
, num_chars
) == num_chars
)
1698 pedwarn ("Ignoring invalid multibyte character");
1701 yylval
.integer
.value
= result
;
1705 /* This is always a signed type. */
1706 yylval
.integer
.signedp
= SIGNED
;
1710 /* some of these chars are invalid in constant expressions;
1711 maybe do something about them later */
1735 if (keyword_parsing
)
1743 mask
= MAX_CHAR_TYPE_MASK
;
1745 if (keyword_parsing
) {
1746 char *start_ptr
= lexptr
;
1751 c
= parse_escape (&lexptr
, mask
);
1755 yylval
.name
.address
= tokstart
;
1756 yylval
.name
.length
= lexptr
- start_ptr
;
1759 yyerror ("string constants not allowed in #if expressions");
1763 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
1765 for (namelen
= 1; ; namelen
++) {
1766 int d
= tokstart
[namelen
];
1767 if (! ((is_idchar
[d
] || d
== '.')
1768 || ((d
== '-' || d
== '+')
1769 && (c
== 'e' || c
== 'E'
1770 || ((c
== 'p' || c
== 'P') && ! c89
))
1775 return parse_number (namelen
);
1778 /* It is a name. See how long it is. */
1780 if (keyword_parsing
) {
1781 for (namelen
= 0;; namelen
++) {
1782 if (is_space
[tokstart
[namelen
]])
1784 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1786 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1790 if (!is_idstart
[c
]) {
1791 yyerror ("Invalid token in expression");
1795 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1800 yylval
.name
.address
= tokstart
;
1801 yylval
.name
.length
= namelen
;
1806 /* Parse a C escape sequence. STRING_PTR points to a variable
1807 containing a pointer to the string to parse. That pointer
1808 is updated past the characters we use. The value of the
1809 escape sequence is returned.
1811 RESULT_MASK is used to mask out the result;
1812 an error is reported if bits are lost thereby.
1814 A negative value means the sequence \ newline was seen,
1815 which is supposed to be equivalent to nothing at all.
1817 If \ is followed by a null character, we return a negative
1818 value and leave the string pointer pointing at the null character.
1820 If \ is followed by 000, we return 0 and leave the string pointer
1821 after the zeros. A value of 0 does not mean end of string. */
1824 parse_escape (string_ptr
, result_mask
)
1826 HOST_WIDE_INT result_mask
;
1828 register int c
= *(*string_ptr
)++;
1838 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1843 return TARGET_NEWLINE
;
1865 register HOST_WIDE_INT i
= c
- '0';
1866 register int count
= 0;
1869 c
= *(*string_ptr
)++;
1870 if (c
>= '0' && c
<= '7')
1871 i
= (i
<< 3) + c
- '0';
1878 if (i
!= (i
& result_mask
))
1881 pedwarn ("octal escape sequence out of range");
1887 register unsigned_HOST_WIDE_INT i
= 0, overflow
= 0;
1888 register int digits_found
= 0, digit
;
1891 c
= *(*string_ptr
)++;
1892 if (c
>= '0' && c
<= '9')
1894 else if (c
>= 'a' && c
<= 'f')
1895 digit
= c
- 'a' + 10;
1896 else if (c
>= 'A' && c
<= 'F')
1897 digit
= c
- 'A' + 10;
1903 overflow
|= i
^ (i
<< 4 >> 4);
1904 i
= (i
<< 4) + digit
;
1908 yyerror ("\\x used with no following hex digits");
1909 if (overflow
| (i
!= (i
& result_mask
)))
1912 pedwarn ("hex escape sequence out of range");
1926 skip_evaluation
= 0;
1927 longjmp (parse_return_error
, 1);
1933 if (!skip_evaluation
&& pedantic
)
1934 pedwarn ("integer overflow in preprocessor expression");
1937 static HOST_WIDE_INT
1940 unsigned_HOST_WIDE_INT b
;
1942 /* It's unclear from the C standard whether shifts can overflow.
1943 The following code ignores overflow; perhaps a C standard
1944 interpretation ruling is needed. */
1945 if (b
>= HOST_BITS_PER_WIDE_INT
)
1948 return (unsigned_HOST_WIDE_INT
) a
->value
<< b
;
1951 static HOST_WIDE_INT
1954 unsigned_HOST_WIDE_INT b
;
1956 if (b
>= HOST_BITS_PER_WIDE_INT
)
1957 return a
->signedp
? a
->value
>> (HOST_BITS_PER_WIDE_INT
- 1) : 0;
1958 else if (a
->signedp
)
1959 return a
->value
>> b
;
1961 return (unsigned_HOST_WIDE_INT
) a
->value
>> b
;
1964 /* This page contains the entry point to this file. */
1966 /* Parse STRING as an expression, and complain if this fails
1967 to use up all of the contents of STRING.
1968 STRING may contain '\0' bytes; it is terminated by the first '\n'
1969 outside a string constant, so that we can diagnose '\0' properly.
1970 If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated.
1971 We do not support C comments. They should be removed before
1972 this function is called. */
1975 parse_c_expression (string
, warn_undefined
)
1980 warn_undef
= warn_undefined
;
1982 /* if there is some sort of scanning error, just return 0 and assume
1983 the parsing routine has printed an error message somewhere.
1984 there is surely a better thing to do than this. */
1985 if (setjmp (parse_return_error
))
1988 if (yyparse () != 0)
1991 if (*lexptr
!= '\n')
1992 error ("Junk after end of expression.");
1994 return expression_value
; /* set by yyparse () */
1997 #ifdef TEST_EXP_READER
2006 int main
PROTO((int, char **));
2007 static void initialize_random_junk
PROTO((void));
2008 static void print_unsigned_host_wide_int
PROTO((unsigned_HOST_WIDE_INT
));
2010 /* Main program for testing purposes. */
2018 unsigned_HOST_WIDE_INT u
;
2020 pedantic
= 1 < argc
;
2021 traditional
= 2 < argc
;
2025 initialize_random_junk ();
2028 printf ("enter expression: ");
2030 while ((buf
[n
] = c
= getchar ()) != '\n' && c
!= EOF
)
2034 parse_c_expression (buf
, 1);
2035 printf ("parser returned ");
2036 u
= (unsigned_HOST_WIDE_INT
) expression_value
;
2037 if (expression_value
< 0 && expression_signedp
) {
2044 print_unsigned_host_wide_int (u
);
2045 if (! expression_signedp
)
2054 print_unsigned_host_wide_int (u
)
2055 unsigned_HOST_WIDE_INT u
;
2058 print_unsigned_host_wide_int (u
/ 10);
2059 putchar ('0' + (int) (u
% 10));
2063 /* table to tell if char can be part of a C identifier. */
2064 unsigned char is_idchar
[256];
2065 /* table to tell if char can be first char of a c identifier. */
2066 unsigned char is_idstart
[256];
2067 /* table to tell if c is horizontal or vertical space. */
2068 unsigned char is_space
[256];
2071 * initialize random junk in the hash table and maybe other places
2074 initialize_random_junk ()
2079 * Set up is_idchar and is_idstart tables. These should be
2080 * faster than saying (is_alpha (c) || c == '_'), etc.
2081 * Must do set up these things before calling any routines tthat
2084 for (i
= 'a'; i
<= 'z'; i
++) {
2085 ++is_idchar
[i
- 'a' + 'A'];
2087 ++is_idstart
[i
- 'a' + 'A'];
2090 for (i
= '0'; i
<= '9'; i
++)
2106 error (PRINTF_ALIST (msg
))
2111 VA_START (args
, msg
);
2112 fprintf (stderr
, "error: ");
2113 vfprintf (stderr
, msg
, args
);
2114 fprintf (stderr
, "\n");
2119 pedwarn (PRINTF_ALIST (msg
))
2124 VA_START (args
, msg
);
2125 fprintf (stderr
, "pedwarn: ");
2126 vfprintf (stderr
, msg
, args
);
2127 fprintf (stderr
, "\n");
2132 warning (PRINTF_ALIST (msg
))
2137 VA_START (args
, msg
);
2138 fprintf (stderr
, "warning: ");
2139 vfprintf (stderr
, msg
, args
);
2140 fprintf (stderr
, "\n");
2145 check_assertion (name
, sym_length
, tokens_specified
, tokens
)
2148 int tokens_specified
;
2149 struct arglist
*tokens
;
2155 lookup (name
, len
, hash
)
2160 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);
2167 return (GENERIC_PTR
) malloc (size
);