2 /* A Bison parser, made from cexp.y
3 by GNU Bison version 1.25
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
335 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
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(TO,FROM,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 (to
, from
, 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 *to
, char *from
, int count
)
618 register char *f
= from
;
619 register char *t
= to
;
620 register int i
= count
;
629 #line 196 "/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. */
639 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
640 #define YYPARSE_PARAM_DECL
641 #else /* not __cplusplus */
642 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
643 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
644 #endif /* not __cplusplus */
645 #else /* not YYPARSE_PARAM */
646 #define YYPARSE_PARAM_ARG
647 #define YYPARSE_PARAM_DECL
648 #endif /* not YYPARSE_PARAM */
651 yyparse(YYPARSE_PARAM_ARG
)
654 register int yystate
;
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 */
661 short yyssa
[YYINITDEPTH
]; /* the state stack */
662 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
664 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
665 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
668 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
669 YYLTYPE
*yyls
= yylsa
;
672 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
674 #define YYPOPSTACK (yyvsp--, yyssp--)
677 int yystacksize
= YYINITDEPTH
;
688 YYSTYPE yyval
; /* the variable used to return */
689 /* semantic values from the action */
696 fprintf(stderr
, "Starting parse\n");
702 yychar
= YYEMPTY
; /* Cause a token to be read. */
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. */
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. */
722 if (yyssp
>= yyss
+ yystacksize
- 1)
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
;
729 YYLTYPE
*yyls1
= yyls
;
732 /* Get the current used size of the three stacks, in elements. */
733 int size
= yyssp
- yyss
+ 1;
736 /* Each stack pointer address is followed by the size of
737 the data in use in that stack, in bytes. */
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
),
747 yyoverflow("parser stack overflow",
748 &yyss1
, size
* sizeof (*yyssp
),
749 &yyvs1
, size
* sizeof (*yyvsp
),
753 yyss
= yyss1
; yyvs
= yyvs1
;
757 #else /* no yyoverflow */
758 /* Extend the stack our own way. */
759 if (yystacksize
>= YYMAXDEPTH
)
761 yyerror("parser stack overflow");
765 if (yystacksize
> YYMAXDEPTH
)
766 yystacksize
= YYMAXDEPTH
;
767 yyss
= (short *) alloca (yystacksize
* sizeof (*yyssp
));
768 __yy_memcpy ((char *)yyss
, (char *)yyss1
, size
* sizeof (*yyssp
));
769 yyvs
= (YYSTYPE
*) alloca (yystacksize
* sizeof (*yyvsp
));
770 __yy_memcpy ((char *)yyvs
, (char *)yyvs1
, size
* sizeof (*yyvsp
));
772 yyls
= (YYLTYPE
*) alloca (yystacksize
* sizeof (*yylsp
));
773 __yy_memcpy ((char *)yyls
, (char *)yyls1
, size
* sizeof (*yylsp
));
775 #endif /* no yyoverflow */
777 yyssp
= yyss
+ size
- 1;
778 yyvsp
= yyvs
+ size
- 1;
780 yylsp
= yyls
+ size
- 1;
785 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
788 if (yyssp
>= yyss
+ yystacksize
- 1)
794 fprintf(stderr
, "Entering state %d\n", yystate
);
800 /* Do appropriate processing given the current state. */
801 /* Read a lookahead token if we need one and don't already have one. */
804 /* First try to decide what to do without reference to lookahead token. */
806 yyn
= yypact
[yystate
];
810 /* Not known => get a lookahead token if don't already have one. */
812 /* yychar is either YYEMPTY or YYEOF
813 or a valid token in external form. */
815 if (yychar
== YYEMPTY
)
819 fprintf(stderr
, "Reading a token: ");
824 /* Convert token to internal form (in yychar1) for indexing tables with */
826 if (yychar
<= 0) /* This means end of input. */
829 yychar
= YYEOF
; /* Don't call YYLEX any more */
833 fprintf(stderr
, "Now at end of input.\n");
838 yychar1
= YYTRANSLATE(yychar
);
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. */
847 YYPRINT (stderr
, yychar
, yylval
);
849 fprintf (stderr
, ")\n");
855 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
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,
865 0, or most negative number => error. */
880 /* Shift the lookahead token. */
884 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
887 /* Discard the token being shifted unless it is eof. */
896 /* count tokens shifted since error; after three, turn off error status. */
897 if (yyerrstatus
) yyerrstatus
--;
902 /* Do the default action for the current state. */
905 yyn
= yydefact
[yystate
];
909 /* Do a reduction. yyn is the number of a rule to reduce with. */
913 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
920 fprintf (stderr
, "Reducing via rule %d (line %d), ",
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
]]);
936 expression_value
= yyvsp
[0].integer
.value
;
937 #ifdef TEST_EXP_READER
938 expression_signedp
= yyvsp
[0].integer
.signedp
;
945 pedwarn ("comma operator in operand of `#if'");
946 yyval
.integer
= yyvsp
[0].integer
; ;
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 (); ;
957 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
958 yyval
.integer
.signedp
= SIGNED
; ;
962 { yyval
.integer
= yyvsp
[0].integer
; ;
966 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
967 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
; ;
971 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
973 yyval
.integer
.signedp
= SIGNED
; ;
977 { keyword_parsing
= 1; ;
981 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
982 1, yyvsp
[-1].keywords
);
984 yyval
.integer
.signedp
= SIGNED
; ;
988 { yyval
.integer
= yyvsp
[-1].integer
; ;
992 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
993 if (yyval
.integer
.signedp
)
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))
1002 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1003 * yyvsp
[0].integer
.value
); ;
1007 { if (yyvsp
[0].integer
.value
== 0)
1009 if (!skip_evaluation
)
1010 error ("division by zero in #if");
1011 yyvsp
[0].integer
.value
= 1;
1013 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
1014 if (yyval
.integer
.signedp
)
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 ();
1021 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1022 / yyvsp
[0].integer
.value
); ;
1026 { if (yyvsp
[0].integer
.value
== 0)
1028 if (!skip_evaluation
)
1029 error ("division by zero in #if");
1030 yyvsp
[0].integer
.value
= 1;
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
;
1036 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1037 % yyvsp
[0].integer
.value
); ;
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 (); ;
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 (); ;
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
);
1061 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
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
);
1069 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1073 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
1074 yyval
.integer
.signedp
= SIGNED
; ;
1078 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
1079 yyval
.integer
.signedp
= SIGNED
; ;
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
;
1087 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1088 <= yyvsp
[0].integer
.value
); ;
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
;
1096 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1097 >= yyvsp
[0].integer
.value
); ;
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
;
1105 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1106 < yyvsp
[0].integer
.value
); ;
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
;
1114 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1115 > yyvsp
[0].integer
.value
); ;
1119 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
1120 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1124 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
1125 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1129 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
1130 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1134 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1138 { skip_evaluation
-= !yyvsp
[-3].integer
.value
;
1139 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
&& yyvsp
[0].integer
.value
);
1140 yyval
.integer
.signedp
= SIGNED
; ;
1144 { skip_evaluation
+= !!yyvsp
[-1].integer
.value
; ;
1148 { skip_evaluation
-= !!yyvsp
[-3].integer
.value
;
1149 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
|| yyvsp
[0].integer
.value
);
1150 yyval
.integer
.signedp
= SIGNED
; ;
1154 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1158 { skip_evaluation
+= !!yyvsp
[-4].integer
.value
- !yyvsp
[-4].integer
.value
; ;
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
; ;
1168 { yyval
.integer
= yylval
.integer
; ;
1172 { yyval
.integer
= yylval
.integer
; ;
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
; ;
1184 { yyval
.keywords
= 0; ;
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)
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; ;
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
; ;
1209 /* the action file gets copied in in place of this dollarsign */
1210 #line 498 "/usr/share/bison.simple"
1221 short *ssp1
= yyss
- 1;
1222 fprintf (stderr
, "state stack now");
1223 while (ssp1
!= yyssp
)
1224 fprintf (stderr
, " %d", *++ssp1
);
1225 fprintf (stderr
, "\n");
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
;
1243 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1244 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
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. */
1255 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1256 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1257 yystate
= yytable
[yystate
];
1259 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1263 yyerrlab
: /* here on detecting error */
1266 /* If not already recovering from an error, report this error. */
1270 #ifdef YYERROR_VERBOSE
1271 yyn
= yypact
[yystate
];
1273 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
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);
1288 strcpy(msg
, "parse error");
1293 for (x
= (yyn
< 0 ? -yyn
: 0);
1294 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1295 if (yycheck
[x
+ yyn
] == x
)
1297 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1298 strcat(msg
, yytname
[x
]);
1307 yyerror ("parse error; also virtual memory exceeded");
1310 #endif /* YYERROR_VERBOSE */
1311 yyerror("parse error");
1315 yyerrlab1
: /* here on error raised explicitly by an action */
1317 if (yyerrstatus
== 3)
1319 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1321 /* return failure if at end of input */
1322 if (yychar
== YYEOF
)
1327 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1333 /* Else will try to reuse lookahead token
1334 after shifting the error token. */
1336 yyerrstatus
= 3; /* Each real token shifted decrements this */
1340 yyerrdefault
: /* current state does not do anything special for the error token. */
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
;
1349 yyerrpop
: /* pop the current state because it cannot handle the error token */
1351 if (yyssp
== yyss
) YYABORT
;
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");
1371 yyn
= yypact
[yystate
];
1376 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1395 fprintf(stderr
, "Shifting error token, ");
1409 /* During parsing of a C expression, the pointer to the next character
1410 is in this variable. */
1412 static char *lexptr
;
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. */
1418 /* maybe needs to actually deal with floating point numbers */
1424 register char *p
= lexptr
;
1426 register unsigned_HOST_WIDE_INT n
= 0, nd
, max_over_base
;
1427 register int base
= 10;
1428 register int len
= olen
;
1429 register int overflow
= 0;
1430 register int digit
, largest_digit
= 0;
1433 yylval
.integer
.signedp
= SIGNED
;
1437 if (len
>= 3 && (p
[1] == 'x' || p
[1] == 'X')) {
1444 max_over_base
= (unsigned_HOST_WIDE_INT
) -1 / base
;
1446 for (; len
> 0; len
--) {
1449 if (c
>= '0' && c
<= '9')
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;
1456 /* `l' means long, and `u' means unsigned. */
1458 if (c
== 'l' || c
== 'L')
1460 if (!pedantic
< spec_long
)
1461 yyerror ("too many `l's in integer constant");
1464 else if (c
== 'u' || c
== 'U')
1466 if (! yylval
.integer
.signedp
)
1467 yyerror ("two `u's in integer constant");
1468 yylval
.integer
.signedp
= UNSIGNED
;
1471 if (c
== '.' || c
== 'e' || c
== 'E' || c
== 'p' || c
== 'P')
1472 yyerror ("Floating point numbers not allowed in #if expressions");
1474 char *buf
= (char *) alloca (p
- lexptr
+ 40);
1475 sprintf (buf
, "missing white space after number `%.*s'",
1476 (int) (p
- lexptr
- 1), lexptr
);
1485 /* Don't look for any more digits after the suffixes. */
1488 if (largest_digit
< digit
)
1489 largest_digit
= digit
;
1490 nd
= n
* base
+ digit
;
1491 overflow
|= (max_over_base
< n
) | (nd
< n
);
1495 if (base
<= largest_digit
)
1496 pedwarn ("integer constant contains digits beyond the radix");
1499 pedwarn ("integer constant out of range");
1501 /* If too big to be signed, consider it unsigned. */
1502 if (((HOST_WIDE_INT
) n
& yylval
.integer
.signedp
) < 0)
1505 warning ("integer constant is so large that it is unsigned");
1506 yylval
.integer
.signedp
= UNSIGNED
;
1510 yylval
.integer
.value
= n
;
1519 static struct token tokentab2
[] = {
1533 /* Read one token, getting characters through lexptr. */
1539 register int namelen
;
1540 register unsigned char *tokstart
;
1541 register struct token
*toktab
;
1547 tokstart
= (unsigned char *) lexptr
;
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]) {
1554 if (toktab
->token
== ERROR
)
1556 char *buf
= (char *) alloca (40);
1557 sprintf (buf
, "`%s' not allowed in operand of `#if'", toktab
->operator);
1560 return toktab
->token
;
1574 /* Capital L may start a wide-string or wide-character constant. */
1575 if (lexptr
[1] == '\'')
1579 mask
= MAX_WCHAR_TYPE_MASK
;
1582 if (lexptr
[1] == '"')
1586 mask
= MAX_WCHAR_TYPE_MASK
;
1587 goto string_constant
;
1593 mask
= MAX_CHAR_TYPE_MASK
;
1596 if (keyword_parsing
) {
1597 char *start_ptr
= lexptr
- 1;
1601 c
= parse_escape (&lexptr
, mask
);
1605 yylval
.name
.address
= tokstart
;
1606 yylval
.name
.length
= lexptr
- start_ptr
;
1610 /* This code for reading a character constant
1611 handles multicharacter constants and wide characters.
1612 It is mostly copied from c-lex.c. */
1614 register HOST_WIDE_INT result
= 0;
1615 register int num_chars
= 0;
1616 unsigned width
= MAX_CHAR_TYPE_SIZE
;
1622 width
= MAX_WCHAR_TYPE_SIZE
;
1623 #ifdef MULTIBYTE_CHARS
1624 max_chars
= MB_CUR_MAX
;
1630 max_chars
= MAX_LONG_TYPE_SIZE
/ width
;
1632 token_buffer
= (char *) alloca (max_chars
+ 1);
1638 if (c
== '\'' || c
== EOF
)
1643 c
= parse_escape (&lexptr
, mask
);
1648 /* Merge character into result; ignore excess chars. */
1649 if (num_chars
<= max_chars
)
1651 if (width
< HOST_BITS_PER_WIDE_INT
)
1652 result
= (result
<< width
) | c
;
1655 token_buffer
[num_chars
- 1] = c
;
1659 token_buffer
[num_chars
] = 0;
1662 error ("malformatted character constant");
1663 else if (num_chars
== 0)
1664 error ("empty character constant");
1665 else if (num_chars
> max_chars
)
1667 num_chars
= max_chars
;
1668 error ("character constant too long");
1670 else if (num_chars
!= 1 && ! traditional
)
1671 warning ("multi-character character constant");
1673 /* If char type is signed, sign-extend the constant. */
1676 int num_bits
= num_chars
* width
;
1678 if (lookup ((U_CHAR
*) "__CHAR_UNSIGNED__",
1679 sizeof ("__CHAR_UNSIGNED__") - 1, -1)
1680 || ((result
>> (num_bits
- 1)) & 1) == 0)
1681 yylval
.integer
.value
1682 = result
& (~ (unsigned_HOST_WIDE_INT
) 0
1683 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1685 yylval
.integer
.value
1686 = result
| ~(~ (unsigned_HOST_WIDE_INT
) 0
1687 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1691 #ifdef MULTIBYTE_CHARS
1692 /* Set the initial shift state and convert the next sequence. */
1694 /* In all locales L'\0' is zero and mbtowc will return zero,
1697 || (num_chars
== 1 && token_buffer
[0] != '\0'))
1700 (void) mbtowc (NULL_PTR
, NULL_PTR
, 0);
1701 if (mbtowc (& wc
, token_buffer
, num_chars
) == num_chars
)
1704 pedwarn ("Ignoring invalid multibyte character");
1707 yylval
.integer
.value
= result
;
1711 /* This is always a signed type. */
1712 yylval
.integer
.signedp
= SIGNED
;
1716 /* some of these chars are invalid in constant expressions;
1717 maybe do something about them later */
1741 if (keyword_parsing
)
1749 mask
= MAX_CHAR_TYPE_MASK
;
1751 if (keyword_parsing
) {
1752 char *start_ptr
= lexptr
;
1757 c
= parse_escape (&lexptr
, mask
);
1761 yylval
.name
.address
= tokstart
;
1762 yylval
.name
.length
= lexptr
- start_ptr
;
1765 yyerror ("string constants not allowed in #if expressions");
1769 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
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
))
1781 return parse_number (namelen
);
1784 /* It is a name. See how long it is. */
1786 if (keyword_parsing
) {
1787 for (namelen
= 0;; namelen
++) {
1788 if (is_space
[tokstart
[namelen
]])
1790 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1792 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1796 if (!is_idstart
[c
]) {
1797 yyerror ("Invalid token in expression");
1801 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1806 yylval
.name
.address
= tokstart
;
1807 yylval
.name
.length
= namelen
;
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.
1817 RESULT_MASK is used to mask out the result;
1818 an error is reported if bits are lost thereby.
1820 A negative value means the sequence \ newline was seen,
1821 which is supposed to be equivalent to nothing at all.
1823 If \ is followed by a null character, we return a negative
1824 value and leave the string pointer pointing at the null character.
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. */
1830 parse_escape (string_ptr
, result_mask
)
1832 HOST_WIDE_INT result_mask
;
1834 register int c
= *(*string_ptr
)++;
1844 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1849 return TARGET_NEWLINE
;
1871 register HOST_WIDE_INT i
= c
- '0';
1872 register int count
= 0;
1875 c
= *(*string_ptr
)++;
1876 if (c
>= '0' && c
<= '7')
1877 i
= (i
<< 3) + c
- '0';
1884 if (i
!= (i
& result_mask
))
1887 pedwarn ("octal escape sequence out of range");
1893 register unsigned_HOST_WIDE_INT i
= 0, overflow
= 0;
1894 register int digits_found
= 0, digit
;
1897 c
= *(*string_ptr
)++;
1898 if (c
>= '0' && c
<= '9')
1900 else if (c
>= 'a' && c
<= 'f')
1901 digit
= c
- 'a' + 10;
1902 else if (c
>= 'A' && c
<= 'F')
1903 digit
= c
- 'A' + 10;
1909 overflow
|= i
^ (i
<< 4 >> 4);
1910 i
= (i
<< 4) + digit
;
1914 yyerror ("\\x used with no following hex digits");
1915 if (overflow
| (i
!= (i
& result_mask
)))
1918 pedwarn ("hex escape sequence out of range");
1932 skip_evaluation
= 0;
1933 longjmp (parse_return_error
, 1);
1939 if (!skip_evaluation
&& pedantic
)
1940 pedwarn ("integer overflow in preprocessor expression");
1943 static HOST_WIDE_INT
1946 unsigned_HOST_WIDE_INT b
;
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
)
1954 return (unsigned_HOST_WIDE_INT
) a
->value
<< b
;
1957 static HOST_WIDE_INT
1960 unsigned_HOST_WIDE_INT b
;
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
;
1967 return (unsigned_HOST_WIDE_INT
) a
->value
>> b
;
1970 /* This page contains the entry point to this file. */
1972 /* Parse STRING as an expression, and complain if this fails
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
1978 this function is called. */
1981 parse_c_expression (string
, warn_undefined
)
1986 warn_undef
= warn_undefined
;
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
))
1994 if (yyparse () != 0)
1997 if (*lexptr
!= '\n')
1998 error ("Junk after end of expression.");
2000 return expression_value
; /* set by yyparse () */
2003 #ifdef TEST_EXP_READER
2012 int main
PROTO((int, char **));
2013 static void initialize_random_junk
PROTO((void));
2014 static void print_unsigned_host_wide_int
PROTO((unsigned_HOST_WIDE_INT
));
2016 /* Main program for testing purposes. */
2024 unsigned_HOST_WIDE_INT u
;
2026 pedantic
= 1 < argc
;
2027 traditional
= 2 < argc
;
2031 initialize_random_junk ();
2034 printf ("enter expression: ");
2036 while ((buf
[n
] = c
= getchar ()) != '\n' && c
!= EOF
)
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
) {
2050 print_unsigned_host_wide_int (u
);
2051 if (! expression_signedp
)
2060 print_unsigned_host_wide_int (u
)
2061 unsigned_HOST_WIDE_INT u
;
2064 print_unsigned_host_wide_int (u
/ 10);
2065 putchar ('0' + (int) (u
% 10));
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];
2077 * initialize random junk in the hash table and maybe other places
2080 initialize_random_junk ()
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
2090 for (i
= 'a'; i
<= 'z'; i
++) {
2091 ++is_idchar
[i
- 'a' + 'A'];
2093 ++is_idstart
[i
- 'a' + 'A'];
2096 for (i
= '0'; i
<= '9'; i
++)
2112 error (PRINTF_ALIST (msg
))
2117 VA_START (args
, msg
);
2118 fprintf (stderr
, "error: ");
2119 vfprintf (stderr
, msg
, args
);
2120 fprintf (stderr
, "\n");
2125 pedwarn (PRINTF_ALIST (msg
))
2130 VA_START (args
, msg
);
2131 fprintf (stderr
, "pedwarn: ");
2132 vfprintf (stderr
, msg
, args
);
2133 fprintf (stderr
, "\n");
2138 warning (PRINTF_ALIST (msg
))
2143 VA_START (args
, msg
);
2144 fprintf (stderr
, "warning: ");
2145 vfprintf (stderr
, msg
, args
);
2146 fprintf (stderr
, "\n");
2151 check_assertion (name
, sym_length
, tokens_specified
, tokens
)
2154 int tokens_specified
;
2155 struct arglist
*tokens
;
2161 lookup (name
, len
, hash
)
2166 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);
2173 return (GENERIC_PTR
) malloc (size
);