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