2 /* A Bison parser, made from cexp.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
28 /* #define YYDEBUG 1 */
30 #ifdef MULTIBYTE_CHARS
33 #endif /* MULTIBYTE_CHARS */
35 typedef unsigned char U_CHAR
;
37 /* This is used for communicating lists of keywords with cccp.c. */
45 HOST_WIDEST_INT parse_c_expression
PARAMS ((char *, int));
47 static int yylex
PARAMS ((void));
48 static void yyerror
PARAMS ((const char *, ...))
49 ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN
;
50 static HOST_WIDEST_INT expression_value
;
51 #ifdef TEST_EXP_READER
52 static int expression_signedp
;
55 static jmp_buf parse_return_error
;
57 /* Nonzero means count most punctuation as part of a name. */
58 static int keyword_parsing
= 0;
60 /* Nonzero means do not evaluate this expression.
61 This is a count, since unevaluated expressions can nest. */
62 static int skip_evaluation
;
64 /* Nonzero means warn if undefined identifiers are evaluated. */
65 static int warn_undef
;
67 /* some external tables of character types */
68 extern unsigned char is_idstart
[], is_idchar
[], is_space
[];
70 /* Flag for -pedantic. */
73 /* Flag for -traditional. */
74 extern int traditional
;
76 /* Flag for -lang-c89. */
79 #ifndef CHAR_TYPE_SIZE
80 #define CHAR_TYPE_SIZE BITS_PER_UNIT
84 #define INT_TYPE_SIZE BITS_PER_WORD
87 #ifndef LONG_TYPE_SIZE
88 #define LONG_TYPE_SIZE BITS_PER_WORD
91 #ifndef WCHAR_TYPE_SIZE
92 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
95 #ifndef MAX_CHAR_TYPE_SIZE
96 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
99 #ifndef MAX_INT_TYPE_SIZE
100 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
103 #ifndef MAX_LONG_TYPE_SIZE
104 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
107 #ifndef MAX_WCHAR_TYPE_SIZE
108 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
111 #define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \
112 ? (~ (~ (HOST_WIDEST_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
113 : ~ (HOST_WIDEST_INT) 0)
115 #define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDEST_INT \
116 ? ~ (~ (HOST_WIDEST_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
117 : ~ (HOST_WIDEST_INT) 0)
119 /* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
120 Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
121 Suppose SIGNEDP is negative if the result is signed, zero if unsigned.
122 Then this yields nonzero if overflow occurred during the addition.
123 Overflow occurs if A and B have the same sign, but A and SUM differ in sign,
124 and SIGNEDP is negative.
125 Use `^' to test whether signs differ, and `< 0' to isolate the sign. */
126 #define overflow_sum_sign(a, b, sum, signedp) \
127 ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0)
131 HOST_WIDEST_INT parse_escape
PARAMS ((char **, HOST_WIDEST_INT
));
132 int check_assertion
PARAMS ((U_CHAR
*, int, int, struct arglist
*));
133 struct hashnode
*lookup
PARAMS ((U_CHAR
*, int, int));
134 void error
PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1
;
135 void verror
PARAMS ((const char *, va_list));
136 void pedwarn
PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1
;
137 void warning
PARAMS ((const char *, ...)) ATTRIBUTE_PRINTF_1
;
139 static int parse_number
PARAMS ((int));
140 static HOST_WIDEST_INT left_shift
PARAMS ((struct constant
*, unsigned HOST_WIDEST_INT
));
141 static HOST_WIDEST_INT right_shift
PARAMS ((struct constant
*, unsigned HOST_WIDEST_INT
));
142 static void integer_overflow
PARAMS ((void));
144 /* `signedp' values */
150 struct constant
{HOST_WIDEST_INT value
; int signedp
;} integer
;
151 struct name
{U_CHAR
*address
; int length
;} name
;
152 struct arglist
*keywords
;
165 #define YYFLAG -32768
168 #define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 43)
170 static const char yytranslate
[] = { 0,
171 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
174 2, 2, 29, 2, 31, 2, 27, 14, 2, 32,
175 33, 25, 23, 9, 24, 2, 26, 2, 2, 2,
176 2, 2, 2, 2, 2, 2, 2, 8, 2, 17,
177 2, 18, 7, 2, 2, 2, 2, 2, 2, 2,
178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
180 2, 2, 2, 13, 2, 2, 2, 2, 2, 2,
181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
183 2, 2, 2, 12, 2, 30, 2, 2, 2, 2,
184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
190 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
196 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
197 10, 11, 15, 16, 19, 20, 21, 22, 28
201 static const short yyprhs
[] = { 0,
202 0, 2, 4, 8, 11, 14, 17, 20, 23, 24,
203 31, 35, 39, 43, 47, 51, 55, 59, 63, 67,
204 71, 75, 79, 83, 87, 91, 95, 99, 100, 105,
205 106, 111, 112, 113, 121, 123, 125, 127, 128, 133
208 static const short yyrhs
[] = { 35,
209 0, 36, 0, 35, 9, 36, 0, 24, 36, 0,
210 29, 36, 0, 23, 36, 0, 30, 36, 0, 31,
211 5, 0, 0, 31, 5, 37, 32, 42, 33, 0,
212 32, 35, 33, 0, 36, 25, 36, 0, 36, 26,
213 36, 0, 36, 27, 36, 0, 36, 23, 36, 0,
214 36, 24, 36, 0, 36, 21, 36, 0, 36, 22,
215 36, 0, 36, 15, 36, 0, 36, 16, 36, 0,
216 36, 19, 36, 0, 36, 20, 36, 0, 36, 17,
217 36, 0, 36, 18, 36, 0, 36, 14, 36, 0,
218 36, 13, 36, 0, 36, 12, 36, 0, 0, 36,
219 11, 38, 36, 0, 0, 36, 10, 39, 36, 0,
220 0, 0, 36, 7, 40, 36, 8, 41, 36, 0,
221 3, 0, 4, 0, 5, 0, 0, 32, 42, 33,
228 static const short yyrline
[] = { 0,
229 185, 195, 196, 203, 208, 211, 213, 216, 220, 222,
230 227, 232, 245, 262, 275, 281, 287, 293, 299, 302,
231 305, 312, 319, 326, 333, 336, 339, 342, 345, 348,
232 351, 354, 356, 359, 362, 364, 366, 374, 376, 389
237 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
239 static const char * const yytname
[] = { "$","error","$undefined.","INT","CHAR",
240 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
241 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
242 "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL
246 static const short yyr1
[] = { 0,
247 34, 35, 35, 36, 36, 36, 36, 36, 37, 36,
248 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
249 36, 36, 36, 36, 36, 36, 36, 38, 36, 39,
250 36, 40, 41, 36, 36, 36, 36, 42, 42, 42
253 static const short yyr2
[] = { 0,
254 1, 1, 3, 2, 2, 2, 2, 2, 0, 6,
255 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
256 3, 3, 3, 3, 3, 3, 3, 0, 4, 0,
257 4, 0, 0, 7, 1, 1, 1, 0, 4, 2
260 static const short yydefact
[] = { 0,
261 35, 36, 37, 0, 0, 0, 0, 0, 0, 1,
262 2, 6, 4, 5, 7, 8, 0, 0, 32, 30,
263 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
264 0, 0, 0, 0, 0, 0, 0, 0, 11, 3,
265 0, 0, 0, 27, 26, 25, 19, 20, 23, 24,
266 21, 22, 17, 18, 15, 16, 12, 13, 14, 38,
267 0, 31, 29, 38, 38, 0, 33, 40, 0, 10,
268 0, 38, 34, 39, 0, 0, 0
271 static const short yydefgoto
[] = { 75,
272 10, 11, 38, 43, 42, 41, 71, 66
275 static const short yypact
[] = { 12,
276 -32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4,
277 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768,
278 -32768, 12, 12, 12, 12, 12, 12, 12, 12, 12,
279 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79,
280 12, 12, 12, 110, 124, 137, 148, 148, 155, 155,
281 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2,
282 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768,
283 12, 2, 79,-32768, 63, 188,-32768
286 static const short yypgoto
[] = {-32768,
287 180, -4,-32768,-32768,-32768,-32768,-32768, -60
294 static const short yytable
[] = { 12,
295 13, 14, 15, 68, 69, 16, 64, 35, 36, 37,
296 -9, 74, 18, 40, 1, 2, 3, 44, 45, 46,
297 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
298 57, 58, 59, 65, 4, 5, 61, 62, 63, 18,
299 6, 7, 8, 9, 21, 22, 23, 24, 25, 26,
300 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
301 37, 60, 76, 39, 19, 67, 73, 20, 21, 22,
302 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
303 33, 34, 35, 36, 37, 19, 70, 72, 20, 21,
304 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
305 32, 33, 34, 35, 36, 37, 22, 23, 24, 25,
306 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
307 36, 37, 23, 24, 25, 26, 27, 28, 29, 30,
308 31, 32, 33, 34, 35, 36, 37, 24, 25, 26,
309 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
310 37, 25, 26, 27, 28, 29, 30, 31, 32, 33,
311 34, 35, 36, 37, 27, 28, 29, 30, 31, 32,
312 33, 34, 35, 36, 37, 31, 32, 33, 34, 35,
313 36, 37, 33, 34, 35, 36, 37, 77, 17
316 static const short yycheck
[] = { 4,
317 5, 6, 7, 64, 65, 5, 5, 25, 26, 27,
318 32, 72, 9, 18, 3, 4, 5, 22, 23, 24,
319 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
320 35, 36, 37, 32, 23, 24, 41, 42, 43, 9,
321 29, 30, 31, 32, 11, 12, 13, 14, 15, 16,
322 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
323 27, 32, 0, 33, 7, 8, 71, 10, 11, 12,
324 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
325 23, 24, 25, 26, 27, 7, 33, 33, 10, 11,
326 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
327 22, 23, 24, 25, 26, 27, 12, 13, 14, 15,
328 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
329 26, 27, 13, 14, 15, 16, 17, 18, 19, 20,
330 21, 22, 23, 24, 25, 26, 27, 14, 15, 16,
331 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
332 27, 15, 16, 17, 18, 19, 20, 21, 22, 23,
333 24, 25, 26, 27, 17, 18, 19, 20, 21, 22,
334 23, 24, 25, 26, 27, 21, 22, 23, 24, 25,
335 26, 27, 23, 24, 25, 26, 27, 0, 9
337 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
338 #line 3 "/usr/lib/bison.simple"
339 /* This file comes from bison-1.28. */
341 /* Skeleton output parser for bison,
342 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
344 This program is free software; you can redistribute it and/or modify
345 it under the terms of the GNU General Public License as published by
346 the Free Software Foundation; either version 2, or (at your option)
349 This program is distributed in the hope that it will be useful,
350 but WITHOUT ANY WARRANTY; without even the implied warranty of
351 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
352 GNU General Public License for more details.
354 You should have received a copy of the GNU General Public License
355 along with this program; if not, write to the Free Software
356 Foundation, Inc., 59 Temple Place - Suite 330,
357 Boston, MA 02111-1307, USA. */
359 /* As a special exception, when this file is copied by Bison into a
360 Bison output file, you may use that output file without restriction.
361 This special exception was added by the Free Software Foundation
362 in version 1.24 of Bison. */
364 /* This is the parser code that is written into each bison parser
365 when the %semantic_parser declaration is not specified in the grammar.
366 It was written by Richard Stallman by simplifying the hairy parser
367 used when %semantic_parser is specified. */
369 #ifndef YYSTACK_USE_ALLOCA
371 #define YYSTACK_USE_ALLOCA
372 #else /* alloca not defined */
374 #define YYSTACK_USE_ALLOCA
375 #define alloca __builtin_alloca
376 #else /* not GNU C. */
377 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
378 #define YYSTACK_USE_ALLOCA
380 #else /* not sparc */
381 /* We think this test detects Watcom and Microsoft C. */
382 /* This used to test MSDOS, but that is a bad idea
383 since that symbol is in the user namespace. */
384 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
385 #if 0 /* No need for malloc.h, which pollutes the namespace;
386 instead, just don't use alloca. */
389 #else /* not MSDOS, or __TURBOC__ */
391 /* I don't know what this was needed for, but it pollutes the namespace.
392 So I turned it off. rms, 2 May 1997. */
393 /* #include <malloc.h> */
395 #define YYSTACK_USE_ALLOCA
396 #else /* not MSDOS, or __TURBOC__, or _AIX */
398 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
399 and on HPUX 10. Eventually we can turn this on. */
400 #define YYSTACK_USE_ALLOCA
401 #define alloca __builtin_alloca
404 #endif /* not _AIX */
405 #endif /* not MSDOS, or __TURBOC__ */
406 #endif /* not sparc */
407 #endif /* not GNU C */
408 #endif /* alloca not defined */
409 #endif /* YYSTACK_USE_ALLOCA not defined */
411 #ifdef YYSTACK_USE_ALLOCA
412 #define YYSTACK_ALLOC alloca
414 #define YYSTACK_ALLOC malloc
417 /* Note: there must be only one dollar sign in this file.
418 It is replaced by the list of actions, each action
419 as one case of the switch. */
421 #define yyerrok (yyerrstatus = 0)
422 #define yyclearin (yychar = YYEMPTY)
425 #define YYACCEPT goto yyacceptlab
426 #define YYABORT goto yyabortlab
427 #define YYERROR goto yyerrlab1
428 /* Like YYERROR except do call yyerror.
429 This remains here temporarily to ease the
430 transition to the new meaning of YYERROR, for GCC.
431 Once GCC version 2 has supplanted version 1, this can go. */
432 #define YYFAIL goto yyerrlab
433 #define YYRECOVERING() (!!yyerrstatus)
434 #define YYBACKUP(token, value) \
436 if (yychar == YYEMPTY && yylen == 1) \
437 { yychar = (token), yylval = (value); \
438 yychar1 = YYTRANSLATE (yychar); \
443 { yyerror ("syntax error: cannot back up"); YYERROR; } \
447 #define YYERRCODE 256
450 #define YYLEX yylex()
456 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
458 #define YYLEX yylex(&yylval, &yylloc)
460 #else /* not YYLSP_NEEDED */
462 #define YYLEX yylex(&yylval, YYLEX_PARAM)
464 #define YYLEX yylex(&yylval)
466 #endif /* not YYLSP_NEEDED */
469 /* If nonreentrant, generate the variables here */
473 int yychar
; /* the lookahead symbol */
474 YYSTYPE yylval
; /* the semantic value of the */
475 /* lookahead symbol */
478 YYLTYPE yylloc
; /* location data for the lookahead */
482 int yynerrs
; /* number of parse errors so far */
483 #endif /* not YYPURE */
486 int yydebug
; /* nonzero means print parse trace */
487 /* Since this is uninitialized, it does not stop multiple parsers
491 /* YYINITDEPTH indicates the initial size of the parser's stacks */
494 #define YYINITDEPTH 200
497 /* YYMAXDEPTH is the maximum size the stacks can grow to
498 (effective only if the built-in stack extension method is used). */
505 #define YYMAXDEPTH 10000
508 /* Define __yy_memcpy. Note that the size argument
509 should be passed with type unsigned int, because that is what the non-GCC
510 definitions require. With GCC, __builtin_memcpy takes an arg
511 of type size_t, but it can handle unsigned int. */
513 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
514 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
515 #else /* not GNU C or C++ */
518 /* This is the most reliable way to avoid incompatibilities
519 in available built-in functions on various systems. */
521 __yy_memcpy (to
, from
, count
)
526 register char *f
= from
;
527 register char *t
= to
;
528 register int i
= count
;
534 #else /* __cplusplus */
536 /* This is the most reliable way to avoid incompatibilities
537 in available built-in functions on various systems. */
539 __yy_memcpy (char *to
, char *from
, unsigned int count
)
541 register char *t
= to
;
542 register char *f
= from
;
543 register int i
= count
;
552 #line 217 "/usr/lib/bison.simple"
554 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
555 into yyparse. The argument should have type void *.
556 It should actually point to an object.
557 Grammar actions can access the variable by casting it
558 to the proper pointer type. */
562 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
563 #define YYPARSE_PARAM_DECL
564 #else /* not __cplusplus */
565 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
566 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
567 #endif /* not __cplusplus */
568 #else /* not YYPARSE_PARAM */
569 #define YYPARSE_PARAM_ARG
570 #define YYPARSE_PARAM_DECL
571 #endif /* not YYPARSE_PARAM */
573 /* Prevent warning if -Wstrict-prototypes. */
576 int yyparse (void *);
583 yyparse(YYPARSE_PARAM_ARG
)
586 register int yystate
;
588 register short *yyssp
;
589 register YYSTYPE
*yyvsp
;
590 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
591 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
593 short yyssa
[YYINITDEPTH
]; /* the state stack */
594 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
596 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
597 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
600 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
601 YYLTYPE
*yyls
= yylsa
;
604 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
606 #define YYPOPSTACK (yyvsp--, yyssp--)
609 int yystacksize
= YYINITDEPTH
;
610 int yyfree_stacks
= 0;
621 YYSTYPE yyval
; /* the variable used to return */
622 /* semantic values from the action */
629 fprintf(stderr
, "Starting parse\n");
635 yychar
= YYEMPTY
; /* Cause a token to be read. */
637 /* Initialize stack pointers.
638 Waste one element of value and location stack
639 so that they stay on the same level as the state stack.
640 The wasted elements are never initialized. */
648 /* Push a new state, which is found in yystate . */
649 /* In all cases, when you get here, the value and location stacks
650 have just been pushed. so pushing a state here evens the stacks. */
655 if (yyssp
>= yyss
+ yystacksize
- 1)
657 /* Give user a chance to reallocate the stack */
658 /* Use copies of these so that the &'s don't force the real ones into memory. */
659 YYSTYPE
*yyvs1
= yyvs
;
662 YYLTYPE
*yyls1
= yyls
;
665 /* Get the current used size of the three stacks, in elements. */
666 int size
= yyssp
- yyss
+ 1;
669 /* Each stack pointer address is followed by the size of
670 the data in use in that stack, in bytes. */
672 /* This used to be a conditional around just the two extra args,
673 but that might be undefined if yyoverflow is a macro. */
674 yyoverflow("parser stack overflow",
675 &yyss1
, size
* sizeof (*yyssp
),
676 &yyvs1
, size
* sizeof (*yyvsp
),
677 &yyls1
, size
* sizeof (*yylsp
),
680 yyoverflow("parser stack overflow",
681 &yyss1
, size
* sizeof (*yyssp
),
682 &yyvs1
, size
* sizeof (*yyvsp
),
686 yyss
= yyss1
; yyvs
= yyvs1
;
690 #else /* no yyoverflow */
691 /* Extend the stack our own way. */
692 if (yystacksize
>= YYMAXDEPTH
)
694 yyerror("parser stack overflow");
706 if (yystacksize
> YYMAXDEPTH
)
707 yystacksize
= YYMAXDEPTH
;
708 #ifndef YYSTACK_USE_ALLOCA
711 yyss
= (short *) YYSTACK_ALLOC (yystacksize
* sizeof (*yyssp
));
712 __yy_memcpy ((char *)yyss
, (char *)yyss1
,
713 size
* (unsigned int) sizeof (*yyssp
));
714 yyvs
= (YYSTYPE
*) YYSTACK_ALLOC (yystacksize
* sizeof (*yyvsp
));
715 __yy_memcpy ((char *)yyvs
, (char *)yyvs1
,
716 size
* (unsigned int) sizeof (*yyvsp
));
718 yyls
= (YYLTYPE
*) YYSTACK_ALLOC (yystacksize
* sizeof (*yylsp
));
719 __yy_memcpy ((char *)yyls
, (char *)yyls1
,
720 size
* (unsigned int) sizeof (*yylsp
));
722 #endif /* no yyoverflow */
724 yyssp
= yyss
+ size
- 1;
725 yyvsp
= yyvs
+ size
- 1;
727 yylsp
= yyls
+ size
- 1;
732 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
735 if (yyssp
>= yyss
+ yystacksize
- 1)
741 fprintf(stderr
, "Entering state %d\n", yystate
);
747 /* Do appropriate processing given the current state. */
748 /* Read a lookahead token if we need one and don't already have one. */
751 /* First try to decide what to do without reference to lookahead token. */
753 yyn
= yypact
[yystate
];
757 /* Not known => get a lookahead token if don't already have one. */
759 /* yychar is either YYEMPTY or YYEOF
760 or a valid token in external form. */
762 if (yychar
== YYEMPTY
)
766 fprintf(stderr
, "Reading a token: ");
771 /* Convert token to internal form (in yychar1) for indexing tables with */
773 if (yychar
<= 0) /* This means end of input. */
776 yychar
= YYEOF
; /* Don't call YYLEX any more */
780 fprintf(stderr
, "Now at end of input.\n");
785 yychar1
= YYTRANSLATE(yychar
);
790 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
791 /* Give the individual parser a way to print the precise meaning
792 of a token, for further debugging info. */
794 YYPRINT (stderr
, yychar
, yylval
);
796 fprintf (stderr
, ")\n");
802 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
807 /* yyn is what to do for this token type in this state.
808 Negative => reduce, -yyn is rule number.
809 Positive => shift, yyn is new state.
810 New state is final state => don't bother to shift,
812 0, or most negative number => error. */
827 /* Shift the lookahead token. */
831 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
834 /* Discard the token being shifted unless it is eof. */
843 /* count tokens shifted since error; after three, turn off error status. */
844 if (yyerrstatus
) yyerrstatus
--;
849 /* Do the default action for the current state. */
852 yyn
= yydefact
[yystate
];
856 /* Do a reduction. yyn is the number of a rule to reduce with. */
860 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
867 fprintf (stderr
, "Reducing via rule %d (line %d), ",
870 /* Print the symbols being reduced, and their result. */
871 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
872 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
873 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
883 expression_value
= yyvsp
[0].integer
.value
;
884 #ifdef TEST_EXP_READER
885 expression_signedp
= yyvsp
[0].integer
.signedp
;
892 pedwarn ("comma operator in operand of `#if'");
893 yyval
.integer
= yyvsp
[0].integer
; ;
897 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
898 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
;
899 if ((yyval
.integer
.value
& yyvsp
[0].integer
.value
& yyval
.integer
.signedp
) < 0)
900 integer_overflow (); ;
904 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
905 yyval
.integer
.signedp
= SIGNED
; ;
909 { yyval
.integer
= yyvsp
[0].integer
; ;
913 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
914 yyval
.integer
.signedp
= yyvsp
[0].integer
.signedp
; ;
918 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
920 yyval
.integer
.signedp
= SIGNED
; ;
924 { keyword_parsing
= 1; ;
928 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
929 1, yyvsp
[-1].keywords
);
931 yyval
.integer
.signedp
= SIGNED
; ;
935 { yyval
.integer
= yyvsp
[-1].integer
; ;
939 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
940 if (yyval
.integer
.signedp
)
942 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
943 if (yyvsp
[-2].integer
.value
944 && (yyval
.integer
.value
/ yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
945 || (yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0))
949 yyval
.integer
.value
= ((unsigned HOST_WIDEST_INT
) yyvsp
[-2].integer
.value
950 * yyvsp
[0].integer
.value
); ;
954 { if (yyvsp
[0].integer
.value
== 0)
956 if (!skip_evaluation
)
957 error ("division by zero in #if");
958 yyvsp
[0].integer
.value
= 1;
960 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
961 if (yyval
.integer
.signedp
)
963 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
964 if ((yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0)
968 yyval
.integer
.value
= ((unsigned HOST_WIDEST_INT
) yyvsp
[-2].integer
.value
969 / yyvsp
[0].integer
.value
); ;
973 { if (yyvsp
[0].integer
.value
== 0)
975 if (!skip_evaluation
)
976 error ("division by zero in #if");
977 yyvsp
[0].integer
.value
= 1;
979 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
980 if (yyval
.integer
.signedp
)
981 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
983 yyval
.integer
.value
= ((unsigned HOST_WIDEST_INT
) yyvsp
[-2].integer
.value
984 % yyvsp
[0].integer
.value
); ;
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 (yyvsp
[-2].integer
.value
, yyvsp
[0].integer
.value
,
991 yyval
.integer
.value
, yyval
.integer
.signedp
))
992 integer_overflow (); ;
996 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
997 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
;
998 if (overflow_sum_sign (yyval
.integer
.value
, yyvsp
[0].integer
.value
,
999 yyvsp
[-2].integer
.value
, yyval
.integer
.signedp
))
1000 integer_overflow (); ;
1004 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
1005 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
1006 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1008 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1012 { yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
;
1013 if ((yyvsp
[0].integer
.value
& yyvsp
[0].integer
.signedp
) < 0)
1014 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
1016 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
1020 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
1021 yyval
.integer
.signedp
= SIGNED
; ;
1025 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
1026 yyval
.integer
.signedp
= SIGNED
; ;
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_WIDEST_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_WIDEST_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_WIDEST_INT
) yyvsp
[-2].integer
.value
1053 < yyvsp
[0].integer
.value
); ;
1057 { yyval
.integer
.signedp
= SIGNED
;
1058 if (yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
)
1059 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
;
1061 yyval
.integer
.value
= ((unsigned HOST_WIDEST_INT
) yyvsp
[-2].integer
.value
1062 > yyvsp
[0].integer
.value
); ;
1066 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
1067 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1071 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
1072 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1076 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
1077 yyval
.integer
.signedp
= yyvsp
[-2].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1081 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1085 { skip_evaluation
-= !yyvsp
[-3].integer
.value
;
1086 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
&& yyvsp
[0].integer
.value
);
1087 yyval
.integer
.signedp
= SIGNED
; ;
1091 { skip_evaluation
+= !!yyvsp
[-1].integer
.value
; ;
1095 { skip_evaluation
-= !!yyvsp
[-3].integer
.value
;
1096 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
|| yyvsp
[0].integer
.value
);
1097 yyval
.integer
.signedp
= SIGNED
; ;
1101 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
1105 { skip_evaluation
+= !!yyvsp
[-4].integer
.value
- !yyvsp
[-4].integer
.value
; ;
1109 { skip_evaluation
-= !!yyvsp
[-6].integer
.value
;
1110 yyval
.integer
.value
= yyvsp
[-6].integer
.value
? yyvsp
[-3].integer
.value
: yyvsp
[0].integer
.value
;
1111 yyval
.integer
.signedp
= yyvsp
[-3].integer
.signedp
& yyvsp
[0].integer
.signedp
; ;
1115 { yyval
.integer
= yylval
.integer
; ;
1119 { yyval
.integer
= yylval
.integer
; ;
1123 { if (warn_undef
&& !skip_evaluation
)
1124 warning ("`%.*s' is not defined",
1125 yyvsp
[0].name
.length
, yyvsp
[0].name
.address
);
1126 yyval
.integer
.value
= 0;
1127 yyval
.integer
.signedp
= SIGNED
; ;
1131 { yyval
.keywords
= 0; ;
1135 { struct arglist
*temp
;
1136 yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1137 yyval
.keywords
->next
= yyvsp
[-2].keywords
;
1138 yyval
.keywords
->name
= (U_CHAR
*) "(";
1139 yyval
.keywords
->length
= 1;
1140 temp
= yyval
.keywords
;
1141 while (temp
!= 0 && temp
->next
!= 0)
1143 temp
->next
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1144 temp
->next
->next
= yyvsp
[0].keywords
;
1145 temp
->next
->name
= (U_CHAR
*) ")";
1146 temp
->next
->length
= 1; ;
1150 { yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1151 yyval
.keywords
->name
= yyvsp
[-1].name
.address
;
1152 yyval
.keywords
->length
= yyvsp
[-1].name
.length
;
1153 yyval
.keywords
->next
= yyvsp
[0].keywords
; ;
1156 /* the action file gets copied in in place of this dollarsign */
1157 #line 543 "/usr/lib/bison.simple"
1168 short *ssp1
= yyss
- 1;
1169 fprintf (stderr
, "state stack now");
1170 while (ssp1
!= yyssp
)
1171 fprintf (stderr
, " %d", *++ssp1
);
1172 fprintf (stderr
, "\n");
1182 yylsp
->first_line
= yylloc
.first_line
;
1183 yylsp
->first_column
= yylloc
.first_column
;
1184 yylsp
->last_line
= (yylsp
-1)->last_line
;
1185 yylsp
->last_column
= (yylsp
-1)->last_column
;
1190 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1191 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1195 /* Now "shift" the result of the reduction.
1196 Determine what state that goes to,
1197 based on the state we popped back to
1198 and the rule number reduced by. */
1202 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1203 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1204 yystate
= yytable
[yystate
];
1206 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1210 yyerrlab
: /* here on detecting error */
1213 /* If not already recovering from an error, report this error. */
1217 #ifdef YYERROR_VERBOSE
1218 yyn
= yypact
[yystate
];
1220 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1227 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1228 for (x
= (yyn
< 0 ? -yyn
: 0);
1229 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1230 if (yycheck
[x
+ yyn
] == x
)
1231 size
+= strlen(yytname
[x
]) + 15, count
++;
1232 msg
= (char *) malloc(size
+ 15);
1235 strcpy(msg
, "parse error");
1240 for (x
= (yyn
< 0 ? -yyn
: 0);
1241 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1242 if (yycheck
[x
+ yyn
] == x
)
1244 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1245 strcat(msg
, yytname
[x
]);
1254 yyerror ("parse error; also virtual memory exceeded");
1257 #endif /* YYERROR_VERBOSE */
1258 yyerror("parse error");
1262 yyerrlab1
: /* here on error raised explicitly by an action */
1264 if (yyerrstatus
== 3)
1266 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1268 /* return failure if at end of input */
1269 if (yychar
== YYEOF
)
1274 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1280 /* Else will try to reuse lookahead token
1281 after shifting the error token. */
1283 yyerrstatus
= 3; /* Each real token shifted decrements this */
1287 yyerrdefault
: /* current state does not do anything special for the error token. */
1290 /* This is wrong; only states that explicitly want error tokens
1291 should shift them. */
1292 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1293 if (yyn
) goto yydefault
;
1296 yyerrpop
: /* pop the current state because it cannot handle the error token */
1298 if (yyssp
== yyss
) YYABORT
;
1308 short *ssp1
= yyss
- 1;
1309 fprintf (stderr
, "Error: state stack now");
1310 while (ssp1
!= yyssp
)
1311 fprintf (stderr
, " %d", *++ssp1
);
1312 fprintf (stderr
, "\n");
1318 yyn
= yypact
[yystate
];
1323 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1342 fprintf(stderr
, "Shifting error token, ");
1354 /* YYACCEPT comes here. */
1366 /* YYABORT comes here. */
1380 /* During parsing of a C expression, the pointer to the next character
1381 is in this variable. */
1383 static char *lexptr
;
1385 /* Take care of parsing a number (anything that starts with a digit).
1386 Set yylval and return the token type; update lexptr.
1387 LEN is the number of characters in it. */
1389 /* maybe needs to actually deal with floating point numbers */
1395 register char *p
= lexptr
;
1397 register unsigned HOST_WIDEST_INT n
= 0, nd
, max_over_base
;
1398 register int base
= 10;
1399 register int len
= olen
;
1400 register int overflow
= 0;
1401 register int digit
, largest_digit
= 0;
1404 yylval
.integer
.signedp
= SIGNED
;
1408 if (len
>= 3 && (p
[1] == 'x' || p
[1] == 'X')) {
1415 max_over_base
= (unsigned HOST_WIDEST_INT
) -1 / base
;
1417 for (; len
> 0; len
--) {
1420 if (c
>= '0' && c
<= '9')
1422 else if (base
== 16 && c
>= 'a' && c
<= 'f')
1423 digit
= c
- 'a' + 10;
1424 else if (base
== 16 && c
>= 'A' && c
<= 'F')
1425 digit
= c
- 'A' + 10;
1427 /* `l' means long, and `u' means unsigned. */
1429 if (c
== 'l' || c
== 'L')
1431 if (!pedantic
< spec_long
)
1432 yyerror ("too many `l's in integer constant");
1435 else if (c
== 'u' || c
== 'U')
1437 if (! yylval
.integer
.signedp
)
1438 yyerror ("two `u's in integer constant");
1439 yylval
.integer
.signedp
= UNSIGNED
;
1442 if (c
== '.' || c
== 'e' || c
== 'E' || c
== 'p' || c
== 'P')
1443 yyerror ("Floating point numbers not allowed in #if expressions");
1445 yyerror ("missing white space after number `%.*s'",
1446 (int) (p
- lexptr
- 1), lexptr
);
1453 /* Don't look for any more digits after the suffixes. */
1456 if (largest_digit
< digit
)
1457 largest_digit
= digit
;
1458 nd
= n
* base
+ digit
;
1459 overflow
|= (max_over_base
< n
) | (nd
< n
);
1463 if (base
<= largest_digit
)
1464 pedwarn ("integer constant contains digits beyond the radix");
1467 pedwarn ("integer constant out of range");
1469 /* If too big to be signed, consider it unsigned. */
1470 if (((HOST_WIDEST_INT
) n
& yylval
.integer
.signedp
) < 0)
1473 warning ("integer constant is so large that it is unsigned");
1474 yylval
.integer
.signedp
= UNSIGNED
;
1478 yylval
.integer
.value
= n
;
1483 const char *operator;
1487 static struct token tokentab2
[] = {
1501 /* Read one token, getting characters through lexptr. */
1507 register int namelen
;
1508 register unsigned char *tokstart
;
1509 register struct token
*toktab
;
1511 HOST_WIDEST_INT mask
;
1515 tokstart
= (unsigned char *) lexptr
;
1517 /* See if it is a special token of length 2. */
1518 if (! keyword_parsing
)
1519 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1520 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1522 if (toktab
->token
== ERROR
)
1523 yyerror ("`%s' not allowed in operand of `#if'", toktab
->operator);
1524 return toktab
->token
;
1538 /* Capital L may start a wide-string or wide-character constant. */
1539 if (lexptr
[1] == '\'')
1543 mask
= MAX_WCHAR_TYPE_MASK
;
1546 if (lexptr
[1] == '"')
1550 mask
= MAX_WCHAR_TYPE_MASK
;
1551 goto string_constant
;
1557 mask
= MAX_CHAR_TYPE_MASK
;
1560 if (keyword_parsing
) {
1561 char *start_ptr
= lexptr
- 1;
1565 c
= parse_escape (&lexptr
, mask
);
1569 yylval
.name
.address
= tokstart
;
1570 yylval
.name
.length
= lexptr
- start_ptr
;
1574 /* This code for reading a character constant
1575 handles multicharacter constants and wide characters.
1576 It is mostly copied from c-lex.c. */
1578 register HOST_WIDEST_INT result
= 0;
1579 register int num_chars
= 0;
1581 unsigned width
= MAX_CHAR_TYPE_SIZE
;
1583 #ifdef MULTIBYTE_CHARS
1584 int longest_char
= local_mb_cur_max ();
1585 char *token_buffer
= (char *) alloca (longest_char
);
1586 (void) local_mbtowc (NULL_PTR
, NULL_PTR
, 0);
1589 max_chars
= MAX_LONG_TYPE_SIZE
/ width
;
1591 width
= MAX_WCHAR_TYPE_SIZE
;
1597 if (c
== '\'' || c
== EOF
)
1603 c
= parse_escape (&lexptr
, mask
);
1607 #ifdef MULTIBYTE_CHARS
1611 for (i
= 1; i
<= longest_char
; ++i
)
1613 token_buffer
[i
- 1] = c
;
1614 char_len
= local_mbtowc (& wc
, token_buffer
, i
);
1621 /* mbtowc sometimes needs an extra char before accepting */
1626 /* Merge character into result; ignore excess chars. */
1627 for (i
= 1; i
<= char_len
; ++i
)
1631 if (width
< HOST_BITS_PER_INT
)
1632 result
= (result
<< width
)
1633 | (token_buffer
[i
- 1]
1634 & ((1 << width
) - 1));
1636 result
= token_buffer
[i
- 1];
1638 num_chars
+= char_len
;
1645 warning ("Ignoring invalid multibyte character");
1649 #endif /* ! MULTIBYTE_CHARS */
1654 if (chars_seen
== 1) /* only keep the first one */
1659 /* Merge character into result; ignore excess chars. */
1661 if (num_chars
<= max_chars
)
1663 if (width
< HOST_BITS_PER_INT
)
1664 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
1671 error ("malformatted character constant");
1672 else if (chars_seen
== 0)
1673 error ("empty character constant");
1674 else if (num_chars
> max_chars
)
1676 num_chars
= max_chars
;
1677 error ("character constant too long");
1679 else if (chars_seen
!= 1 && ! traditional
)
1680 warning ("multi-character character constant");
1682 /* If char type is signed, sign-extend the constant. */
1685 int num_bits
= num_chars
* width
;
1687 /* We already got an error; avoid invalid shift. */
1688 yylval
.integer
.value
= 0;
1689 else if (lookup ((U_CHAR
*) "__CHAR_UNSIGNED__",
1690 sizeof ("__CHAR_UNSIGNED__") - 1, -1)
1691 || ((result
>> (num_bits
- 1)) & 1) == 0)
1692 yylval
.integer
.value
1693 = result
& (~ (unsigned HOST_WIDEST_INT
) 0
1694 >> (HOST_BITS_PER_WIDEST_INT
- num_bits
));
1696 yylval
.integer
.value
1697 = result
| ~(~ (unsigned HOST_WIDEST_INT
) 0
1698 >> (HOST_BITS_PER_WIDEST_INT
- num_bits
));
1702 yylval
.integer
.value
= result
;
1706 /* This is always a signed type. */
1707 yylval
.integer
.signedp
= SIGNED
;
1711 /* some of these chars are invalid in constant expressions;
1712 maybe do something about them later */
1736 if (keyword_parsing
)
1744 mask
= MAX_CHAR_TYPE_MASK
;
1746 if (keyword_parsing
) {
1747 char *start_ptr
= lexptr
;
1752 c
= parse_escape (&lexptr
, mask
);
1756 yylval
.name
.address
= tokstart
;
1757 yylval
.name
.length
= lexptr
- start_ptr
;
1760 yyerror ("string constants not allowed in #if expressions");
1764 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
1766 for (namelen
= 1; ; namelen
++) {
1767 int d
= tokstart
[namelen
];
1768 if (! ((is_idchar
[d
] || d
== '.')
1769 || ((d
== '-' || d
== '+')
1770 && (c
== 'e' || c
== 'E'
1771 || ((c
== 'p' || c
== 'P') && ! c89
))
1776 return parse_number (namelen
);
1779 /* It is a name. See how long it is. */
1781 if (keyword_parsing
) {
1782 for (namelen
= 0;; namelen
++) {
1783 if (is_space
[tokstart
[namelen
]])
1785 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1787 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1791 if (!is_idstart
[c
]) {
1792 yyerror ("Invalid token in expression");
1796 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1801 yylval
.name
.address
= tokstart
;
1802 yylval
.name
.length
= namelen
;
1807 /* Parse a C escape sequence. STRING_PTR points to a variable
1808 containing a pointer to the string to parse. That pointer
1809 is updated past the characters we use. The value of the
1810 escape sequence is returned.
1812 RESULT_MASK is used to mask out the result;
1813 an error is reported if bits are lost thereby.
1815 A negative value means the sequence \ newline was seen,
1816 which is supposed to be equivalent to nothing at all.
1818 If \ is followed by a null character, we return a negative
1819 value and leave the string pointer pointing at the null character.
1821 If \ is followed by 000, we return 0 and leave the string pointer
1822 after the zeros. A value of 0 does not mean end of string. */
1825 parse_escape (string_ptr
, result_mask
)
1827 HOST_WIDEST_INT result_mask
;
1829 register int c
= *(*string_ptr
)++;
1839 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1844 return TARGET_NEWLINE
;
1866 register HOST_WIDEST_INT i
= c
- '0';
1867 register int count
= 0;
1870 c
= *(*string_ptr
)++;
1871 if (c
>= '0' && c
<= '7')
1872 i
= (i
<< 3) + c
- '0';
1879 if (i
!= (i
& result_mask
))
1882 pedwarn ("octal escape sequence out of range");
1888 register unsigned HOST_WIDEST_INT i
= 0, overflow
= 0;
1889 register int digits_found
= 0, digit
;
1892 c
= *(*string_ptr
)++;
1893 if (c
>= '0' && c
<= '9')
1895 else if (c
>= 'a' && c
<= 'f')
1896 digit
= c
- 'a' + 10;
1897 else if (c
>= 'A' && c
<= 'F')
1898 digit
= c
- 'A' + 10;
1904 overflow
|= i
^ (i
<< 4 >> 4);
1905 i
= (i
<< 4) + digit
;
1909 yyerror ("\\x used with no following hex digits");
1910 if (overflow
| (i
!= (i
& result_mask
)))
1913 pedwarn ("hex escape sequence out of range");
1925 if (!skip_evaluation
&& pedantic
)
1926 pedwarn ("integer overflow in preprocessor expression");
1929 static HOST_WIDEST_INT
1932 unsigned HOST_WIDEST_INT b
;
1934 /* It's unclear from the C standard whether shifts can overflow.
1935 The following code ignores overflow; perhaps a C standard
1936 interpretation ruling is needed. */
1937 if (b
>= HOST_BITS_PER_WIDEST_INT
)
1940 return (unsigned HOST_WIDEST_INT
) a
->value
<< b
;
1943 static HOST_WIDEST_INT
1946 unsigned HOST_WIDEST_INT b
;
1948 if (b
>= HOST_BITS_PER_WIDEST_INT
)
1949 return a
->signedp
? a
->value
>> (HOST_BITS_PER_WIDEST_INT
- 1) : 0;
1950 else if (a
->signedp
)
1951 return a
->value
>> b
;
1953 return (unsigned HOST_WIDEST_INT
) a
->value
>> b
;
1956 /* This page contains the entry point to this file. */
1958 /* Parse STRING as an expression, and complain if this fails
1959 to use up all of the contents of STRING.
1960 STRING may contain '\0' bytes; it is terminated by the first '\n'
1961 outside a string constant, so that we can diagnose '\0' properly.
1962 If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated.
1963 We do not support C comments. They should be removed before
1964 this function is called. */
1967 parse_c_expression (string
, warn_undefined
)
1972 warn_undef
= warn_undefined
;
1974 /* if there is some sort of scanning error, just return 0 and assume
1975 the parsing routine has printed an error message somewhere.
1976 there is surely a better thing to do than this. */
1977 if (setjmp (parse_return_error
))
1980 if (yyparse () != 0)
1983 if (*lexptr
!= '\n')
1984 error ("Junk after end of expression.");
1986 return expression_value
; /* set by yyparse () */
1990 yyerror
VPARAMS ((const char * msgid
, ...))
1992 #ifndef ANSI_PROTOTYPES
1997 VA_START (args
, msgid
);
1999 #ifndef ANSI_PROTOTYPES
2000 msgid
= va_arg (args
, const char *);
2003 verror (msgid
, args
);
2005 skip_evaluation
= 0;
2006 longjmp (parse_return_error
, 1);
2010 #ifdef TEST_EXP_READER
2020 int main
PARAMS ((int, char **));
2021 static void initialize_random_junk
PARAMS ((void));
2022 static void print_unsigned_host_widest_int
PARAMS ((unsigned HOST_WIDEST_INT
));
2024 /* Main program for testing purposes. */
2032 unsigned HOST_WIDEST_INT u
;
2034 pedantic
= 1 < argc
;
2035 traditional
= 2 < argc
;
2040 initialize_random_junk ();
2043 printf ("enter expression: ");
2045 while ((buf
[n
] = c
= getchar ()) != '\n' && c
!= EOF
)
2049 parse_c_expression (buf
, 1);
2050 printf ("parser returned ");
2051 u
= (unsigned HOST_WIDEST_INT
) expression_value
;
2052 if (expression_value
< 0 && expression_signedp
) {
2059 print_unsigned_host_widest_int (u
);
2060 if (! expression_signedp
)
2069 print_unsigned_host_widest_int (u
)
2070 unsigned HOST_WIDEST_INT u
;
2073 print_unsigned_host_widest_int (u
/ 10);
2074 putchar ('0' + (int) (u
% 10));
2078 /* table to tell if char can be part of a C identifier. */
2079 unsigned char is_idchar
[256];
2080 /* table to tell if char can be first char of a c identifier. */
2081 unsigned char is_idstart
[256];
2082 /* table to tell if c is horizontal or vertical space. */
2083 unsigned char is_space
[256];
2086 * initialize random junk in the hash table and maybe other places
2089 initialize_random_junk ()
2094 * Set up is_idchar and is_idstart tables. These should be
2095 * faster than saying (is_alpha (c) || c == '_'), etc.
2096 * Must do set up these things before calling any routines tthat
2099 for (i
= 'a'; i
<= 'z'; i
++) {
2100 ++is_idchar
[TOUPPER(i
)];
2102 ++is_idstart
[TOUPPER(i
)];
2105 for (i
= '0'; i
<= '9'; i
++)
2121 error
VPARAMS ((char * msgid
, ...))
2123 #ifndef ANSI_PROTOTYPES
2128 VA_START (args
, msgid
);
2130 #ifndef ANSI_PROTOTYPES
2131 msgid
= va_arg (args
, char *);
2134 fprintf (stderr
, "error: ");
2135 vfprintf (stderr
, _(msgid
), args
);
2136 fprintf (stderr
, "\n");
2141 pedwarn
VPARAMS ((char * msgid
, ...))
2143 #ifndef ANSI_PROTOTYPES
2148 VA_START (args
, msgid
);
2150 #ifndef ANSI_PROTOTYPES
2151 msgid
= va_arg (args
, char *);
2154 fprintf (stderr
, "pedwarn: ");
2155 vfprintf (stderr
, _(msgid
), args
);
2156 fprintf (stderr
, "\n");
2161 warning
VPARAMS ((char * msgid
, ...))
2163 #ifndef ANSI_PROTOTYPES
2168 VA_START (args
, msgid
);
2170 #ifndef ANSI_PROTOTYPES
2171 msgid
= va_arg (args
, char *);
2174 fprintf (stderr
, "warning: ");
2175 vfprintf (stderr
, _(msgid
), args
);
2176 fprintf (stderr
, "\n");
2182 check_assertion (name
, sym_length
, tokens_specified
, tokens
)
2185 int tokens_specified
;
2186 struct arglist
*tokens
;
2192 lookup (name
, len
, hash
)
2197 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);
2204 return (PTR
) malloc (size
);