OSDN Git Service

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