2 /* A Bison parser, made from tradcif.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
27 int yylex
PARAMS ((void));
28 void yyerror
PARAMS ((const char *msgid
));
29 extern void error
PARAMS ((const char *msgid
, ...));
30 extern void warning
PARAMS ((const char *msgid
, ...));
31 extern struct hashnode
*lookup
PARAMS ((const unsigned char *, int, int));
33 int parse_number
PARAMS ((int));
34 int parse_escape
PARAMS ((char **));
35 int parse_c_expression
PARAMS ((char *));
38 static jmp_buf parse_return_error
;
40 /* some external tables of character types */
41 extern unsigned char is_idstart
[], is_idchar
[];
43 #ifndef CHAR_TYPE_SIZE
44 #define CHAR_TYPE_SIZE BITS_PER_UNIT
49 struct constant
{long value
; int unsignedp
;} integer
;
67 #define YYTRANSLATE(x) ((unsigned)(x) <= 269 ? yytranslate[x] : 36)
69 static const char yytranslate
[] = { 0,
70 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
71 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
72 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
73 2, 2, 29, 2, 2, 2, 27, 14, 2, 31,
74 32, 25, 23, 9, 24, 2, 26, 2, 2, 2,
75 2, 2, 2, 2, 2, 2, 2, 8, 2, 17,
76 2, 18, 7, 2, 2, 2, 2, 2, 2, 2,
77 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
78 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
79 2, 2, 2, 13, 2, 2, 2, 2, 2, 2,
80 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
81 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
82 2, 2, 2, 12, 2, 30, 2, 2, 2, 2,
83 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
84 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
85 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
87 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
90 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
91 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
92 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
96 10, 11, 15, 16, 19, 20, 21, 22, 28
100 static const short yyprhs
[] = { 0,
101 0, 2, 4, 8, 11, 14, 17, 20, 24, 28,
102 32, 36, 40, 44, 48, 52, 56, 60, 64, 68,
103 72, 76, 80, 84, 88, 92, 96, 102, 104, 106
106 static const short yyrhs
[] = { 34,
107 0, 35, 0, 34, 9, 35, 0, 24, 35, 0,
108 29, 35, 0, 23, 35, 0, 30, 35, 0, 31,
109 34, 32, 0, 35, 25, 35, 0, 35, 26, 35,
110 0, 35, 27, 35, 0, 35, 23, 35, 0, 35,
111 24, 35, 0, 35, 21, 35, 0, 35, 22, 35,
112 0, 35, 15, 35, 0, 35, 16, 35, 0, 35,
113 19, 35, 0, 35, 20, 35, 0, 35, 17, 35,
114 0, 35, 18, 35, 0, 35, 14, 35, 0, 35,
115 13, 35, 0, 35, 12, 35, 0, 35, 11, 35,
116 0, 35, 10, 35, 0, 35, 7, 35, 8, 35,
123 static const short yyrline
[] = { 0,
124 81, 86, 87, 92, 95, 98, 100, 103, 108, 114,
125 125, 136, 139, 142, 148, 154, 157, 160, 167, 174,
126 181, 188, 191, 194, 197, 200, 203, 206, 208, 210
131 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
133 static const char * const yytname
[] = { "$","error","$undefined.","INT","CHAR",
134 "NAME","ERROR","'?'","':'","','","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL",
135 "'<'","'>'","LEQ","GEQ","LSH","RSH","'+'","'-'","'*'","'/'","'%'","UNARY","'!'",
136 "'~'","'('","')'","start","exp1","exp", NULL
140 static const short yyr1
[] = { 0,
141 33, 34, 34, 35, 35, 35, 35, 35, 35, 35,
142 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
143 35, 35, 35, 35, 35, 35, 35, 35, 35, 35
146 static const short yyr2
[] = { 0,
147 1, 1, 3, 2, 2, 2, 2, 3, 3, 3,
148 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
149 3, 3, 3, 3, 3, 3, 5, 1, 1, 1
152 static const short yydefact
[] = { 0,
153 28, 29, 30, 0, 0, 0, 0, 0, 1, 2,
154 6, 4, 5, 7, 0, 0, 0, 0, 0, 0,
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 0, 0, 8, 3, 0, 26, 25,
157 24, 23, 22, 16, 17, 20, 21, 18, 19, 14,
158 15, 12, 13, 9, 10, 11, 0, 27, 0, 0,
162 static const short yydefgoto
[] = { 59,
166 static const short yypact
[] = { 31,
167 -32768,-32768,-32768, 31, 31, 31, 31, 31, 1, 77,
168 -32768,-32768,-32768,-32768, 0, 31, 31, 31, 31, 31,
169 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
170 31, 31, 31, 31, 31,-32768, 77, 56, 94, 25,
171 109, 123, 136, 147, 147, 154, 154, 154, 154, -19,
172 -19, 32, 32,-32768,-32768,-32768, 31, 77, 11, 33,
176 static const short yypgoto
[] = {-32768,
184 static const short yytable
[] = { 11,
185 12, 13, 14, 31, 32, 33, 34, 35, 16, 16,
186 60, 37, 38, 39, 40, 41, 42, 43, 44, 45,
187 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
188 56, 36, 61, 1, 2, 3, 20, 21, 22, 23,
189 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
190 34, 35, 58, 4, 5, 15, 33, 34, 35, 6,
191 7, 8, 17, 57, 0, 18, 19, 20, 21, 22,
192 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
193 33, 34, 35, 17, 0, 0, 18, 19, 20, 21,
194 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
195 32, 33, 34, 35, 19, 20, 21, 22, 23, 24,
196 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
197 35, 21, 22, 23, 24, 25, 26, 27, 28, 29,
198 30, 31, 32, 33, 34, 35, 22, 23, 24, 25,
199 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
200 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
201 33, 34, 35, 25, 26, 27, 28, 29, 30, 31,
202 32, 33, 34, 35, 29, 30, 31, 32, 33, 34,
206 static const short yycheck
[] = { 4,
207 5, 6, 7, 23, 24, 25, 26, 27, 9, 9,
208 0, 16, 17, 18, 19, 20, 21, 22, 23, 24,
209 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
210 35, 32, 0, 3, 4, 5, 12, 13, 14, 15,
211 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
212 26, 27, 57, 23, 24, 8, 25, 26, 27, 29,
213 30, 31, 7, 8, -1, 10, 11, 12, 13, 14,
214 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
215 25, 26, 27, 7, -1, -1, 10, 11, 12, 13,
216 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
217 24, 25, 26, 27, 11, 12, 13, 14, 15, 16,
218 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
219 27, 13, 14, 15, 16, 17, 18, 19, 20, 21,
220 22, 23, 24, 25, 26, 27, 14, 15, 16, 17,
221 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
222 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
223 25, 26, 27, 17, 18, 19, 20, 21, 22, 23,
224 24, 25, 26, 27, 21, 22, 23, 24, 25, 26,
227 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
228 #line 3 "/usr/share/misc/bison.simple"
229 /* This file comes from bison-1.28. */
231 /* Skeleton output parser for bison,
232 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
234 This program is free software; you can redistribute it and/or modify
235 it under the terms of the GNU General Public License as published by
236 the Free Software Foundation; either version 2, or (at your option)
239 This program is distributed in the hope that it will be useful,
240 but WITHOUT ANY WARRANTY; without even the implied warranty of
241 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
242 GNU General Public License for more details.
244 You should have received a copy of the GNU General Public License
245 along with this program; if not, write to the Free Software
246 Foundation, Inc., 59 Temple Place - Suite 330,
247 Boston, MA 02111-1307, USA. */
249 /* As a special exception, when this file is copied by Bison into a
250 Bison output file, you may use that output file without restriction.
251 This special exception was added by the Free Software Foundation
252 in version 1.24 of Bison. */
254 /* This is the parser code that is written into each bison parser
255 when the %semantic_parser declaration is not specified in the grammar.
256 It was written by Richard Stallman by simplifying the hairy parser
257 used when %semantic_parser is specified. */
259 #ifndef YYSTACK_USE_ALLOCA
261 #define YYSTACK_USE_ALLOCA
262 #else /* alloca not defined */
264 #define YYSTACK_USE_ALLOCA
265 #define alloca __builtin_alloca
266 #else /* not GNU C. */
267 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
268 #define YYSTACK_USE_ALLOCA
270 #else /* not sparc */
271 /* We think this test detects Watcom and Microsoft C. */
272 /* This used to test MSDOS, but that is a bad idea
273 since that symbol is in the user namespace. */
274 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
275 #if 0 /* No need for malloc.h, which pollutes the namespace;
276 instead, just don't use alloca. */
279 #else /* not MSDOS, or __TURBOC__ */
281 /* I don't know what this was needed for, but it pollutes the namespace.
282 So I turned it off. rms, 2 May 1997. */
283 /* #include <malloc.h> */
285 #define YYSTACK_USE_ALLOCA
286 #else /* not MSDOS, or __TURBOC__, or _AIX */
288 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
289 and on HPUX 10. Eventually we can turn this on. */
290 #define YYSTACK_USE_ALLOCA
291 #define alloca __builtin_alloca
294 #endif /* not _AIX */
295 #endif /* not MSDOS, or __TURBOC__ */
296 #endif /* not sparc */
297 #endif /* not GNU C */
298 #endif /* alloca not defined */
299 #endif /* YYSTACK_USE_ALLOCA not defined */
301 #ifdef YYSTACK_USE_ALLOCA
302 #define YYSTACK_ALLOC alloca
304 #define YYSTACK_ALLOC malloc
307 /* Note: there must be only one dollar sign in this file.
308 It is replaced by the list of actions, each action
309 as one case of the switch. */
311 #define yyerrok (yyerrstatus = 0)
312 #define yyclearin (yychar = YYEMPTY)
315 #define YYACCEPT goto yyacceptlab
316 #define YYABORT goto yyabortlab
317 #define YYERROR goto yyerrlab1
318 /* Like YYERROR except do call yyerror.
319 This remains here temporarily to ease the
320 transition to the new meaning of YYERROR, for GCC.
321 Once GCC version 2 has supplanted version 1, this can go. */
322 #define YYFAIL goto yyerrlab
323 #define YYRECOVERING() (!!yyerrstatus)
324 #define YYBACKUP(token, value) \
326 if (yychar == YYEMPTY && yylen == 1) \
327 { yychar = (token), yylval = (value); \
328 yychar1 = YYTRANSLATE (yychar); \
333 { yyerror ("syntax error: cannot back up"); YYERROR; } \
337 #define YYERRCODE 256
340 #define YYLEX yylex()
346 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
348 #define YYLEX yylex(&yylval, &yylloc)
350 #else /* not YYLSP_NEEDED */
352 #define YYLEX yylex(&yylval, YYLEX_PARAM)
354 #define YYLEX yylex(&yylval)
356 #endif /* not YYLSP_NEEDED */
359 /* If nonreentrant, generate the variables here */
363 int yychar
; /* the lookahead symbol */
364 YYSTYPE yylval
; /* the semantic value of the */
365 /* lookahead symbol */
368 YYLTYPE yylloc
; /* location data for the lookahead */
372 int yynerrs
; /* number of parse errors so far */
373 #endif /* not YYPURE */
376 int yydebug
; /* nonzero means print parse trace */
377 /* Since this is uninitialized, it does not stop multiple parsers
381 /* YYINITDEPTH indicates the initial size of the parser's stacks */
384 #define YYINITDEPTH 200
387 /* YYMAXDEPTH is the maximum size the stacks can grow to
388 (effective only if the built-in stack extension method is used). */
395 #define YYMAXDEPTH 10000
398 /* Define __yy_memcpy. Note that the size argument
399 should be passed with type unsigned int, because that is what the non-GCC
400 definitions require. With GCC, __builtin_memcpy takes an arg
401 of type size_t, but it can handle unsigned int. */
403 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
404 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
405 #else /* not GNU C or C++ */
408 /* This is the most reliable way to avoid incompatibilities
409 in available built-in functions on various systems. */
411 __yy_memcpy (to
, from
, count
)
416 register char *f
= from
;
417 register char *t
= to
;
418 register int i
= count
;
424 #else /* __cplusplus */
426 /* This is the most reliable way to avoid incompatibilities
427 in available built-in functions on various systems. */
429 __yy_memcpy (char *to
, char *from
, unsigned int count
)
431 register char *t
= to
;
432 register char *f
= from
;
433 register int i
= count
;
442 #line 217 "/usr/share/misc/bison.simple"
444 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
445 into yyparse. The argument should have type void *.
446 It should actually point to an object.
447 Grammar actions can access the variable by casting it
448 to the proper pointer type. */
452 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
453 #define YYPARSE_PARAM_DECL
454 #else /* not __cplusplus */
455 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
456 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
457 #endif /* not __cplusplus */
458 #else /* not YYPARSE_PARAM */
459 #define YYPARSE_PARAM_ARG
460 #define YYPARSE_PARAM_DECL
461 #endif /* not YYPARSE_PARAM */
463 /* Prevent warning if -Wstrict-prototypes. */
466 int yyparse (void *);
473 yyparse(YYPARSE_PARAM_ARG
)
476 register int yystate
;
478 register short *yyssp
;
479 register YYSTYPE
*yyvsp
;
480 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
481 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
483 short yyssa
[YYINITDEPTH
]; /* the state stack */
484 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
486 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
487 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
490 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
491 YYLTYPE
*yyls
= yylsa
;
494 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
496 #define YYPOPSTACK (yyvsp--, yyssp--)
499 int yystacksize
= YYINITDEPTH
;
500 int yyfree_stacks
= 0;
511 YYSTYPE yyval
; /* the variable used to return */
512 /* semantic values from the action */
519 fprintf(stderr
, "Starting parse\n");
525 yychar
= YYEMPTY
; /* Cause a token to be read. */
527 /* Initialize stack pointers.
528 Waste one element of value and location stack
529 so that they stay on the same level as the state stack.
530 The wasted elements are never initialized. */
538 /* Push a new state, which is found in yystate . */
539 /* In all cases, when you get here, the value and location stacks
540 have just been pushed. so pushing a state here evens the stacks. */
545 if (yyssp
>= yyss
+ yystacksize
- 1)
547 /* Give user a chance to reallocate the stack */
548 /* Use copies of these so that the &'s don't force the real ones into memory. */
549 YYSTYPE
*yyvs1
= yyvs
;
552 YYLTYPE
*yyls1
= yyls
;
555 /* Get the current used size of the three stacks, in elements. */
556 int size
= yyssp
- yyss
+ 1;
559 /* Each stack pointer address is followed by the size of
560 the data in use in that stack, in bytes. */
562 /* This used to be a conditional around just the two extra args,
563 but that might be undefined if yyoverflow is a macro. */
564 yyoverflow("parser stack overflow",
565 &yyss1
, size
* sizeof (*yyssp
),
566 &yyvs1
, size
* sizeof (*yyvsp
),
567 &yyls1
, size
* sizeof (*yylsp
),
570 yyoverflow("parser stack overflow",
571 &yyss1
, size
* sizeof (*yyssp
),
572 &yyvs1
, size
* sizeof (*yyvsp
),
576 yyss
= yyss1
; yyvs
= yyvs1
;
580 #else /* no yyoverflow */
581 /* Extend the stack our own way. */
582 if (yystacksize
>= YYMAXDEPTH
)
584 yyerror("parser stack overflow");
596 if (yystacksize
> YYMAXDEPTH
)
597 yystacksize
= YYMAXDEPTH
;
598 #ifndef YYSTACK_USE_ALLOCA
601 yyss
= (short *) YYSTACK_ALLOC (yystacksize
* sizeof (*yyssp
));
602 __yy_memcpy ((char *)yyss
, (char *)yyss1
,
603 size
* (unsigned int) sizeof (*yyssp
));
604 yyvs
= (YYSTYPE
*) YYSTACK_ALLOC (yystacksize
* sizeof (*yyvsp
));
605 __yy_memcpy ((char *)yyvs
, (char *)yyvs1
,
606 size
* (unsigned int) sizeof (*yyvsp
));
608 yyls
= (YYLTYPE
*) YYSTACK_ALLOC (yystacksize
* sizeof (*yylsp
));
609 __yy_memcpy ((char *)yyls
, (char *)yyls1
,
610 size
* (unsigned int) sizeof (*yylsp
));
612 #endif /* no yyoverflow */
614 yyssp
= yyss
+ size
- 1;
615 yyvsp
= yyvs
+ size
- 1;
617 yylsp
= yyls
+ size
- 1;
622 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
625 if (yyssp
>= yyss
+ yystacksize
- 1)
631 fprintf(stderr
, "Entering state %d\n", yystate
);
637 /* Do appropriate processing given the current state. */
638 /* Read a lookahead token if we need one and don't already have one. */
641 /* First try to decide what to do without reference to lookahead token. */
643 yyn
= yypact
[yystate
];
647 /* Not known => get a lookahead token if don't already have one. */
649 /* yychar is either YYEMPTY or YYEOF
650 or a valid token in external form. */
652 if (yychar
== YYEMPTY
)
656 fprintf(stderr
, "Reading a token: ");
661 /* Convert token to internal form (in yychar1) for indexing tables with */
663 if (yychar
<= 0) /* This means end of input. */
666 yychar
= YYEOF
; /* Don't call YYLEX any more */
670 fprintf(stderr
, "Now at end of input.\n");
675 yychar1
= YYTRANSLATE(yychar
);
680 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
681 /* Give the individual parser a way to print the precise meaning
682 of a token, for further debugging info. */
684 YYPRINT (stderr
, yychar
, yylval
);
686 fprintf (stderr
, ")\n");
692 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
697 /* yyn is what to do for this token type in this state.
698 Negative => reduce, -yyn is rule number.
699 Positive => shift, yyn is new state.
700 New state is final state => don't bother to shift,
702 0, or most negative number => error. */
717 /* Shift the lookahead token. */
721 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
724 /* Discard the token being shifted unless it is eof. */
733 /* count tokens shifted since error; after three, turn off error status. */
734 if (yyerrstatus
) yyerrstatus
--;
739 /* Do the default action for the current state. */
742 yyn
= yydefact
[yystate
];
746 /* Do a reduction. yyn is the number of a rule to reduce with. */
750 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
757 fprintf (stderr
, "Reducing via rule %d (line %d), ",
760 /* Print the symbols being reduced, and their result. */
761 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
762 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
763 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
772 { expression_value
= yyvsp
[0].integer
.value
; ;
776 { yyval
.integer
= yyvsp
[0].integer
; ;
780 { yyval
.integer
.value
= - yyvsp
[0].integer
.value
;
781 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; ;
785 { yyval
.integer
.value
= ! yyvsp
[0].integer
.value
;
786 yyval
.integer
.unsignedp
= 0; ;
790 { yyval
.integer
= yyvsp
[0].integer
; ;
793 #line 101 "tradcif.y"
794 { yyval
.integer
.value
= ~ yyvsp
[0].integer
.value
;
795 yyval
.integer
.unsignedp
= yyvsp
[0].integer
.unsignedp
; ;
798 #line 104 "tradcif.y"
799 { yyval
.integer
= yyvsp
[-1].integer
; ;
802 #line 109 "tradcif.y"
803 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
804 if (yyval
.integer
.unsignedp
)
805 yyval
.integer
.value
= (unsigned) yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
;
807 yyval
.integer
.value
= yyvsp
[-2].integer
.value
* yyvsp
[0].integer
.value
; ;
810 #line 115 "tradcif.y"
811 { if (yyvsp
[0].integer
.value
== 0)
813 error ("division by zero in #if");
814 yyvsp
[0].integer
.value
= 1;
816 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
817 if (yyval
.integer
.unsignedp
)
818 yyval
.integer
.value
= (unsigned) yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
;
820 yyval
.integer
.value
= yyvsp
[-2].integer
.value
/ yyvsp
[0].integer
.value
; ;
823 #line 126 "tradcif.y"
824 { if (yyvsp
[0].integer
.value
== 0)
826 error ("division by zero in #if");
827 yyvsp
[0].integer
.value
= 1;
829 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
;
830 if (yyval
.integer
.unsignedp
)
831 yyval
.integer
.value
= (unsigned) yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
;
833 yyval
.integer
.value
= yyvsp
[-2].integer
.value
% yyvsp
[0].integer
.value
; ;
836 #line 137 "tradcif.y"
837 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
+ yyvsp
[0].integer
.value
;
838 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
841 #line 140 "tradcif.y"
842 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
- yyvsp
[0].integer
.value
;
843 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
846 #line 143 "tradcif.y"
847 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
848 if (yyval
.integer
.unsignedp
)
849 yyval
.integer
.value
= (unsigned) yyvsp
[-2].integer
.value
<< yyvsp
[0].integer
.value
;
851 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<< yyvsp
[0].integer
.value
; ;
854 #line 149 "tradcif.y"
855 { yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
;
856 if (yyval
.integer
.unsignedp
)
857 yyval
.integer
.value
= (unsigned) yyvsp
[-2].integer
.value
>> yyvsp
[0].integer
.value
;
859 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>> yyvsp
[0].integer
.value
; ;
862 #line 155 "tradcif.y"
863 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
== yyvsp
[0].integer
.value
);
864 yyval
.integer
.unsignedp
= 0; ;
867 #line 158 "tradcif.y"
868 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
!= yyvsp
[0].integer
.value
);
869 yyval
.integer
.unsignedp
= 0; ;
872 #line 161 "tradcif.y"
873 { yyval
.integer
.unsignedp
= 0;
874 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
875 yyval
.integer
.value
=
876 (unsigned) yyvsp
[-2].integer
.value
<= (unsigned) yyvsp
[0].integer
.value
;
878 yyval
.integer
.value
= yyvsp
[-2].integer
.value
<= yyvsp
[0].integer
.value
; ;
881 #line 168 "tradcif.y"
882 { yyval
.integer
.unsignedp
= 0;
883 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
884 yyval
.integer
.value
=
885 (unsigned) yyvsp
[-2].integer
.value
>= (unsigned) yyvsp
[0].integer
.value
;
887 yyval
.integer
.value
= yyvsp
[-2].integer
.value
>= yyvsp
[0].integer
.value
; ;
890 #line 175 "tradcif.y"
891 { yyval
.integer
.unsignedp
= 0;
892 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
893 yyval
.integer
.value
=
894 (unsigned) yyvsp
[-2].integer
.value
< (unsigned) yyvsp
[0].integer
.value
;
896 yyval
.integer
.value
= yyvsp
[-2].integer
.value
< yyvsp
[0].integer
.value
; ;
899 #line 182 "tradcif.y"
900 { yyval
.integer
.unsignedp
= 0;
901 if (yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
)
902 yyval
.integer
.value
=
903 (unsigned) yyvsp
[-2].integer
.value
> (unsigned) yyvsp
[0].integer
.value
;
905 yyval
.integer
.value
= yyvsp
[-2].integer
.value
> yyvsp
[0].integer
.value
; ;
908 #line 189 "tradcif.y"
909 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
& yyvsp
[0].integer
.value
;
910 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
913 #line 192 "tradcif.y"
914 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
^ yyvsp
[0].integer
.value
;
915 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
918 #line 195 "tradcif.y"
919 { yyval
.integer
.value
= yyvsp
[-2].integer
.value
| yyvsp
[0].integer
.value
;
920 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
923 #line 198 "tradcif.y"
924 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
&& yyvsp
[0].integer
.value
);
925 yyval
.integer
.unsignedp
= 0; ;
928 #line 201 "tradcif.y"
929 { yyval
.integer
.value
= (yyvsp
[-2].integer
.value
|| yyvsp
[0].integer
.value
);
930 yyval
.integer
.unsignedp
= 0; ;
933 #line 204 "tradcif.y"
934 { yyval
.integer
.value
= yyvsp
[-4].integer
.value
? yyvsp
[-2].integer
.value
: yyvsp
[0].integer
.value
;
935 yyval
.integer
.unsignedp
= yyvsp
[-2].integer
.unsignedp
|| yyvsp
[0].integer
.unsignedp
; ;
938 #line 207 "tradcif.y"
939 { yyval
.integer
= yylval
.integer
; ;
942 #line 209 "tradcif.y"
943 { yyval
.integer
= yylval
.integer
; ;
946 #line 211 "tradcif.y"
947 { yyval
.integer
.value
= 0;
948 yyval
.integer
.unsignedp
= 0; ;
951 /* the action file gets copied in in place of this dollarsign */
952 #line 543 "/usr/share/misc/bison.simple"
963 short *ssp1
= yyss
- 1;
964 fprintf (stderr
, "state stack now");
965 while (ssp1
!= yyssp
)
966 fprintf (stderr
, " %d", *++ssp1
);
967 fprintf (stderr
, "\n");
977 yylsp
->first_line
= yylloc
.first_line
;
978 yylsp
->first_column
= yylloc
.first_column
;
979 yylsp
->last_line
= (yylsp
-1)->last_line
;
980 yylsp
->last_column
= (yylsp
-1)->last_column
;
985 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
986 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
990 /* Now "shift" the result of the reduction.
991 Determine what state that goes to,
992 based on the state we popped back to
993 and the rule number reduced by. */
997 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
998 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
999 yystate
= yytable
[yystate
];
1001 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1005 yyerrlab
: /* here on detecting error */
1008 /* If not already recovering from an error, report this error. */
1012 #ifdef YYERROR_VERBOSE
1013 yyn
= yypact
[yystate
];
1015 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1022 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1023 for (x
= (yyn
< 0 ? -yyn
: 0);
1024 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1025 if (yycheck
[x
+ yyn
] == x
)
1026 size
+= strlen(yytname
[x
]) + 15, count
++;
1027 msg
= (char *) malloc(size
+ 15);
1030 strcpy(msg
, "parse error");
1035 for (x
= (yyn
< 0 ? -yyn
: 0);
1036 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1037 if (yycheck
[x
+ yyn
] == x
)
1039 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1040 strcat(msg
, yytname
[x
]);
1049 yyerror ("parse error; also virtual memory exceeded");
1052 #endif /* YYERROR_VERBOSE */
1053 yyerror("parse error");
1057 yyerrlab1
: /* here on error raised explicitly by an action */
1059 if (yyerrstatus
== 3)
1061 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1063 /* return failure if at end of input */
1064 if (yychar
== YYEOF
)
1069 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1075 /* Else will try to reuse lookahead token
1076 after shifting the error token. */
1078 yyerrstatus
= 3; /* Each real token shifted decrements this */
1082 yyerrdefault
: /* current state does not do anything special for the error token. */
1085 /* This is wrong; only states that explicitly want error tokens
1086 should shift them. */
1087 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1088 if (yyn
) goto yydefault
;
1091 yyerrpop
: /* pop the current state because it cannot handle the error token */
1093 if (yyssp
== yyss
) YYABORT
;
1103 short *ssp1
= yyss
- 1;
1104 fprintf (stderr
, "Error: state stack now");
1105 while (ssp1
!= yyssp
)
1106 fprintf (stderr
, " %d", *++ssp1
);
1107 fprintf (stderr
, "\n");
1113 yyn
= yypact
[yystate
];
1118 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1137 fprintf(stderr
, "Shifting error token, ");
1149 /* YYACCEPT comes here. */
1161 /* YYABORT comes here. */
1172 #line 214 "tradcif.y"
1175 /* During parsing of a C expression, the pointer to the next character
1176 is in this variable. */
1178 static char *lexptr
;
1180 /* Take care of parsing a number (anything that starts with a digit).
1181 Set yylval and return the token type; update lexptr.
1182 LEN is the number of characters in it. */
1184 /* maybe needs to actually deal with floating point numbers */
1190 register char *p
= lexptr
;
1191 register long n
= 0;
1193 register int base
= 10;
1194 register int len
= olen
;
1196 for (c
= 0; c
< len
; c
++)
1198 /* It's a float since it contains a point. */
1199 yyerror ("floating point numbers not allowed in #if expressions");
1203 yylval
.integer
.unsignedp
= 0;
1205 if (len
>= 3 && (!strncmp (p
, "0x", 2) || !strncmp (p
, "0X", 2))) {
1216 if (c
>= 'A' && c
<= 'Z') c
+= 'a' - 'A';
1218 if (c
>= '0' && c
<= '9') {
1221 } else if (base
== 16 && c
>= 'a' && c
<= 'f') {
1225 /* `l' means long, and `u' means unsigned. */
1227 if (c
== 'l' || c
== 'L')
1229 else if (c
== 'u' || c
== 'U')
1230 yylval
.integer
.unsignedp
= 1;
1239 /* Don't look for any more digits after the suffixes. */
1245 yyerror ("Invalid number in #if expression");
1249 /* If too big to be signed, consider it unsigned. */
1251 yylval
.integer
.unsignedp
= 1;
1254 yylval
.integer
.value
= n
;
1259 const char *operator;
1267 static struct token tokentab2
[] = {
1279 /* Read one token, getting characters through lexptr. */
1285 register int namelen
;
1286 register char *tokstart
;
1287 register struct token
*toktab
;
1293 /* See if it is a special token of length 2. */
1294 for (toktab
= tokentab2
; toktab
->operator != NULL
; toktab
++)
1295 if (c
== *toktab
->operator && tokstart
[1] == toktab
->operator[1]) {
1297 return toktab
->token
;
1315 c
= parse_escape (&lexptr
);
1317 /* Sign-extend the constant if chars are signed on target machine. */
1319 if (lookup ((const unsigned char *)"__CHAR_UNSIGNED__",
1320 sizeof ("__CHAR_UNSIGNED__")-1, -1)
1321 || ((c
>> (CHAR_TYPE_SIZE
- 1)) & 1) == 0)
1322 yylval
.integer
.value
= c
& ((1 << CHAR_TYPE_SIZE
) - 1);
1324 yylval
.integer
.value
= c
| ~((1 << CHAR_TYPE_SIZE
) - 1);
1327 yylval
.integer
.unsignedp
= 0;
1330 yyerror ("Invalid character constant in #if");
1336 /* some of these chars are invalid in constant expressions;
1337 maybe do something about them later */
1366 yyerror ("double quoted strings not allowed in #if expressions");
1369 if (c
>= '0' && c
<= '9') {
1372 c
= tokstart
[namelen
], is_idchar
[c
] || c
== '.';
1375 return parse_number (namelen
);
1378 if (!is_idstart
[c
]) {
1379 yyerror ("Invalid token in expression");
1383 /* It is a name. See how long it is. */
1386 is_idchar
[(int)(unsigned char)tokstart
[namelen
]];
1395 /* Parse a C escape sequence. STRING_PTR points to a variable
1396 containing a pointer to the string to parse. That pointer
1397 is updated past the characters we use. The value of the
1398 escape sequence is returned.
1400 A negative value means the sequence \ newline was seen,
1401 which is supposed to be equivalent to nothing at all.
1403 If \ is followed by a null character, we return a negative
1404 value and leave the string pointer pointing at the null character.
1406 If \ is followed by 000, we return 0 and leave the string pointer
1407 after the zeros. A value of 0 does not mean end of string. */
1410 parse_escape (string_ptr
)
1413 register int c
= *(*string_ptr
)++;
1425 return TARGET_NEWLINE
;
1438 c
= *(*string_ptr
)++;
1440 c
= parse_escape (string_ptr
);
1443 return (c
& 0200) | (c
& 037);
1454 register int i
= c
- '0';
1455 register int count
= 0;
1458 c
= *(*string_ptr
)++;
1459 if (c
>= '0' && c
<= '7')
1460 i
= (i
<< 3) + c
- '0';
1467 if ((i
& ~((1 << CHAR_TYPE_SIZE
) - 1)) != 0)
1469 i
&= (1 << CHAR_TYPE_SIZE
) - 1;
1470 warning ("octal character constant does not fit in a byte");
1479 c
= *(*string_ptr
)++;
1480 if (c
>= '0' && c
<= '9')
1481 i
= (i
<< 4) + c
- '0';
1482 else if (c
>= 'a' && c
<= 'f')
1483 i
= (i
<< 4) + c
- 'a' + 10;
1484 else if (c
>= 'A' && c
<= 'F')
1485 i
= (i
<< 4) + c
- 'A' + 10;
1492 if ((i
& ~((1 << BITS_PER_UNIT
) - 1)) != 0)
1494 i
&= (1 << BITS_PER_UNIT
) - 1;
1495 warning ("hex character constant does not fit in a byte");
1509 longjmp (parse_return_error
, 1);
1512 /* This page contains the entry point to this file. */
1514 /* Parse STRING as an expression, and complain if this fails
1515 to use up all of the contents of STRING. */
1516 /* We do not support C comments. They should be removed before
1517 this function is called. */
1520 parse_c_expression (string
)
1525 if (lexptr
== 0 || *lexptr
== 0) {
1526 error ("empty #if expression");
1527 return 0; /* don't include the #if group */
1530 /* if there is some sort of scanning error, just return 0 and assume
1531 the parsing routine has printed an error message somewhere.
1532 there is surely a better thing to do than this. */
1533 if (setjmp (parse_return_error
))
1537 return 0; /* actually this is never reached
1538 the way things stand. */
1540 error ("Junk after end of expression.");
1542 return expression_value
; /* set by yyparse () */