source: trunk/third/gcc/cexp.c @ 11288

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