2 /* A Bison parser, made from cexp.y with Bison version GNU Bison version 1.22
5 #define YYBISON 1 /* Identify Bison output. */
24 /* #define YYDEBUG 1 */
26 #ifdef MULTIBYTE_CHARS
33 typedef unsigned char U_CHAR
;
35 /* This is used for communicating lists of keywords with cccp.c. */
43 /* Define a generic NULL if one hasn't already been defined. */
50 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
51 #define GENERIC_PTR void *
53 #define GENERIC_PTR char *
57 /* Find the largest host integer type and set its size and type. */
59 #ifndef HOST_BITS_PER_WIDE_INT
61 #if HOST_BITS_PER_LONG > HOST_BITS_PER_INT
62 #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
63 #define HOST_WIDE_INT long
65 #define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_INT
66 #define HOST_WIDE_INT int
72 #define NULL_PTR ((GENERIC_PTR)0)
77 HOST_WIDE_INT expression_value
;
79 static jmp_buf parse_return_error
;
81 /* Nonzero means count most punctuation as part of a name. */
82 static int keyword_parsing
= 0;
84 /* Nonzero means do not evaluate this expression.
85 This is a count, since unevaluated expressions can nest. */
86 static int skip_evaluation
;
88 /* some external tables of character types */
89 extern unsigned char is_idstart
[], is_idchar
[], is_hor_space
[];
91 extern char *xmalloc ();
93 /* Flag for -pedantic. */
96 /* Flag for -traditional. */
97 extern int traditional
;
99 #ifndef CHAR_TYPE_SIZE
100 #define CHAR_TYPE_SIZE BITS_PER_UNIT
103 #ifndef INT_TYPE_SIZE
104 #define INT_TYPE_SIZE BITS_PER_WORD
107 #ifndef LONG_TYPE_SIZE
108 #define LONG_TYPE_SIZE BITS_PER_WORD
111 #ifndef WCHAR_TYPE_SIZE
112 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
115 #ifndef MAX_CHAR_TYPE_SIZE
116 #define MAX_CHAR_TYPE_SIZE CHAR_TYPE_SIZE
119 #ifndef MAX_INT_TYPE_SIZE
120 #define MAX_INT_TYPE_SIZE INT_TYPE_SIZE
123 #ifndef MAX_LONG_TYPE_SIZE
124 #define MAX_LONG_TYPE_SIZE LONG_TYPE_SIZE
127 #ifndef MAX_WCHAR_TYPE_SIZE
128 #define MAX_WCHAR_TYPE_SIZE WCHAR_TYPE_SIZE
131 /* Yield nonzero if adding two numbers with A's and B's signs can yield a
132 number with SUM's sign, where A, B, and SUM are all C integers. */
133 #define possible_sum_sign(a, b, sum) ((((a) ^ (b)) | ~ ((a) ^ (sum))) < 0)
135 static void integer_overflow ();
136 static long left_shift ();
137 static long right_shift ();
140 struct constant
{long value
; int unsignedp
;} integer
;
141 struct name
{U_CHAR
*address
; int length
;} name
;
142 struct arglist
*keywords
;
158 #define YYLTYPE yyltype
172 #define YYFLAG -32768
175 #define YYTRANSLATE(x) ((unsigned)(x) <= 270 ? yytranslate[x] : 43)
177 static const char yytranslate
[] = { 0,
178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
181 2, 2, 29, 2, 31, 2, 27, 14, 2, 32,
182 33, 25, 23, 9, 24, 2, 26, 2, 2, 2,
183 2, 2, 2, 2, 2, 2, 2, 8, 2, 17,
184 2, 18, 7, 2, 2, 2, 2, 2, 2, 2,
185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
187 2, 2, 2, 13, 2, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
190 2, 2, 2, 12, 2, 30, 2, 2, 2, 2,
191 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
193 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
196 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
199 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
200 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
201 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
202 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
203 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
204 6, 10, 11, 15, 16, 19, 20, 21, 22, 28
208 static const short yyprhs
[] = { 0,
209 0, 2, 4, 8, 11, 14, 17, 20, 23, 24,
210 31, 35, 39, 43, 47, 51, 55, 59, 63, 67,
211 71, 75, 79, 83, 87, 91, 95, 99, 100, 105,
212 106, 111, 112, 113, 121, 123, 125, 127, 128, 133
215 static const short yyrhs
[] = { 35,
216 0, 36, 0, 35, 9, 36, 0, 24, 36, 0,
217 29, 36, 0, 23, 36, 0, 30, 36, 0, 31,
218 5, 0, 0, 31, 5, 37, 32, 42, 33, 0,
219 32, 35, 33, 0, 36, 25, 36, 0, 36, 26,
220 36, 0, 36, 27, 36, 0, 36, 23, 36, 0,
221 36, 24, 36, 0, 36, 21, 36, 0, 36, 22,
222 36, 0, 36, 15, 36, 0, 36, 16, 36, 0,
223 36, 19, 36, 0, 36, 20, 36, 0, 36, 17,
224 36, 0, 36, 18, 36, 0, 36, 14, 36, 0,
225 36, 13, 36, 0, 36, 12, 36, 0, 0, 36,
226 11, 38, 36, 0, 0, 36, 10, 39, 36, 0,
227 0, 0, 36, 7, 40, 36, 8, 41, 36, 0,
228 3, 0, 4, 0, 5, 0, 0, 32, 42, 33,
235 static const short yyrline
[] = { 0,
236 176, 181, 182, 189, 194, 197, 199, 202, 206, 208,
237 213, 218, 230, 246, 258, 265, 272, 278, 284, 287,
238 290, 296, 302, 308, 314, 317, 320, 323, 326, 329,
239 332, 335, 337, 340, 343, 345, 347, 352, 354, 367
242 static const char * const yytname
[] = { "$","error","$illegal.","INT","CHAR",
243 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
244 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
245 "'~'","'#'","'('","')'","start","exp1","exp","@1","@2","@3","@4","@5","keywords",
250 static const short yyr1
[] = { 0,
251 34, 35, 35, 36, 36, 36, 36, 36, 37, 36,
252 36, 36, 36, 36, 36, 36, 36, 36, 36, 36,
253 36, 36, 36, 36, 36, 36, 36, 38, 36, 39,
254 36, 40, 41, 36, 36, 36, 36, 42, 42, 42
257 static const short yyr2
[] = { 0,
258 1, 1, 3, 2, 2, 2, 2, 2, 0, 6,
259 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
260 3, 3, 3, 3, 3, 3, 3, 0, 4, 0,
261 4, 0, 0, 7, 1, 1, 1, 0, 4, 2
264 static const short yydefact
[] = { 0,
265 35, 36, 37, 0, 0, 0, 0, 0, 0, 1,
266 2, 6, 4, 5, 7, 8, 0, 0, 32, 30,
267 28, 0, 0, 0, 0, 0, 0, 0, 0, 0,
268 0, 0, 0, 0, 0, 0, 0, 0, 11, 3,
269 0, 0, 0, 27, 26, 25, 19, 20, 23, 24,
270 21, 22, 17, 18, 15, 16, 12, 13, 14, 38,
271 0, 31, 29, 38, 38, 0, 33, 40, 0, 10,
272 0, 38, 34, 39, 0, 0, 0
275 static const short yydefgoto
[] = { 75,
276 10, 11, 38, 43, 42, 41, 71, 66
279 static const short yypact
[] = { 12,
280 -32768,-32768,-32768, 12, 12, 12, 12, 1, 12, 4,
281 79,-32768,-32768,-32768,-32768, -21, 31, 12,-32768,-32768,
282 -32768, 12, 12, 12, 12, 12, 12, 12, 12, 12,
283 12, 12, 12, 12, 12, 12, 12, 30,-32768, 79,
284 12, 12, 12, 110, 124, 137, 148, 148, 155, 155,
285 155, 155, 160, 160, -17, -17,-32768,-32768,-32768, 2,
286 58, 34, 95, 2, 2, 54,-32768,-32768, 55,-32768,
287 12, 2, 79,-32768, 63, 188,-32768
290 static const short yypgoto
[] = {-32768,
291 180, -4,-32768,-32768,-32768,-32768,-32768, -60
298 static const short yytable
[] = { 12,
299 13, 14, 15, 68, 69, 16, 64, 35, 36, 37,
300 -9, 74, 18, 40, 1, 2, 3, 44, 45, 46,
301 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
302 57, 58, 59, 65, 4, 5, 61, 62, 63, 18,
303 6, 7, 8, 9, 21, 22, 23, 24, 25, 26,
304 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
305 37, 60, 76, 39, 19, 67, 73, 20, 21, 22,
306 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
307 33, 34, 35, 36, 37, 19, 70, 72, 20, 21,
308 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
309 32, 33, 34, 35, 36, 37, 22, 23, 24, 25,
310 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
311 36, 37, 23, 24, 25, 26, 27, 28, 29, 30,
312 31, 32, 33, 34, 35, 36, 37, 24, 25, 26,
313 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
314 37, 25, 26, 27, 28, 29, 30, 31, 32, 33,
315 34, 35, 36, 37, 27, 28, 29, 30, 31, 32,
316 33, 34, 35, 36, 37, 31, 32, 33, 34, 35,
317 36, 37, 33, 34, 35, 36, 37, 77, 17
320 static const short yycheck
[] = { 4,
321 5, 6, 7, 64, 65, 5, 5, 25, 26, 27,
322 32, 72, 9, 18, 3, 4, 5, 22, 23, 24,
323 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
324 35, 36, 37, 32, 23, 24, 41, 42, 43, 9,
325 29, 30, 31, 32, 11, 12, 13, 14, 15, 16,
326 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
327 27, 32, 0, 33, 7, 8, 71, 10, 11, 12,
328 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
329 23, 24, 25, 26, 27, 7, 33, 33, 10, 11,
330 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
331 22, 23, 24, 25, 26, 27, 12, 13, 14, 15,
332 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
333 26, 27, 13, 14, 15, 16, 17, 18, 19, 20,
334 21, 22, 23, 24, 25, 26, 27, 14, 15, 16,
335 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
336 27, 15, 16, 17, 18, 19, 20, 21, 22, 23,
337 24, 25, 26, 27, 17, 18, 19, 20, 21, 22,
338 23, 24, 25, 26, 27, 21, 22, 23, 24, 25,
339 26, 27, 23, 24, 25, 26, 27, 0, 9
341 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
344 /* Skeleton output parser for bison,
345 Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
347 This program is free software; you can redistribute it and/or modify
348 it under the terms of the GNU General Public License as published by
349 the Free Software Foundation; either version 1, or (at your option)
352 This program is distributed in the hope that it will be useful,
353 but WITHOUT ANY WARRANTY; without even the implied warranty of
354 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
355 GNU General Public License for more details.
357 You should have received a copy of the GNU General Public License
358 along with this program; if not, write to the Free Software
359 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
364 #define alloca __builtin_alloca
365 #else /* not GNU C. */
366 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
368 #else /* not sparc */
369 #if defined (MSDOS) && !defined (__TURBOC__)
371 #else /* not MSDOS, or __TURBOC__ */
375 #else /* not MSDOS, __TURBOC__, or _AIX */
379 void *alloca (unsigned int);
381 #else /* not __cplusplus */
383 #endif /* not __cplusplus */
385 #endif /* not _AIX */
386 #endif /* not MSDOS, or __TURBOC__ */
387 #endif /* not sparc. */
388 #endif /* not GNU C. */
389 #endif /* alloca not defined. */
391 /* This is the parser code that is written into each bison parser
392 when the %semantic_parser declaration is not specified in the grammar.
393 It was written by Richard Stallman by simplifying the hairy parser
394 used when %semantic_parser is specified. */
396 /* Note: there must be only one dollar sign in this file.
397 It is replaced by the list of actions, each action
398 as one case of the switch. */
400 #define yyerrok (yyerrstatus = 0)
401 #define yyclearin (yychar = YYEMPTY)
404 #define YYACCEPT return(0)
405 #define YYABORT return(1)
406 #define YYERROR goto yyerrlab1
407 /* Like YYERROR except do call yyerror.
408 This remains here temporarily to ease the
409 transition to the new meaning of YYERROR, for GCC.
410 Once GCC version 2 has supplanted version 1, this can go. */
411 #define YYFAIL goto yyerrlab
412 #define YYRECOVERING() (!!yyerrstatus)
413 #define YYBACKUP(token, value) \
415 if (yychar == YYEMPTY && yylen == 1) \
416 { yychar = (token), yylval = (value); \
417 yychar1 = YYTRANSLATE (yychar); \
422 { yyerror ("syntax error: cannot back up"); YYERROR; } \
426 #define YYERRCODE 256
429 #define YYLEX yylex()
434 #define YYLEX yylex(&yylval, &yylloc)
436 #define YYLEX yylex(&yylval)
440 /* If nonreentrant, generate the variables here */
444 int yychar
; /* the lookahead symbol */
445 YYSTYPE yylval
; /* the semantic value of the */
446 /* lookahead symbol */
449 YYLTYPE yylloc
; /* location data for the lookahead */
453 int yynerrs
; /* number of parse errors so far */
454 #endif /* not YYPURE */
457 int yydebug
; /* nonzero means print parse trace */
458 /* Since this is uninitialized, it does not stop multiple parsers
462 /* YYINITDEPTH indicates the initial size of the parser's stacks */
465 #define YYINITDEPTH 200
468 /* YYMAXDEPTH is the maximum size the stacks can grow to
469 (effective only if the built-in stack extension method is used). */
476 #define YYMAXDEPTH 10000
479 /* Prevent warning if -Wstrict-prototypes. */
484 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
485 #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
486 #else /* not GNU C or C++ */
489 /* This is the most reliable way to avoid incompatibilities
490 in available built-in functions on various systems. */
492 __yy_bcopy (from
, to
, count
)
497 register char *f
= from
;
498 register char *t
= to
;
499 register int i
= count
;
505 #else /* __cplusplus */
507 /* This is the most reliable way to avoid incompatibilities
508 in available built-in functions on various systems. */
510 __yy_bcopy (char *from
, char *to
, int count
)
512 register char *f
= from
;
513 register char *t
= to
;
514 register int i
= count
;
527 register int yystate
;
529 register short *yyssp
;
530 register YYSTYPE
*yyvsp
;
531 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
532 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
534 short yyssa
[YYINITDEPTH
]; /* the state stack */
535 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
537 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
538 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
541 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
542 YYLTYPE
*yyls
= yylsa
;
545 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
547 #define YYPOPSTACK (yyvsp--, yyssp--)
550 int yystacksize
= YYINITDEPTH
;
561 YYSTYPE yyval
; /* the variable used to return */
562 /* semantic values from the action */
569 fprintf(stderr
, "Starting parse\n");
575 yychar
= YYEMPTY
; /* Cause a token to be read. */
577 /* Initialize stack pointers.
578 Waste one element of value and location stack
579 so that they stay on the same level as the state stack.
580 The wasted elements are never initialized. */
588 /* Push a new state, which is found in yystate . */
589 /* In all cases, when you get here, the value and location stacks
590 have just been pushed. so pushing a state here evens the stacks. */
595 if (yyssp
>= yyss
+ yystacksize
- 1)
597 /* Give user a chance to reallocate the stack */
598 /* Use copies of these so that the &'s don't force the real ones into memory. */
599 YYSTYPE
*yyvs1
= yyvs
;
602 YYLTYPE
*yyls1
= yyls
;
605 /* Get the current used size of the three stacks, in elements. */
606 int size
= yyssp
- yyss
+ 1;
609 /* Each stack pointer address is followed by the size of
610 the data in use in that stack, in bytes. */
612 /* This used to be a conditional around just the two extra args,
613 but that might be undefined if yyoverflow is a macro. */
614 yyoverflow("parser stack overflow",
615 &yyss1
, size
* sizeof (*yyssp
),
616 &yyvs1
, size
* sizeof (*yyvsp
),
617 &yyls1
, size
* sizeof (*yylsp
),
620 yyoverflow("parser stack overflow",
621 &yyss1
, size
* sizeof (*yyssp
),
622 &yyvs1
, size
* sizeof (*yyvsp
),
626 yyss
= yyss1
; yyvs
= yyvs1
;
630 #else /* no yyoverflow */
631 /* Extend the stack our own way. */
632 if (yystacksize
>= YYMAXDEPTH
)
634 yyerror("parser stack overflow");
638 if (yystacksize
> YYMAXDEPTH
)
639 yystacksize
= YYMAXDEPTH
;
640 yyss
= (short *) alloca (yystacksize
* sizeof (*yyssp
));
641 __yy_bcopy ((char *)yyss1
, (char *)yyss
, size
* sizeof (*yyssp
));
642 yyvs
= (YYSTYPE
*) alloca (yystacksize
* sizeof (*yyvsp
));
643 __yy_bcopy ((char *)yyvs1
, (char *)yyvs
, size
* sizeof (*yyvsp
));
645 yyls
= (YYLTYPE
*) alloca (yystacksize
* sizeof (*yylsp
));
646 __yy_bcopy ((char *)yyls1
, (char *)yyls
, size
* sizeof (*yylsp
));
648 #endif /* no yyoverflow */
650 yyssp
= yyss
+ size
- 1;
651 yyvsp
= yyvs
+ size
- 1;
653 yylsp
= yyls
+ size
- 1;
658 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
661 if (yyssp
>= yyss
+ yystacksize
- 1)
667 fprintf(stderr
, "Entering state %d\n", yystate
);
673 /* Do appropriate processing given the current state. */
674 /* Read a lookahead token if we need one and don't already have one. */
677 /* First try to decide what to do without reference to lookahead token. */
679 yyn
= yypact
[yystate
];
683 /* Not known => get a lookahead token if don't already have one. */
685 /* yychar is either YYEMPTY or YYEOF
686 or a valid token in external form. */
688 if (yychar
== YYEMPTY
)
692 fprintf(stderr
, "Reading a token: ");
697 /* Convert token to internal form (in yychar1) for indexing tables with */
699 if (yychar
<= 0) /* This means end of input. */
702 yychar
= YYEOF
; /* Don't call YYLEX any more */
706 fprintf(stderr
, "Now at end of input.\n");
711 yychar1
= YYTRANSLATE(yychar
);
716 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
717 /* Give the individual parser a way to print the precise meaning
718 of a token, for further debugging info. */
720 YYPRINT (stderr
, yychar
, yylval
);
722 fprintf (stderr
, ")\n");
728 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
733 /* yyn is what to do for this token type in this state.
734 Negative => reduce, -yyn is rule number.
735 Positive => shift, yyn is new state.
736 New state is final state => don't bother to shift,
738 0, or most negative number => error. */
753 /* Shift the lookahead token. */
757 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
760 /* Discard the token being shifted unless it is eof. */
769 /* count tokens shifted since error; after three, turn off error status. */
770 if (yyerrstatus
) yyerrstatus
--;
775 /* Do the default action for the current state. */
778 yyn
= yydefact
[yystate
];
782 /* Do a reduction. yyn is the number of a rule to reduce with. */
786 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
793 fprintf (stderr
, "Reducing via rule %d (line %d), ",
796 /* Print the symbols being reduced, and their result. */
797 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
798 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
799 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
807 { expression_value
= yyvsp
[0].integer
.value
; ;
811 pedwarn ("comma operator in operand of `#if'");
812 yyval
.integer
= yyvsp
[0].integer
; ;
815 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
816 if ((yyval
.integer
.value
& yyvsp
[0].integer
.value
) < 0 && ! yyvsp
[0].integer
.unsignedp
)
818 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; ;
821 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
822 yyval
.integer
.unsignedp
= 0; ;
825 { yyval
.integer
= yyvsp
[0].integer
; ;
828 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
829 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; ;
832 { yyval
.integer
.value
= check_assertion (yyvsp
[0].name
.address
, yyvsp
[0].name
.length
,
834 yyval
.integer
.unsignedp
= 0; ;
837 { keyword_parsing
= 1; ;
840 { yyval
.integer
.value
= check_assertion (yyvsp
[-4].name
.address
, yyvsp
[-4].name
.length
,
841 1, yyvsp
[-1].keywords
);
843 yyval
.integer
.unsignedp
= 0; ;
846 { yyval
.integer
= yyvsp
[-1].integer
; ;
849 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
850 if (yyval
.integer
.unsignedp
)
851 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
854 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
855 if (yyvsp
[-2].integer
.value
856 && (yyval
.integer
.value
/ yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
857 || (yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0))
862 { if (yyvsp
[0].integer
.value
== 0)
864 if (!skip_evaluation
)
865 error ("division by zero in #if");
866 yyvsp
[0].integer
.value
= 1;
868 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
869 if (yyval
.integer
.unsignedp
)
870 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
873 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
874 if ((yyval
.integer
.value
& yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
) < 0)
879 { if (yyvsp
[0].integer
.value
== 0)
881 if (!skip_evaluation
)
882 error ("division by zero in #if");
883 yyvsp
[0].integer
.value
= 1;
885 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
886 if (yyval
.integer
.unsignedp
)
887 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
889 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
; ;
892 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
+ yyvsp
[0].integer
.value
;
893 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
894 if (! yyval
.integer
.unsignedp
895 && ! possible_sum_sign (yyvsp
[-2].integer
.value
, yyvsp
[0].integer
.value
,
896 yyval
.integer
.value
))
897 integer_overflow (); ;
900 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
901 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
902 if (! yyval
.integer
.unsignedp
903 && ! possible_sum_sign (yyval
.integer
.value
, yyvsp
[0].integer
.value
,
904 yyvsp
[-2].integer
.value
))
905 integer_overflow (); ;
908 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
909 if (yyvsp
[0].integer
.value
< 0 && ! yyvsp
[0].integer
.unsignedp
)
910 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
912 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
915 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
916 if (yyvsp
[0].integer
.value
< 0 && ! yyvsp
[0].integer
.unsignedp
)
917 yyval
.integer
.value
= left_shift (&yyvsp
[-2].integer
, -yyvsp
[0].integer
.value
);
919 yyval
.integer
.value
= right_shift (&yyvsp
[-2].integer
, yyvsp
[0].integer
.value
); ;
922 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
923 yyval
.integer
.unsignedp
= 0; ;
926 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
927 yyval
.integer
.unsignedp
= 0; ;
930 { yyval
.integer
.unsignedp
= 0;
931 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
932 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
;
934 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
; ;
937 { yyval
.integer
.unsignedp
= 0;
938 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
939 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
;
941 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
; ;
944 { yyval
.integer
.unsignedp
= 0;
945 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
946 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
;
948 yyval
.integer
.value
= yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
; ;
951 { yyval
.integer
.unsignedp
= 0;
952 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
953 yyval
.integer
.value
= (unsigned long) yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
;
955 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
; ;
958 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
959 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
962 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
963 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
966 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
967 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
970 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
973 { skip_evaluation
-= !yyvsp
[-3].integer
.value
;
974 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
&& yyvsp
[0].integer
.value
);
975 yyval
.integer
.unsignedp
= 0; ;
978 { skip_evaluation
+= !!yyvsp
[-1].integer
.value
; ;
981 { skip_evaluation
-= !!yyvsp
[-3].integer
.value
;
982 yyval
.integer
.value
= (yyvsp
[-3].integer
.value
|| yyvsp
[0].integer
.value
);
983 yyval
.integer
.unsignedp
= 0; ;
986 { skip_evaluation
+= !yyvsp
[-1].integer
.value
; ;
989 { skip_evaluation
+= !!yyvsp
[-4].integer
.value
- !yyvsp
[-4].integer
.value
; ;
992 { skip_evaluation
-= !!yyvsp
[-6].integer
.value
;
993 yyval
.integer
.value
= yyvsp
[-6].integer
.value
? yyvsp
[-3].integer
.value
: yyvsp
[0].integer
.value
;
994 yyval
.integer
.unsignedp
= yyvsp
[-3].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
997 { yyval
.integer
= yylval
.integer
; ;
1000 { yyval
.integer
= yylval
.integer
; ;
1003 { yyval
.integer
.value
= 0;
1004 yyval
.integer
.unsignedp
= 0; ;
1007 { yyval
.keywords
= 0; ;
1010 { struct arglist
*temp
;
1011 yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1012 yyval
.keywords
->next
= yyvsp
[-2].keywords
;
1013 yyval
.keywords
->name
= (U_CHAR
*) "(";
1014 yyval
.keywords
->length
= 1;
1015 temp
= yyval
.keywords
;
1016 while (temp
!= 0 && temp
->next
!= 0)
1018 temp
->next
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1019 temp
->next
->next
= yyvsp
[0].keywords
;
1020 temp
->next
->name
= (U_CHAR
*) ")";
1021 temp
->next
->length
= 1; ;
1024 { yyval
.keywords
= (struct arglist
*) xmalloc (sizeof (struct arglist
));
1025 yyval
.keywords
->name
= yyvsp
[-1].name
.address
;
1026 yyval
.keywords
->length
= yyvsp
[-1].name
.length
;
1027 yyval
.keywords
->next
= yyvsp
[0].keywords
; ;
1030 /* the action file gets copied in in place of this dollarsign */
1042 short *ssp1
= yyss
- 1;
1043 fprintf (stderr
, "state stack now");
1044 while (ssp1
!= yyssp
)
1045 fprintf (stderr
, " %d", *++ssp1
);
1046 fprintf (stderr
, "\n");
1056 yylsp
->first_line
= yylloc
.first_line
;
1057 yylsp
->first_column
= yylloc
.first_column
;
1058 yylsp
->last_line
= (yylsp
-1)->last_line
;
1059 yylsp
->last_column
= (yylsp
-1)->last_column
;
1064 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1065 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1069 /* Now "shift" the result of the reduction.
1070 Determine what state that goes to,
1071 based on the state we popped back to
1072 and the rule number reduced by. */
1076 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1077 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1078 yystate
= yytable
[yystate
];
1080 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1084 yyerrlab
: /* here on detecting error */
1087 /* If not already recovering from an error, report this error. */
1091 #ifdef YYERROR_VERBOSE
1092 yyn
= yypact
[yystate
];
1094 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1101 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1102 for (x
= (yyn
< 0 ? -yyn
: 0);
1103 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1104 if (yycheck
[x
+ yyn
] == x
)
1105 size
+= strlen(yytname
[x
]) + 15, count
++;
1106 msg
= (char *) malloc(size
+ 15);
1109 strcpy(msg
, "parse error");
1114 for (x
= (yyn
< 0 ? -yyn
: 0);
1115 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1116 if (yycheck
[x
+ yyn
] == x
)
1118 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1119 strcat(msg
, yytname
[x
]);
1128 yyerror ("parse error; also virtual memory exceeded");
1131 #endif /* YYERROR_VERBOSE */
1132 yyerror("parse error");
1136 yyerrlab1
: /* here on error raised explicitly by an action */
1138 if (yyerrstatus
== 3)
1140 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1142 /* return failure if at end of input */
1143 if (yychar
== YYEOF
)
1148 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1154 /* Else will try to reuse lookahead token
1155 after shifting the error token. */
1157 yyerrstatus
= 3; /* Each real token shifted decrements this */
1161 yyerrdefault
: /* current state does not do anything special for the error token. */
1164 /* This is wrong; only states that explicitly want error tokens
1165 should shift them. */
1166 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1167 if (yyn
) goto yydefault
;
1170 yyerrpop
: /* pop the current state because it cannot handle the error token */
1172 if (yyssp
== yyss
) YYABORT
;
1182 short *ssp1
= yyss
- 1;
1183 fprintf (stderr
, "Error: state stack now");
1184 while (ssp1
!= yyssp
)
1185 fprintf (stderr
, " %d", *++ssp1
);
1186 fprintf (stderr
, "\n");
1192 yyn
= yypact
[yystate
];
1197 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1216 fprintf(stderr
, "Shifting error token, ");
1229 /* During parsing of a C expression, the pointer to the next character
1230 is in this variable. */
1232 static char *lexptr
;
1234 /* Take care of parsing a number (anything that starts with a digit).
1235 Set yylval and return the token type; update lexptr.
1236 LEN is the number of characters in it. */
1238 /* maybe needs to actually deal with floating point numbers */
1244 register char *p
= lexptr
;
1246 register unsigned long n
= 0, nd
, ULONG_MAX_over_base
;
1247 register int base
= 10;
1248 register int len
= olen
;
1249 register int overflow
= 0;
1250 register int digit
, largest_digit
= 0;
1253 for (c
= 0; c
< len
; c
++)
1255 /* It's a float since it contains a point. */
1256 yyerror ("floating point numbers not allowed in #if expressions");
1260 yylval
.integer
.unsignedp
= 0;
1262 if (len
>= 3 && (!strncmp (p
, "0x", 2) || !strncmp (p
, "0X", 2))) {
1270 ULONG_MAX_over_base
= (unsigned long) -1 / base
;
1272 for (; len
> 0; len
--) {
1275 if (c
>= '0' && c
<= '9')
1277 else if (base
== 16 && c
>= 'a' && c
<= 'f')
1278 digit
= c
- 'a' + 10;
1279 else if (base
== 16 && c
>= 'A' && c
<= 'F')
1280 digit
= c
- 'A' + 10;
1282 /* `l' means long, and `u' means unsigned. */
1284 if (c
== 'l' || c
== 'L')
1287 yyerror ("two `l's in integer constant");
1290 else if (c
== 'u' || c
== 'U')
1292 if (yylval
.integer
.unsignedp
)
1293 yyerror ("two `u's in integer constant");
1294 yylval
.integer
.unsignedp
= 1;
1303 /* Don't look for any more digits after the suffixes. */
1306 if (largest_digit
< digit
)
1307 largest_digit
= digit
;
1308 nd
= n
* base
+ digit
;
1309 overflow
|= ULONG_MAX_over_base
< n
| nd
< n
;
1314 yyerror ("Invalid number in #if expression");
1318 if (base
<= largest_digit
)
1319 warning ("integer constant contains digits beyond the radix");
1322 warning ("integer constant out of range");
1324 /* If too big to be signed, consider it unsigned. */
1325 if ((long) n
< 0 && ! yylval
.integer
.unsignedp
)
1328 warning ("integer constant is so large that it is unsigned");
1329 yylval
.integer
.unsignedp
= 1;
1333 yylval
.integer
.value
= n
;
1342 static struct token tokentab2
[] = {
1356 /* Read one token, getting characters through lexptr. */
1362 register int namelen
;
1363 register unsigned char *tokstart
;
1364 register struct token
*toktab
;
1369 tokstart
= (unsigned char *) lexptr
;
1371 /* See if it is a special token of length 2. */
1372 if (! keyword_parsing
)
1373 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1374 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1376 if (toktab
->token
== ERROR
)
1378 char *buf
= (char *) alloca (40);
1379 sprintf (buf
, "`%s' not allowed in operand of `#if'", toktab
->operator);
1382 return toktab
->token
;
1397 /* Capital L may start a wide-string or wide-character constant. */
1398 if (lexptr
[1] == '\'')
1404 if (lexptr
[1] == '"')
1408 goto string_constant
;
1416 if (keyword_parsing
) {
1417 char *start_ptr
= lexptr
- 1;
1421 c
= parse_escape (&lexptr
);
1425 yylval
.name
.address
= tokstart
;
1426 yylval
.name
.length
= lexptr
- start_ptr
;
1430 /* This code for reading a character constant
1431 handles multicharacter constants and wide characters.
1432 It is mostly copied from c-lex.c. */
1434 register int result
= 0;
1435 register num_chars
= 0;
1436 unsigned width
= MAX_CHAR_TYPE_SIZE
;
1442 width
= MAX_WCHAR_TYPE_SIZE
;
1443 #ifdef MULTIBYTE_CHARS
1444 max_chars
= MB_CUR_MAX
;
1450 max_chars
= MAX_LONG_TYPE_SIZE
/ width
;
1452 token_buffer
= (char *) alloca (max_chars
+ 1);
1458 if (c
== '\'' || c
== EOF
)
1463 c
= parse_escape (&lexptr
);
1464 if (width
< HOST_BITS_PER_INT
1465 && (unsigned) c
>= (1 << width
))
1466 pedwarn ("escape sequence out of range for character");
1471 /* Merge character into result; ignore excess chars. */
1472 if (num_chars
< max_chars
+ 1)
1474 if (width
< HOST_BITS_PER_INT
)
1475 result
= (result
<< width
) | (c
& ((1 << width
) - 1));
1478 token_buffer
[num_chars
- 1] = c
;
1482 token_buffer
[num_chars
] = 0;
1485 error ("malformatted character constant");
1486 else if (num_chars
== 0)
1487 error ("empty character constant");
1488 else if (num_chars
> max_chars
)
1490 num_chars
= max_chars
;
1491 error ("character constant too long");
1493 else if (num_chars
!= 1 && ! traditional
)
1494 warning ("multi-character character constant");
1496 /* If char type is signed, sign-extend the constant. */
1499 int num_bits
= num_chars
* width
;
1501 if (lookup ("__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1, -1)
1502 || ((result
>> (num_bits
- 1)) & 1) == 0)
1503 yylval
.integer
.value
1504 = result
& ((unsigned long) ~0 >> (HOST_BITS_PER_LONG
- num_bits
));
1506 yylval
.integer
.value
1507 = result
| ~((unsigned long) ~0 >> (HOST_BITS_PER_LONG
- num_bits
));
1511 #ifdef MULTIBYTE_CHARS
1512 /* Set the initial shift state and convert the next sequence. */
1514 /* In all locales L'\0' is zero and mbtowc will return zero,
1517 || (num_chars
== 1 && token_buffer
[0] != '\0'))
1520 (void) mbtowc (NULL_PTR
, NULL_PTR
, 0);
1521 if (mbtowc (& wc
, token_buffer
, num_chars
) == num_chars
)
1524 warning ("Ignoring invalid multibyte character");
1527 yylval
.integer
.value
= result
;
1531 /* This is always a signed type. */
1532 yylval
.integer
.unsignedp
= 0;
1536 /* some of these chars are invalid in constant expressions;
1537 maybe do something about them later */
1561 if (keyword_parsing
)
1570 if (keyword_parsing
) {
1571 char *start_ptr
= lexptr
;
1576 c
= parse_escape (&lexptr
);
1580 yylval
.name
.address
= tokstart
;
1581 yylval
.name
.length
= lexptr
- start_ptr
;
1584 yyerror ("string constants not allowed in #if expressions");
1588 if (c
>= '0' && c
<= '9' && !keyword_parsing
) {
1591 c
= tokstart
[namelen
], is_idchar
[c
] || c
== '.';
1594 return parse_number (namelen
);
1597 /* It is a name. See how long it is. */
1599 if (keyword_parsing
) {
1600 for (namelen
= 0;; namelen
++) {
1601 if (is_hor_space
[tokstart
[namelen
]])
1603 if (tokstart
[namelen
] == '(' || tokstart
[namelen
] == ')')
1605 if (tokstart
[namelen
] == '"' || tokstart
[namelen
] == '\'')
1609 if (!is_idstart
[c
]) {
1610 yyerror ("Invalid token in expression");
1614 for (namelen
= 0; is_idchar
[tokstart
[namelen
]]; namelen
++)
1619 yylval
.name
.address
= tokstart
;
1620 yylval
.name
.length
= namelen
;
1625 /* Parse a C escape sequence. STRING_PTR points to a variable
1626 containing a pointer to the string to parse. That pointer
1627 is updated past the characters we use. The value of the
1628 escape sequence is returned.
1630 A negative value means the sequence \ newline was seen,
1631 which is supposed to be equivalent to nothing at all.
1633 If \ is followed by a null character, we return a negative
1634 value and leave the string pointer pointing at the null character.
1636 If \ is followed by 000, we return 0 and leave the string pointer
1637 after the zeros. A value of 0 does not mean end of string. */
1640 parse_escape (string_ptr
)
1643 register int c
= *(*string_ptr
)++;
1653 pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c
);
1658 return TARGET_NEWLINE
;
1680 register int i
= c
- '0';
1681 register int count
= 0;
1684 c
= *(*string_ptr
)++;
1685 if (c
>= '0' && c
<= '7')
1686 i
= (i
<< 3) + c
- '0';
1693 if ((i
& ~((1 << MAX_CHAR_TYPE_SIZE
) - 1)) != 0)
1695 i
&= (1 << MAX_CHAR_TYPE_SIZE
) - 1;
1696 warning ("octal character constant does not fit in a byte");
1702 register unsigned i
= 0, overflow
= 0, digits_found
= 0, digit
;
1705 c
= *(*string_ptr
)++;
1706 if (c
>= '0' && c
<= '9')
1708 else if (c
>= 'a' && c
<= 'f')
1709 digit
= c
- 'a' + 10;
1710 else if (c
>= 'A' && c
<= 'F')
1711 digit
= c
- 'A' + 10;
1717 overflow
|= i
^ (i
<< 4 >> 4);
1718 i
= (i
<< 4) + digit
;
1722 yyerror ("\\x used with no following hex digits");
1723 if (overflow
| (i
& ~((1 << BITS_PER_UNIT
) - 1)))
1725 i
&= (1 << BITS_PER_UNIT
) - 1;
1726 warning ("hex character constant does not fit in a byte");
1740 skip_evaluation
= 0;
1741 longjmp (parse_return_error
, 1);
1747 if (!skip_evaluation
&& pedantic
)
1748 pedwarn ("integer overflow in preprocessor expression");
1756 /* It's unclear from the C standard whether shifts can overflow.
1757 The following code ignores overflow; perhaps a C standard
1758 interpretation ruling is needed. */
1759 if (b
>= HOST_BITS_PER_LONG
)
1761 else if (a
->unsignedp
)
1762 return (unsigned long) a
->value
<< b
;
1764 return a
->value
<< b
;
1772 if (b
>= HOST_BITS_PER_LONG
)
1773 return a
->unsignedp
? 0 : a
->value
>> (HOST_BITS_PER_LONG
- 1);
1774 else if (a
->unsignedp
)
1775 return (unsigned long) a
->value
>> b
;
1777 return a
->value
>> b
;
1780 /* This page contains the entry point to this file. */
1782 /* Parse STRING as an expression, and complain if this fails
1783 to use up all of the contents of STRING. */
1784 /* We do not support C comments. They should be removed before
1785 this function is called. */
1788 parse_c_expression (string
)
1793 if (lexptr
== 0 || *lexptr
== 0) {
1794 error ("empty #if expression");
1795 return 0; /* don't include the #if group */
1798 /* if there is some sort of scanning error, just return 0 and assume
1799 the parsing routine has printed an error message somewhere.
1800 there is surely a better thing to do than this. */
1801 if (setjmp (parse_return_error
))
1805 return 0; /* actually this is never reached
1806 the way things stand. */
1808 error ("Junk after end of expression.");
1810 return expression_value
; /* set by yyparse () */
1813 #ifdef TEST_EXP_READER
1816 /* Main program for testing purposes. */
1826 initialize_random_junk ();
1829 printf ("enter expression: ");
1831 while ((buf
[n
] = getchar ()) != '\n' && buf
[n
] != EOF
)
1836 printf ("parser returned %ld\n", parse_c_expression (buf
));
1842 /* table to tell if char can be part of a C identifier. */
1843 unsigned char is_idchar
[256];
1844 /* table to tell if char can be first char of a c identifier. */
1845 unsigned char is_idstart
[256];
1846 /* table to tell if c is horizontal space. isspace () thinks that
1847 newline is space; this is not a good idea for this program. */
1848 char is_hor_space
[256];
1851 * initialize random junk in the hash table and maybe other places
1853 initialize_random_junk ()
1858 * Set up is_idchar and is_idstart tables. These should be
1859 * faster than saying (is_alpha (c) || c == '_'), etc.
1860 * Must do set up these things before calling any routines tthat
1863 for (i
= 'a'; i
<= 'z'; i
++) {
1864 ++is_idchar
[i
- 'a' + 'A'];
1866 ++is_idstart
[i
- 'a' + 'A'];
1869 for (i
= '0'; i
<= '9'; i
++)
1873 #if DOLLARS_IN_IDENTIFIERS
1878 /* horizontal space table */
1879 ++is_hor_space
[' '];
1880 ++is_hor_space
['\t'];
1885 printf ("error: %s\n", msg
);
1890 printf ("warning: %s\n", msg
);
1894 lookup (name
, len
, hash
)
1899 return (DEFAULT_SIGNED_CHAR
) ? 0 : ((struct hashnode
*) -1);