2 /* A Bison parser, made from cexp.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
26 #define PRINTF_PROTO(ARGS, m, n) PVPROTO (ARGS) ATTRIBUTE_PRINTF(m, n)
28 #define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)
32 /* #define YYDEBUG 1 */
33 #include "gansidecl.h"
35 #ifdef MULTIBYTE_CHARS
38 #endif /* MULTIBYTE_CHARS */
40 typedef unsigned char U_CHAR
;
42 /* This is used for communicating lists of keywords with cccp.c. */
50 /* Find the largest host integer type and set its size and type.
51 Watch out: on some crazy hosts `long' is shorter than `int'. */
55 # include <inttypes.h>
56 # define HOST_WIDE_INT intmax_t
57 # define unsigned_HOST_WIDE_INT uintmax_t
59 # if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT)
60 # define HOST_WIDE_INT int
62 # if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG || ! (defined LONG_LONG_MAX || defined LLONG_MAX))
63 # define HOST_WIDE_INT long
65 # define HOST_WIDE_INT long long
71 #ifndef unsigned_HOST_WIDE_INT
72 #define unsigned_HOST_WIDE_INT unsigned HOST_WIDE_INT
79 #ifndef HOST_BITS_PER_WIDE_INT
80 #define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
83 HOST_WIDE_INT parse_c_expression
PROTO((char *, int));
85 static int yylex
PROTO((void));
86 static void yyerror
PROTO((char *)) __attribute__ ((noreturn
));
87 static HOST_WIDE_INT expression_value
;
88 #ifdef TEST_EXP_READER
89 static int expression_signedp
;
92 static jmp_buf parse_return_error
;
94 /* Nonzero means count most punctuation as part of a name. */
95 static int keyword_parsing
= 0;
97 /* Nonzero means do not evaluate this expression.
98 This is a count, since unevaluated expressions can nest. */
99 static int skip_evaluation
;
101 /* Nonzero means warn if undefined identifiers are evaluated. */
102 static int warn_undef
;
104 /* some external tables of character types */
105 extern unsigned char is_idstart
[], is_idchar
[], is_space
[];
107 /* Flag for -pedantic. */
110 /* Flag for -traditional. */
111 extern int traditional
;
113 /* Flag for -lang-c89. */
116 #ifndef CHAR_TYPE_SIZE
117 #define CHAR_TYPE_SIZE BITS_PER_UNIT
120 #ifndef INT_TYPE_SIZE
121 #define INT_TYPE_SIZE BITS_PER_WORD
124 #ifndef LONG_TYPE_SIZE
125 #define LONG_TYPE_SIZE BITS_PER_WORD
128 #ifndef WCHAR_TYPE_SIZE
129 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
132 #ifndef MAX_CHAR_TYPE_SIZE
133 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
136 #ifndef MAX_INT_TYPE_SIZE
137 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
140 #ifndef MAX_LONG_TYPE_SIZE
141 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
144 #ifndef MAX_WCHAR_TYPE_SIZE
145 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
148 #define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
149 ? (~ (~ (HOST_WIDE_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
150 : ~ (HOST_WIDE_INT) 0)
152 #define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
153 ? ~ (~ (HOST_WIDE_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
154 : ~ (HOST_WIDE_INT) 0)
156 /* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
157 Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
158 Suppose SIGNEDP is negative if the result is signed, zero if unsigned.
159 Then this yields nonzero if overflow occurred during the addition.
160 Overflow occurs if A and B have the same sign, but A and SUM differ in sign,
161 and SIGNEDP is negative.
162 Use `^' to test whether signs differ, and `< 0' to isolate the sign. */
163 #define overflow_sum_sign(a, b, sum, signedp) \
164 ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0)
168 GENERIC_PTR xmalloc
PROTO((size_t));
169 HOST_WIDE_INT parse_escape
PROTO((char **, HOST_WIDE_INT
));
170 int check_assertion
PROTO((U_CHAR
*, int, int, struct arglist
*));
171 struct hashnode
*lookup
PROTO((U_CHAR
*, int, int));
172 void error
PRINTF_PROTO_1((char *, ...));
173 void pedwarn
PRINTF_PROTO_1((char *, ...));
174 void warning
PRINTF_PROTO_1((char *, ...));
176 static int parse_number
PROTO((int));
177 static HOST_WIDE_INT left_shift
PROTO((struct constant
*, unsigned_HOST_WIDE_INT
));
178 static HOST_WIDE_INT right_shift
PROTO((struct constant
*, unsigned_HOST_WIDE_INT
));
179 static void integer_overflow
PROTO((void));
181 /* `signedp' values */
187 struct constant
{HOST_WIDE_INT value
; int signedp
;} integer
;
188 struct name
{U_CHAR
*address
; int length
;} name
;
189 struct arglist
*keywords
;
202 #define YYFLAG -32768
205 #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)
207 static const char yytranslate
[] = { 0,
208 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
209 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
210 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
211 2, 2, 29, 2, 31, 2, 27, 14, 2, 32,
212 33, 25, 23, 9, 24, 2, 26, 2, 2, 2,
213 2, 2, 2, 2, 2, 2, 2, 8, 2, 17,
214 2, 18, 7, 2, 2, 2, 2, 2, 2, 2,
215 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
216 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
217 2, 2, 2, 13, 2, 2, 2, 2, 2, 2,
218 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
219 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
220 2, 2, 2, 12, 2, 30, 2, 2, 2, 2,
221 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
222 2, 2, 2, 2, 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, 2, 2, 2, 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, 1, 2, 3, 4, 5,
234 6, 10, 11, 15, 16, 19, 20, 21, 22, 28
238 static const short yyprhs
[] = { 0,
239 0, 2, 4, 8, 11, 14, 17, 20, 23, 24,
240 31, 35, 39, 43, 47, 51, 55, 59, 63, 67,
241 71, 75, 79, 83, 87, 91, 95, 99, 100, 105,
242 106, 111, 112, 113, 121, 123, 125, 127, 128, 133
245 static const short yyrhs
[] = { 35,
246 0, 36, 0, 35, 9, 36, 0, 24, 36, 0,
247 29, 36, 0, 23, 36, 0, 30, 36, 0, 31,
248 5, 0, 0, 31, 5, 37, 32, 42, 33, 0,
249 32, 35, 33, 0, 36, 25, 36, 0, 36, 26,
250 36, 0, 36, 27, 36, 0, 36, 23, 36, 0,
251 36, 24, 36, 0, 36, 21, 36, 0, 36, 22,
252 36, 0, 36, 15, 36, 0, 36, 16, 36, 0,
253 36, 19, 36, 0, 36, 20, 36, 0, 36, 17,
254 36, 0, 36, 18, 36, 0, 36, 14, 36, 0,
255 36, 13, 36, 0, 36, 12, 36, 0, 0, 36,
256 11, 38, 36, 0, 0, 36, 10, 39, 36, 0,
257 0, 0, 36, 7, 40, 36, 8, 41, 36, 0,
258 3, 0, 4, 0, 5, 0, 0, 32, 42, 33,
265 static const short yyrline
[] = { 0,
266 225, 235, 236, 243, 248, 251, 253, 256, 260, 262,
267 267, 272, 285, 302, 315, 321, 327, 333, 339, 342,
268 345, 352, 359, 366, 373, 376, 379, 382, 385, 388,
269 391, 394, 396, 399, 402, 404, 406, 414, 416, 429
274 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
276 static const char * const yytname
[] = { "$","error","$undefined.","INT","CHAR",
277 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
278 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
279 "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL
283 static const short yyr1
[] = { 0,
284 34, 35, 35, 36, 36, 36, 36, 36, 37, 36,
285 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
286 36, 36, 36, 36, 36, 36, 36, 38, 36, 39,
287 36, 40, 41, 36, 36, 36, 36, 42, 42, 42
290 static const short yyr2
[] = { 0,
291 1, 1, 3, 2, 2, 2, 2, 2, 0, 6,
292 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
293 3, 3, 3, 3, 3, 3, 3, 0, 4, 0,
294 4, 0, 0, 7, 1, 1, 1, 0, 4, 2
297 static const short yydefact
[] = { 0,
298 35, 36, 37, 0, 0, 0, 0, 0, 0, 1,
299 2, 6, 4, 5, 7, 8, 0, 0, 32, 30,
300 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
301 0, 0, 0, 0, 0, 0, 0, 0, 11, 3,
302 0, 0, 0, 27, 26, 25, 19, 20, 23, 24,
303 21, 22, 17, 18, 15, 16, 12, 13, 14, 38,
304 0, 31, 29, 38, 38, 0, 33, 40, 0, 10,
305 0, 38, 34, 39, 0, 0, 0
308 static const short yydefgoto
[] = { 75,
309 10, 11, 38, 43, 42, 41, 71, 66
312 static const short yypact
[] = { 12,
313 -32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4,
314 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768,
315 -32768, 12, 12, 12, 12, 12, 12, 12, 12, 12,
316 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79,
317 12, 12, 12, 110, 124, 137, 148, 148, 155, 155,
318 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2,
319 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768,
320 12, 2, 79,-32768, 63, 188,-32768
323 static const short yypgoto
[] = {-32768,
324 180, -4,-32768,-32768,-32768,-32768,-32768, -60
331 static const short yytable
[] = { 12,
332 13, 14, 15, 68, 69, 16, 64, 35, 36, 37,
333 -9, 74, 18, 40, 1, 2, 3, 44, 45, 46,
334 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
335 57, 58, 59, 65, 4, 5, 61, 62, 63, 18,
336 6, 7, 8, 9, 21, 22, 23, 24, 25, 26,
337 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
338 37, 60, 76, 39, 19, 67, 73, 20, 21, 22,
339 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
340 33, 34, 35, 36, 37, 19, 70, 72, 20, 21,
341 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
342 32, 33, 34, 35, 36, 37, 22, 23, 24, 25,
343 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
344 36, 37, 23, 24, 25, 26, 27, 28, 29, 30,
345 31, 32, 33, 34, 35, 36, 37, 24, 25, 26,
346 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
347 37, 25, 26, 27, 28, 29, 30, 31, 32, 33,
348 34, 35, 36, 37, 27, 28, 29, 30, 31, 32,
349 33, 34, 35, 36, 37, 31, 32, 33, 34, 35,
350 36, 37, 33, 34, 35, 36, 37, 77, 17
353 static const short yycheck
[] = { 4,
354 5, 6, 7, 64, 65, 5, 5, 25, 26, 27,
355 32, 72, 9, 18, 3, 4, 5, 22, 23, 24,
356 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
357 35, 36, 37, 32, 23, 24, 41, 42, 43, 9,
358 29, 30, 31, 32, 11, 12, 13, 14, 15, 16,
359 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
360 27, 32, 0, 33, 7, 8, 71, 10, 11, 12,
361 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
362 23, 24, 25, 26, 27, 7, 33, 33, 10, 11,
363 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
364 22, 23, 24, 25, 26, 27, 12, 13, 14, 15,
365 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
366 26, 27, 13, 14, 15, 16, 17, 18, 19, 20,
367 21, 22, 23, 24, 25, 26, 27, 14, 15, 16,
368 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
369 27, 15, 16, 17, 18, 19, 20, 21, 22, 23,
370 24, 25, 26, 27, 17, 18, 19, 20, 21, 22,
371 23, 24, 25, 26, 27, 21, 22, 23, 24, 25,
372 26, 27, 23, 24, 25, 26, 27, 0, 9
374 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
375 #line 3 "/usr/cygnus/gnupro-98r1/share/bison.simple"
377 /* Skeleton output parser for bison,
378 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
380 This program is free software; you can redistribute it and/or modify
381 it under the terms of the GNU General Public License as published by
382 the Free Software Foundation; either version 2, or (at your option)
385 This program is distributed in the hope that it will be useful,
386 but WITHOUT ANY WARRANTY; without even the implied warranty of
387 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
388 GNU General Public License for more details.
390 You should have received a copy of the GNU General Public License
391 along with this program; if not, write to the Free Software
392 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
394 /* As a special exception, when this file is copied by Bison into a
395 Bison output file, you may use that output file without restriction.
396 This special exception was added by the Free Software Foundation
397 in version 1.24 of Bison. */
401 #define alloca __builtin_alloca
402 #else /* not GNU C. */
403 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
405 #else /* not sparc */
406 #if defined (MSDOS) && !defined (__TURBOC__)
408 #else /* not MSDOS, or __TURBOC__ */
412 #else /* not MSDOS, __TURBOC__, or _AIX */
416 void *alloca (unsigned int);
418 #else /* not __cplusplus */
420 #endif /* not __cplusplus */
422 #endif /* not _AIX */
423 #endif /* not MSDOS, or __TURBOC__ */
424 #endif /* not sparc. */
425 #endif /* not GNU C. */
426 #endif /* alloca not defined. */
428 /* This is the parser code that is written into each bison parser
429 when the %semantic_parser declaration is not specified in the grammar.
430 It was written by Richard Stallman by simplifying the hairy parser
431 used when %semantic_parser is specified. */
433 /* Note: there must be only one dollar sign in this file.
434 It is replaced by the list of actions, each action
435 as one case of the switch. */
437 #define yyerrok (yyerrstatus = 0)
438 #define yyclearin (yychar = YYEMPTY)
441 #define YYACCEPT return(0)
442 #define YYABORT return(1)
443 #define YYERROR goto yyerrlab1
444 /* Like YYERROR except do call yyerror.
445 This remains here temporarily to ease the
446 transition to the new meaning of YYERROR, for GCC.
447 Once GCC version 2 has supplanted version 1, this can go. */
448 #define YYFAIL goto yyerrlab
449 #define YYRECOVERING() (!!yyerrstatus)
450 #define YYBACKUP(token, value) \
452 if (yychar == YYEMPTY && yylen == 1) \
453 { yychar = (token), yylval = (value); \
454 yychar1 = YYTRANSLATE (yychar); \
459 { yyerror ("syntax error: cannot back up"); YYERROR; } \
463 #define YYERRCODE 256
466 #define YYLEX yylex()
472 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
474 #define YYLEX yylex(&yylval, &yylloc)
476 #else /* not YYLSP_NEEDED */
478 #define YYLEX yylex(&yylval, YYLEX_PARAM)
480 #define YYLEX yylex(&yylval)
482 #endif /* not YYLSP_NEEDED */
485 /* If nonreentrant, generate the variables here */
489 int yychar
; /* the lookahead symbol */
490 YYSTYPE yylval
; /* the semantic value of the */
491 /* lookahead symbol */
494 YYLTYPE yylloc
; /* location data for the lookahead */
498 int yynerrs
; /* number of parse errors so far */
499 #endif /* not YYPURE */
502 int yydebug
; /* nonzero means print parse trace */
503 /* Since this is uninitialized, it does not stop multiple parsers
507 /* YYINITDEPTH indicates the initial size of the parser's stacks */
510 #define YYINITDEPTH 200
513 /* YYMAXDEPTH is the maximum size the stacks can grow to
514 (effective only if the built-in stack extension method is used). */
521 #define YYMAXDEPTH 10000
524 /* Prevent warning if -Wstrict-prototypes. */
529 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
530 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
531 #else /* not GNU C or C++ */
534 /* This is the most reliable way to avoid incompatibilities
535 in available built-in functions on various systems. */
537 __yy_memcpy (to
, from
, count
)
542 register char *f
= from
;
543 register char *t
= to
;
544 register int i
= count
;
550 #else /* __cplusplus */
552 /* This is the most reliable way to avoid incompatibilities
553 in available built-in functions on various systems. */
555 __yy_memcpy (char *to
, char *from
, int count
)
557 register char *f
= from
;
558 register char *t
= to
;
559 register int i
= count
;
568 #line 196 "/usr/cygnus/gnupro-98r1/share/bison.simple"
570 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
571 into yyparse. The argument should have type void *.
572 It should actually point to an object.
573 Grammar actions can access the variable by casting it
574 to the proper pointer type. */
578 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
579 #define YYPARSE_PARAM_DECL
580 #else /* not __cplusplus */
581 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
582 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
583 #endif /* not __cplusplus */
584 #else /* not YYPARSE_PARAM */
585 #define YYPARSE_PARAM_ARG
586 #define YYPARSE_PARAM_DECL
587 #endif /* not YYPARSE_PARAM */
590 yyparse(YYPARSE_PARAM_ARG
)
593 register int yystate
;
595 register short *yyssp
;
596 register YYSTYPE
*yyvsp
;
597 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
598 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
600 short yyssa
[YYINITDEPTH
]; /* the state stack */
601 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
603 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
604 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
607 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
608 YYLTYPE
*yyls
= yylsa
;
611 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
613 #define YYPOPSTACK (yyvsp--, yyssp--)
616 int yystacksize
= YYINITDEPTH
;
627 YYSTYPE yyval
; /* the variable used to return */
628 /* semantic values from the action */
635 fprintf(stderr
, "Starting parse\n");
641 yychar
= YYEMPTY
; /* Cause a token to be read. */
643 /* Initialize stack pointers.
644 Waste one element of value and location stack
645 so that they stay on the same level as the state stack.
646 The wasted elements are never initialized. */
654 /* Push a new state, which is found in yystate . */
655 /* In all cases, when you get here, the value and location stacks
656 have just been pushed. so pushing a state here evens the stacks. */
661 if (yyssp
>= yyss
+ yystacksize
- 1)
663 /* Give user a chance to reallocate the stack */
664 /* Use copies of these so that the &'s don't force the real ones into memory. */
665 YYSTYPE
*yyvs1
= yyvs
;
668 YYLTYPE
*yyls1
= yyls
;
671 /* Get the current used size of the three stacks, in elements. */
672 int size
= yyssp
- yyss
+ 1;
675 /* Each stack pointer address is followed by the size of
676 the data in use in that stack, in bytes. */
678 /* This used to be a conditional around just the two extra args,
679 but that might be undefined if yyoverflow is a macro. */
680 yyoverflow("parser stack overflow",
681 &yyss1
, size
* sizeof (*yyssp
),
682 &yyvs1
, size
* sizeof (*yyvsp
),
683 &yyls1
, size
* sizeof (*yylsp
),
686 yyoverflow("parser stack overflow",
687 &yyss1
, size
* sizeof (*yyssp
),
688 &yyvs1
, size
* sizeof (*yyvsp
),
692 yyss
= yyss1
; yyvs
= yyvs1
;
696 #else /* no yyoverflow */
697 /* Extend the stack our own way. */
698 if (yystacksize
>= YYMAXDEPTH
)
700 yyerror("parser stack overflow");
704 if (yystacksize
> YYMAXDEPTH
)
705 yystacksize
= YYMAXDEPTH
;
706 yyss
= (short *) alloca (yystacksize
* sizeof (*yyssp
));
707 __yy_memcpy ((char *)yyss
, (char *)yyss1
, size
* sizeof (*yyssp
));
708 yyvs
= (YYSTYPE
*) alloca (yystacksize
* sizeof (*yyvsp
));
709 __yy_memcpy ((char *)yyvs
, (char *)yyvs1
, size
* sizeof (*yyvsp
));
711 yyls
= (YYLTYPE
*) alloca (yystacksize
* sizeof (*yylsp
));
712 __yy_memcpy ((char *)yyls
, (char *)yyls1
, size
* sizeof (*yylsp
));
714 #endif /* no yyoverflow */
716 yyssp
= yyss
+ size
- 1;
717 yyvsp
= yyvs
+ size
- 1;
719 yylsp
= yyls
+ size
- 1;
724 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
727 if (yyssp
>= yyss
+ yystacksize
- 1)
733 fprintf(stderr
, "Entering state %d\n", yystate
);
739 /* Do appropriate processing given the current state. */
740 /* Read a lookahead token if we need one and don't already have one. */
743 /* First try to decide what to do without reference to lookahead token. */
745 yyn
= yypact
[yystate
];
749 /* Not known => get a lookahead token if don't already have one. */
751 /* yychar is either YYEMPTY or YYEOF
752 or a valid token in external form. */
754 if (yychar
== YYEMPTY
)
758 fprintf(stderr
, "Reading a token: ");
763 /* Convert token to internal form (in yychar1) for indexing tables with */
765 if (yychar
<= 0) /* This means end of input. */
768 yychar
= YYEOF
; /* Don't call YYLEX any more */
772 fprintf(stderr
, "Now at end of input.\n");
777 yychar1
= YYTRANSLATE(yychar
);
782 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
783 /* Give the individual parser a way to print the precise meaning
784 of a token, for further debugging info. */
786 YYPRINT (stderr
, yychar
, yylval
);
788 fprintf (stderr
, ")\n");
794 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
799 /* yyn is what to do for this token type in this state.
800 Negative => reduce, -yyn is rule number.
801 Positive => shift, yyn is new state.
802 New state is final state => don't bother to shift,
804 0, or most negative number => error. */
819 /* Shift the lookahead token. */
823 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
826 /* Discard the token being shifted unless it is eof. */
835 /* count tokens shifted since error; after three, turn off error status. */
836 if (yyerrstatus
) yyerrstatus
--;
841 /* Do the default action for the current state. */
844 yyn
= yydefact
[yystate
];
848 /* Do a reduction. yyn is the number of a rule to reduce with. */
852 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
859 fprintf (stderr
, "Reducing via rule %d (line %d), ",
862 /* Print the symbols being reduced, and their result. */
863 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
864 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
865 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
875 expression_value
= yyvsp
[0].integer
.value
;
876 #ifdef TEST_EXP_READER
877 expression_signedp
= yyvsp
[0].integer
.signedp
;
884 pedwarn ("comma operator in operand of `#if'");
885 yyval
.integer
= yyvsp
[0].integer
; ;
889 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
890 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
;
891 if ((yyval
.integer
.value
& yyvsp
[0].integer
.value
& yyval
.integer
.signedp
) < 0)
892 integer_overflow (); ;
896 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
897 yyval
.integer
.signedp
= SIGNED
; ;
901 { yyval
.integer
= yyvsp
[0].integer
; ;
905 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
906 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
; ;
910 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
912 yyval
.integer
.signedp
= SIGNED
; ;
916 { keyword_parsing
= 1; ;
920 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
921 1, yyvsp
[-1].keywords
);
923 yyval
.integer
.signedp
= SIGNED
; ;
927 { yyval
.integer
= yyvsp
[-1].integer
; ;
931 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
932 if (yyval
.integer
.signedp
)
934 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
935 if (yyvsp
[-2].integer
.value
936 && (yyval
.integer
.value
/ yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
937 || (yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0))
941 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
942 * yyvsp
[0].integer
.value
); ;
946 { if (yyvsp
[0].integer
.value
== 0)
948 if (!skip_evaluation
)
949 error ("division by zero in #if");
950 yyvsp
[0].integer
.value
= 1;
952 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
953 if (yyval
.integer
.signedp
)
955 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
956 if ((yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0)
960 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
961 / yyvsp
[0].integer
.value
); ;
965 { if (yyvsp
[0].integer
.value
== 0)
967 if (!skip_evaluation
)
968 error ("division by zero in #if");
969 yyvsp
[0].integer
.value
= 1;
971 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
972 if (yyval
.integer
.signedp
)
973 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
975 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
976 % yyvsp
[0].integer
.value
); ;
980 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
+ yyvsp
[0].integer
.value
;
981 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
982 if (overflow_sum_sign (yyvsp
[-2].integer
.value
, yyvsp
[0].integer
.value
,
983 yyval
.integer
.value
, yyval
.integer
.signedp
))
984 integer_overflow (); ;
988 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
989 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
990 if (overflow_sum_sign (yyval
.integer
.value
, yyvsp
[0].integer
.value
,
991 yyvsp
[-2].integer
.value
, yyval
.integer
.signedp
))
992 integer_overflow (); ;
996 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
997 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
998 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1000 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1004 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
1005 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
1006 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1008 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1012 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
1013 yyval
.integer
.signedp
= SIGNED
; ;
1017 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
1018 yyval
.integer
.signedp
= SIGNED
; ;
1022 { yyval
.integer
.signedp
= SIGNED
;
1023 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1024 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
;
1026 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1027 <= yyvsp
[0].integer
.value
); ;
1031 { yyval
.integer
.signedp
= SIGNED
;
1032 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1033 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
;
1035 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1036 >= yyvsp
[0].integer
.value
); ;
1040 { yyval
.integer
.signedp
= SIGNED
;
1041 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1042 yyval
.integer
.value
= yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
;
1044 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1045 < yyvsp
[0].integer
.value
); ;
1049 { yyval
.integer
.signedp
= SIGNED
;
1050 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1051 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
;
1053 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1054 > yyvsp
[0].integer
.value
); ;
1058 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
1059 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
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 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1077 { skip_evaluation
-= !yyvsp
[-3].integer
.value
;
1078 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
&& yyvsp
[0].integer
.value
);
1079 yyval
.integer
.signedp
= SIGNED
; ;
1083 { skip_evaluation
+= !!yyvsp
[-1].integer
.value
; ;
1087 { skip_evaluation
-= !!yyvsp
[-3].integer
.value
;
1088 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
|| yyvsp
[0].integer
.value
);
1089 yyval
.integer
.signedp
= SIGNED
; ;
1093 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1097 { skip_evaluation
+= !!yyvsp
[-4].integer
.value
- !yyvsp
[-4].integer
.value
; ;
1101 { skip_evaluation
-= !!yyvsp
[-6].integer
.value
;
1102 yyval
.integer
.value
= yyvsp
[-6].integer
.value
? yyvsp
[-3].integer
.value
: yyvsp
[0].integer
.value
;
1103 yyval
.integer
.signedp
= yyvsp
[-3].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1107 { yyval
.integer
= yylval
.integer
; ;
1111 { yyval
.integer
= yylval
.integer
; ;
1115 { if (warn_undef
&& !skip_evaluation
)
1116 warning ("`%.*s' is not defined",
1117 yyvsp
[0].name
.length
, yyvsp
[0].name
.address
);
1118 yyval
.integer
.value
= 0;
1119 yyval
.integer
.signedp
= SIGNED
; ;
1123 { yyval
.keywords
= 0; ;
1127 { struct arglist
*temp
;
1128 yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1129 yyval
.keywords
->next
= yyvsp
[-2].keywords
;
1130 yyval
.keywords
->name
= (U_CHAR
*) "(";
1131 yyval
.keywords
->length
= 1;
1132 temp
= yyval
.keywords
;
1133 while (temp
!= 0 && temp
->next
!= 0)
1135 temp
->next
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1136 temp
->next
->next
= yyvsp
[0].keywords
;
1137 temp
->next
->name
= (U_CHAR
*) ")";
1138 temp
->next
->length
= 1; ;
1142 { yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1143 yyval
.keywords
->name
= yyvsp
[-1].name
.address
;
1144 yyval
.keywords
->length
= yyvsp
[-1].name
.length
;
1145 yyval
.keywords
->next
= yyvsp
[0].keywords
; ;
1148 /* the action file gets copied in in place of this dollarsign */
1149 #line 498 "/usr/cygnus/gnupro-98r1/share/bison.simple"
1160 short *ssp1
= yyss
- 1;
1161 fprintf (stderr
, "state stack now");
1162 while (ssp1
!= yyssp
)
1163 fprintf (stderr
, " %d", *++ssp1
);
1164 fprintf (stderr
, "\n");
1174 yylsp
->first_line
= yylloc
.first_line
;
1175 yylsp
->first_column
= yylloc
.first_column
;
1176 yylsp
->last_line
= (yylsp
-1)->last_line
;
1177 yylsp
->last_column
= (yylsp
-1)->last_column
;
1182 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1183 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1187 /* Now "shift" the result of the reduction.
1188 Determine what state that goes to,
1189 based on the state we popped back to
1190 and the rule number reduced by. */
1194 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1195 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1196 yystate
= yytable
[yystate
];
1198 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1202 yyerrlab
: /* here on detecting error */
1205 /* If not already recovering from an error, report this error. */
1209 #ifdef YYERROR_VERBOSE
1210 yyn
= yypact
[yystate
];
1212 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1219 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1220 for (x
= (yyn
< 0 ? -yyn
: 0);
1221 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1222 if (yycheck
[x
+ yyn
] == x
)
1223 size
+= strlen(yytname
[x
]) + 15, count
++;
1224 msg
= (char *) malloc(size
+ 15);
1227 strcpy(msg
, "parse error");
1232 for (x
= (yyn
< 0 ? -yyn
: 0);
1233 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1234 if (yycheck
[x
+ yyn
] == x
)
1236 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1237 strcat(msg
, yytname
[x
]);
1246 yyerror ("parse error; also virtual memory exceeded");
1249 #endif /* YYERROR_VERBOSE */
1250 yyerror("parse error");
1254 yyerrlab1
: /* here on error raised explicitly by an action */
1256 if (yyerrstatus
== 3)
1258 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1260 /* return failure if at end of input */
1261 if (yychar
== YYEOF
)
1266 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1272 /* Else will try to reuse lookahead token
1273 after shifting the error token. */
1275 yyerrstatus
= 3; /* Each real token shifted decrements this */
1279 yyerrdefault
: /* current state does not do anything special for the error token. */
1282 /* This is wrong; only states that explicitly want error tokens
1283 should shift them. */
1284 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1285 if (yyn
) goto yydefault
;
1288 yyerrpop
: /* pop the current state because it cannot handle the error token */
1290 if (yyssp
== yyss
) YYABORT
;
1300 short *ssp1
= yyss
- 1;
1301 fprintf (stderr
, "Error: state stack now");
1302 while (ssp1
!= yyssp
)
1303 fprintf (stderr
, " %d", *++ssp1
);
1304 fprintf (stderr
, "\n");
1310 yyn
= yypact
[yystate
];
1315 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1334 fprintf(stderr
, "Shifting error token, ");
1348 /* During parsing of a C expression, the pointer to the next character
1349 is in this variable. */
1351 static char *lexptr
;
1353 /* Take care of parsing a number (anything that starts with a digit).
1354 Set yylval and return the token type; update lexptr.
1355 LEN is the number of characters in it. */
1357 /* maybe needs to actually deal with floating point numbers */
1363 register char *p
= lexptr
;
1365 register unsigned_HOST_WIDE_INT n
= 0, nd
, max_over_base
;
1366 register int base
= 10;
1367 register int len
= olen
;
1368 register int overflow
= 0;
1369 register int digit
, largest_digit
= 0;
1372 yylval
.integer
.signedp
= SIGNED
;
1376 if (len
>= 3 && (p
[1] == 'x' || p
[1] == 'X')) {
1383 max_over_base
= (unsigned_HOST_WIDE_INT
) -1 / base
;
1385 for (; len
> 0; len
--) {
1388 if (c
>= '0' && c
<= '9')
1390 else if (base
== 16 && c
>= 'a' && c
<= 'f')
1391 digit
= c
- 'a' + 10;
1392 else if (base
== 16 && c
>= 'A' && c
<= 'F')
1393 digit
= c
- 'A' + 10;
1395 /* `l' means long, and `u' means unsigned. */
1397 if (c
== 'l' || c
== 'L')
1399 if (!pedantic
< spec_long
)
1400 yyerror ("too many `l's in integer constant");
1403 else if (c
== 'u' || c
== 'U')
1405 if (! yylval
.integer
.signedp
)
1406 yyerror ("two `u's in integer constant");
1407 yylval
.integer
.signedp
= UNSIGNED
;
1410 if (c
== '.' || c
== 'e' || c
== 'E' || c
== 'p' || c
== 'P')
1411 yyerror ("Floating point numbers not allowed in #if expressions");
1413 char *buf
= (char *) alloca (p
- lexptr
+ 40);
1414 sprintf (buf
, "missing white space after number `%.*s'",
1415 (int) (p
- lexptr
- 1), lexptr
);
1424 /* Don't look for any more digits after the suffixes. */
1427 if (largest_digit
< digit
)
1428 largest_digit
= digit
;
1429 nd
= n
* base
+ digit
;
1430 overflow
|= (max_over_base
< n
) | (nd
< n
);
1434 if (base
<= largest_digit
)
1435 pedwarn ("integer constant contains digits beyond the radix");
1438 pedwarn ("integer constant out of range");
1440 /* If too big to be signed, consider it unsigned. */
1441 if (((HOST_WIDE_INT
) n
& yylval
.integer
.signedp
) < 0)
1444 warning ("integer constant is so large that it is unsigned");
1445 yylval
.integer
.signedp
= UNSIGNED
;
1449 yylval
.integer
.value
= n
;
1458 static struct token tokentab2
[] = {
1472 /* Read one token, getting characters through lexptr. */
1478 register int namelen
;
1479 register unsigned char *tokstart
;
1480 register struct token
*toktab
;
1486 tokstart
= (unsigned char *) lexptr
;
1488 /* See if it is a special token of length 2. */
1489 if (! keyword_parsing
)
1490 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1491 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1493 if (toktab
->token
== ERROR
)
1495 char *buf
= (char *) alloca (40);
1496 sprintf (buf
, "`%s' not allowed in operand of `#if'", toktab
->operator);
1499 return toktab
->token
;
1513 /* Capital L may start a wide-string or wide-character constant. */
1514 if (lexptr
[1] == '\'')
1518 mask
= MAX_WCHAR_TYPE_MASK
;
1521 if (lexptr
[1] == '"')
1525 mask
= MAX_WCHAR_TYPE_MASK
;
1526 goto string_constant
;
1532 mask
= MAX_CHAR_TYPE_MASK
;
1535 if (keyword_parsing
) {
1536 char *start_ptr
= lexptr
- 1;
1540 c
= parse_escape (&lexptr
, mask
);
1544 yylval
.name
.address
= tokstart
;
1545 yylval
.name
.length
= lexptr
- start_ptr
;
1549 /* This code for reading a character constant
1550 handles multicharacter constants and wide characters.
1551 It is mostly copied from c-lex.c. */
1553 register HOST_WIDE_INT result
= 0;
1554 register int num_chars
= 0;
1556 unsigned width
= MAX_CHAR_TYPE_SIZE
;
1558 #ifdef MULTIBYTE_CHARS
1559 int longest_char
= local_mb_cur_max ();
1560 char *token_buffer
= (char *) alloca (longest_char
);
1561 (void) local_mbtowc (NULL_PTR
, NULL_PTR
, 0);
1564 max_chars
= MAX_LONG_TYPE_SIZE
/ width
;
1566 width
= MAX_WCHAR_TYPE_SIZE
;
1572 if (c
== '\'' || c
== EOF
)
1578 c
= parse_escape (&lexptr
, mask
);
1582 #ifdef MULTIBYTE_CHARS
1586 for (i
= 1; i
<= longest_char
; ++i
)
1588 token_buffer
[i
- 1] = c
;
1589 char_len
= local_mbtowc (& wc
, token_buffer
, i
);
1596 /* mbtowc sometimes needs an extra char before accepting */
1601 /* Merge character into result; ignore excess chars. */
1602 for (i
= 1; i
<= char_len
; ++i
)
1606 if (width
< HOST_BITS_PER_INT
)
1607 result
= (result
<< width
)
1608 | (token_buffer
[i
- 1]
1609 & ((1 << width
) - 1));
1611 result
= token_buffer
[i
- 1];
1613 num_chars
+= char_len
;
1620 warning ("Ignoring invalid multibyte character");
1624 #endif /* ! MULTIBYTE_CHARS */
1629 if (chars_seen
== 1) /* only keep the first one */
1634 /* Merge character into result; ignore excess chars. */
1636 if (num_chars
<= max_chars
)
1638 if (width
< HOST_BITS_PER_INT
)
1639 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
1646 error ("malformatted character constant");
1647 else if (chars_seen
== 0)
1648 error ("empty character constant");
1649 else if (num_chars
> max_chars
)
1651 num_chars
= max_chars
;
1652 error ("character constant too long");
1654 else if (chars_seen
!= 1 && ! traditional
)
1655 warning ("multi-character character constant");
1657 /* If char type is signed, sign-extend the constant. */
1660 int num_bits
= num_chars
* width
;
1662 /* We already got an error; avoid invalid shift. */
1663 yylval
.integer
.value
= 0;
1664 else if (lookup ((U_CHAR
*) "__CHAR_UNSIGNED__",
1665 sizeof ("__CHAR_UNSIGNED__") - 1, -1)
1666 || ((result
>> (num_bits
- 1)) & 1) == 0)
1667 yylval
.integer
.value
1668 = result
& (~ (unsigned_HOST_WIDE_INT
) 0
1669 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1671 yylval
.integer
.value
1672 = result
| ~(~ (unsigned_HOST_WIDE_INT
) 0
1673 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1677 yylval
.integer
.value
= result
;
1681 /* This is always a signed type. */
1682 yylval
.integer
.signedp
= SIGNED
;
1686 /* some of these chars are invalid in constant expressions;
1687 maybe do something about them later */
1711 if (keyword_parsing
)
1719 mask
= MAX_CHAR_TYPE_MASK
;
1721 if (keyword_parsing
) {
1722 char *start_ptr
= lexptr
;
1727 c
= parse_escape (&lexptr
, mask
);
1731 yylval
.name
.address
= tokstart
;
1732 yylval
.name
.length
= lexptr
- start_ptr
;
1735 yyerror ("string constants not allowed in #if expressions");
1739 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
1741 for (namelen
= 1; ; namelen
++) {
1742 int d
= tokstart
[namelen
];
1743 if (! ((is_idchar
[d
] || d
== '.')
1744 || ((d
== '-' || d
== '+')
1745 && (c
== 'e' || c
== 'E'
1746 || ((c
== 'p' || c
== 'P') && ! c89
))
1751 return parse_number (namelen
);
1754 /* It is a name. See how long it is. */
1756 if (keyword_parsing
) {
1757 for (namelen
= 0;; namelen
++) {
1758 if (is_space
[tokstart
[namelen
]])
1760 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1762 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1766 if (!is_idstart
[c
]) {
1767 yyerror ("Invalid token in expression");
1771 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1776 yylval
.name
.address
= tokstart
;
1777 yylval
.name
.length
= namelen
;
1782 /* Parse a C escape sequence. STRING_PTR points to a variable
1783 containing a pointer to the string to parse. That pointer
1784 is updated past the characters we use. The value of the
1785 escape sequence is returned.
1787 RESULT_MASK is used to mask out the result;
1788 an error is reported if bits are lost thereby.
1790 A negative value means the sequence \ newline was seen,
1791 which is supposed to be equivalent to nothing at all.
1793 If \ is followed by a null character, we return a negative
1794 value and leave the string pointer pointing at the null character.
1796 If \ is followed by 000, we return 0 and leave the string pointer
1797 after the zeros. A value of 0 does not mean end of string. */
1800 parse_escape (string_ptr
, result_mask
)
1802 HOST_WIDE_INT result_mask
;
1804 register int c
= *(*string_ptr
)++;
1814 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1819 return TARGET_NEWLINE
;
1841 register HOST_WIDE_INT i
= c
- '0';
1842 register int count
= 0;
1845 c
= *(*string_ptr
)++;
1846 if (c
>= '0' && c
<= '7')
1847 i
= (i
<< 3) + c
- '0';
1854 if (i
!= (i
& result_mask
))
1857 pedwarn ("octal escape sequence out of range");
1863 register unsigned_HOST_WIDE_INT i
= 0, overflow
= 0;
1864 register int digits_found
= 0, digit
;
1867 c
= *(*string_ptr
)++;
1868 if (c
>= '0' && c
<= '9')
1870 else if (c
>= 'a' && c
<= 'f')
1871 digit
= c
- 'a' + 10;
1872 else if (c
>= 'A' && c
<= 'F')
1873 digit
= c
- 'A' + 10;
1879 overflow
|= i
^ (i
<< 4 >> 4);
1880 i
= (i
<< 4) + digit
;
1884 yyerror ("\\x used with no following hex digits");
1885 if (overflow
| (i
!= (i
& result_mask
)))
1888 pedwarn ("hex escape sequence out of range");
1902 skip_evaluation
= 0;
1903 longjmp (parse_return_error
, 1);
1909 if (!skip_evaluation
&& pedantic
)
1910 pedwarn ("integer overflow in preprocessor expression");
1913 static HOST_WIDE_INT
1916 unsigned_HOST_WIDE_INT b
;
1918 /* It's unclear from the C standard whether shifts can overflow.
1919 The following code ignores overflow; perhaps a C standard
1920 interpretation ruling is needed. */
1921 if (b
>= HOST_BITS_PER_WIDE_INT
)
1924 return (unsigned_HOST_WIDE_INT
) a
->value
<< b
;
1927 static HOST_WIDE_INT
1930 unsigned_HOST_WIDE_INT b
;
1932 if (b
>= HOST_BITS_PER_WIDE_INT
)
1933 return a
->signedp
? a
->value
>> (HOST_BITS_PER_WIDE_INT
- 1) : 0;
1934 else if (a
->signedp
)
1935 return a
->value
>> b
;
1937 return (unsigned_HOST_WIDE_INT
) a
->value
>> b
;
1940 /* This page contains the entry point to this file. */
1942 /* Parse STRING as an expression, and complain if this fails
1943 to use up all of the contents of STRING.
1944 STRING may contain '\0' bytes; it is terminated by the first '\n'
1945 outside a string constant, so that we can diagnose '\0' properly.
1946 If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated.
1947 We do not support C comments. They should be removed before
1948 this function is called. */
1951 parse_c_expression (string
, warn_undefined
)
1956 warn_undef
= warn_undefined
;
1958 /* if there is some sort of scanning error, just return 0 and assume
1959 the parsing routine has printed an error message somewhere.
1960 there is surely a better thing to do than this. */
1961 if (setjmp (parse_return_error
))
1964 if (yyparse () != 0)
1967 if (*lexptr
!= '\n')
1968 error ("Junk after end of expression.");
1970 return expression_value
; /* set by yyparse () */
1973 #ifdef TEST_EXP_READER
1982 int main
PROTO((int, char **));
1983 static void initialize_random_junk
PROTO((void));
1984 static void print_unsigned_host_wide_int
PROTO((unsigned_HOST_WIDE_INT
));
1986 /* Main program for testing purposes. */
1994 unsigned_HOST_WIDE_INT u
;
1996 pedantic
= 1 < argc
;
1997 traditional
= 2 < argc
;
2001 initialize_random_junk ();
2004 printf ("enter expression: ");
2006 while ((buf
[n
] = c
= getchar ()) != '\n' && c
!= EOF
)
2010 parse_c_expression (buf
, 1);
2011 printf ("parser returned ");
2012 u
= (unsigned_HOST_WIDE_INT
) expression_value
;
2013 if (expression_value
< 0 && expression_signedp
) {
2020 print_unsigned_host_wide_int (u
);
2021 if (! expression_signedp
)
2030 print_unsigned_host_wide_int (u
)
2031 unsigned_HOST_WIDE_INT u
;
2034 print_unsigned_host_wide_int (u
/ 10);
2035 putchar ('0' + (int) (u
% 10));
2039 /* table to tell if char can be part of a C identifier. */
2040 unsigned char is_idchar
[256];
2041 /* table to tell if char can be first char of a c identifier. */
2042 unsigned char is_idstart
[256];
2043 /* table to tell if c is horizontal or vertical space. */
2044 unsigned char is_space
[256];
2047 * initialize random junk in the hash table and maybe other places
2050 initialize_random_junk ()
2055 * Set up is_idchar and is_idstart tables. These should be
2056 * faster than saying (is_alpha (c) || c == '_'), etc.
2057 * Must do set up these things before calling any routines tthat
2060 for (i
= 'a'; i
<= 'z'; i
++) {
2061 ++is_idchar
[i
- 'a' + 'A'];
2063 ++is_idstart
[i
- 'a' + 'A'];
2066 for (i
= '0'; i
<= '9'; i
++)
2082 error
VPROTO ((char * msg
, ...))
2089 VA_START (args
, msg
);
2092 msg
= va_arg (args
, char *);
2095 fprintf (stderr
, "error: ");
2096 vfprintf (stderr
, msg
, args
);
2097 fprintf (stderr
, "\n");
2102 pedwarn
VPROTO ((char * msg
, ...))
2109 VA_START (args
, msg
);
2112 msg
= va_arg (args
, char *);
2115 fprintf (stderr
, "pedwarn: ");
2116 vfprintf (stderr
, msg
, args
);
2117 fprintf (stderr
, "\n");
2122 warning
VPROTO ((char * msg
, ...))
2129 VA_START (args
, msg
);
2132 msg
= va_arg (args
, char *);
2135 fprintf (stderr
, "warning: ");
2136 vfprintf (stderr
, msg
, args
);
2137 fprintf (stderr
, "\n");
2142 check_assertion (name
, sym_length
, tokens_specified
, tokens
)
2145 int tokens_specified
;
2146 struct arglist
*tokens
;
2152 lookup (name
, len
, hash
)
2157 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);
2164 return (GENERIC_PTR
) malloc (size
);