36d2fce44229761786903d73daa2ea415186ee24
[platform/upstream/gcc.git] / gcc / tradcif.c
1
2 /*  A Bison parser, made from tradcif.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 26 "tradcif.y"
22
23 #include "config.h"
24 #include "system.h"
25 #include <setjmp.h>
26
27   int yylex PARAMS ((void));
28   void yyerror PARAMS ((const char *msgid));
29   extern void error   PARAMS ((const char *msgid, ...));
30   extern void warning PARAMS ((const char *msgid, ...));
31   extern struct hashnode *lookup PARAMS ((const unsigned char *, int, int));
32
33   int parse_number PARAMS ((int));
34   int parse_escape PARAMS ((char **));
35   int parse_c_expression PARAMS ((char *));
36
37   int expression_value;
38   static jmp_buf parse_return_error;
39
40   /* some external tables of character types */
41   extern unsigned char is_idstart[], is_idchar[];
42
43 #ifndef CHAR_TYPE_SIZE
44 #define CHAR_TYPE_SIZE BITS_PER_UNIT
45 #endif
46
47 #line 52 "tradcif.y"
48 typedef union {
49   struct constant {long value; int unsignedp;} integer;
50   int voidval;
51   char *sval;
52 } YYSTYPE;
53 #include <stdio.h>
54
55 #ifndef __cplusplus
56 #ifndef __STDC__
57 #define const
58 #endif
59 #endif
60
61
62
63 #define YYFINAL         61
64 #define YYFLAG          -32768
65 #define YYNTBASE        33
66
67 #define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 36)
68
69 static const char yytranslate[] = {     0,
70      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
71      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
72      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
73      2,     2,    29,     2,     2,     2,    27,    14,     2,    31,
74     32,    25,    23,     9,    24,     2,    26,     2,     2,     2,
75      2,     2,     2,     2,     2,     2,     2,     8,     2,    17,
76      2,    18,     7,     2,     2,     2,     2,     2,     2,     2,
77      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
78      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
79      2,     2,     2,    13,     2,     2,     2,     2,     2,     2,
80      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
81      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
82      2,     2,     2,    12,     2,    30,     2,     2,     2,     2,
83      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
84      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
85      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
86      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
87      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
88      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
89      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
90      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
91      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
92      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
93      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
94      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
95      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
96     10,    11,    15,    16,    19,    20,    21,    22,    28
97 };
98
99 #if YYDEBUG != 0
100 static const short yyprhs[] = {     0,
101      0,     2,     4,     8,    11,    14,    17,    20,    24,    28,
102     32,    36,    40,    44,    48,    52,    56,    60,    64,    68,
103     72,    76,    80,    84,    88,    92,    96,   102,   104,   106
104 };
105
106 static const short yyrhs[] = {    34,
107      0,    35,     0,    34,     9,    35,     0,    24,    35,     0,
108     29,    35,     0,    23,    35,     0,    30,    35,     0,    31,
109     34,    32,     0,    35,    25,    35,     0,    35,    26,    35,
110      0,    35,    27,    35,     0,    35,    23,    35,     0,    35,
111     24,    35,     0,    35,    21,    35,     0,    35,    22,    35,
112      0,    35,    15,    35,     0,    35,    16,    35,     0,    35,
113     19,    35,     0,    35,    20,    35,     0,    35,    17,    35,
114      0,    35,    18,    35,     0,    35,    14,    35,     0,    35,
115     13,    35,     0,    35,    12,    35,     0,    35,    11,    35,
116      0,    35,    10,    35,     0,    35,     7,    35,     8,    35,
117      0,     3,     0,     4,     0,     5,     0
118 };
119
120 #endif
121
122 #if YYDEBUG != 0
123 static const short yyrline[] = { 0,
124     81,    86,    87,    92,    95,    98,   100,   103,   108,   114,
125    125,   136,   139,   142,   148,   154,   157,   160,   167,   174,
126    181,   188,   191,   194,   197,   200,   203,   206,   208,   210
127 };
128 #endif
129
130
131 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
132
133 static const char * const yytname[] = {   "$","error","$undefined.","INT","CHAR",
134 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
135 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
136 "'~'","'('","')'","start","exp1","exp", NULL
137 };
138 #endif
139
140 static const short yyr1[] = {     0,
141     33,    34,    34,    35,    35,    35,    35,    35,    35,    35,
142     35,    35,    35,    35,    35,    35,    35,    35,    35,    35,
143     35,    35,    35,    35,    35,    35,    35,    35,    35,    35
144 };
145
146 static const short yyr2[] = {     0,
147      1,     1,     3,     2,     2,     2,     2,     3,     3,     3,
148      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
149      3,     3,     3,     3,     3,     3,     5,     1,     1,     1
150 };
151
152 static const short yydefact[] = {     0,
153     28,    29,    30,     0,     0,     0,     0,     0,     1,     2,
154      6,     4,     5,     7,     0,     0,     0,     0,     0,     0,
155      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
156      0,     0,     0,     0,     0,     8,     3,     0,    26,    25,
157     24,    23,    22,    16,    17,    20,    21,    18,    19,    14,
158     15,    12,    13,     9,    10,    11,     0,    27,     0,     0,
159      0
160 };
161
162 static const short yydefgoto[] = {    59,
163      9,    10
164 };
165
166 static const short yypact[] = {    31,
167 -32768,-32768,-32768,    31,    31,    31,    31,    31,     1,    77,
168 -32768,-32768,-32768,-32768,     0,    31,    31,    31,    31,    31,
169     31,    31,    31,    31,    31,    31,    31,    31,    31,    31,
170     31,    31,    31,    31,    31,-32768,    77,    56,    94,    25,
171    109,   123,   136,   147,   147,   154,   154,   154,   154,   -19,
172    -19,    32,    32,-32768,-32768,-32768,    31,    77,    11,    33,
173 -32768
174 };
175
176 static const short yypgoto[] = {-32768,
177     48,    -4
178 };
179
180
181 #define YYLAST          181
182
183
184 static const short yytable[] = {    11,
185     12,    13,    14,    31,    32,    33,    34,    35,    16,    16,
186     60,    37,    38,    39,    40,    41,    42,    43,    44,    45,
187     46,    47,    48,    49,    50,    51,    52,    53,    54,    55,
188     56,    36,    61,     1,     2,     3,    20,    21,    22,    23,
189     24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
190     34,    35,    58,     4,     5,    15,    33,    34,    35,     6,
191      7,     8,    17,    57,     0,    18,    19,    20,    21,    22,
192     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
193     33,    34,    35,    17,     0,     0,    18,    19,    20,    21,
194     22,    23,    24,    25,    26,    27,    28,    29,    30,    31,
195     32,    33,    34,    35,    19,    20,    21,    22,    23,    24,
196     25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
197     35,    21,    22,    23,    24,    25,    26,    27,    28,    29,
198     30,    31,    32,    33,    34,    35,    22,    23,    24,    25,
199     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
200     23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
201     33,    34,    35,    25,    26,    27,    28,    29,    30,    31,
202     32,    33,    34,    35,    29,    30,    31,    32,    33,    34,
203     35
204 };
205
206 static const short yycheck[] = {     4,
207      5,     6,     7,    23,    24,    25,    26,    27,     9,     9,
208      0,    16,    17,    18,    19,    20,    21,    22,    23,    24,
209     25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
210     35,    32,     0,     3,     4,     5,    12,    13,    14,    15,
211     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
212     26,    27,    57,    23,    24,     8,    25,    26,    27,    29,
213     30,    31,     7,     8,    -1,    10,    11,    12,    13,    14,
214     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
215     25,    26,    27,     7,    -1,    -1,    10,    11,    12,    13,
216     14,    15,    16,    17,    18,    19,    20,    21,    22,    23,
217     24,    25,    26,    27,    11,    12,    13,    14,    15,    16,
218     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
219     27,    13,    14,    15,    16,    17,    18,    19,    20,    21,
220     22,    23,    24,    25,    26,    27,    14,    15,    16,    17,
221     18,    19,    20,    21,    22,    23,    24,    25,    26,    27,
222     15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
223     25,    26,    27,    17,    18,    19,    20,    21,    22,    23,
224     24,    25,    26,    27,    21,    22,    23,    24,    25,    26,
225     27
226 };
227 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
228 #line 3 "/usr/share/misc/bison.simple"
229 /* This file comes from bison-1.28.  */
230
231 /* Skeleton output parser for bison,
232    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
233
234    This program is free software; you can redistribute it and/or modify
235    it under the terms of the GNU General Public License as published by
236    the Free Software Foundation; either version 2, or (at your option)
237    any later version.
238
239    This program is distributed in the hope that it will be useful,
240    but WITHOUT ANY WARRANTY; without even the implied warranty of
241    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
242    GNU General Public License for more details.
243
244    You should have received a copy of the GNU General Public License
245    along with this program; if not, write to the Free Software
246    Foundation, Inc., 59 Temple Place - Suite 330,
247    Boston, MA 02111-1307, USA.  */
248
249 /* As a special exception, when this file is copied by Bison into a
250    Bison output file, you may use that output file without restriction.
251    This special exception was added by the Free Software Foundation
252    in version 1.24 of Bison.  */
253
254 /* This is the parser code that is written into each bison parser
255   when the %semantic_parser declaration is not specified in the grammar.
256   It was written by Richard Stallman by simplifying the hairy parser
257   used when %semantic_parser is specified.  */
258
259 #ifndef YYSTACK_USE_ALLOCA
260 #ifdef alloca
261 #define YYSTACK_USE_ALLOCA
262 #else /* alloca not defined */
263 #ifdef __GNUC__
264 #define YYSTACK_USE_ALLOCA
265 #define alloca __builtin_alloca
266 #else /* not GNU C.  */
267 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
268 #define YYSTACK_USE_ALLOCA
269 #include <alloca.h>
270 #else /* not sparc */
271 /* We think this test detects Watcom and Microsoft C.  */
272 /* This used to test MSDOS, but that is a bad idea
273    since that symbol is in the user namespace.  */
274 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
275 #if 0 /* No need for malloc.h, which pollutes the namespace;
276          instead, just don't use alloca.  */
277 #include <malloc.h>
278 #endif
279 #else /* not MSDOS, or __TURBOC__ */
280 #if defined(_AIX)
281 /* I don't know what this was needed for, but it pollutes the namespace.
282    So I turned it off.   rms, 2 May 1997.  */
283 /* #include <malloc.h>  */
284  #pragma alloca
285 #define YYSTACK_USE_ALLOCA
286 #else /* not MSDOS, or __TURBOC__, or _AIX */
287 #if 0
288 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
289                  and on HPUX 10.  Eventually we can turn this on.  */
290 #define YYSTACK_USE_ALLOCA
291 #define alloca __builtin_alloca
292 #endif /* __hpux */
293 #endif
294 #endif /* not _AIX */
295 #endif /* not MSDOS, or __TURBOC__ */
296 #endif /* not sparc */
297 #endif /* not GNU C */
298 #endif /* alloca not defined */
299 #endif /* YYSTACK_USE_ALLOCA not defined */
300
301 #ifdef YYSTACK_USE_ALLOCA
302 #define YYSTACK_ALLOC alloca
303 #else
304 #define YYSTACK_ALLOC malloc
305 #endif
306
307 /* Note: there must be only one dollar sign in this file.
308    It is replaced by the list of actions, each action
309    as one case of the switch.  */
310
311 #define yyerrok         (yyerrstatus = 0)
312 #define yyclearin       (yychar = YYEMPTY)
313 #define YYEMPTY         -2
314 #define YYEOF           0
315 #define YYACCEPT        goto yyacceptlab
316 #define YYABORT         goto yyabortlab
317 #define YYERROR         goto yyerrlab1
318 /* Like YYERROR except do call yyerror.
319    This remains here temporarily to ease the
320    transition to the new meaning of YYERROR, for GCC.
321    Once GCC version 2 has supplanted version 1, this can go.  */
322 #define YYFAIL          goto yyerrlab
323 #define YYRECOVERING()  (!!yyerrstatus)
324 #define YYBACKUP(token, value) \
325 do                                                              \
326   if (yychar == YYEMPTY && yylen == 1)                          \
327     { yychar = (token), yylval = (value);                       \
328       yychar1 = YYTRANSLATE (yychar);                           \
329       YYPOPSTACK;                                               \
330       goto yybackup;                                            \
331     }                                                           \
332   else                                                          \
333     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
334 while (0)
335
336 #define YYTERROR        1
337 #define YYERRCODE       256
338
339 #ifndef YYPURE
340 #define YYLEX           yylex()
341 #endif
342
343 #ifdef YYPURE
344 #ifdef YYLSP_NEEDED
345 #ifdef YYLEX_PARAM
346 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
347 #else
348 #define YYLEX           yylex(&yylval, &yylloc)
349 #endif
350 #else /* not YYLSP_NEEDED */
351 #ifdef YYLEX_PARAM
352 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
353 #else
354 #define YYLEX           yylex(&yylval)
355 #endif
356 #endif /* not YYLSP_NEEDED */
357 #endif
358
359 /* If nonreentrant, generate the variables here */
360
361 #ifndef YYPURE
362
363 int     yychar;                 /*  the lookahead symbol                */
364 YYSTYPE yylval;                 /*  the semantic value of the           */
365                                 /*  lookahead symbol                    */
366
367 #ifdef YYLSP_NEEDED
368 YYLTYPE yylloc;                 /*  location data for the lookahead     */
369                                 /*  symbol                              */
370 #endif
371
372 int yynerrs;                    /*  number of parse errors so far       */
373 #endif  /* not YYPURE */
374
375 #if YYDEBUG != 0
376 int yydebug;                    /*  nonzero means print parse trace     */
377 /* Since this is uninitialized, it does not stop multiple parsers
378    from coexisting.  */
379 #endif
380
381 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
382
383 #ifndef YYINITDEPTH
384 #define YYINITDEPTH 200
385 #endif
386
387 /*  YYMAXDEPTH is the maximum size the stacks can grow to
388     (effective only if the built-in stack extension method is used).  */
389
390 #if YYMAXDEPTH == 0
391 #undef YYMAXDEPTH
392 #endif
393
394 #ifndef YYMAXDEPTH
395 #define YYMAXDEPTH 10000
396 #endif
397 \f
398 /* Define __yy_memcpy.  Note that the size argument
399    should be passed with type unsigned int, because that is what the non-GCC
400    definitions require.  With GCC, __builtin_memcpy takes an arg
401    of type size_t, but it can handle unsigned int.  */
402
403 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
404 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
405 #else                           /* not GNU C or C++ */
406 #ifndef __cplusplus
407
408 /* This is the most reliable way to avoid incompatibilities
409    in available built-in functions on various systems.  */
410 static void
411 __yy_memcpy (to, from, count)
412      char *to;
413      char *from;
414      unsigned int count;
415 {
416   register char *f = from;
417   register char *t = to;
418   register int i = count;
419
420   while (i-- > 0)
421     *t++ = *f++;
422 }
423
424 #else /* __cplusplus */
425
426 /* This is the most reliable way to avoid incompatibilities
427    in available built-in functions on various systems.  */
428 static void
429 __yy_memcpy (char *to, char *from, unsigned int count)
430 {
431   register char *t = to;
432   register char *f = from;
433   register int i = count;
434
435   while (i-- > 0)
436     *t++ = *f++;
437 }
438
439 #endif
440 #endif
441 \f
442 #line 217 "/usr/share/misc/bison.simple"
443
444 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
445    into yyparse.  The argument should have type void *.
446    It should actually point to an object.
447    Grammar actions can access the variable by casting it
448    to the proper pointer type.  */
449
450 #ifdef YYPARSE_PARAM
451 #ifdef __cplusplus
452 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
453 #define YYPARSE_PARAM_DECL
454 #else /* not __cplusplus */
455 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
456 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
457 #endif /* not __cplusplus */
458 #else /* not YYPARSE_PARAM */
459 #define YYPARSE_PARAM_ARG
460 #define YYPARSE_PARAM_DECL
461 #endif /* not YYPARSE_PARAM */
462
463 /* Prevent warning if -Wstrict-prototypes.  */
464 #ifdef __GNUC__
465 #ifdef YYPARSE_PARAM
466 int yyparse (void *);
467 #else
468 int yyparse (void);
469 #endif
470 #endif
471
472 int
473 yyparse(YYPARSE_PARAM_ARG)
474      YYPARSE_PARAM_DECL
475 {
476   register int yystate;
477   register int yyn;
478   register short *yyssp;
479   register YYSTYPE *yyvsp;
480   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
481   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
482
483   short yyssa[YYINITDEPTH];     /*  the state stack                     */
484   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
485
486   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
487   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
488
489 #ifdef YYLSP_NEEDED
490   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
491   YYLTYPE *yyls = yylsa;
492   YYLTYPE *yylsp;
493
494 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
495 #else
496 #define YYPOPSTACK   (yyvsp--, yyssp--)
497 #endif
498
499   int yystacksize = YYINITDEPTH;
500   int yyfree_stacks = 0;
501
502 #ifdef YYPURE
503   int yychar;
504   YYSTYPE yylval;
505   int yynerrs;
506 #ifdef YYLSP_NEEDED
507   YYLTYPE yylloc;
508 #endif
509 #endif
510
511   YYSTYPE yyval;                /*  the variable used to return         */
512                                 /*  semantic values from the action     */
513                                 /*  routines                            */
514
515   int yylen;
516
517 #if YYDEBUG != 0
518   if (yydebug)
519     fprintf(stderr, "Starting parse\n");
520 #endif
521
522   yystate = 0;
523   yyerrstatus = 0;
524   yynerrs = 0;
525   yychar = YYEMPTY;             /* Cause a token to be read.  */
526
527   /* Initialize stack pointers.
528      Waste one element of value and location stack
529      so that they stay on the same level as the state stack.
530      The wasted elements are never initialized.  */
531
532   yyssp = yyss - 1;
533   yyvsp = yyvs;
534 #ifdef YYLSP_NEEDED
535   yylsp = yyls;
536 #endif
537
538 /* Push a new state, which is found in  yystate  .  */
539 /* In all cases, when you get here, the value and location stacks
540    have just been pushed. so pushing a state here evens the stacks.  */
541 yynewstate:
542
543   *++yyssp = yystate;
544
545   if (yyssp >= yyss + yystacksize - 1)
546     {
547       /* Give user a chance to reallocate the stack */
548       /* Use copies of these so that the &'s don't force the real ones into memory. */
549       YYSTYPE *yyvs1 = yyvs;
550       short *yyss1 = yyss;
551 #ifdef YYLSP_NEEDED
552       YYLTYPE *yyls1 = yyls;
553 #endif
554
555       /* Get the current used size of the three stacks, in elements.  */
556       int size = yyssp - yyss + 1;
557
558 #ifdef yyoverflow
559       /* Each stack pointer address is followed by the size of
560          the data in use in that stack, in bytes.  */
561 #ifdef YYLSP_NEEDED
562       /* This used to be a conditional around just the two extra args,
563          but that might be undefined if yyoverflow is a macro.  */
564       yyoverflow("parser stack overflow",
565                  &yyss1, size * sizeof (*yyssp),
566                  &yyvs1, size * sizeof (*yyvsp),
567                  &yyls1, size * sizeof (*yylsp),
568                  &yystacksize);
569 #else
570       yyoverflow("parser stack overflow",
571                  &yyss1, size * sizeof (*yyssp),
572                  &yyvs1, size * sizeof (*yyvsp),
573                  &yystacksize);
574 #endif
575
576       yyss = yyss1; yyvs = yyvs1;
577 #ifdef YYLSP_NEEDED
578       yyls = yyls1;
579 #endif
580 #else /* no yyoverflow */
581       /* Extend the stack our own way.  */
582       if (yystacksize >= YYMAXDEPTH)
583         {
584           yyerror("parser stack overflow");
585           if (yyfree_stacks)
586             {
587               free (yyss);
588               free (yyvs);
589 #ifdef YYLSP_NEEDED
590               free (yyls);
591 #endif
592             }
593           return 2;
594         }
595       yystacksize *= 2;
596       if (yystacksize > YYMAXDEPTH)
597         yystacksize = YYMAXDEPTH;
598 #ifndef YYSTACK_USE_ALLOCA
599       yyfree_stacks = 1;
600 #endif
601       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
602       __yy_memcpy ((char *)yyss, (char *)yyss1,
603                    size * (unsigned int) sizeof (*yyssp));
604       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
605       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
606                    size * (unsigned int) sizeof (*yyvsp));
607 #ifdef YYLSP_NEEDED
608       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
609       __yy_memcpy ((char *)yyls, (char *)yyls1,
610                    size * (unsigned int) sizeof (*yylsp));
611 #endif
612 #endif /* no yyoverflow */
613
614       yyssp = yyss + size - 1;
615       yyvsp = yyvs + size - 1;
616 #ifdef YYLSP_NEEDED
617       yylsp = yyls + size - 1;
618 #endif
619
620 #if YYDEBUG != 0
621       if (yydebug)
622         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
623 #endif
624
625       if (yyssp >= yyss + yystacksize - 1)
626         YYABORT;
627     }
628
629 #if YYDEBUG != 0
630   if (yydebug)
631     fprintf(stderr, "Entering state %d\n", yystate);
632 #endif
633
634   goto yybackup;
635  yybackup:
636
637 /* Do appropriate processing given the current state.  */
638 /* Read a lookahead token if we need one and don't already have one.  */
639 /* yyresume: */
640
641   /* First try to decide what to do without reference to lookahead token.  */
642
643   yyn = yypact[yystate];
644   if (yyn == YYFLAG)
645     goto yydefault;
646
647   /* Not known => get a lookahead token if don't already have one.  */
648
649   /* yychar is either YYEMPTY or YYEOF
650      or a valid token in external form.  */
651
652   if (yychar == YYEMPTY)
653     {
654 #if YYDEBUG != 0
655       if (yydebug)
656         fprintf(stderr, "Reading a token: ");
657 #endif
658       yychar = YYLEX;
659     }
660
661   /* Convert token to internal form (in yychar1) for indexing tables with */
662
663   if (yychar <= 0)              /* This means end of input. */
664     {
665       yychar1 = 0;
666       yychar = YYEOF;           /* Don't call YYLEX any more */
667
668 #if YYDEBUG != 0
669       if (yydebug)
670         fprintf(stderr, "Now at end of input.\n");
671 #endif
672     }
673   else
674     {
675       yychar1 = YYTRANSLATE(yychar);
676
677 #if YYDEBUG != 0
678       if (yydebug)
679         {
680           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
681           /* Give the individual parser a way to print the precise meaning
682              of a token, for further debugging info.  */
683 #ifdef YYPRINT
684           YYPRINT (stderr, yychar, yylval);
685 #endif
686           fprintf (stderr, ")\n");
687         }
688 #endif
689     }
690
691   yyn += yychar1;
692   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
693     goto yydefault;
694
695   yyn = yytable[yyn];
696
697   /* yyn is what to do for this token type in this state.
698      Negative => reduce, -yyn is rule number.
699      Positive => shift, yyn is new state.
700        New state is final state => don't bother to shift,
701        just return success.
702      0, or most negative number => error.  */
703
704   if (yyn < 0)
705     {
706       if (yyn == YYFLAG)
707         goto yyerrlab;
708       yyn = -yyn;
709       goto yyreduce;
710     }
711   else if (yyn == 0)
712     goto yyerrlab;
713
714   if (yyn == YYFINAL)
715     YYACCEPT;
716
717   /* Shift the lookahead token.  */
718
719 #if YYDEBUG != 0
720   if (yydebug)
721     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
722 #endif
723
724   /* Discard the token being shifted unless it is eof.  */
725   if (yychar != YYEOF)
726     yychar = YYEMPTY;
727
728   *++yyvsp = yylval;
729 #ifdef YYLSP_NEEDED
730   *++yylsp = yylloc;
731 #endif
732
733   /* count tokens shifted since error; after three, turn off error status.  */
734   if (yyerrstatus) yyerrstatus--;
735
736   yystate = yyn;
737   goto yynewstate;
738
739 /* Do the default action for the current state.  */
740 yydefault:
741
742   yyn = yydefact[yystate];
743   if (yyn == 0)
744     goto yyerrlab;
745
746 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
747 yyreduce:
748   yylen = yyr2[yyn];
749   if (yylen > 0)
750     yyval = yyvsp[1-yylen]; /* implement default value of the action */
751
752 #if YYDEBUG != 0
753   if (yydebug)
754     {
755       int i;
756
757       fprintf (stderr, "Reducing via rule %d (line %d), ",
758                yyn, yyrline[yyn]);
759
760       /* Print the symbols being reduced, and their result.  */
761       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
762         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
763       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
764     }
765 #endif
766
767
768   switch (yyn) {
769
770 case 1:
771 #line 82 "tradcif.y"
772 { expression_value = yyvsp[0].integer.value; ;
773     break;}
774 case 3:
775 #line 88 "tradcif.y"
776 { yyval.integer = yyvsp[0].integer; ;
777     break;}
778 case 4:
779 #line 93 "tradcif.y"
780 { yyval.integer.value = - yyvsp[0].integer.value;
781                           yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ;
782     break;}
783 case 5:
784 #line 96 "tradcif.y"
785 { yyval.integer.value = ! yyvsp[0].integer.value;
786                           yyval.integer.unsignedp = 0; ;
787     break;}
788 case 6:
789 #line 99 "tradcif.y"
790 { yyval.integer = yyvsp[0].integer; ;
791     break;}
792 case 7:
793 #line 101 "tradcif.y"
794 { yyval.integer.value = ~ yyvsp[0].integer.value;
795                           yyval.integer.unsignedp = yyvsp[0].integer.unsignedp; ;
796     break;}
797 case 8:
798 #line 104 "tradcif.y"
799 { yyval.integer = yyvsp[-1].integer; ;
800     break;}
801 case 9:
802 #line 109 "tradcif.y"
803 { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
804                           if (yyval.integer.unsignedp)
805                             yyval.integer.value = (unsigned) yyvsp[-2].integer.value * yyvsp[0].integer.value;
806                           else
807                             yyval.integer.value = yyvsp[-2].integer.value * yyvsp[0].integer.value; ;
808     break;}
809 case 10:
810 #line 115 "tradcif.y"
811 { if (yyvsp[0].integer.value == 0)
812                             {
813                               error ("division by zero in #if");
814                               yyvsp[0].integer.value = 1;
815                             }
816                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
817                           if (yyval.integer.unsignedp)
818                             yyval.integer.value = (unsigned) yyvsp[-2].integer.value / yyvsp[0].integer.value;
819                           else
820                             yyval.integer.value = yyvsp[-2].integer.value / yyvsp[0].integer.value; ;
821     break;}
822 case 11:
823 #line 126 "tradcif.y"
824 { if (yyvsp[0].integer.value == 0)
825                             {
826                               error ("division by zero in #if");
827                               yyvsp[0].integer.value = 1;
828                             }
829                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp;
830                           if (yyval.integer.unsignedp)
831                             yyval.integer.value = (unsigned) yyvsp[-2].integer.value % yyvsp[0].integer.value;
832                           else
833                             yyval.integer.value = yyvsp[-2].integer.value % yyvsp[0].integer.value; ;
834     break;}
835 case 12:
836 #line 137 "tradcif.y"
837 { yyval.integer.value = yyvsp[-2].integer.value + yyvsp[0].integer.value;
838                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
839     break;}
840 case 13:
841 #line 140 "tradcif.y"
842 { yyval.integer.value = yyvsp[-2].integer.value - yyvsp[0].integer.value;
843                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
844     break;}
845 case 14:
846 #line 143 "tradcif.y"
847 { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp;
848                           if (yyval.integer.unsignedp)
849                             yyval.integer.value = (unsigned) yyvsp[-2].integer.value << yyvsp[0].integer.value;
850                           else
851                             yyval.integer.value = yyvsp[-2].integer.value << yyvsp[0].integer.value; ;
852     break;}
853 case 15:
854 #line 149 "tradcif.y"
855 { yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp;
856                           if (yyval.integer.unsignedp)
857                             yyval.integer.value = (unsigned) yyvsp[-2].integer.value >> yyvsp[0].integer.value;
858                           else
859                             yyval.integer.value = yyvsp[-2].integer.value >> yyvsp[0].integer.value; ;
860     break;}
861 case 16:
862 #line 155 "tradcif.y"
863 { yyval.integer.value = (yyvsp[-2].integer.value == yyvsp[0].integer.value);
864                           yyval.integer.unsignedp = 0; ;
865     break;}
866 case 17:
867 #line 158 "tradcif.y"
868 { yyval.integer.value = (yyvsp[-2].integer.value != yyvsp[0].integer.value);
869                           yyval.integer.unsignedp = 0; ;
870     break;}
871 case 18:
872 #line 161 "tradcif.y"
873 { yyval.integer.unsignedp = 0;
874                           if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
875                             yyval.integer.value =
876                               (unsigned) yyvsp[-2].integer.value <= (unsigned) yyvsp[0].integer.value;
877                           else
878                             yyval.integer.value = yyvsp[-2].integer.value <= yyvsp[0].integer.value; ;
879     break;}
880 case 19:
881 #line 168 "tradcif.y"
882 { yyval.integer.unsignedp = 0;
883                           if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
884                             yyval.integer.value =
885                               (unsigned) yyvsp[-2].integer.value >= (unsigned) yyvsp[0].integer.value;
886                           else
887                             yyval.integer.value = yyvsp[-2].integer.value >= yyvsp[0].integer.value; ;
888     break;}
889 case 20:
890 #line 175 "tradcif.y"
891 { yyval.integer.unsignedp = 0;
892                           if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
893                             yyval.integer.value =
894                               (unsigned) yyvsp[-2].integer.value < (unsigned) yyvsp[0].integer.value;
895                           else
896                             yyval.integer.value = yyvsp[-2].integer.value < yyvsp[0].integer.value; ;
897     break;}
898 case 21:
899 #line 182 "tradcif.y"
900 { yyval.integer.unsignedp = 0;
901                           if (yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp)
902                             yyval.integer.value =
903                               (unsigned) yyvsp[-2].integer.value > (unsigned) yyvsp[0].integer.value;
904                           else
905                             yyval.integer.value = yyvsp[-2].integer.value > yyvsp[0].integer.value; ;
906     break;}
907 case 22:
908 #line 189 "tradcif.y"
909 { yyval.integer.value = yyvsp[-2].integer.value & yyvsp[0].integer.value;
910                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
911     break;}
912 case 23:
913 #line 192 "tradcif.y"
914 { yyval.integer.value = yyvsp[-2].integer.value ^ yyvsp[0].integer.value;
915                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
916     break;}
917 case 24:
918 #line 195 "tradcif.y"
919 { yyval.integer.value = yyvsp[-2].integer.value | yyvsp[0].integer.value;
920                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
921     break;}
922 case 25:
923 #line 198 "tradcif.y"
924 { yyval.integer.value = (yyvsp[-2].integer.value && yyvsp[0].integer.value);
925                           yyval.integer.unsignedp = 0; ;
926     break;}
927 case 26:
928 #line 201 "tradcif.y"
929 { yyval.integer.value = (yyvsp[-2].integer.value || yyvsp[0].integer.value);
930                           yyval.integer.unsignedp = 0; ;
931     break;}
932 case 27:
933 #line 204 "tradcif.y"
934 { yyval.integer.value = yyvsp[-4].integer.value ? yyvsp[-2].integer.value : yyvsp[0].integer.value;
935                           yyval.integer.unsignedp = yyvsp[-2].integer.unsignedp || yyvsp[0].integer.unsignedp; ;
936     break;}
937 case 28:
938 #line 207 "tradcif.y"
939 { yyval.integer = yylval.integer; ;
940     break;}
941 case 29:
942 #line 209 "tradcif.y"
943 { yyval.integer = yylval.integer; ;
944     break;}
945 case 30:
946 #line 211 "tradcif.y"
947 { yyval.integer.value = 0;
948                           yyval.integer.unsignedp = 0; ;
949     break;}
950 }
951    /* the action file gets copied in in place of this dollarsign */
952 #line 543 "/usr/share/misc/bison.simple"
953 \f
954   yyvsp -= yylen;
955   yyssp -= yylen;
956 #ifdef YYLSP_NEEDED
957   yylsp -= yylen;
958 #endif
959
960 #if YYDEBUG != 0
961   if (yydebug)
962     {
963       short *ssp1 = yyss - 1;
964       fprintf (stderr, "state stack now");
965       while (ssp1 != yyssp)
966         fprintf (stderr, " %d", *++ssp1);
967       fprintf (stderr, "\n");
968     }
969 #endif
970
971   *++yyvsp = yyval;
972
973 #ifdef YYLSP_NEEDED
974   yylsp++;
975   if (yylen == 0)
976     {
977       yylsp->first_line = yylloc.first_line;
978       yylsp->first_column = yylloc.first_column;
979       yylsp->last_line = (yylsp-1)->last_line;
980       yylsp->last_column = (yylsp-1)->last_column;
981       yylsp->text = 0;
982     }
983   else
984     {
985       yylsp->last_line = (yylsp+yylen-1)->last_line;
986       yylsp->last_column = (yylsp+yylen-1)->last_column;
987     }
988 #endif
989
990   /* Now "shift" the result of the reduction.
991      Determine what state that goes to,
992      based on the state we popped back to
993      and the rule number reduced by.  */
994
995   yyn = yyr1[yyn];
996
997   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
998   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
999     yystate = yytable[yystate];
1000   else
1001     yystate = yydefgoto[yyn - YYNTBASE];
1002
1003   goto yynewstate;
1004
1005 yyerrlab:   /* here on detecting error */
1006
1007   if (! yyerrstatus)
1008     /* If not already recovering from an error, report this error.  */
1009     {
1010       ++yynerrs;
1011
1012 #ifdef YYERROR_VERBOSE
1013       yyn = yypact[yystate];
1014
1015       if (yyn > YYFLAG && yyn < YYLAST)
1016         {
1017           int size = 0;
1018           char *msg;
1019           int x, count;
1020
1021           count = 0;
1022           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
1023           for (x = (yyn < 0 ? -yyn : 0);
1024                x < (sizeof(yytname) / sizeof(char *)); x++)
1025             if (yycheck[x + yyn] == x)
1026               size += strlen(yytname[x]) + 15, count++;
1027           msg = (char *) malloc(size + 15);
1028           if (msg != 0)
1029             {
1030               strcpy(msg, "parse error");
1031
1032               if (count < 5)
1033                 {
1034                   count = 0;
1035                   for (x = (yyn < 0 ? -yyn : 0);
1036                        x < (sizeof(yytname) / sizeof(char *)); x++)
1037                     if (yycheck[x + yyn] == x)
1038                       {
1039                         strcat(msg, count == 0 ? ", expecting `" : " or `");
1040                         strcat(msg, yytname[x]);
1041                         strcat(msg, "'");
1042                         count++;
1043                       }
1044                 }
1045               yyerror(msg);
1046               free(msg);
1047             }
1048           else
1049             yyerror ("parse error; also virtual memory exceeded");
1050         }
1051       else
1052 #endif /* YYERROR_VERBOSE */
1053         yyerror("parse error");
1054     }
1055
1056   goto yyerrlab1;
1057 yyerrlab1:   /* here on error raised explicitly by an action */
1058
1059   if (yyerrstatus == 3)
1060     {
1061       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1062
1063       /* return failure if at end of input */
1064       if (yychar == YYEOF)
1065         YYABORT;
1066
1067 #if YYDEBUG != 0
1068       if (yydebug)
1069         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1070 #endif
1071
1072       yychar = YYEMPTY;
1073     }
1074
1075   /* Else will try to reuse lookahead token
1076      after shifting the error token.  */
1077
1078   yyerrstatus = 3;              /* Each real token shifted decrements this */
1079
1080   goto yyerrhandle;
1081
1082 yyerrdefault:  /* current state does not do anything special for the error token. */
1083
1084 #if 0
1085   /* This is wrong; only states that explicitly want error tokens
1086      should shift them.  */
1087   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1088   if (yyn) goto yydefault;
1089 #endif
1090
1091 yyerrpop:   /* pop the current state because it cannot handle the error token */
1092
1093   if (yyssp == yyss) YYABORT;
1094   yyvsp--;
1095   yystate = *--yyssp;
1096 #ifdef YYLSP_NEEDED
1097   yylsp--;
1098 #endif
1099
1100 #if YYDEBUG != 0
1101   if (yydebug)
1102     {
1103       short *ssp1 = yyss - 1;
1104       fprintf (stderr, "Error: state stack now");
1105       while (ssp1 != yyssp)
1106         fprintf (stderr, " %d", *++ssp1);
1107       fprintf (stderr, "\n");
1108     }
1109 #endif
1110
1111 yyerrhandle:
1112
1113   yyn = yypact[yystate];
1114   if (yyn == YYFLAG)
1115     goto yyerrdefault;
1116
1117   yyn += YYTERROR;
1118   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1119     goto yyerrdefault;
1120
1121   yyn = yytable[yyn];
1122   if (yyn < 0)
1123     {
1124       if (yyn == YYFLAG)
1125         goto yyerrpop;
1126       yyn = -yyn;
1127       goto yyreduce;
1128     }
1129   else if (yyn == 0)
1130     goto yyerrpop;
1131
1132   if (yyn == YYFINAL)
1133     YYACCEPT;
1134
1135 #if YYDEBUG != 0
1136   if (yydebug)
1137     fprintf(stderr, "Shifting error token, ");
1138 #endif
1139
1140   *++yyvsp = yylval;
1141 #ifdef YYLSP_NEEDED
1142   *++yylsp = yylloc;
1143 #endif
1144
1145   yystate = yyn;
1146   goto yynewstate;
1147
1148  yyacceptlab:
1149   /* YYACCEPT comes here.  */
1150   if (yyfree_stacks)
1151     {
1152       free (yyss);
1153       free (yyvs);
1154 #ifdef YYLSP_NEEDED
1155       free (yyls);
1156 #endif
1157     }
1158   return 0;
1159
1160  yyabortlab:
1161   /* YYABORT comes here.  */
1162   if (yyfree_stacks)
1163     {
1164       free (yyss);
1165       free (yyvs);
1166 #ifdef YYLSP_NEEDED
1167       free (yyls);
1168 #endif
1169     }
1170   return 1;
1171 }
1172 #line 214 "tradcif.y"
1173
1174 \f
1175 /* During parsing of a C expression, the pointer to the next character
1176    is in this variable.  */
1177
1178 static char *lexptr;
1179
1180 /* Take care of parsing a number (anything that starts with a digit).
1181    Set yylval and return the token type; update lexptr.
1182    LEN is the number of characters in it.  */
1183
1184 /* maybe needs to actually deal with floating point numbers */
1185
1186 int
1187 parse_number (olen)
1188      int olen;
1189 {
1190   register char *p = lexptr;
1191   register long n = 0;
1192   register int c;
1193   register int base = 10;
1194   register int len = olen;
1195
1196   for (c = 0; c < len; c++)
1197     if (p[c] == '.') {
1198       /* It's a float since it contains a point.  */
1199       yyerror ("floating point numbers not allowed in #if expressions");
1200       return ERROR;
1201     }
1202
1203   yylval.integer.unsignedp = 0;
1204
1205   if (len >= 3 && (!strncmp (p, "0x", 2) || !strncmp (p, "0X", 2))) {
1206     p += 2;
1207     base = 16;
1208     len -= 2;
1209   }
1210   else if (*p == '0')
1211     base = 8;
1212
1213   while (len > 0) {
1214     c = *p++;
1215     len--;
1216     if (c >= 'A' && c <= 'Z') c += 'a' - 'A';
1217
1218     if (c >= '0' && c <= '9') {
1219       n *= base;
1220       n += c - '0';
1221     } else if (base == 16 && c >= 'a' && c <= 'f') {
1222       n *= base;
1223       n += c - 'a' + 10;
1224     } else {
1225       /* `l' means long, and `u' means unsigned.  */
1226       while (1) {
1227         if (c == 'l' || c == 'L')
1228           ;
1229         else if (c == 'u' || c == 'U')
1230           yylval.integer.unsignedp = 1;
1231         else
1232           break;
1233
1234         if (len == 0)
1235           break;
1236         c = *p++;
1237         len--;
1238       }
1239       /* Don't look for any more digits after the suffixes.  */
1240       break;
1241     }
1242   }
1243
1244   if (len != 0) {
1245     yyerror ("Invalid number in #if expression");
1246     return ERROR;
1247   }
1248
1249   /* If too big to be signed, consider it unsigned.  */
1250   if (n < 0)
1251     yylval.integer.unsignedp = 1;
1252
1253   lexptr = p;
1254   yylval.integer.value = n;
1255   return INT;
1256 }
1257
1258 struct token {
1259   const char *operator;
1260   int token;
1261 };
1262
1263 #ifndef NULL
1264 #define NULL 0
1265 #endif
1266
1267 static struct token tokentab2[] = {
1268   {"&&", AND},
1269   {"||", OR},
1270   {"<<", LSH},
1271   {">>", RSH},
1272   {"==", EQUAL},
1273   {"!=", NOTEQUAL},
1274   {"<=", LEQ},
1275   {">=", GEQ},
1276   {NULL, ERROR}
1277 };
1278
1279 /* Read one token, getting characters through lexptr.  */
1280
1281 int
1282 yylex ()
1283 {
1284   register int c;
1285   register int namelen;
1286   register char *tokstart;
1287   register struct token *toktab;
1288
1289  retry:
1290
1291   tokstart = lexptr;
1292   c = *tokstart;
1293   /* See if it is a special token of length 2.  */
1294   for (toktab = tokentab2; toktab->operator != NULL; toktab++)
1295     if (c == *toktab->operator && tokstart[1] == toktab->operator[1]) {
1296       lexptr += 2;
1297       return toktab->token;
1298     }
1299
1300   switch (c) {
1301   case 0:
1302     return 0;
1303     
1304   case ' ':
1305   case '\t':
1306   case '\r':
1307   case '\n':
1308     lexptr++;
1309     goto retry;
1310     
1311   case '\'':
1312     lexptr++;
1313     c = *lexptr++;
1314     if (c == '\\')
1315       c = parse_escape (&lexptr);
1316
1317     /* Sign-extend the constant if chars are signed on target machine.  */
1318     {
1319       if (lookup ((const unsigned char *)"__CHAR_UNSIGNED__",
1320                    sizeof ("__CHAR_UNSIGNED__")-1, -1)
1321           || ((c >> (CHAR_TYPE_SIZE - 1)) & 1) == 0)
1322         yylval.integer.value = c & ((1 << CHAR_TYPE_SIZE) - 1);
1323       else
1324         yylval.integer.value = c | ~((1 << CHAR_TYPE_SIZE) - 1);
1325     }
1326
1327     yylval.integer.unsignedp = 0;
1328     c = *lexptr++;
1329     if (c != '\'') {
1330       yyerror ("Invalid character constant in #if");
1331       return ERROR;
1332     }
1333     
1334     return CHAR;
1335
1336     /* some of these chars are invalid in constant expressions;
1337        maybe do something about them later */
1338   case '/':
1339   case '+':
1340   case '-':
1341   case '*':
1342   case '%':
1343   case '|':
1344   case '&':
1345   case '^':
1346   case '~':
1347   case '!':
1348   case '@':
1349   case '<':
1350   case '>':
1351   case '(':
1352   case ')':
1353   case '[':
1354   case ']':
1355   case '.':
1356   case '?':
1357   case ':':
1358   case '=':
1359   case '{':
1360   case '}':
1361   case ',':
1362     lexptr++;
1363     return c;
1364     
1365   case '"':
1366     yyerror ("double quoted strings not allowed in #if expressions");
1367     return ERROR;
1368   }
1369   if (c >= '0' && c <= '9') {
1370     /* It's a number */
1371     for (namelen = 0;
1372          c = tokstart[namelen], is_idchar[c] || c == '.'; 
1373          namelen++)
1374       ;
1375     return parse_number (namelen);
1376   }
1377   
1378   if (!is_idstart[c]) {
1379     yyerror ("Invalid token in expression");
1380     return ERROR;
1381   }
1382   
1383   /* It is a name.  See how long it is.  */
1384   
1385   for (namelen = 0;
1386        is_idchar[(int)(unsigned char)tokstart[namelen]];
1387        namelen++)
1388     ;
1389   
1390   lexptr += namelen;
1391   return NAME;
1392 }
1393
1394
1395 /* Parse a C escape sequence.  STRING_PTR points to a variable
1396    containing a pointer to the string to parse.  That pointer
1397    is updated past the characters we use.  The value of the
1398    escape sequence is returned.
1399
1400    A negative value means the sequence \ newline was seen,
1401    which is supposed to be equivalent to nothing at all.
1402
1403    If \ is followed by a null character, we return a negative
1404    value and leave the string pointer pointing at the null character.
1405
1406    If \ is followed by 000, we return 0 and leave the string pointer
1407    after the zeros.  A value of 0 does not mean end of string.  */
1408
1409 int
1410 parse_escape (string_ptr)
1411      char **string_ptr;
1412 {
1413   register int c = *(*string_ptr)++;
1414   switch (c)
1415     {
1416     case 'a':
1417       return TARGET_BELL;
1418     case 'b':
1419       return TARGET_BS;
1420     case 'e':
1421       return 033;
1422     case 'f':
1423       return TARGET_FF;
1424     case 'n':
1425       return TARGET_NEWLINE;
1426     case 'r':
1427       return TARGET_CR;
1428     case 't':
1429       return TARGET_TAB;
1430     case 'v':
1431       return TARGET_VT;
1432     case '\n':
1433       return -2;
1434     case 0:
1435       (*string_ptr)--;
1436       return 0;
1437     case '^':
1438       c = *(*string_ptr)++;
1439       if (c == '\\')
1440         c = parse_escape (string_ptr);
1441       if (c == '?')
1442         return 0177;
1443       return (c & 0200) | (c & 037);
1444       
1445     case '0':
1446     case '1':
1447     case '2':
1448     case '3':
1449     case '4':
1450     case '5':
1451     case '6':
1452     case '7':
1453       {
1454         register int i = c - '0';
1455         register int count = 0;
1456         while (++count < 3)
1457           {
1458             c = *(*string_ptr)++;
1459             if (c >= '0' && c <= '7')
1460               i = (i << 3) + c - '0';
1461             else
1462               {
1463                 (*string_ptr)--;
1464                 break;
1465               }
1466           }
1467         if ((i & ~((1 << CHAR_TYPE_SIZE) - 1)) != 0)
1468           {
1469             i &= (1 << CHAR_TYPE_SIZE) - 1;
1470             warning ("octal character constant does not fit in a byte");
1471           }
1472         return i;
1473       }
1474     case 'x':
1475       {
1476         register int i = 0;
1477         for (;;)
1478           {
1479             c = *(*string_ptr)++;
1480             if (c >= '0' && c <= '9')
1481               i = (i << 4) + c - '0';
1482             else if (c >= 'a' && c <= 'f')
1483               i = (i << 4) + c - 'a' + 10;
1484             else if (c >= 'A' && c <= 'F')
1485               i = (i << 4) + c - 'A' + 10;
1486             else
1487               {
1488                 (*string_ptr)--;
1489                 break;
1490               }
1491           }
1492         if ((i & ~((1 << BITS_PER_UNIT) - 1)) != 0)
1493           {
1494             i &= (1 << BITS_PER_UNIT) - 1;
1495             warning ("hex character constant does not fit in a byte");
1496           }
1497         return i;
1498       }
1499     default:
1500       return c;
1501     }
1502 }
1503
1504 void
1505 yyerror (s)
1506      const char *s;
1507 {
1508   error (s);
1509   longjmp (parse_return_error, 1);
1510 }
1511 \f
1512 /* This page contains the entry point to this file.  */
1513
1514 /* Parse STRING as an expression, and complain if this fails
1515    to use up all of the contents of STRING.  */
1516 /* We do not support C comments.  They should be removed before
1517    this function is called.  */
1518
1519 int
1520 parse_c_expression (string)
1521      char *string;
1522 {
1523   lexptr = string;
1524   
1525   if (lexptr == 0 || *lexptr == 0) {
1526     error ("empty #if expression");
1527     return 0;                   /* don't include the #if group */
1528   }
1529
1530   /* if there is some sort of scanning error, just return 0 and assume
1531      the parsing routine has printed an error message somewhere.
1532      there is surely a better thing to do than this.     */
1533   if (setjmp (parse_return_error))
1534     return 0;
1535
1536   if (yyparse ())
1537     return 0;                   /* actually this is never reached
1538                                    the way things stand. */
1539   if (*lexptr)
1540     error ("Junk after end of expression.");
1541
1542   return expression_value;      /* set by yyparse () */
1543 }