OSDN Git Service

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