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 */
34 #ifdef MULTIBYTE_CHARS
37 #endif /* MULTIBYTE_CHARS */
39 typedef unsigned char U_CHAR
;
41 /* This is used for communicating lists of keywords with cccp.c. */
49 /* Find the largest host integer type and set its size and type.
50 Watch out: on some crazy hosts `long' is shorter than `int'. */
54 # include <inttypes.h>
55 # define HOST_WIDE_INT intmax_t
56 # define unsigned_HOST_WIDE_INT uintmax_t
58 # if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT)
59 # define HOST_WIDE_INT int
61 # if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG || ! (defined LONG_LONG_MAX || defined LLONG_MAX))
62 # define HOST_WIDE_INT long
64 # define HOST_WIDE_INT long long
70 #ifndef unsigned_HOST_WIDE_INT
71 #define unsigned_HOST_WIDE_INT unsigned HOST_WIDE_INT
78 #ifndef HOST_BITS_PER_WIDE_INT
79 #define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
82 HOST_WIDE_INT parse_c_expression
PROTO((char *, int));
84 static int yylex
PROTO((void));
85 static void yyerror
PROTO((char *)) __attribute__ ((noreturn
));
86 static HOST_WIDE_INT expression_value
;
87 #ifdef TEST_EXP_READER
88 static int expression_signedp
;
91 static jmp_buf parse_return_error
;
93 /* Nonzero means count most punctuation as part of a name. */
94 static int keyword_parsing
= 0;
96 /* Nonzero means do not evaluate this expression.
97 This is a count, since unevaluated expressions can nest. */
98 static int skip_evaluation
;
100 /* Nonzero means warn if undefined identifiers are evaluated. */
101 static int warn_undef
;
103 /* some external tables of character types */
104 extern unsigned char is_idstart
[], is_idchar
[], is_space
[];
106 /* Flag for -pedantic. */
109 /* Flag for -traditional. */
110 extern int traditional
;
112 /* Flag for -lang-c89. */
115 #ifndef CHAR_TYPE_SIZE
116 #define CHAR_TYPE_SIZE BITS_PER_UNIT
119 #ifndef INT_TYPE_SIZE
120 #define INT_TYPE_SIZE BITS_PER_WORD
123 #ifndef LONG_TYPE_SIZE
124 #define LONG_TYPE_SIZE BITS_PER_WORD
127 #ifndef WCHAR_TYPE_SIZE
128 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
131 #ifndef MAX_CHAR_TYPE_SIZE
132 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
135 #ifndef MAX_INT_TYPE_SIZE
136 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
139 #ifndef MAX_LONG_TYPE_SIZE
140 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
143 #ifndef MAX_WCHAR_TYPE_SIZE
144 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
147 #define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
148 ? (~ (~ (HOST_WIDE_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
149 : ~ (HOST_WIDE_INT) 0)
151 #define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
152 ? ~ (~ (HOST_WIDE_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
153 : ~ (HOST_WIDE_INT) 0)
155 /* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
156 Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
157 Suppose SIGNEDP is negative if the result is signed, zero if unsigned.
158 Then this yields nonzero if overflow occurred during the addition.
159 Overflow occurs if A and B have the same sign, but A and SUM differ in sign,
160 and SIGNEDP is negative.
161 Use `^' to test whether signs differ, and `< 0' to isolate the sign. */
162 #define overflow_sum_sign(a, b, sum, signedp) \
163 ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0)
167 HOST_WIDE_INT parse_escape
PROTO((char **, HOST_WIDE_INT
));
168 int check_assertion
PROTO((U_CHAR
*, int, int, struct arglist
*));
169 struct hashnode
*lookup
PROTO((U_CHAR
*, int, int));
170 void error
PRINTF_PROTO_1((char *, ...));
171 void pedwarn
PRINTF_PROTO_1((char *, ...));
172 void warning
PRINTF_PROTO_1((char *, ...));
174 static int parse_number
PROTO((int));
175 static HOST_WIDE_INT left_shift
PROTO((struct constant
*, unsigned_HOST_WIDE_INT
));
176 static HOST_WIDE_INT right_shift
PROTO((struct constant
*, unsigned_HOST_WIDE_INT
));
177 static void integer_overflow
PROTO((void));
179 /* `signedp' values */
185 struct constant
{HOST_WIDE_INT value
; int signedp
;} integer
;
186 struct name
{U_CHAR
*address
; int length
;} name
;
187 struct arglist
*keywords
;
200 #define YYFLAG -32768
203 #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)
205 static const char yytranslate
[] = { 0,
206 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
207 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
208 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
209 2, 2, 29, 2, 31, 2, 27, 14, 2, 32,
210 33, 25, 23, 9, 24, 2, 26, 2, 2, 2,
211 2, 2, 2, 2, 2, 2, 2, 8, 2, 17,
212 2, 18, 7, 2, 2, 2, 2, 2, 2, 2,
213 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
214 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
215 2, 2, 2, 13, 2, 2, 2, 2, 2, 2,
216 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
217 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
218 2, 2, 2, 12, 2, 30, 2, 2, 2, 2,
219 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
220 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
221 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
222 2, 2, 2, 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, 1, 2, 3, 4, 5,
232 6, 10, 11, 15, 16, 19, 20, 21, 22, 28
236 static const short yyprhs
[] = { 0,
237 0, 2, 4, 8, 11, 14, 17, 20, 23, 24,
238 31, 35, 39, 43, 47, 51, 55, 59, 63, 67,
239 71, 75, 79, 83, 87, 91, 95, 99, 100, 105,
240 106, 111, 112, 113, 121, 123, 125, 127, 128, 133
243 static const short yyrhs
[] = { 35,
244 0, 36, 0, 35, 9, 36, 0, 24, 36, 0,
245 29, 36, 0, 23, 36, 0, 30, 36, 0, 31,
246 5, 0, 0, 31, 5, 37, 32, 42, 33, 0,
247 32, 35, 33, 0, 36, 25, 36, 0, 36, 26,
248 36, 0, 36, 27, 36, 0, 36, 23, 36, 0,
249 36, 24, 36, 0, 36, 21, 36, 0, 36, 22,
250 36, 0, 36, 15, 36, 0, 36, 16, 36, 0,
251 36, 19, 36, 0, 36, 20, 36, 0, 36, 17,
252 36, 0, 36, 18, 36, 0, 36, 14, 36, 0,
253 36, 13, 36, 0, 36, 12, 36, 0, 0, 36,
254 11, 38, 36, 0, 0, 36, 10, 39, 36, 0,
255 0, 0, 36, 7, 40, 36, 8, 41, 36, 0,
256 3, 0, 4, 0, 5, 0, 0, 32, 42, 33,
263 static const short yyrline
[] = { 0,
264 218, 228, 229, 236, 241, 244, 246, 249, 253, 255,
265 260, 265, 278, 295, 308, 314, 320, 326, 332, 335,
266 338, 345, 352, 359, 366, 369, 372, 375, 378, 381,
267 384, 387, 389, 392, 395, 397, 399, 407, 409, 422
272 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
274 static const char * const yytname
[] = { "$","error","$undefined.","INT","CHAR",
275 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
276 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
277 "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL
281 static const short yyr1
[] = { 0,
282 34, 35, 35, 36, 36, 36, 36, 36, 37, 36,
283 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
284 36, 36, 36, 36, 36, 36, 36, 38, 36, 39,
285 36, 40, 41, 36, 36, 36, 36, 42, 42, 42
288 static const short yyr2
[] = { 0,
289 1, 1, 3, 2, 2, 2, 2, 2, 0, 6,
290 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
291 3, 3, 3, 3, 3, 3, 3, 0, 4, 0,
292 4, 0, 0, 7, 1, 1, 1, 0, 4, 2
295 static const short yydefact
[] = { 0,
296 35, 36, 37, 0, 0, 0, 0, 0, 0, 1,
297 2, 6, 4, 5, 7, 8, 0, 0, 32, 30,
298 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
299 0, 0, 0, 0, 0, 0, 0, 0, 11, 3,
300 0, 0, 0, 27, 26, 25, 19, 20, 23, 24,
301 21, 22, 17, 18, 15, 16, 12, 13, 14, 38,
302 0, 31, 29, 38, 38, 0, 33, 40, 0, 10,
303 0, 38, 34, 39, 0, 0, 0
306 static const short yydefgoto
[] = { 75,
307 10, 11, 38, 43, 42, 41, 71, 66
310 static const short yypact
[] = { 12,
311 -32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4,
312 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768,
313 -32768, 12, 12, 12, 12, 12, 12, 12, 12, 12,
314 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79,
315 12, 12, 12, 110, 124, 137, 148, 148, 155, 155,
316 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2,
317 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768,
318 12, 2, 79,-32768, 63, 188,-32768
321 static const short yypgoto
[] = {-32768,
322 180, -4,-32768,-32768,-32768,-32768,-32768, -60
329 static const short yytable
[] = { 12,
330 13, 14, 15, 68, 69, 16, 64, 35, 36, 37,
331 -9, 74, 18, 40, 1, 2, 3, 44, 45, 46,
332 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
333 57, 58, 59, 65, 4, 5, 61, 62, 63, 18,
334 6, 7, 8, 9, 21, 22, 23, 24, 25, 26,
335 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
336 37, 60, 76, 39, 19, 67, 73, 20, 21, 22,
337 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
338 33, 34, 35, 36, 37, 19, 70, 72, 20, 21,
339 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
340 32, 33, 34, 35, 36, 37, 22, 23, 24, 25,
341 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
342 36, 37, 23, 24, 25, 26, 27, 28, 29, 30,
343 31, 32, 33, 34, 35, 36, 37, 24, 25, 26,
344 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
345 37, 25, 26, 27, 28, 29, 30, 31, 32, 33,
346 34, 35, 36, 37, 27, 28, 29, 30, 31, 32,
347 33, 34, 35, 36, 37, 31, 32, 33, 34, 35,
348 36, 37, 33, 34, 35, 36, 37, 77, 17
351 static const short yycheck
[] = { 4,
352 5, 6, 7, 64, 65, 5, 5, 25, 26, 27,
353 32, 72, 9, 18, 3, 4, 5, 22, 23, 24,
354 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
355 35, 36, 37, 32, 23, 24, 41, 42, 43, 9,
356 29, 30, 31, 32, 11, 12, 13, 14, 15, 16,
357 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
358 27, 32, 0, 33, 7, 8, 71, 10, 11, 12,
359 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
360 23, 24, 25, 26, 27, 7, 33, 33, 10, 11,
361 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
362 22, 23, 24, 25, 26, 27, 12, 13, 14, 15,
363 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
364 26, 27, 13, 14, 15, 16, 17, 18, 19, 20,
365 21, 22, 23, 24, 25, 26, 27, 14, 15, 16,
366 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
367 27, 15, 16, 17, 18, 19, 20, 21, 22, 23,
368 24, 25, 26, 27, 17, 18, 19, 20, 21, 22,
369 23, 24, 25, 26, 27, 21, 22, 23, 24, 25,
370 26, 27, 23, 24, 25, 26, 27, 0, 9
372 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
373 #line 3 "/usr/cygnus/gnupro-98r1/share/bison.simple"
375 /* Skeleton output parser for bison,
376 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
378 This program is free software; you can redistribute it and/or modify
379 it under the terms of the GNU General Public License as published by
380 the Free Software Foundation; either version 2, or (at your option)
383 This program is distributed in the hope that it will be useful,
384 but WITHOUT ANY WARRANTY; without even the implied warranty of
385 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
386 GNU General Public License for more details.
388 You should have received a copy of the GNU General Public License
389 along with this program; if not, write to the Free Software
390 Foundation, 59 Temple Place - Suite 330,
391 Boston, MA 02111-1307, USA. */
393 /* As a special exception, when this file is copied by Bison into a
394 Bison output file, you may use that output file without restriction.
395 This special exception was added by the Free Software Foundation
396 in version 1.24 of Bison. */
400 #define alloca __builtin_alloca
401 #else /* not GNU C. */
402 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
404 #else /* not sparc */
405 #if defined (MSDOS) && !defined (__TURBOC__)
407 #else /* not MSDOS, or __TURBOC__ */
411 #else /* not MSDOS, __TURBOC__, or _AIX */
415 void *alloca (unsigned int);
417 #else /* not __cplusplus */
419 #endif /* not __cplusplus */
421 #endif /* not _AIX */
422 #endif /* not MSDOS, or __TURBOC__ */
423 #endif /* not sparc. */
424 #endif /* not GNU C. */
425 #endif /* alloca not defined. */
427 /* This is the parser code that is written into each bison parser
428 when the %semantic_parser declaration is not specified in the grammar.
429 It was written by Richard Stallman by simplifying the hairy parser
430 used when %semantic_parser is specified. */
432 /* Note: there must be only one dollar sign in this file.
433 It is replaced by the list of actions, each action
434 as one case of the switch. */
436 #define yyerrok (yyerrstatus = 0)
437 #define yyclearin (yychar = YYEMPTY)
440 #define YYACCEPT return(0)
441 #define YYABORT return(1)
442 #define YYERROR goto yyerrlab1
443 /* Like YYERROR except do call yyerror.
444 This remains here temporarily to ease the
445 transition to the new meaning of YYERROR, for GCC.
446 Once GCC version 2 has supplanted version 1, this can go. */
447 #define YYFAIL goto yyerrlab
448 #define YYRECOVERING() (!!yyerrstatus)
449 #define YYBACKUP(token, value) \
451 if (yychar == YYEMPTY && yylen == 1) \
452 { yychar = (token), yylval = (value); \
453 yychar1 = YYTRANSLATE (yychar); \
458 { yyerror ("syntax error: cannot back up"); YYERROR; } \
462 #define YYERRCODE 256
465 #define YYLEX yylex()
471 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
473 #define YYLEX yylex(&yylval, &yylloc)
475 #else /* not YYLSP_NEEDED */
477 #define YYLEX yylex(&yylval, YYLEX_PARAM)
479 #define YYLEX yylex(&yylval)
481 #endif /* not YYLSP_NEEDED */
484 /* If nonreentrant, generate the variables here */
488 int yychar
; /* the lookahead symbol */
489 YYSTYPE yylval
; /* the semantic value of the */
490 /* lookahead symbol */
493 YYLTYPE yylloc
; /* location data for the lookahead */
497 int yynerrs
; /* number of parse errors so far */
498 #endif /* not YYPURE */
501 int yydebug
; /* nonzero means print parse trace */
502 /* Since this is uninitialized, it does not stop multiple parsers
506 /* YYINITDEPTH indicates the initial size of the parser's stacks */
509 #define YYINITDEPTH 200
512 /* YYMAXDEPTH is the maximum size the stacks can grow to
513 (effective only if the built-in stack extension method is used). */
520 #define YYMAXDEPTH 10000
523 /* Prevent warning if -Wstrict-prototypes. */
528 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
529 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
530 #else /* not GNU C or C++ */
533 /* This is the most reliable way to avoid incompatibilities
534 in available built-in functions on various systems. */
536 __yy_memcpy (to
, from
, count
)
541 register char *f
= from
;
542 register char *t
= to
;
543 register int i
= count
;
549 #else /* __cplusplus */
551 /* This is the most reliable way to avoid incompatibilities
552 in available built-in functions on various systems. */
554 __yy_memcpy (char *to
, char *from
, int count
)
556 register char *f
= from
;
557 register char *t
= to
;
558 register int i
= count
;
567 #line 196 "/usr/cygnus/gnupro-98r1/share/bison.simple"
569 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
570 into yyparse. The argument should have type void *.
571 It should actually point to an object.
572 Grammar actions can access the variable by casting it
573 to the proper pointer type. */
577 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
578 #define YYPARSE_PARAM_DECL
579 #else /* not __cplusplus */
580 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
581 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
582 #endif /* not __cplusplus */
583 #else /* not YYPARSE_PARAM */
584 #define YYPARSE_PARAM_ARG
585 #define YYPARSE_PARAM_DECL
586 #endif /* not YYPARSE_PARAM */
589 yyparse(YYPARSE_PARAM_ARG
)
592 register int yystate
;
594 register short *yyssp
;
595 register YYSTYPE
*yyvsp
;
596 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
597 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
599 short yyssa
[YYINITDEPTH
]; /* the state stack */
600 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
602 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
603 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
606 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
607 YYLTYPE
*yyls
= yylsa
;
610 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
612 #define YYPOPSTACK (yyvsp--, yyssp--)
615 int yystacksize
= YYINITDEPTH
;
626 YYSTYPE yyval
; /* the variable used to return */
627 /* semantic values from the action */
634 fprintf(stderr
, "Starting parse\n");
640 yychar
= YYEMPTY
; /* Cause a token to be read. */
642 /* Initialize stack pointers.
643 Waste one element of value and location stack
644 so that they stay on the same level as the state stack.
645 The wasted elements are never initialized. */
653 /* Push a new state, which is found in yystate . */
654 /* In all cases, when you get here, the value and location stacks
655 have just been pushed. so pushing a state here evens the stacks. */
660 if (yyssp
>= yyss
+ yystacksize
- 1)
662 /* Give user a chance to reallocate the stack */
663 /* Use copies of these so that the &'s don't force the real ones into memory. */
664 YYSTYPE
*yyvs1
= yyvs
;
667 YYLTYPE
*yyls1
= yyls
;
670 /* Get the current used size of the three stacks, in elements. */
671 int size
= yyssp
- yyss
+ 1;
674 /* Each stack pointer address is followed by the size of
675 the data in use in that stack, in bytes. */
677 /* This used to be a conditional around just the two extra args,
678 but that might be undefined if yyoverflow is a macro. */
679 yyoverflow("parser stack overflow",
680 &yyss1
, size
* sizeof (*yyssp
),
681 &yyvs1
, size
* sizeof (*yyvsp
),
682 &yyls1
, size
* sizeof (*yylsp
),
685 yyoverflow("parser stack overflow",
686 &yyss1
, size
* sizeof (*yyssp
),
687 &yyvs1
, size
* sizeof (*yyvsp
),
691 yyss
= yyss1
; yyvs
= yyvs1
;
695 #else /* no yyoverflow */
696 /* Extend the stack our own way. */
697 if (yystacksize
>= YYMAXDEPTH
)
699 yyerror("parser stack overflow");
703 if (yystacksize
> YYMAXDEPTH
)
704 yystacksize
= YYMAXDEPTH
;
705 yyss
= (short *) alloca (yystacksize
* sizeof (*yyssp
));
706 __yy_memcpy ((char *)yyss
, (char *)yyss1
, size
* sizeof (*yyssp
));
707 yyvs
= (YYSTYPE
*) alloca (yystacksize
* sizeof (*yyvsp
));
708 __yy_memcpy ((char *)yyvs
, (char *)yyvs1
, size
* sizeof (*yyvsp
));
710 yyls
= (YYLTYPE
*) alloca (yystacksize
* sizeof (*yylsp
));
711 __yy_memcpy ((char *)yyls
, (char *)yyls1
, size
* sizeof (*yylsp
));
713 #endif /* no yyoverflow */
715 yyssp
= yyss
+ size
- 1;
716 yyvsp
= yyvs
+ size
- 1;
718 yylsp
= yyls
+ size
- 1;
723 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
726 if (yyssp
>= yyss
+ yystacksize
- 1)
732 fprintf(stderr
, "Entering state %d\n", yystate
);
738 /* Do appropriate processing given the current state. */
739 /* Read a lookahead token if we need one and don't already have one. */
742 /* First try to decide what to do without reference to lookahead token. */
744 yyn
= yypact
[yystate
];
748 /* Not known => get a lookahead token if don't already have one. */
750 /* yychar is either YYEMPTY or YYEOF
751 or a valid token in external form. */
753 if (yychar
== YYEMPTY
)
757 fprintf(stderr
, "Reading a token: ");
762 /* Convert token to internal form (in yychar1) for indexing tables with */
764 if (yychar
<= 0) /* This means end of input. */
767 yychar
= YYEOF
; /* Don't call YYLEX any more */
771 fprintf(stderr
, "Now at end of input.\n");
776 yychar1
= YYTRANSLATE(yychar
);
781 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
782 /* Give the individual parser a way to print the precise meaning
783 of a token, for further debugging info. */
785 YYPRINT (stderr
, yychar
, yylval
);
787 fprintf (stderr
, ")\n");
793 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
798 /* yyn is what to do for this token type in this state.
799 Negative => reduce, -yyn is rule number.
800 Positive => shift, yyn is new state.
801 New state is final state => don't bother to shift,
803 0, or most negative number => error. */
818 /* Shift the lookahead token. */
822 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
825 /* Discard the token being shifted unless it is eof. */
834 /* count tokens shifted since error; after three, turn off error status. */
835 if (yyerrstatus
) yyerrstatus
--;
840 /* Do the default action for the current state. */
843 yyn
= yydefact
[yystate
];
847 /* Do a reduction. yyn is the number of a rule to reduce with. */
851 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
858 fprintf (stderr
, "Reducing via rule %d (line %d), ",
861 /* Print the symbols being reduced, and their result. */
862 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
863 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
864 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
874 expression_value
= yyvsp
[0].integer
.value
;
875 #ifdef TEST_EXP_READER
876 expression_signedp
= yyvsp
[0].integer
.signedp
;
883 pedwarn ("comma operator in operand of `#if'");
884 yyval
.integer
= yyvsp
[0].integer
; ;
888 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
889 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
;
890 if ((yyval
.integer
.value
& yyvsp
[0].integer
.value
& yyval
.integer
.signedp
) < 0)
891 integer_overflow (); ;
895 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
896 yyval
.integer
.signedp
= SIGNED
; ;
900 { yyval
.integer
= yyvsp
[0].integer
; ;
904 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
905 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
; ;
909 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
911 yyval
.integer
.signedp
= SIGNED
; ;
915 { keyword_parsing
= 1; ;
919 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
920 1, yyvsp
[-1].keywords
);
922 yyval
.integer
.signedp
= SIGNED
; ;
926 { yyval
.integer
= yyvsp
[-1].integer
; ;
930 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
931 if (yyval
.integer
.signedp
)
933 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
934 if (yyvsp
[-2].integer
.value
935 && (yyval
.integer
.value
/ yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
936 || (yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0))
940 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
941 * yyvsp
[0].integer
.value
); ;
945 { if (yyvsp
[0].integer
.value
== 0)
947 if (!skip_evaluation
)
948 error ("division by zero in #if");
949 yyvsp
[0].integer
.value
= 1;
951 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
952 if (yyval
.integer
.signedp
)
954 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
955 if ((yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0)
959 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
960 / yyvsp
[0].integer
.value
); ;
964 { if (yyvsp
[0].integer
.value
== 0)
966 if (!skip_evaluation
)
967 error ("division by zero in #if");
968 yyvsp
[0].integer
.value
= 1;
970 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
971 if (yyval
.integer
.signedp
)
972 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
974 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
975 % yyvsp
[0].integer
.value
); ;
979 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
+ yyvsp
[0].integer
.value
;
980 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
981 if (overflow_sum_sign (yyvsp
[-2].integer
.value
, yyvsp
[0].integer
.value
,
982 yyval
.integer
.value
, yyval
.integer
.signedp
))
983 integer_overflow (); ;
987 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
988 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
989 if (overflow_sum_sign (yyval
.integer
.value
, yyvsp
[0].integer
.value
,
990 yyvsp
[-2].integer
.value
, yyval
.integer
.signedp
))
991 integer_overflow (); ;
995 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
996 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
997 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
999 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1003 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
1004 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
1005 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1007 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1011 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
1012 yyval
.integer
.signedp
= SIGNED
; ;
1016 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
1017 yyval
.integer
.signedp
= SIGNED
; ;
1021 { yyval
.integer
.signedp
= SIGNED
;
1022 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1023 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
;
1025 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1026 <= yyvsp
[0].integer
.value
); ;
1030 { yyval
.integer
.signedp
= SIGNED
;
1031 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1032 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
;
1034 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1035 >= yyvsp
[0].integer
.value
); ;
1039 { yyval
.integer
.signedp
= SIGNED
;
1040 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1041 yyval
.integer
.value
= yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
;
1043 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1044 < yyvsp
[0].integer
.value
); ;
1048 { yyval
.integer
.signedp
= SIGNED
;
1049 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1050 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
;
1052 yyval
.integer
.value
= ((unsigned_HOST_WIDE_INT
) yyvsp
[-2].integer
.value
1053 > yyvsp
[0].integer
.value
); ;
1057 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
1058 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1062 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
1063 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1067 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
1068 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1072 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1076 { skip_evaluation
-= !yyvsp
[-3].integer
.value
;
1077 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
&& yyvsp
[0].integer
.value
);
1078 yyval
.integer
.signedp
= SIGNED
; ;
1082 { skip_evaluation
+= !!yyvsp
[-1].integer
.value
; ;
1086 { skip_evaluation
-= !!yyvsp
[-3].integer
.value
;
1087 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
|| yyvsp
[0].integer
.value
);
1088 yyval
.integer
.signedp
= SIGNED
; ;
1092 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1096 { skip_evaluation
+= !!yyvsp
[-4].integer
.value
- !yyvsp
[-4].integer
.value
; ;
1100 { skip_evaluation
-= !!yyvsp
[-6].integer
.value
;
1101 yyval
.integer
.value
= yyvsp
[-6].integer
.value
? yyvsp
[-3].integer
.value
: yyvsp
[0].integer
.value
;
1102 yyval
.integer
.signedp
= yyvsp
[-3].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1106 { yyval
.integer
= yylval
.integer
; ;
1110 { yyval
.integer
= yylval
.integer
; ;
1114 { if (warn_undef
&& !skip_evaluation
)
1115 warning ("`%.*s' is not defined",
1116 yyvsp
[0].name
.length
, yyvsp
[0].name
.address
);
1117 yyval
.integer
.value
= 0;
1118 yyval
.integer
.signedp
= SIGNED
; ;
1122 { yyval
.keywords
= 0; ;
1126 { struct arglist
*temp
;
1127 yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1128 yyval
.keywords
->next
= yyvsp
[-2].keywords
;
1129 yyval
.keywords
->name
= (U_CHAR
*) "(";
1130 yyval
.keywords
->length
= 1;
1131 temp
= yyval
.keywords
;
1132 while (temp
!= 0 && temp
->next
!= 0)
1134 temp
->next
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1135 temp
->next
->next
= yyvsp
[0].keywords
;
1136 temp
->next
->name
= (U_CHAR
*) ")";
1137 temp
->next
->length
= 1; ;
1141 { yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1142 yyval
.keywords
->name
= yyvsp
[-1].name
.address
;
1143 yyval
.keywords
->length
= yyvsp
[-1].name
.length
;
1144 yyval
.keywords
->next
= yyvsp
[0].keywords
; ;
1147 /* the action file gets copied in in place of this dollarsign */
1148 #line 498 "/usr/cygnus/gnupro-98r1/share/bison.simple"
1159 short *ssp1
= yyss
- 1;
1160 fprintf (stderr
, "state stack now");
1161 while (ssp1
!= yyssp
)
1162 fprintf (stderr
, " %d", *++ssp1
);
1163 fprintf (stderr
, "\n");
1173 yylsp
->first_line
= yylloc
.first_line
;
1174 yylsp
->first_column
= yylloc
.first_column
;
1175 yylsp
->last_line
= (yylsp
-1)->last_line
;
1176 yylsp
->last_column
= (yylsp
-1)->last_column
;
1181 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1182 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1186 /* Now "shift" the result of the reduction.
1187 Determine what state that goes to,
1188 based on the state we popped back to
1189 and the rule number reduced by. */
1193 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1194 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1195 yystate
= yytable
[yystate
];
1197 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1201 yyerrlab
: /* here on detecting error */
1204 /* If not already recovering from an error, report this error. */
1208 #ifdef YYERROR_VERBOSE
1209 yyn
= yypact
[yystate
];
1211 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1218 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1219 for (x
= (yyn
< 0 ? -yyn
: 0);
1220 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1221 if (yycheck
[x
+ yyn
] == x
)
1222 size
+= strlen(yytname
[x
]) + 15, count
++;
1223 msg
= (char *) malloc(size
+ 15);
1226 strcpy(msg
, "parse error");
1231 for (x
= (yyn
< 0 ? -yyn
: 0);
1232 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1233 if (yycheck
[x
+ yyn
] == x
)
1235 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1236 strcat(msg
, yytname
[x
]);
1245 yyerror ("parse error; also virtual memory exceeded");
1248 #endif /* YYERROR_VERBOSE */
1249 yyerror("parse error");
1253 yyerrlab1
: /* here on error raised explicitly by an action */
1255 if (yyerrstatus
== 3)
1257 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1259 /* return failure if at end of input */
1260 if (yychar
== YYEOF
)
1265 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1271 /* Else will try to reuse lookahead token
1272 after shifting the error token. */
1274 yyerrstatus
= 3; /* Each real token shifted decrements this */
1278 yyerrdefault
: /* current state does not do anything special for the error token. */
1281 /* This is wrong; only states that explicitly want error tokens
1282 should shift them. */
1283 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1284 if (yyn
) goto yydefault
;
1287 yyerrpop
: /* pop the current state because it cannot handle the error token */
1289 if (yyssp
== yyss
) YYABORT
;
1299 short *ssp1
= yyss
- 1;
1300 fprintf (stderr
, "Error: state stack now");
1301 while (ssp1
!= yyssp
)
1302 fprintf (stderr
, " %d", *++ssp1
);
1303 fprintf (stderr
, "\n");
1309 yyn
= yypact
[yystate
];
1314 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1333 fprintf(stderr
, "Shifting error token, ");
1347 /* During parsing of a C expression, the pointer to the next character
1348 is in this variable. */
1350 static char *lexptr
;
1352 /* Take care of parsing a number (anything that starts with a digit).
1353 Set yylval and return the token type; update lexptr.
1354 LEN is the number of characters in it. */
1356 /* maybe needs to actually deal with floating point numbers */
1362 register char *p
= lexptr
;
1364 register unsigned_HOST_WIDE_INT n
= 0, nd
, max_over_base
;
1365 register int base
= 10;
1366 register int len
= olen
;
1367 register int overflow
= 0;
1368 register int digit
, largest_digit
= 0;
1371 yylval
.integer
.signedp
= SIGNED
;
1375 if (len
>= 3 && (p
[1] == 'x' || p
[1] == 'X')) {
1382 max_over_base
= (unsigned_HOST_WIDE_INT
) -1 / base
;
1384 for (; len
> 0; len
--) {
1387 if (c
>= '0' && c
<= '9')
1389 else if (base
== 16 && c
>= 'a' && c
<= 'f')
1390 digit
= c
- 'a' + 10;
1391 else if (base
== 16 && c
>= 'A' && c
<= 'F')
1392 digit
= c
- 'A' + 10;
1394 /* `l' means long, and `u' means unsigned. */
1396 if (c
== 'l' || c
== 'L')
1398 if (!pedantic
< spec_long
)
1399 yyerror ("too many `l's in integer constant");
1402 else if (c
== 'u' || c
== 'U')
1404 if (! yylval
.integer
.signedp
)
1405 yyerror ("two `u's in integer constant");
1406 yylval
.integer
.signedp
= UNSIGNED
;
1409 if (c
== '.' || c
== 'e' || c
== 'E' || c
== 'p' || c
== 'P')
1410 yyerror ("Floating point numbers not allowed in #if expressions");
1412 char *buf
= (char *) alloca (p
- lexptr
+ 40);
1413 sprintf (buf
, "missing white space after number `%.*s'",
1414 (int) (p
- lexptr
- 1), lexptr
);
1423 /* Don't look for any more digits after the suffixes. */
1426 if (largest_digit
< digit
)
1427 largest_digit
= digit
;
1428 nd
= n
* base
+ digit
;
1429 overflow
|= (max_over_base
< n
) | (nd
< n
);
1433 if (base
<= largest_digit
)
1434 pedwarn ("integer constant contains digits beyond the radix");
1437 pedwarn ("integer constant out of range");
1439 /* If too big to be signed, consider it unsigned. */
1440 if (((HOST_WIDE_INT
) n
& yylval
.integer
.signedp
) < 0)
1443 warning ("integer constant is so large that it is unsigned");
1444 yylval
.integer
.signedp
= UNSIGNED
;
1448 yylval
.integer
.value
= n
;
1457 static struct token tokentab2
[] = {
1471 /* Read one token, getting characters through lexptr. */
1477 register int namelen
;
1478 register unsigned char *tokstart
;
1479 register struct token
*toktab
;
1485 tokstart
= (unsigned char *) lexptr
;
1487 /* See if it is a special token of length 2. */
1488 if (! keyword_parsing
)
1489 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1490 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1492 if (toktab
->token
== ERROR
)
1494 char *buf
= (char *) alloca (40);
1495 sprintf (buf
, "`%s' not allowed in operand of `#if'", toktab
->operator);
1498 return toktab
->token
;
1512 /* Capital L may start a wide-string or wide-character constant. */
1513 if (lexptr
[1] == '\'')
1517 mask
= MAX_WCHAR_TYPE_MASK
;
1520 if (lexptr
[1] == '"')
1524 mask
= MAX_WCHAR_TYPE_MASK
;
1525 goto string_constant
;
1531 mask
= MAX_CHAR_TYPE_MASK
;
1534 if (keyword_parsing
) {
1535 char *start_ptr
= lexptr
- 1;
1539 c
= parse_escape (&lexptr
, mask
);
1543 yylval
.name
.address
= tokstart
;
1544 yylval
.name
.length
= lexptr
- start_ptr
;
1548 /* This code for reading a character constant
1549 handles multicharacter constants and wide characters.
1550 It is mostly copied from c-lex.c. */
1552 register HOST_WIDE_INT result
= 0;
1553 register int num_chars
= 0;
1555 unsigned width
= MAX_CHAR_TYPE_SIZE
;
1557 #ifdef MULTIBYTE_CHARS
1558 int longest_char
= local_mb_cur_max ();
1559 char *token_buffer
= (char *) alloca (longest_char
);
1560 (void) local_mbtowc (NULL_PTR
, NULL_PTR
, 0);
1563 max_chars
= MAX_LONG_TYPE_SIZE
/ width
;
1565 width
= MAX_WCHAR_TYPE_SIZE
;
1571 if (c
== '\'' || c
== EOF
)
1577 c
= parse_escape (&lexptr
, mask
);
1581 #ifdef MULTIBYTE_CHARS
1585 for (i
= 1; i
<= longest_char
; ++i
)
1587 token_buffer
[i
- 1] = c
;
1588 char_len
= local_mbtowc (& wc
, token_buffer
, i
);
1595 /* mbtowc sometimes needs an extra char before accepting */
1600 /* Merge character into result; ignore excess chars. */
1601 for (i
= 1; i
<= char_len
; ++i
)
1605 if (width
< HOST_BITS_PER_INT
)
1606 result
= (result
<< width
)
1607 | (token_buffer
[i
- 1]
1608 & ((1 << width
) - 1));
1610 result
= token_buffer
[i
- 1];
1612 num_chars
+= char_len
;
1619 warning ("Ignoring invalid multibyte character");
1623 #endif /* ! MULTIBYTE_CHARS */
1628 if (chars_seen
== 1) /* only keep the first one */
1633 /* Merge character into result; ignore excess chars. */
1635 if (num_chars
<= max_chars
)
1637 if (width
< HOST_BITS_PER_INT
)
1638 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
1645 error ("malformatted character constant");
1646 else if (chars_seen
== 0)
1647 error ("empty character constant");
1648 else if (num_chars
> max_chars
)
1650 num_chars
= max_chars
;
1651 error ("character constant too long");
1653 else if (chars_seen
!= 1 && ! traditional
)
1654 warning ("multi-character character constant");
1656 /* If char type is signed, sign-extend the constant. */
1659 int num_bits
= num_chars
* width
;
1661 /* We already got an error; avoid invalid shift. */
1662 yylval
.integer
.value
= 0;
1663 else if (lookup ((U_CHAR
*) "__CHAR_UNSIGNED__",
1664 sizeof ("__CHAR_UNSIGNED__") - 1, -1)
1665 || ((result
>> (num_bits
- 1)) & 1) == 0)
1666 yylval
.integer
.value
1667 = result
& (~ (unsigned_HOST_WIDE_INT
) 0
1668 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1670 yylval
.integer
.value
1671 = result
| ~(~ (unsigned_HOST_WIDE_INT
) 0
1672 >> (HOST_BITS_PER_WIDE_INT
- num_bits
));
1676 yylval
.integer
.value
= result
;
1680 /* This is always a signed type. */
1681 yylval
.integer
.signedp
= SIGNED
;
1685 /* some of these chars are invalid in constant expressions;
1686 maybe do something about them later */
1710 if (keyword_parsing
)
1718 mask
= MAX_CHAR_TYPE_MASK
;
1720 if (keyword_parsing
) {
1721 char *start_ptr
= lexptr
;
1726 c
= parse_escape (&lexptr
, mask
);
1730 yylval
.name
.address
= tokstart
;
1731 yylval
.name
.length
= lexptr
- start_ptr
;
1734 yyerror ("string constants not allowed in #if expressions");
1738 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
1740 for (namelen
= 1; ; namelen
++) {
1741 int d
= tokstart
[namelen
];
1742 if (! ((is_idchar
[d
] || d
== '.')
1743 || ((d
== '-' || d
== '+')
1744 && (c
== 'e' || c
== 'E'
1745 || ((c
== 'p' || c
== 'P') && ! c89
))
1750 return parse_number (namelen
);
1753 /* It is a name. See how long it is. */
1755 if (keyword_parsing
) {
1756 for (namelen
= 0;; namelen
++) {
1757 if (is_space
[tokstart
[namelen
]])
1759 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1761 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1765 if (!is_idstart
[c
]) {
1766 yyerror ("Invalid token in expression");
1770 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1775 yylval
.name
.address
= tokstart
;
1776 yylval
.name
.length
= namelen
;
1781 /* Parse a C escape sequence. STRING_PTR points to a variable
1782 containing a pointer to the string to parse. That pointer
1783 is updated past the characters we use. The value of the
1784 escape sequence is returned.
1786 RESULT_MASK is used to mask out the result;
1787 an error is reported if bits are lost thereby.
1789 A negative value means the sequence \ newline was seen,
1790 which is supposed to be equivalent to nothing at all.
1792 If \ is followed by a null character, we return a negative
1793 value and leave the string pointer pointing at the null character.
1795 If \ is followed by 000, we return 0 and leave the string pointer
1796 after the zeros. A value of 0 does not mean end of string. */
1799 parse_escape (string_ptr
, result_mask
)
1801 HOST_WIDE_INT result_mask
;
1803 register int c
= *(*string_ptr
)++;
1813 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1818 return TARGET_NEWLINE
;
1840 register HOST_WIDE_INT i
= c
- '0';
1841 register int count
= 0;
1844 c
= *(*string_ptr
)++;
1845 if (c
>= '0' && c
<= '7')
1846 i
= (i
<< 3) + c
- '0';
1853 if (i
!= (i
& result_mask
))
1856 pedwarn ("octal escape sequence out of range");
1862 register unsigned_HOST_WIDE_INT i
= 0, overflow
= 0;
1863 register int digits_found
= 0, digit
;
1866 c
= *(*string_ptr
)++;
1867 if (c
>= '0' && c
<= '9')
1869 else if (c
>= 'a' && c
<= 'f')
1870 digit
= c
- 'a' + 10;
1871 else if (c
>= 'A' && c
<= 'F')
1872 digit
= c
- 'A' + 10;
1878 overflow
|= i
^ (i
<< 4 >> 4);
1879 i
= (i
<< 4) + digit
;
1883 yyerror ("\\x used with no following hex digits");
1884 if (overflow
| (i
!= (i
& result_mask
)))
1887 pedwarn ("hex escape sequence out of range");
1901 skip_evaluation
= 0;
1902 longjmp (parse_return_error
, 1);
1908 if (!skip_evaluation
&& pedantic
)
1909 pedwarn ("integer overflow in preprocessor expression");
1912 static HOST_WIDE_INT
1915 unsigned_HOST_WIDE_INT b
;
1917 /* It's unclear from the C standard whether shifts can overflow.
1918 The following code ignores overflow; perhaps a C standard
1919 interpretation ruling is needed. */
1920 if (b
>= HOST_BITS_PER_WIDE_INT
)
1923 return (unsigned_HOST_WIDE_INT
) a
->value
<< b
;
1926 static HOST_WIDE_INT
1929 unsigned_HOST_WIDE_INT b
;
1931 if (b
>= HOST_BITS_PER_WIDE_INT
)
1932 return a
->signedp
? a
->value
>> (HOST_BITS_PER_WIDE_INT
- 1) : 0;
1933 else if (a
->signedp
)
1934 return a
->value
>> b
;
1936 return (unsigned_HOST_WIDE_INT
) a
->value
>> b
;
1939 /* This page contains the entry point to this file. */
1941 /* Parse STRING as an expression, and complain if this fails
1942 to use up all of the contents of STRING.
1943 STRING may contain '\0' bytes; it is terminated by the first '\n'
1944 outside a string constant, so that we can diagnose '\0' properly.
1945 If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated.
1946 We do not support C comments. They should be removed before
1947 this function is called. */
1950 parse_c_expression (string
, warn_undefined
)
1955 warn_undef
= warn_undefined
;
1957 /* if there is some sort of scanning error, just return 0 and assume
1958 the parsing routine has printed an error message somewhere.
1959 there is surely a better thing to do than this. */
1960 if (setjmp (parse_return_error
))
1963 if (yyparse () != 0)
1966 if (*lexptr
!= '\n')
1967 error ("Junk after end of expression.");
1969 return expression_value
; /* set by yyparse () */
1972 #ifdef TEST_EXP_READER
1981 int main
PROTO((int, char **));
1982 static void initialize_random_junk
PROTO((void));
1983 static void print_unsigned_host_wide_int
PROTO((unsigned_HOST_WIDE_INT
));
1985 /* Main program for testing purposes. */
1993 unsigned_HOST_WIDE_INT u
;
1995 pedantic
= 1 < argc
;
1996 traditional
= 2 < argc
;
2000 initialize_random_junk ();
2003 printf ("enter expression: ");
2005 while ((buf
[n
] = c
= getchar ()) != '\n' && c
!= EOF
)
2009 parse_c_expression (buf
, 1);
2010 printf ("parser returned ");
2011 u
= (unsigned_HOST_WIDE_INT
) expression_value
;
2012 if (expression_value
< 0 && expression_signedp
) {
2019 print_unsigned_host_wide_int (u
);
2020 if (! expression_signedp
)
2029 print_unsigned_host_wide_int (u
)
2030 unsigned_HOST_WIDE_INT u
;
2033 print_unsigned_host_wide_int (u
/ 10);
2034 putchar ('0' + (int) (u
% 10));
2038 /* table to tell if char can be part of a C identifier. */
2039 unsigned char is_idchar
[256];
2040 /* table to tell if char can be first char of a c identifier. */
2041 unsigned char is_idstart
[256];
2042 /* table to tell if c is horizontal or vertical space. */
2043 unsigned char is_space
[256];
2046 * initialize random junk in the hash table and maybe other places
2049 initialize_random_junk ()
2054 * Set up is_idchar and is_idstart tables. These should be
2055 * faster than saying (is_alpha (c) || c == '_'), etc.
2056 * Must do set up these things before calling any routines tthat
2059 for (i
= 'a'; i
<= 'z'; i
++) {
2060 ++is_idchar
[i
- 'a' + 'A'];
2062 ++is_idstart
[i
- 'a' + 'A'];
2065 for (i
= '0'; i
<= '9'; i
++)
2081 error
VPROTO ((char * msg
, ...))
2083 #ifndef ANSI_PROTOTYPES
2088 VA_START (args
, msg
);
2090 #ifndef ANSI_PROTOTYPES
2091 msg
= va_arg (args
, char *);
2094 fprintf (stderr
, "error: ");
2095 vfprintf (stderr
, msg
, args
);
2096 fprintf (stderr
, "\n");
2101 pedwarn
VPROTO ((char * msg
, ...))
2103 #ifndef ANSI_PROTOTYPES
2108 VA_START (args
, msg
);
2110 #ifndef ANSI_PROTOTYPES
2111 msg
= va_arg (args
, char *);
2114 fprintf (stderr
, "pedwarn: ");
2115 vfprintf (stderr
, msg
, args
);
2116 fprintf (stderr
, "\n");
2121 warning
VPROTO ((char * msg
, ...))
2123 #ifndef ANSI_PROTOTYPES
2128 VA_START (args
, msg
);
2130 #ifndef ANSI_PROTOTYPES
2131 msg
= va_arg (args
, char *);
2134 fprintf (stderr
, "warning: ");
2135 vfprintf (stderr
, msg
, args
);
2136 fprintf (stderr
, "\n");
2141 check_assertion (name
, sym_length
, tokens_specified
, tokens
)
2144 int tokens_specified
;
2145 struct arglist
*tokens
;
2151 lookup (name
, len
, hash
)
2156 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);
2163 return (PTR
) malloc (size
);