OSDN Git Service

Fix mips64vr4100-elf build failure.
[pf3gnuchains/gcc-fork.git] / gcc / cexp.c
1
2 /*  A Bison parser, made from cexp.y
3  by  GNU Bison version 1.25
4   */
5
6 #define YYBISON 1  /* Identify Bison output.  */
7
8 #define INT     258
9 #define CHAR    259
10 #define NAME    260
11 #define ERROR   261
12 #define OR      262
13 #define AND     263
14 #define EQUAL   264
15 #define NOTEQUAL        265
16 #define LEQ     266
17 #define GEQ     267
18 #define LSH     268
19 #define RSH     269
20 #define UNARY   270
21
22 #line 27 "cexp.y"
23
24 #include "config.h"
25 #ifdef __STDC__
26 # include <stdarg.h>
27 #else
28 # include <varargs.h>
29 #endif
30
31 #define PRINTF_PROTO(ARGS, m, n) PVPROTO (ARGS) ATTRIBUTE_PRINTF(m, n)
32
33 #define PRINTF_PROTO_1(ARGS) PRINTF_PROTO(ARGS, 1, 2)
34
35 #include "system.h"
36 #include <setjmp.h>
37 /* #define YYDEBUG 1 */
38
39 #ifdef MULTIBYTE_CHARS
40 #include <locale.h>
41 #endif
42
43 #include "gansidecl.h"
44
45 typedef unsigned char U_CHAR;
46
47 /* This is used for communicating lists of keywords with cccp.c.  */
48 struct arglist {
49   struct arglist *next;
50   U_CHAR *name;
51   int length;
52   int argno;
53 };
54
55 /* Find the largest host integer type and set its size and type.
56    Watch out: on some crazy hosts `long' is shorter than `int'.  */
57
58 #ifndef HOST_WIDE_INT
59 # if HAVE_INTTYPES_H
60 #  include <inttypes.h>
61 #  define HOST_WIDE_INT intmax_t
62 #  define unsigned_HOST_WIDE_INT uintmax_t
63 # else
64 #  if (HOST_BITS_PER_LONG <= HOST_BITS_PER_INT && HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_INT)
65 #   define HOST_WIDE_INT int
66 #  else
67 #  if (HOST_BITS_PER_LONGLONG <= HOST_BITS_PER_LONG || ! (defined LONG_LONG_MAX || defined LLONG_MAX))
68 #   define HOST_WIDE_INT long
69 #  else
70 #   define HOST_WIDE_INT long long
71 #  endif
72 #  endif
73 # endif
74 #endif
75
76 #ifndef unsigned_HOST_WIDE_INT
77 #define unsigned_HOST_WIDE_INT unsigned HOST_WIDE_INT
78 #endif
79
80 #ifndef CHAR_BIT
81 #define CHAR_BIT 8
82 #endif
83
84 #ifndef HOST_BITS_PER_WIDE_INT
85 #define HOST_BITS_PER_WIDE_INT (CHAR_BIT * sizeof (HOST_WIDE_INT))
86 #endif
87
88 HOST_WIDE_INT parse_c_expression PROTO((char *, int));
89
90 static int yylex PROTO((void));
91 static void yyerror PROTO((char *)) __attribute__ ((noreturn));
92 static HOST_WIDE_INT expression_value;
93 #ifdef TEST_EXP_READER
94 static int expression_signedp;
95 #endif
96
97 static jmp_buf parse_return_error;
98
99 /* Nonzero means count most punctuation as part of a name.  */
100 static int keyword_parsing = 0;
101
102 /* Nonzero means do not evaluate this expression.
103    This is a count, since unevaluated expressions can nest.  */
104 static int skip_evaluation;
105
106 /* Nonzero means warn if undefined identifiers are evaluated.  */
107 static int warn_undef;
108
109 /* some external tables of character types */
110 extern unsigned char is_idstart[], is_idchar[], is_space[];
111
112 /* Flag for -pedantic.  */
113 extern int pedantic;
114
115 /* Flag for -traditional.  */
116 extern int traditional;
117
118 /* Flag for -lang-c89.  */
119 extern int c89;
120
121 #ifndef CHAR_TYPE_SIZE
122 #define CHAR_TYPE_SIZE BITS_PER_UNIT
123 #endif
124
125 #ifndef INT_TYPE_SIZE
126 #define INT_TYPE_SIZE BITS_PER_WORD
127 #endif
128
129 #ifndef LONG_TYPE_SIZE
130 #define LONG_TYPE_SIZE BITS_PER_WORD
131 #endif
132
133 #ifndef WCHAR_TYPE_SIZE
134 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
135 #endif
136
137 #ifndef MAX_CHAR_TYPE_SIZE
138 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
139 #endif
140
141 #ifndef MAX_INT_TYPE_SIZE
142 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
143 #endif
144
145 #ifndef MAX_LONG_TYPE_SIZE
146 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
147 #endif
148
149 #ifndef MAX_WCHAR_TYPE_SIZE
150 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
151 #endif
152
153 #define MAX_CHAR_TYPE_MASK (MAX_CHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
154                             ? (~ (~ (HOST_WIDE_INT) 0 << MAX_CHAR_TYPE_SIZE)) \
155                             : ~ (HOST_WIDE_INT) 0)
156
157 #define MAX_WCHAR_TYPE_MASK (MAX_WCHAR_TYPE_SIZE < HOST_BITS_PER_WIDE_INT \
158                              ? ~ (~ (HOST_WIDE_INT) 0 << MAX_WCHAR_TYPE_SIZE) \
159                              : ~ (HOST_WIDE_INT) 0)
160
161 /* Suppose A1 + B1 = SUM1, using 2's complement arithmetic ignoring overflow.
162    Suppose A, B and SUM have the same respective signs as A1, B1, and SUM1.
163    Suppose SIGNEDP is negative if the result is signed, zero if unsigned.
164    Then this yields nonzero if overflow occurred during the addition.
165    Overflow occurs if A and B have the same sign, but A and SUM differ in sign,
166    and SIGNEDP is negative.
167    Use `^' to test whether signs differ, and `< 0' to isolate the sign.  */
168 #define overflow_sum_sign(a, b, sum, signedp) \
169         ((~((a) ^ (b)) & ((a) ^ (sum)) & (signedp)) < 0)
170
171 struct constant;
172
173 GENERIC_PTR xmalloc PROTO((size_t));
174 HOST_WIDE_INT parse_escape PROTO((char **, HOST_WIDE_INT));
175 int check_assertion PROTO((U_CHAR *, int, int, struct arglist *));
176 struct hashnode *lookup PROTO((U_CHAR *, int, int));
177 void error PRINTF_PROTO_1((char *, ...));
178 void pedwarn PRINTF_PROTO_1((char *, ...));
179 void warning PRINTF_PROTO_1((char *, ...));
180
181 static int parse_number PROTO((int));
182 static HOST_WIDE_INT left_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT));
183 static HOST_WIDE_INT right_shift PROTO((struct constant *, unsigned_HOST_WIDE_INT));
184 static void integer_overflow PROTO((void));
185
186 /* `signedp' values */
187 #define SIGNED (~0)
188 #define UNSIGNED 0
189
190 #line 251 "cexp.y"
191 typedef union {
192   struct constant {HOST_WIDE_INT value; int signedp;} integer;
193   struct name {U_CHAR *address; int length;} name;
194   struct arglist *keywords;
195 } YYSTYPE;
196 #include <stdio.h>
197
198 #ifndef __cplusplus
199 #ifndef __STDC__
200 #define const
201 #endif
202 #endif
203
204
205
206 #define YYFINAL         77
207 #define YYFLAG          -32768
208 #define YYNTBASE        34
209
210 #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)
211
212 static const char yytranslate[] = {     0,
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,     2,     2,     2,     2,     2,     2,     2,
216      2,     2,    29,     2,    31,     2,    27,    14,     2,    32,
217     33,    25,    23,     9,    24,     2,    26,     2,     2,     2,
218      2,     2,     2,     2,     2,     2,     2,     8,     2,    17,
219      2,    18,     7,     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,    13,     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,    12,     2,    30,     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,     2,     2,     2,     2,     2,
234      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
235      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
236      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
237      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
238      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
239      6,    10,    11,    15,    16,    19,    20,    21,    22,    28
240 };
241
242 #if YYDEBUG != 0
243 static const short yyprhs[] = {     0,
244      0,     2,     4,     8,    11,    14,    17,    20,    23,    24,
245     31,    35,    39,    43,    47,    51,    55,    59,    63,    67,
246     71,    75,    79,    83,    87,    91,    95,    99,   100,   105,
247    106,   111,   112,   113,   121,   123,   125,   127,   128,   133
248 };
249
250 static const short yyrhs[] = {    35,
251      0,    36,     0,    35,     9,    36,     0,    24,    36,     0,
252     29,    36,     0,    23,    36,     0,    30,    36,     0,    31,
253      5,     0,     0,    31,     5,    37,    32,    42,    33,     0,
254     32,    35,    33,     0,    36,    25,    36,     0,    36,    26,
255     36,     0,    36,    27,    36,     0,    36,    23,    36,     0,
256     36,    24,    36,     0,    36,    21,    36,     0,    36,    22,
257     36,     0,    36,    15,    36,     0,    36,    16,    36,     0,
258     36,    19,    36,     0,    36,    20,    36,     0,    36,    17,
259     36,     0,    36,    18,    36,     0,    36,    14,    36,     0,
260     36,    13,    36,     0,    36,    12,    36,     0,     0,    36,
261     11,    38,    36,     0,     0,    36,    10,    39,    36,     0,
262      0,     0,    36,     7,    40,    36,     8,    41,    36,     0,
263      3,     0,     4,     0,     5,     0,     0,    32,    42,    33,
264     42,     0,     5,    42,     0
265 };
266
267 #endif
268
269 #if YYDEBUG != 0
270 static const short yyrline[] = { 0,
271    281,   291,   292,   299,   304,   307,   309,   312,   316,   318,
272    323,   328,   341,   358,   371,   377,   383,   389,   395,   398,
273    401,   408,   415,   422,   429,   432,   435,   438,   441,   444,
274    447,   450,   452,   455,   458,   460,   462,   470,   472,   485
275 };
276 #endif
277
278
279 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
280
281 static const char * const yytname[] = {   "$","error","$undefined.","INT","CHAR",
282 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
283 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
284 "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords", NULL
285 };
286 #endif
287
288 static const short yyr1[] = {     0,
289     34,    35,    35,    36,    36,    36,    36,    36,    37,    36,
290     36,    36,    36,    36,    36,    36,    36,    36,    36,    36,
291     36,    36,    36,    36,    36,    36,    36,    38,    36,    39,
292     36,    40,    41,    36,    36,    36,    36,    42,    42,    42
293 };
294
295 static const short yyr2[] = {     0,
296      1,     1,     3,     2,     2,     2,     2,     2,     0,     6,
297      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
298      3,     3,     3,     3,     3,     3,     3,     0,     4,     0,
299      4,     0,     0,     7,     1,     1,     1,     0,     4,     2
300 };
301
302 static const short yydefact[] = {     0,
303     35,    36,    37,     0,     0,     0,     0,     0,     0,     1,
304      2,     6,     4,     5,     7,     8,     0,     0,    32,    30,
305     28,     0,     0,     0,     0,     0,     0,     0,     0,     0,
306      0,     0,     0,     0,     0,     0,     0,     0,    11,     3,
307      0,     0,     0,    27,    26,    25,    19,    20,    23,    24,
308     21,    22,    17,    18,    15,    16,    12,    13,    14,    38,
309      0,    31,    29,    38,    38,     0,    33,    40,     0,    10,
310      0,    38,    34,    39,     0,     0,     0
311 };
312
313 static const short yydefgoto[] = {    75,
314     10,    11,    38,    43,    42,    41,    71,    66
315 };
316
317 static const short yypact[] = {    12,
318 -32768,-32768,-32768,    12,    12,    12,    12,     1,    12,     4,
319     79,-32768,-32768,-32768,-32768,   -21,    31,    12,-32768,-32768,
320 -32768,    12,    12,    12,    12,    12,    12,    12,    12,    12,
321     12,    12,    12,    12,    12,    12,    12,    30,-32768,    79,
322     12,    12,    12,   110,   124,   137,   148,   148,   155,   155,
323    155,   155,   160,   160,   -17,   -17,-32768,-32768,-32768,     2,
324     58,    34,    95,     2,     2,    54,-32768,-32768,    55,-32768,
325     12,     2,    79,-32768,    63,   188,-32768
326 };
327
328 static const short yypgoto[] = {-32768,
329    180,    -4,-32768,-32768,-32768,-32768,-32768,   -60
330 };
331
332
333 #define YYLAST          189
334
335
336 static const short yytable[] = {    12,
337     13,    14,    15,    68,    69,    16,    64,    35,    36,    37,
338     -9,    74,    18,    40,     1,     2,     3,    44,    45,    46,
339     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
340     57,    58,    59,    65,     4,     5,    61,    62,    63,    18,
341      6,     7,     8,     9,    21,    22,    23,    24,    25,    26,
342     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
343     37,    60,    76,    39,    19,    67,    73,    20,    21,    22,
344     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
345     33,    34,    35,    36,    37,    19,    70,    72,    20,    21,
346     22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
347     32,    33,    34,    35,    36,    37,    22,    23,    24,    25,
348     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
349     36,    37,    23,    24,    25,    26,    27,    28,    29,    30,
350     31,    32,    33,    34,    35,    36,    37,    24,    25,    26,
351     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
352     37,    25,    26,    27,    28,    29,    30,    31,    32,    33,
353     34,    35,    36,    37,    27,    28,    29,    30,    31,    32,
354     33,    34,    35,    36,    37,    31,    32,    33,    34,    35,
355     36,    37,    33,    34,    35,    36,    37,    77,    17
356 };
357
358 static const short yycheck[] = {     4,
359      5,     6,     7,    64,    65,     5,     5,    25,    26,    27,
360     32,    72,     9,    18,     3,     4,     5,    22,    23,    24,
361     25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
362     35,    36,    37,    32,    23,    24,    41,    42,    43,     9,
363     29,    30,    31,    32,    11,    12,    13,    14,    15,    16,
364     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
365     27,    32,     0,    33,     7,     8,    71,    10,    11,    12,
366     13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
367     23,    24,    25,    26,    27,     7,    33,    33,    10,    11,
368     12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
369     22,    23,    24,    25,    26,    27,    12,    13,    14,    15,
370     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
371     26,    27,    13,    14,    15,    16,    17,    18,    19,    20,
372     21,    22,    23,    24,    25,    26,    27,    14,    15,    16,
373     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
374     27,    15,    16,    17,    18,    19,    20,    21,    22,    23,
375     24,    25,    26,    27,    17,    18,    19,    20,    21,    22,
376     23,    24,    25,    26,    27,    21,    22,    23,    24,    25,
377     26,    27,    23,    24,    25,    26,    27,     0,     9
378 };
379 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
380 #line 3 "/usr/cygnus/latest-940103/share/bison.simple"
381
382 /* Skeleton output parser for bison,
383    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
384
385    This program is free software; you can redistribute it and/or modify
386    it under the terms of the GNU General Public License as published by
387    the Free Software Foundation; either version 2, or (at your option)
388    any later version.
389
390    This program is distributed in the hope that it will be useful,
391    but WITHOUT ANY WARRANTY; without even the implied warranty of
392    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
393    GNU General Public License for more details.
394
395    You should have received a copy of the GNU General Public License
396    along with this program; if not, write to the Free Software
397    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
398
399 /* As a special exception, when this file is copied by Bison into a
400    Bison output file, you may use that output file without restriction.
401    This special exception was added by the Free Software Foundation
402    in version 1.24 of Bison.  */
403
404 #ifndef alloca
405 #ifdef __GNUC__
406 #define alloca __builtin_alloca
407 #else /* not GNU C.  */
408 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
409 #include <alloca.h>
410 #else /* not sparc */
411 #if defined (MSDOS) && !defined (__TURBOC__)
412 #include <malloc.h>
413 #else /* not MSDOS, or __TURBOC__ */
414 #if defined(_AIX)
415 #include <malloc.h>
416  #pragma alloca
417 #else /* not MSDOS, __TURBOC__, or _AIX */
418 #ifdef __hpux
419 #ifdef __cplusplus
420 extern "C" {
421 void *alloca (unsigned int);
422 };
423 #else /* not __cplusplus */
424 void *alloca ();
425 #endif /* not __cplusplus */
426 #endif /* __hpux */
427 #endif /* not _AIX */
428 #endif /* not MSDOS, or __TURBOC__ */
429 #endif /* not sparc.  */
430 #endif /* not GNU C.  */
431 #endif /* alloca not defined.  */
432
433 /* This is the parser code that is written into each bison parser
434   when the %semantic_parser declaration is not specified in the grammar.
435   It was written by Richard Stallman by simplifying the hairy parser
436   used when %semantic_parser is specified.  */
437
438 /* Note: there must be only one dollar sign in this file.
439    It is replaced by the list of actions, each action
440    as one case of the switch.  */
441
442 #define yyerrok         (yyerrstatus = 0)
443 #define yyclearin       (yychar = YYEMPTY)
444 #define YYEMPTY         -2
445 #define YYEOF           0
446 #define YYACCEPT        return(0)
447 #define YYABORT         return(1)
448 #define YYERROR         goto yyerrlab1
449 /* Like YYERROR except do call yyerror.
450    This remains here temporarily to ease the
451    transition to the new meaning of YYERROR, for GCC.
452    Once GCC version 2 has supplanted version 1, this can go.  */
453 #define YYFAIL          goto yyerrlab
454 #define YYRECOVERING()  (!!yyerrstatus)
455 #define YYBACKUP(token, value) \
456 do                                                              \
457   if (yychar == YYEMPTY && yylen == 1)                          \
458     { yychar = (token), yylval = (value);                       \
459       yychar1 = YYTRANSLATE (yychar);                           \
460       YYPOPSTACK;                                               \
461       goto yybackup;                                            \
462     }                                                           \
463   else                                                          \
464     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
465 while (0)
466
467 #define YYTERROR        1
468 #define YYERRCODE       256
469
470 #ifndef YYPURE
471 #define YYLEX           yylex()
472 #endif
473
474 #ifdef YYPURE
475 #ifdef YYLSP_NEEDED
476 #ifdef YYLEX_PARAM
477 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
478 #else
479 #define YYLEX           yylex(&yylval, &yylloc)
480 #endif
481 #else /* not YYLSP_NEEDED */
482 #ifdef YYLEX_PARAM
483 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
484 #else
485 #define YYLEX           yylex(&yylval)
486 #endif
487 #endif /* not YYLSP_NEEDED */
488 #endif
489
490 /* If nonreentrant, generate the variables here */
491
492 #ifndef YYPURE
493
494 int     yychar;                 /*  the lookahead symbol                */
495 YYSTYPE yylval;                 /*  the semantic value of the           */
496                                 /*  lookahead symbol                    */
497
498 #ifdef YYLSP_NEEDED
499 YYLTYPE yylloc;                 /*  location data for the lookahead     */
500                                 /*  symbol                              */
501 #endif
502
503 int yynerrs;                    /*  number of parse errors so far       */
504 #endif  /* not YYPURE */
505
506 #if YYDEBUG != 0
507 int yydebug;                    /*  nonzero means print parse trace     */
508 /* Since this is uninitialized, it does not stop multiple parsers
509    from coexisting.  */
510 #endif
511
512 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
513
514 #ifndef YYINITDEPTH
515 #define YYINITDEPTH 200
516 #endif
517
518 /*  YYMAXDEPTH is the maximum size the stacks can grow to
519     (effective only if the built-in stack extension method is used).  */
520
521 #if YYMAXDEPTH == 0
522 #undef YYMAXDEPTH
523 #endif
524
525 #ifndef YYMAXDEPTH
526 #define YYMAXDEPTH 10000
527 #endif
528
529 /* Prevent warning if -Wstrict-prototypes.  */
530 #ifdef __GNUC__
531 int yyparse (void);
532 #endif
533 \f
534 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
535 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
536 #else                           /* not GNU C or C++ */
537 #ifndef __cplusplus
538
539 /* This is the most reliable way to avoid incompatibilities
540    in available built-in functions on various systems.  */
541 static void
542 __yy_memcpy (to, from, count)
543      char *to;
544      char *from;
545      int count;
546 {
547   register char *f = from;
548   register char *t = to;
549   register int i = count;
550
551   while (i-- > 0)
552     *t++ = *f++;
553 }
554
555 #else /* __cplusplus */
556
557 /* This is the most reliable way to avoid incompatibilities
558    in available built-in functions on various systems.  */
559 static void
560 __yy_memcpy (char *to, char *from, int count)
561 {
562   register char *f = from;
563   register char *t = to;
564   register int i = count;
565
566   while (i-- > 0)
567     *t++ = *f++;
568 }
569
570 #endif
571 #endif
572 \f
573 #line 196 "/usr/cygnus/latest-940103/share/bison.simple"
574
575 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
576    into yyparse.  The argument should have type void *.
577    It should actually point to an object.
578    Grammar actions can access the variable by casting it
579    to the proper pointer type.  */
580
581 #ifdef YYPARSE_PARAM
582 #ifdef __cplusplus
583 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
584 #define YYPARSE_PARAM_DECL
585 #else /* not __cplusplus */
586 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
587 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
588 #endif /* not __cplusplus */
589 #else /* not YYPARSE_PARAM */
590 #define YYPARSE_PARAM_ARG
591 #define YYPARSE_PARAM_DECL
592 #endif /* not YYPARSE_PARAM */
593
594 int
595 yyparse(YYPARSE_PARAM_ARG)
596      YYPARSE_PARAM_DECL
597 {
598   register int yystate;
599   register int yyn;
600   register short *yyssp;
601   register YYSTYPE *yyvsp;
602   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
603   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
604
605   short yyssa[YYINITDEPTH];     /*  the state stack                     */
606   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
607
608   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
609   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
610
611 #ifdef YYLSP_NEEDED
612   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
613   YYLTYPE *yyls = yylsa;
614   YYLTYPE *yylsp;
615
616 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
617 #else
618 #define YYPOPSTACK   (yyvsp--, yyssp--)
619 #endif
620
621   int yystacksize = YYINITDEPTH;
622
623 #ifdef YYPURE
624   int yychar;
625   YYSTYPE yylval;
626   int yynerrs;
627 #ifdef YYLSP_NEEDED
628   YYLTYPE yylloc;
629 #endif
630 #endif
631
632   YYSTYPE yyval;                /*  the variable used to return         */
633                                 /*  semantic values from the action     */
634                                 /*  routines                            */
635
636   int yylen;
637
638 #if YYDEBUG != 0
639   if (yydebug)
640     fprintf(stderr, "Starting parse\n");
641 #endif
642
643   yystate = 0;
644   yyerrstatus = 0;
645   yynerrs = 0;
646   yychar = YYEMPTY;             /* Cause a token to be read.  */
647
648   /* Initialize stack pointers.
649      Waste one element of value and location stack
650      so that they stay on the same level as the state stack.
651      The wasted elements are never initialized.  */
652
653   yyssp = yyss - 1;
654   yyvsp = yyvs;
655 #ifdef YYLSP_NEEDED
656   yylsp = yyls;
657 #endif
658
659 /* Push a new state, which is found in  yystate  .  */
660 /* In all cases, when you get here, the value and location stacks
661    have just been pushed. so pushing a state here evens the stacks.  */
662 yynewstate:
663
664   *++yyssp = yystate;
665
666   if (yyssp >= yyss + yystacksize - 1)
667     {
668       /* Give user a chance to reallocate the stack */
669       /* Use copies of these so that the &'s don't force the real ones into memory. */
670       YYSTYPE *yyvs1 = yyvs;
671       short *yyss1 = yyss;
672 #ifdef YYLSP_NEEDED
673       YYLTYPE *yyls1 = yyls;
674 #endif
675
676       /* Get the current used size of the three stacks, in elements.  */
677       int size = yyssp - yyss + 1;
678
679 #ifdef yyoverflow
680       /* Each stack pointer address is followed by the size of
681          the data in use in that stack, in bytes.  */
682 #ifdef YYLSP_NEEDED
683       /* This used to be a conditional around just the two extra args,
684          but that might be undefined if yyoverflow is a macro.  */
685       yyoverflow("parser stack overflow",
686                  &yyss1, size * sizeof (*yyssp),
687                  &yyvs1, size * sizeof (*yyvsp),
688                  &yyls1, size * sizeof (*yylsp),
689                  &yystacksize);
690 #else
691       yyoverflow("parser stack overflow",
692                  &yyss1, size * sizeof (*yyssp),
693                  &yyvs1, size * sizeof (*yyvsp),
694                  &yystacksize);
695 #endif
696
697       yyss = yyss1; yyvs = yyvs1;
698 #ifdef YYLSP_NEEDED
699       yyls = yyls1;
700 #endif
701 #else /* no yyoverflow */
702       /* Extend the stack our own way.  */
703       if (yystacksize >= YYMAXDEPTH)
704         {
705           yyerror("parser stack overflow");
706           return 2;
707         }
708       yystacksize *= 2;
709       if (yystacksize > YYMAXDEPTH)
710         yystacksize = YYMAXDEPTH;
711       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
712       __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
713       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
714       __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
715 #ifdef YYLSP_NEEDED
716       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
717       __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
718 #endif
719 #endif /* no yyoverflow */
720
721       yyssp = yyss + size - 1;
722       yyvsp = yyvs + size - 1;
723 #ifdef YYLSP_NEEDED
724       yylsp = yyls + size - 1;
725 #endif
726
727 #if YYDEBUG != 0
728       if (yydebug)
729         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
730 #endif
731
732       if (yyssp >= yyss + yystacksize - 1)
733         YYABORT;
734     }
735
736 #if YYDEBUG != 0
737   if (yydebug)
738     fprintf(stderr, "Entering state %d\n", yystate);
739 #endif
740
741   goto yybackup;
742  yybackup:
743
744 /* Do appropriate processing given the current state.  */
745 /* Read a lookahead token if we need one and don't already have one.  */
746 /* yyresume: */
747
748   /* First try to decide what to do without reference to lookahead token.  */
749
750   yyn = yypact[yystate];
751   if (yyn == YYFLAG)
752     goto yydefault;
753
754   /* Not known => get a lookahead token if don't already have one.  */
755
756   /* yychar is either YYEMPTY or YYEOF
757      or a valid token in external form.  */
758
759   if (yychar == YYEMPTY)
760     {
761 #if YYDEBUG != 0
762       if (yydebug)
763         fprintf(stderr, "Reading a token: ");
764 #endif
765       yychar = YYLEX;
766     }
767
768   /* Convert token to internal form (in yychar1) for indexing tables with */
769
770   if (yychar <= 0)              /* This means end of input. */
771     {
772       yychar1 = 0;
773       yychar = YYEOF;           /* Don't call YYLEX any more */
774
775 #if YYDEBUG != 0
776       if (yydebug)
777         fprintf(stderr, "Now at end of input.\n");
778 #endif
779     }
780   else
781     {
782       yychar1 = YYTRANSLATE(yychar);
783
784 #if YYDEBUG != 0
785       if (yydebug)
786         {
787           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
788           /* Give the individual parser a way to print the precise meaning
789              of a token, for further debugging info.  */
790 #ifdef YYPRINT
791           YYPRINT (stderr, yychar, yylval);
792 #endif
793           fprintf (stderr, ")\n");
794         }
795 #endif
796     }
797
798   yyn += yychar1;
799   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
800     goto yydefault;
801
802   yyn = yytable[yyn];
803
804   /* yyn is what to do for this token type in this state.
805      Negative => reduce, -yyn is rule number.
806      Positive => shift, yyn is new state.
807        New state is final state => don't bother to shift,
808        just return success.
809      0, or most negative number => error.  */
810
811   if (yyn < 0)
812     {
813       if (yyn == YYFLAG)
814         goto yyerrlab;
815       yyn = -yyn;
816       goto yyreduce;
817     }
818   else if (yyn == 0)
819     goto yyerrlab;
820
821   if (yyn == YYFINAL)
822     YYACCEPT;
823
824   /* Shift the lookahead token.  */
825
826 #if YYDEBUG != 0
827   if (yydebug)
828     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
829 #endif
830
831   /* Discard the token being shifted unless it is eof.  */
832   if (yychar != YYEOF)
833     yychar = YYEMPTY;
834
835   *++yyvsp = yylval;
836 #ifdef YYLSP_NEEDED
837   *++yylsp = yylloc;
838 #endif
839
840   /* count tokens shifted since error; after three, turn off error status.  */
841   if (yyerrstatus) yyerrstatus--;
842
843   yystate = yyn;
844   goto yynewstate;
845
846 /* Do the default action for the current state.  */
847 yydefault:
848
849   yyn = yydefact[yystate];
850   if (yyn == 0)
851     goto yyerrlab;
852
853 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
854 yyreduce:
855   yylen = yyr2[yyn];
856   if (yylen > 0)
857     yyval = yyvsp[1-yylen]; /* implement default value of the action */
858
859 #if YYDEBUG != 0
860   if (yydebug)
861     {
862       int i;
863
864       fprintf (stderr, "Reducing via rule %d (line %d), ",
865                yyn, yyrline[yyn]);
866
867       /* Print the symbols being reduced, and their result.  */
868       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
869         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
870       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
871     }
872 #endif
873
874
875   switch (yyn) {
876
877 case 1:
878 #line 282 "cexp.y"
879 {
880                   expression_value = yyvsp[0].integer.value;
881 #ifdef TEST_EXP_READER
882                   expression_signedp = yyvsp[0].integer.signedp;
883 #endif
884                 ;
885     break;}
886 case 3:
887 #line 293 "cexp.y"
888 { if (pedantic)
889                             pedwarn ("comma operator in operand of `#if'");
890                           yyval.integer = yyvsp[0].integer; ;
891     break;}
892 case 4:
893 #line 300 "cexp.y"
894 { yyval.integer.value = - yyvsp[0].integer.value;
895                           yyval.integer.signedp = yyvsp[0].integer.signedp;
896                           if ((yyval.integer.value & yyvsp[0].integer.value & yyval.integer.signedp) < 0)
897                             integer_overflow (); ;
898     break;}
899 case 5:
900 #line 305 "cexp.y"
901 { yyval.integer.value = ! yyvsp[0].integer.value;
902                           yyval.integer.signedp = SIGNED; ;
903     break;}
904 case 6:
905 #line 308 "cexp.y"
906 { yyval.integer = yyvsp[0].integer; ;
907     break;}
908 case 7:
909 #line 310 "cexp.y"
910 { yyval.integer.value = ~ yyvsp[0].integer.value;
911                           yyval.integer.signedp = yyvsp[0].integer.signedp; ;
912     break;}
913 case 8:
914 #line 313 "cexp.y"
915 { yyval.integer.value = check_assertion (yyvsp[0].name.address, yyvsp[0].name.length,
916                                                       0, NULL_PTR);
917                           yyval.integer.signedp = SIGNED; ;
918     break;}
919 case 9:
920 #line 317 "cexp.y"
921 { keyword_parsing = 1; ;
922     break;}
923 case 10:
924 #line 319 "cexp.y"
925 { yyval.integer.value = check_assertion (yyvsp[-4].name.address, yyvsp[-4].name.length,
926                                                       1, yyvsp[-1].keywords);
927                           keyword_parsing = 0;
928                           yyval.integer.signedp = SIGNED; ;
929     break;}
930 case 11:
931 #line 324 "cexp.y"
932 { yyval.integer = yyvsp[-1].integer; ;
933     break;}
934 case 12:
935 #line 329 "cexp.y"
936 { yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
937                           if (yyval.integer.signedp)
938                             {
939                               yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value;
940                               if (yyvsp[-2].integer.value
941                                   && (yyval.integer.value / yyvsp[-2].integer.value != yyvsp[0].integer.value
942                                       || (yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0))
943                                 integer_overflow ();
944                             }
945                           else
946                             yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
947                                         * yyvsp[0].integer.value); ;
948     break;}
949 case 13:
950 #line 342 "cexp.y"
951 { if (yyvsp[0].integer.value == 0)
952                             {
953                               if (!skip_evaluation)
954                                 error ("division by zero in #if");
955                               yyvsp[0].integer.value = 1;
956                             }
957                           yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
958                           if (yyval.integer.signedp)
959                             {
960                               yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value;
961                               if ((yyval.integer.value & yyvsp[-2].integer.value & yyvsp[0].integer.value) < 0)
962                                 integer_overflow ();
963                             }
964                           else
965                             yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
966                                         / yyvsp[0].integer.value); ;
967     break;}
968 case 14:
969 #line 359 "cexp.y"
970 { if (yyvsp[0].integer.value == 0)
971                             {
972                               if (!skip_evaluation)
973                                 error ("division by zero in #if");
974                               yyvsp[0].integer.value = 1;
975                             }
976                           yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
977                           if (yyval.integer.signedp)
978                             yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value;
979                           else
980                             yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
981                                         % yyvsp[0].integer.value); ;
982     break;}
983 case 15:
984 #line 372 "cexp.y"
985 { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value;
986                           yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
987                           if (overflow_sum_sign (yyvsp[-2].integer.value, yyvsp[0].integer.value,
988                                                  yyval.integer.value, yyval.integer.signedp))
989                             integer_overflow (); ;
990     break;}
991 case 16:
992 #line 378 "cexp.y"
993 { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value;
994                           yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp;
995                           if (overflow_sum_sign (yyval.integer.value, yyvsp[0].integer.value,
996                                                  yyvsp[-2].integer.value, yyval.integer.signedp))
997                             integer_overflow (); ;
998     break;}
999 case 17:
1000 #line 384 "cexp.y"
1001 { yyval.integer.signedp = yyvsp[-2].integer.signedp;
1002                           if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0)
1003                             yyval.integer.value = right_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value);
1004                           else
1005                             yyval.integer.value = left_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ;
1006     break;}
1007 case 18:
1008 #line 390 "cexp.y"
1009 { yyval.integer.signedp = yyvsp[-2].integer.signedp;
1010                           if ((yyvsp[0].integer.value & yyvsp[0].integer.signedp) < 0)
1011                             yyval.integer.value = left_shift (&yyvsp[-2].integer, -yyvsp[0].integer.value);
1012                           else
1013                             yyval.integer.value = right_shift (&yyvsp[-2].integer, yyvsp[0].integer.value); ;
1014     break;}
1015 case 19:
1016 #line 396 "cexp.y"
1017 { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value);
1018                           yyval.integer.signedp = SIGNED; ;
1019     break;}
1020 case 20:
1021 #line 399 "cexp.y"
1022 { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value);
1023                           yyval.integer.signedp = SIGNED; ;
1024     break;}
1025 case 21:
1026 #line 402 "cexp.y"
1027 { yyval.integer.signedp = SIGNED;
1028                           if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1029                             yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value;
1030                           else
1031                             yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1032                                         <= yyvsp[0].integer.value); ;
1033     break;}
1034 case 22:
1035 #line 409 "cexp.y"
1036 { yyval.integer.signedp = SIGNED;
1037                           if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1038                             yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value;
1039                           else
1040                             yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1041                                         >= yyvsp[0].integer.value); ;
1042     break;}
1043 case 23:
1044 #line 416 "cexp.y"
1045 { yyval.integer.signedp = SIGNED;
1046                           if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1047                             yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value;
1048                           else
1049                             yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1050                                         < yyvsp[0].integer.value); ;
1051     break;}
1052 case 24:
1053 #line 423 "cexp.y"
1054 { yyval.integer.signedp = SIGNED;
1055                           if (yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp)
1056                             yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value;
1057                           else
1058                             yyval.integer.value = ((unsigned_HOST_WIDE_INT) yyvsp[-2].integer.value
1059                                         > yyvsp[0].integer.value); ;
1060     break;}
1061 case 25:
1062 #line 430 "cexp.y"
1063 { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value;
1064                           yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ;
1065     break;}
1066 case 26:
1067 #line 433 "cexp.y"
1068 { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value;
1069                           yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ;
1070     break;}
1071 case 27:
1072 #line 436 "cexp.y"
1073 { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value;
1074                           yyval.integer.signedp = yyvsp[-2].integer.signedp & yyvsp[0].integer.signedp; ;
1075     break;}
1076 case 28:
1077 #line 439 "cexp.y"
1078 { skip_evaluation += !yyvsp[-1].integer.value; ;
1079     break;}
1080 case 29:
1081 #line 441 "cexp.y"
1082 { skip_evaluation -= !yyvsp[-3].integer.value;
1083                           yyval.integer.value = (yyvsp[-3].integer.value && yyvsp[0].integer.value);
1084                           yyval.integer.signedp = SIGNED; ;
1085     break;}
1086 case 30:
1087 #line 445 "cexp.y"
1088 { skip_evaluation += !!yyvsp[-1].integer.value; ;
1089     break;}
1090 case 31:
1091 #line 447 "cexp.y"
1092 { skip_evaluation -= !!yyvsp[-3].integer.value;
1093                           yyval.integer.value = (yyvsp[-3].integer.value || yyvsp[0].integer.value);
1094                           yyval.integer.signedp = SIGNED; ;
1095     break;}
1096 case 32:
1097 #line 451 "cexp.y"
1098 { skip_evaluation += !yyvsp[-1].integer.value; ;
1099     break;}
1100 case 33:
1101 #line 453 "cexp.y"
1102 { skip_evaluation += !!yyvsp[-4].integer.value - !yyvsp[-4].integer.value; ;
1103     break;}
1104 case 34:
1105 #line 455 "cexp.y"
1106 { skip_evaluation -= !!yyvsp[-6].integer.value;
1107                           yyval.integer.value = yyvsp[-6].integer.value ? yyvsp[-3].integer.value : yyvsp[0].integer.value;
1108                           yyval.integer.signedp = yyvsp[-3].integer.signedp & yyvsp[0].integer.signedp; ;
1109     break;}
1110 case 35:
1111 #line 459 "cexp.y"
1112 { yyval.integer = yylval.integer; ;
1113     break;}
1114 case 36:
1115 #line 461 "cexp.y"
1116 { yyval.integer = yylval.integer; ;
1117     break;}
1118 case 37:
1119 #line 463 "cexp.y"
1120 { if (warn_undef && !skip_evaluation)
1121                             warning ("`%.*s' is not defined",
1122                                      yyvsp[0].name.length, yyvsp[0].name.address);
1123                           yyval.integer.value = 0;
1124                           yyval.integer.signedp = SIGNED; ;
1125     break;}
1126 case 38:
1127 #line 471 "cexp.y"
1128 { yyval.keywords = 0; ;
1129     break;}
1130 case 39:
1131 #line 473 "cexp.y"
1132 { struct arglist *temp;
1133                           yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist));
1134                           yyval.keywords->next = yyvsp[-2].keywords;
1135                           yyval.keywords->name = (U_CHAR *) "(";
1136                           yyval.keywords->length = 1;
1137                           temp = yyval.keywords;
1138                           while (temp != 0 && temp->next != 0)
1139                             temp = temp->next;
1140                           temp->next = (struct arglist *) xmalloc (sizeof (struct arglist));
1141                           temp->next->next = yyvsp[0].keywords;
1142                           temp->next->name = (U_CHAR *) ")";
1143                           temp->next->length = 1; ;
1144     break;}
1145 case 40:
1146 #line 486 "cexp.y"
1147 { yyval.keywords = (struct arglist *) xmalloc (sizeof (struct arglist));
1148                           yyval.keywords->name = yyvsp[-1].name.address;
1149                           yyval.keywords->length = yyvsp[-1].name.length;
1150                           yyval.keywords->next = yyvsp[0].keywords; ;
1151     break;}
1152 }
1153    /* the action file gets copied in in place of this dollarsign */
1154 #line 498 "/usr/cygnus/latest-940103/share/bison.simple"
1155 \f
1156   yyvsp -= yylen;
1157   yyssp -= yylen;
1158 #ifdef YYLSP_NEEDED
1159   yylsp -= yylen;
1160 #endif
1161
1162 #if YYDEBUG != 0
1163   if (yydebug)
1164     {
1165       short *ssp1 = yyss - 1;
1166       fprintf (stderr, "state stack now");
1167       while (ssp1 != yyssp)
1168         fprintf (stderr, " %d", *++ssp1);
1169       fprintf (stderr, "\n");
1170     }
1171 #endif
1172
1173   *++yyvsp = yyval;
1174
1175 #ifdef YYLSP_NEEDED
1176   yylsp++;
1177   if (yylen == 0)
1178     {
1179       yylsp->first_line = yylloc.first_line;
1180       yylsp->first_column = yylloc.first_column;
1181       yylsp->last_line = (yylsp-1)->last_line;
1182       yylsp->last_column = (yylsp-1)->last_column;
1183       yylsp->text = 0;
1184     }
1185   else
1186     {
1187       yylsp->last_line = (yylsp+yylen-1)->last_line;
1188       yylsp->last_column = (yylsp+yylen-1)->last_column;
1189     }
1190 #endif
1191
1192   /* Now "shift" the result of the reduction.
1193      Determine what state that goes to,
1194      based on the state we popped back to
1195      and the rule number reduced by.  */
1196
1197   yyn = yyr1[yyn];
1198
1199   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1200   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1201     yystate = yytable[yystate];
1202   else
1203     yystate = yydefgoto[yyn - YYNTBASE];
1204
1205   goto yynewstate;
1206
1207 yyerrlab:   /* here on detecting error */
1208
1209   if (! yyerrstatus)
1210     /* If not already recovering from an error, report this error.  */
1211     {
1212       ++yynerrs;
1213
1214 #ifdef YYERROR_VERBOSE
1215       yyn = yypact[yystate];
1216
1217       if (yyn > YYFLAG && yyn < YYLAST)
1218         {
1219           int size = 0;
1220           char *msg;
1221           int x, count;
1222
1223           count = 0;
1224           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
1225           for (x = (yyn < 0 ? -yyn : 0);
1226                x < (sizeof(yytname) / sizeof(char *)); x++)
1227             if (yycheck[x + yyn] == x)
1228               size += strlen(yytname[x]) + 15, count++;
1229           msg = (char *) malloc(size + 15);
1230           if (msg != 0)
1231             {
1232               strcpy(msg, "parse error");
1233
1234               if (count < 5)
1235                 {
1236                   count = 0;
1237                   for (x = (yyn < 0 ? -yyn : 0);
1238                        x < (sizeof(yytname) / sizeof(char *)); x++)
1239                     if (yycheck[x + yyn] == x)
1240                       {
1241                         strcat(msg, count == 0 ? ", expecting `" : " or `");
1242                         strcat(msg, yytname[x]);
1243                         strcat(msg, "'");
1244                         count++;
1245                       }
1246                 }
1247               yyerror(msg);
1248               free(msg);
1249             }
1250           else
1251             yyerror ("parse error; also virtual memory exceeded");
1252         }
1253       else
1254 #endif /* YYERROR_VERBOSE */
1255         yyerror("parse error");
1256     }
1257
1258   goto yyerrlab1;
1259 yyerrlab1:   /* here on error raised explicitly by an action */
1260
1261   if (yyerrstatus == 3)
1262     {
1263       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1264
1265       /* return failure if at end of input */
1266       if (yychar == YYEOF)
1267         YYABORT;
1268
1269 #if YYDEBUG != 0
1270       if (yydebug)
1271         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1272 #endif
1273
1274       yychar = YYEMPTY;
1275     }
1276
1277   /* Else will try to reuse lookahead token
1278      after shifting the error token.  */
1279
1280   yyerrstatus = 3;              /* Each real token shifted decrements this */
1281
1282   goto yyerrhandle;
1283
1284 yyerrdefault:  /* current state does not do anything special for the error token. */
1285
1286 #if 0
1287   /* This is wrong; only states that explicitly want error tokens
1288      should shift them.  */
1289   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1290   if (yyn) goto yydefault;
1291 #endif
1292
1293 yyerrpop:   /* pop the current state because it cannot handle the error token */
1294
1295   if (yyssp == yyss) YYABORT;
1296   yyvsp--;
1297   yystate = *--yyssp;
1298 #ifdef YYLSP_NEEDED
1299   yylsp--;
1300 #endif
1301
1302 #if YYDEBUG != 0
1303   if (yydebug)
1304     {
1305       short *ssp1 = yyss - 1;
1306       fprintf (stderr, "Error: state stack now");
1307       while (ssp1 != yyssp)
1308         fprintf (stderr, " %d", *++ssp1);
1309       fprintf (stderr, "\n");
1310     }
1311 #endif
1312
1313 yyerrhandle:
1314
1315   yyn = yypact[yystate];
1316   if (yyn == YYFLAG)
1317     goto yyerrdefault;
1318
1319   yyn += YYTERROR;
1320   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1321     goto yyerrdefault;
1322
1323   yyn = yytable[yyn];
1324   if (yyn < 0)
1325     {
1326       if (yyn == YYFLAG)
1327         goto yyerrpop;
1328       yyn = -yyn;
1329       goto yyreduce;
1330     }
1331   else if (yyn == 0)
1332     goto yyerrpop;
1333
1334   if (yyn == YYFINAL)
1335     YYACCEPT;
1336
1337 #if YYDEBUG != 0
1338   if (yydebug)
1339     fprintf(stderr, "Shifting error token, ");
1340 #endif
1341
1342   *++yyvsp = yylval;
1343 #ifdef YYLSP_NEEDED
1344   *++yylsp = yylloc;
1345 #endif
1346
1347   yystate = yyn;
1348   goto yynewstate;
1349 }
1350 #line 491 "cexp.y"
1351
1352 \f
1353 /* During parsing of a C expression, the pointer to the next character
1354    is in this variable.  */
1355
1356 static char *lexptr;
1357
1358 /* Take care of parsing a number (anything that starts with a digit).
1359    Set yylval and return the token type; update lexptr.
1360    LEN is the number of characters in it.  */
1361
1362 /* maybe needs to actually deal with floating point numbers */
1363
1364 static int
1365 parse_number (olen)
1366      int olen;
1367 {
1368   register char *p = lexptr;
1369   register int c;
1370   register unsigned_HOST_WIDE_INT n = 0, nd, max_over_base;
1371   register int base = 10;
1372   register int len = olen;
1373   register int overflow = 0;
1374   register int digit, largest_digit = 0;
1375   int spec_long = 0;
1376
1377   yylval.integer.signedp = SIGNED;
1378
1379   if (*p == '0') {
1380     base = 8;
1381     if (len >= 3 && (p[1] == 'x' || p[1] == 'X')) {
1382       p += 2;
1383       base = 16;
1384       len -= 2;
1385     }
1386   }
1387
1388   max_over_base = (unsigned_HOST_WIDE_INT) -1 / base;
1389
1390   for (; len > 0; len--) {
1391     c = *p++;
1392
1393     if (c >= '0' && c <= '9')
1394       digit = c - '0';
1395     else if (base == 16 && c >= 'a' && c <= 'f')
1396       digit = c - 'a' + 10;
1397     else if (base == 16 && c >= 'A' && c <= 'F')
1398       digit = c - 'A' + 10;
1399     else {
1400       /* `l' means long, and `u' means unsigned.  */
1401       while (1) {
1402         if (c == 'l' || c == 'L')
1403           {
1404             if (!pedantic < spec_long)
1405               yyerror ("too many `l's in integer constant");
1406             spec_long++;
1407           }
1408         else if (c == 'u' || c == 'U')
1409           {
1410             if (! yylval.integer.signedp)
1411               yyerror ("two `u's in integer constant");
1412             yylval.integer.signedp = UNSIGNED;
1413           }
1414         else {
1415           if (c == '.' || c == 'e' || c == 'E' || c == 'p' || c == 'P')
1416             yyerror ("Floating point numbers not allowed in #if expressions");
1417           else {
1418             char *buf = (char *) alloca (p - lexptr + 40);
1419             sprintf (buf, "missing white space after number `%.*s'",
1420                      (int) (p - lexptr - 1), lexptr);
1421             yyerror (buf);
1422           }
1423         }
1424
1425         if (--len == 0)
1426           break;
1427         c = *p++;
1428       }
1429       /* Don't look for any more digits after the suffixes.  */
1430       break;
1431     }
1432     if (largest_digit < digit)
1433       largest_digit = digit;
1434     nd = n * base + digit;
1435     overflow |= (max_over_base < n) | (nd < n);
1436     n = nd;
1437   }
1438
1439   if (base <= largest_digit)
1440     pedwarn ("integer constant contains digits beyond the radix");
1441
1442   if (overflow)
1443     pedwarn ("integer constant out of range");
1444
1445   /* If too big to be signed, consider it unsigned.  */
1446   if (((HOST_WIDE_INT) n & yylval.integer.signedp) < 0)
1447     {
1448       if (base == 10)
1449         warning ("integer constant is so large that it is unsigned");
1450       yylval.integer.signedp = UNSIGNED;
1451     }
1452
1453   lexptr = p;
1454   yylval.integer.value = n;
1455   return INT;
1456 }
1457
1458 struct token {
1459   char *operator;
1460   int token;
1461 };
1462
1463 static struct token tokentab2[] = {
1464   {"&&", AND},
1465   {"||", OR},
1466   {"<<", LSH},
1467   {">>", RSH},
1468   {"==", EQUAL},
1469   {"!=", NOTEQUAL},
1470   {"<=", LEQ},
1471   {">=", GEQ},
1472   {"++", ERROR},
1473   {"--", ERROR},
1474   {NULL, ERROR}
1475 };
1476
1477 /* Read one token, getting characters through lexptr.  */
1478
1479 static int
1480 yylex ()
1481 {
1482   register int c;
1483   register int namelen;
1484   register unsigned char *tokstart;
1485   register struct token *toktab;
1486   int wide_flag;
1487   HOST_WIDE_INT mask;
1488
1489  retry:
1490
1491   tokstart = (unsigned char *) lexptr;
1492   c = *tokstart;
1493   /* See if it is a special token of length 2.  */
1494   if (! keyword_parsing)
1495     for (toktab = tokentab2; toktab->operator != NULL; toktab++)
1496       if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) {
1497         lexptr += 2;
1498         if (toktab->token == ERROR)
1499           {
1500             char *buf = (char *) alloca (40);
1501             sprintf (buf, "`%s' not allowed in operand of `#if'", toktab->operator);
1502             yyerror (buf);
1503           }
1504         return toktab->token;
1505       }
1506
1507   switch (c) {
1508   case '\n':
1509     return 0;
1510     
1511   case ' ':
1512   case '\t':
1513   case '\r':
1514     lexptr++;
1515     goto retry;
1516     
1517   case 'L':
1518     /* Capital L may start a wide-string or wide-character constant.  */
1519     if (lexptr[1] == '\'')
1520       {
1521         lexptr++;
1522         wide_flag = 1;
1523         mask = MAX_WCHAR_TYPE_MASK;
1524         goto char_constant;
1525       }
1526     if (lexptr[1] == '"')
1527       {
1528         lexptr++;
1529         wide_flag = 1;
1530         mask = MAX_WCHAR_TYPE_MASK;
1531         goto string_constant;
1532       }
1533     break;
1534
1535   case '\'':
1536     wide_flag = 0;
1537     mask = MAX_CHAR_TYPE_MASK;
1538   char_constant:
1539     lexptr++;
1540     if (keyword_parsing) {
1541       char *start_ptr = lexptr - 1;
1542       while (1) {
1543         c = *lexptr++;
1544         if (c == '\\')
1545           c = parse_escape (&lexptr, mask);
1546         else if (c == '\'')
1547           break;
1548       }
1549       yylval.name.address = tokstart;
1550       yylval.name.length = lexptr - start_ptr;
1551       return NAME;
1552     }
1553
1554     /* This code for reading a character constant
1555        handles multicharacter constants and wide characters.
1556        It is mostly copied from c-lex.c.  */
1557     {
1558       register HOST_WIDE_INT result = 0;
1559       register int num_chars = 0;
1560       unsigned width = MAX_CHAR_TYPE_SIZE;
1561       int max_chars;
1562       char *token_buffer;
1563
1564       if (wide_flag)
1565         {
1566           width = MAX_WCHAR_TYPE_SIZE;
1567 #ifdef MULTIBYTE_CHARS
1568           max_chars = MB_CUR_MAX;
1569 #else
1570           max_chars = 1;
1571 #endif
1572         }
1573       else
1574         max_chars = MAX_LONG_TYPE_SIZE / width;
1575
1576       token_buffer = (char *) alloca (max_chars + 1);
1577
1578       while (1)
1579         {
1580           c = *lexptr++;
1581
1582           if (c == '\'' || c == EOF)
1583             break;
1584
1585           if (c == '\\')
1586             {
1587               c = parse_escape (&lexptr, mask);
1588             }
1589
1590           num_chars++;
1591
1592           /* Merge character into result; ignore excess chars.  */
1593           if (num_chars <= max_chars)
1594             {
1595               if (width < HOST_BITS_PER_WIDE_INT)
1596                 result = (result << width) | c;
1597               else
1598                 result = c;
1599               token_buffer[num_chars - 1] = c;
1600             }
1601         }
1602
1603       token_buffer[num_chars] = 0;
1604
1605       if (c != '\'')
1606         error ("malformatted character constant");
1607       else if (num_chars == 0)
1608         error ("empty character constant");
1609       else if (num_chars > max_chars)
1610         {
1611           num_chars = max_chars;
1612           error ("character constant too long");
1613         }
1614       else if (num_chars != 1 && ! traditional)
1615         warning ("multi-character character constant");
1616
1617       /* If char type is signed, sign-extend the constant.  */
1618       if (! wide_flag)
1619         {
1620           int num_bits = num_chars * width;
1621
1622           if (lookup ((U_CHAR *) "__CHAR_UNSIGNED__",
1623                       sizeof ("__CHAR_UNSIGNED__") - 1, -1)
1624               || ((result >> (num_bits - 1)) & 1) == 0)
1625             yylval.integer.value
1626               = result & (~ (unsigned_HOST_WIDE_INT) 0
1627                           >> (HOST_BITS_PER_WIDE_INT - num_bits));
1628           else
1629             yylval.integer.value
1630               = result | ~(~ (unsigned_HOST_WIDE_INT) 0
1631                            >> (HOST_BITS_PER_WIDE_INT - num_bits));
1632         }
1633       else
1634         {
1635 #ifdef MULTIBYTE_CHARS
1636           /* Set the initial shift state and convert the next sequence.  */
1637           result = 0;
1638           /* In all locales L'\0' is zero and mbtowc will return zero,
1639              so don't use it.  */
1640           if (num_chars > 1
1641               || (num_chars == 1 && token_buffer[0] != '\0'))
1642             {
1643               wchar_t wc;
1644               (void) mbtowc (NULL_PTR, NULL_PTR, 0);
1645               if (mbtowc (& wc, token_buffer, num_chars) == num_chars)
1646                 result = wc;
1647               else
1648                 pedwarn ("Ignoring invalid multibyte character");
1649             }
1650 #endif
1651           yylval.integer.value = result;
1652         }
1653     }
1654
1655     /* This is always a signed type.  */
1656     yylval.integer.signedp = SIGNED;
1657     
1658     return CHAR;
1659
1660     /* some of these chars are invalid in constant expressions;
1661        maybe do something about them later */
1662   case '/':
1663   case '+':
1664   case '-':
1665   case '*':
1666   case '%':
1667   case '|':
1668   case '&':
1669   case '^':
1670   case '~':
1671   case '!':
1672   case '@':
1673   case '<':
1674   case '>':
1675   case '[':
1676   case ']':
1677   case '.':
1678   case '?':
1679   case ':':
1680   case '=':
1681   case '{':
1682   case '}':
1683   case ',':
1684   case '#':
1685     if (keyword_parsing)
1686       break;
1687   case '(':
1688   case ')':
1689     lexptr++;
1690     return c;
1691
1692   case '"':
1693     mask = MAX_CHAR_TYPE_MASK;
1694   string_constant:
1695     if (keyword_parsing) {
1696       char *start_ptr = lexptr;
1697       lexptr++;
1698       while (1) {
1699         c = *lexptr++;
1700         if (c == '\\')
1701           c = parse_escape (&lexptr, mask);
1702         else if (c == '"')
1703           break;
1704       }
1705       yylval.name.address = tokstart;
1706       yylval.name.length = lexptr - start_ptr;
1707       return NAME;
1708     }
1709     yyerror ("string constants not allowed in #if expressions");
1710     return ERROR;
1711   }
1712
1713   if (c >= '0' && c <= '9' && !keyword_parsing) {
1714     /* It's a number */
1715     for (namelen = 1; ; namelen++) {
1716       int d = tokstart[namelen];
1717       if (! ((is_idchar[d] || d == '.')
1718              || ((d == '-' || d == '+')
1719                  && (c == 'e' || c == 'E'
1720                      || ((c == 'p' || c == 'P') && ! c89))
1721                  && ! traditional)))
1722         break;
1723       c = d;
1724     }
1725     return parse_number (namelen);
1726   }
1727
1728   /* It is a name.  See how long it is.  */
1729
1730   if (keyword_parsing) {
1731     for (namelen = 0;; namelen++) {
1732       if (is_space[tokstart[namelen]])
1733         break;
1734       if (tokstart[namelen] == '(' || tokstart[namelen] == ')')
1735         break;
1736       if (tokstart[namelen] == '"' || tokstart[namelen] == '\'')
1737         break;
1738     }
1739   } else {
1740     if (!is_idstart[c]) {
1741       yyerror ("Invalid token in expression");
1742       return ERROR;
1743     }
1744
1745     for (namelen = 0; is_idchar[tokstart[namelen]]; namelen++)
1746       ;
1747   }
1748   
1749   lexptr += namelen;
1750   yylval.name.address = tokstart;
1751   yylval.name.length = namelen;
1752   return NAME;
1753 }
1754
1755
1756 /* Parse a C escape sequence.  STRING_PTR points to a variable
1757    containing a pointer to the string to parse.  That pointer
1758    is updated past the characters we use.  The value of the
1759    escape sequence is returned.
1760
1761    RESULT_MASK is used to mask out the result;
1762    an error is reported if bits are lost thereby.
1763
1764    A negative value means the sequence \ newline was seen,
1765    which is supposed to be equivalent to nothing at all.
1766
1767    If \ is followed by a null character, we return a negative
1768    value and leave the string pointer pointing at the null character.
1769
1770    If \ is followed by 000, we return 0 and leave the string pointer
1771    after the zeros.  A value of 0 does not mean end of string.  */
1772
1773 HOST_WIDE_INT
1774 parse_escape (string_ptr, result_mask)
1775      char **string_ptr;
1776      HOST_WIDE_INT result_mask;
1777 {
1778   register int c = *(*string_ptr)++;
1779   switch (c)
1780     {
1781     case 'a':
1782       return TARGET_BELL;
1783     case 'b':
1784       return TARGET_BS;
1785     case 'e':
1786     case 'E':
1787       if (pedantic)
1788         pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
1789       return 033;
1790     case 'f':
1791       return TARGET_FF;
1792     case 'n':
1793       return TARGET_NEWLINE;
1794     case 'r':
1795       return TARGET_CR;
1796     case 't':
1797       return TARGET_TAB;
1798     case 'v':
1799       return TARGET_VT;
1800     case '\n':
1801       return -2;
1802     case 0:
1803       (*string_ptr)--;
1804       return 0;
1805       
1806     case '0':
1807     case '1':
1808     case '2':
1809     case '3':
1810     case '4':
1811     case '5':
1812     case '6':
1813     case '7':
1814       {
1815         register HOST_WIDE_INT i = c - '0';
1816         register int count = 0;
1817         while (++count < 3)
1818           {
1819             c = *(*string_ptr)++;
1820             if (c >= '0' && c <= '7')
1821               i = (i << 3) + c - '0';
1822             else
1823               {
1824                 (*string_ptr)--;
1825                 break;
1826               }
1827           }
1828         if (i != (i & result_mask))
1829           {
1830             i &= result_mask;
1831             pedwarn ("octal escape sequence out of range");
1832           }
1833         return i;
1834       }
1835     case 'x':
1836       {
1837         register unsigned_HOST_WIDE_INT i = 0, overflow = 0;
1838         register int digits_found = 0, digit;
1839         for (;;)
1840           {
1841             c = *(*string_ptr)++;
1842             if (c >= '0' && c <= '9')
1843               digit = c - '0';
1844             else if (c >= 'a' && c <= 'f')
1845               digit = c - 'a' + 10;
1846             else if (c >= 'A' && c <= 'F')
1847               digit = c - 'A' + 10;
1848             else
1849               {
1850                 (*string_ptr)--;
1851                 break;
1852               }
1853             overflow |= i ^ (i << 4 >> 4);
1854             i = (i << 4) + digit;
1855             digits_found = 1;
1856           }
1857         if (!digits_found)
1858           yyerror ("\\x used with no following hex digits");
1859         if (overflow | (i != (i & result_mask)))
1860           {
1861             i &= result_mask;
1862             pedwarn ("hex escape sequence out of range");
1863           }
1864         return i;
1865       }
1866     default:
1867       return c;
1868     }
1869 }
1870
1871 static void
1872 yyerror (s)
1873      char *s;
1874 {
1875   error ("%s", s);
1876   skip_evaluation = 0;
1877   longjmp (parse_return_error, 1);
1878 }
1879
1880 static void
1881 integer_overflow ()
1882 {
1883   if (!skip_evaluation && pedantic)
1884     pedwarn ("integer overflow in preprocessor expression");
1885 }
1886
1887 static HOST_WIDE_INT
1888 left_shift (a, b)
1889      struct constant *a;
1890      unsigned_HOST_WIDE_INT b;
1891 {
1892    /* It's unclear from the C standard whether shifts can overflow.
1893       The following code ignores overflow; perhaps a C standard
1894       interpretation ruling is needed.  */
1895   if (b >= HOST_BITS_PER_WIDE_INT)
1896     return 0;
1897   else
1898     return (unsigned_HOST_WIDE_INT) a->value << b;
1899 }
1900
1901 static HOST_WIDE_INT
1902 right_shift (a, b)
1903      struct constant *a;
1904      unsigned_HOST_WIDE_INT b;
1905 {
1906   if (b >= HOST_BITS_PER_WIDE_INT)
1907     return a->signedp ? a->value >> (HOST_BITS_PER_WIDE_INT - 1) : 0;
1908   else if (a->signedp)
1909     return a->value >> b;
1910   else
1911     return (unsigned_HOST_WIDE_INT) a->value >> b;
1912 }
1913 \f
1914 /* This page contains the entry point to this file.  */
1915
1916 /* Parse STRING as an expression, and complain if this fails
1917    to use up all of the contents of STRING.
1918    STRING may contain '\0' bytes; it is terminated by the first '\n'
1919    outside a string constant, so that we can diagnose '\0' properly.
1920    If WARN_UNDEFINED is nonzero, warn if undefined identifiers are evaluated.
1921    We do not support C comments.  They should be removed before
1922    this function is called.  */
1923
1924 HOST_WIDE_INT
1925 parse_c_expression (string, warn_undefined)
1926      char *string;
1927      int warn_undefined;
1928 {
1929   lexptr = string;
1930   warn_undef = warn_undefined;
1931
1932   /* if there is some sort of scanning error, just return 0 and assume
1933      the parsing routine has printed an error message somewhere.
1934      there is surely a better thing to do than this.     */
1935   if (setjmp (parse_return_error))
1936     return 0;
1937
1938   if (yyparse () != 0)
1939     abort ();
1940
1941   if (*lexptr != '\n')
1942     error ("Junk after end of expression.");
1943
1944   return expression_value;      /* set by yyparse () */
1945 }
1946 \f
1947 #ifdef TEST_EXP_READER
1948
1949 #if YYDEBUG
1950 extern int yydebug;
1951 #endif
1952
1953 int pedantic;
1954 int traditional;
1955
1956 int main PROTO((int, char **));
1957 static void initialize_random_junk PROTO((void));
1958 static void print_unsigned_host_wide_int PROTO((unsigned_HOST_WIDE_INT));
1959
1960 /* Main program for testing purposes.  */
1961 int
1962 main (argc, argv)
1963      int argc;
1964      char **argv;
1965 {
1966   int n, c;
1967   char buf[1024];
1968   unsigned_HOST_WIDE_INT u;
1969
1970   pedantic = 1 < argc;
1971   traditional = 2 < argc;
1972 #if YYDEBUG
1973   yydebug = 3 < argc;
1974 #endif
1975   initialize_random_junk ();
1976
1977   for (;;) {
1978     printf ("enter expression: ");
1979     n = 0;
1980     while ((buf[n] = c = getchar ()) != '\n' && c != EOF)
1981       n++;
1982     if (c == EOF)
1983       break;
1984     parse_c_expression (buf, 1);
1985     printf ("parser returned ");
1986     u = (unsigned_HOST_WIDE_INT) expression_value;
1987     if (expression_value < 0 && expression_signedp) {
1988       u = -u;
1989       printf ("-");
1990     }
1991     if (u == 0)
1992       printf ("0");
1993     else
1994       print_unsigned_host_wide_int (u);
1995     if (! expression_signedp)
1996       printf("u");
1997     printf ("\n");
1998   }
1999
2000   return 0;
2001 }
2002
2003 static void
2004 print_unsigned_host_wide_int (u)
2005      unsigned_HOST_WIDE_INT u;
2006 {
2007   if (u) {
2008     print_unsigned_host_wide_int (u / 10);
2009     putchar ('0' + (int) (u % 10));
2010   }
2011 }
2012
2013 /* table to tell if char can be part of a C identifier. */
2014 unsigned char is_idchar[256];
2015 /* table to tell if char can be first char of a c identifier. */
2016 unsigned char is_idstart[256];
2017 /* table to tell if c is horizontal or vertical space.  */
2018 unsigned char is_space[256];
2019
2020 /*
2021  * initialize random junk in the hash table and maybe other places
2022  */
2023 static void
2024 initialize_random_junk ()
2025 {
2026   register int i;
2027
2028   /*
2029    * Set up is_idchar and is_idstart tables.  These should be
2030    * faster than saying (is_alpha (c) || c == '_'), etc.
2031    * Must do set up these things before calling any routines tthat
2032    * refer to them.
2033    */
2034   for (i = 'a'; i <= 'z'; i++) {
2035     ++is_idchar[i - 'a' + 'A'];
2036     ++is_idchar[i];
2037     ++is_idstart[i - 'a' + 'A'];
2038     ++is_idstart[i];
2039   }
2040   for (i = '0'; i <= '9'; i++)
2041     ++is_idchar[i];
2042   ++is_idchar['_'];
2043   ++is_idstart['_'];
2044   ++is_idchar['$'];
2045   ++is_idstart['$'];
2046
2047   ++is_space[' '];
2048   ++is_space['\t'];
2049   ++is_space['\v'];
2050   ++is_space['\f'];
2051   ++is_space['\n'];
2052   ++is_space['\r'];
2053 }
2054
2055 void
2056 error VPROTO ((char * msg, ...))
2057 {
2058 #ifndef __STDC__
2059   char * msg;
2060 #endif
2061   va_list args;
2062
2063   VA_START (args, msg);
2064  
2065 #ifndef __STDC__
2066   msg = va_arg (args, char *);
2067 #endif
2068  
2069   fprintf (stderr, "error: ");
2070   vfprintf (stderr, msg, args);
2071   fprintf (stderr, "\n");
2072   va_end (args);
2073 }
2074
2075 void
2076 pedwarn VPROTO ((char * msg, ...))
2077 {
2078 #ifndef __STDC__
2079   char * msg;
2080 #endif
2081   va_list args;
2082
2083   VA_START (args, msg);
2084  
2085 #ifndef __STDC__
2086   msg = va_arg (args, char *);
2087 #endif
2088  
2089   fprintf (stderr, "pedwarn: ");
2090   vfprintf (stderr, msg, args);
2091   fprintf (stderr, "\n");
2092   va_end (args);
2093 }
2094
2095 void
2096 warning VPROTO ((char * msg, ...))
2097 {
2098 #ifndef __STDC__
2099   char * msg;
2100 #endif
2101   va_list args;
2102
2103   VA_START (args, msg);
2104  
2105 #ifndef __STDC__
2106   msg = va_arg (args, char *);
2107 #endif
2108  
2109   fprintf (stderr, "warning: ");
2110   vfprintf (stderr, msg, args);
2111   fprintf (stderr, "\n");
2112   va_end (args);
2113 }
2114
2115 int
2116 check_assertion (name, sym_length, tokens_specified, tokens)
2117      U_CHAR *name;
2118      int sym_length;
2119      int tokens_specified;
2120      struct arglist *tokens;
2121 {
2122   return 0;
2123 }
2124
2125 struct hashnode *
2126 lookup (name, len, hash)
2127      U_CHAR *name;
2128      int len;
2129      int hash;
2130 {
2131   return (DEFAULT_SIGNED_CHAR) ? 0 : ((struct hashnode *) -1);
2132 }
2133
2134 GENERIC_PTR
2135 xmalloc (size)
2136      size_t size;
2137 {
2138   return (GENERIC_PTR) malloc (size);
2139 }
2140 #endif