1
2 /* A Bison parser, made from expr.y
3 by GNU Bison version 1.28 */
4
5 #define YYBISON 1 /* Identify Bison output. */
6
7 #define TOKEN_IDENTIFIER 257
8 #define TOKEN_DOT 258
9 #define TOKEN_STAR 259
10 #define TOKEN_ARROW 260
11 #define TOKEN_ADDR 261
12 #define TOKEN_SIZEOF 262
13 #define TOKEN_NUMBER 263
14
15 #line 1 "expr.y"
16
17 #include <sys/types.h>
18 #include <stdio.h>
19 #include <memory.h>
20 #include <stdlib.h>
21 #include <string.h>
22
23 #include "System.h"
24 #include "elf.h"
25 #include "exprNode.h"
26
27 extern int yyerror(char *);
28 extern int yylex();
29 extern char *yytext;
30
31
32 //#define YYERROR_VERBOSE 1
33 //#define YYDEBUG 1
34
35 Node *result = NULL;
36 #ifndef YYSTYPE
37 #define YYSTYPE int
38 #endif
39 #include <stdio.h>
40
41 #ifndef __cplusplus
42 #ifndef __STDC__
43 #define const
44 #endif
45 #endif
46
47
48
49 #define YYFINAL 26
50 #define YYFLAG -32768
51 #define YYNTBASE 14
52
53 #define YYTRANSLATE(x) ((unsigned)(x) <= 263 ? yytranslate[x] : 19)
54
55 static const char yytranslate[] = { 0,
56 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
57 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
58 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
59 2, 2, 2, 2, 2, 2, 2, 2, 2, 11,
60 12, 2, 2, 2, 2, 2, 2, 2, 2, 2,
61 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
62 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
63 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
64 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
65 10, 2, 13, 2, 2, 2, 2, 2, 2, 2,
66 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
67 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
68 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
69 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
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, 2, 2, 2, 2, 2, 2, 2, 2,
74 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
75 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
76 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2,
80 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
81 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
82 7, 8, 9
83 };
84
85 #if YYDEBUG != 0
86 static const short yyprhs[] = { 0,
87 0, 2, 4, 8, 12, 16, 21, 23, 26, 29,
88 34, 36
89 };
90
91 static const short yyrhs[] = { 15,
92 0, 16, 0, 11, 15, 12, 0, 15, 4, 18,
93 0, 15, 6, 18, 0, 15, 10, 17, 13, 0,
94 18, 0, 5, 15, 0, 7, 15, 0, 8, 11,
95 15, 12, 0, 9, 0, 3, 0
96 };
97
98 #endif
99
100 #if YYDEBUG != 0
101 static const short yyrline[] = { 0,
102 32, 35, 36, 37, 38, 39, 42, 43, 44, 45,
103 49, 53
104 };
105 #endif
106
107
108 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
109
110 static const char * const yytname[] = { "$","error","$undefined.","TOKEN_IDENTIFIER",
111 "TOKEN_DOT","TOKEN_STAR","TOKEN_ARROW","TOKEN_ADDR","TOKEN_SIZEOF","TOKEN_NUMBER",
112 "'['","'('","')'","']'","final","expression","simple_expression","number","ident", NULL
113 };
114 #endif
115
116 static const short yyr1[] = { 0,
117 14, 15, 15, 15, 15, 15, 16, 16, 16, 16,
118 17, 18
119 };
120
121 static const short yyr2[] = { 0,
122 1, 1, 3, 3, 3, 4, 1, 2, 2, 4,
123 1, 1
124 };
125
126 static const short yydefact[] = { 0,
127 12, 0, 0, 0, 0, 1, 2, 7, 8, 9,
128 0, 0, 0, 0, 0, 0, 3, 4, 5, 11,
129 0, 10, 6, 0, 0, 0
130 };
131
132 static const short yydefgoto[] = { 24,
133 6, 7, 21, 8
134 };
135
136 static const short yypact[] = { -1,
137 -32768, -1, -1, -6, -1, 17,-32768,-32768, 17, 17,
138 -1, 7, 5, 5, 13, 8,-32768,-32768,-32768,-32768,
139 11,-32768,-32768, 25, 26,-32768
140 };
141
142 static const short yypgoto[] = {-32768,
143 -2,-32768,-32768, 2
144 };
145
146
147 #define YYLAST 27
148
149
150 static const short yytable[] = { 9,
151 10, 1, 12, 2, 11, 3, 4, 1, 16, 5,
152 13, 13, 14, 14, 18, 19, 15, 15, 17, 22,
153 13, 20, 14, 23, 25, 26, 15
154 };
155
156 static const short yycheck[] = { 2,
157 3, 3, 5, 5, 11, 7, 8, 3, 11, 11,
158 4, 4, 6, 6, 13, 14, 10, 10, 12, 12,
159 4, 9, 6, 13, 0, 0, 10
160 };
161 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
162 #line 3 "/usr/lib/bison.simple"
163 /* This file comes from bison-1.28. */
164
165 /* Skeleton output parser for bison,
166 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
167
168 This program is free software; you can redistribute it and/or modify
169 it under the terms of the GNU General Public License as published by
170 the Free Software Foundation; either version 2, or (at your option)
171 any later version.
172
173 This program is distributed in the hope that it will be useful,
174 but WITHOUT ANY WARRANTY; without even the implied warranty of
175 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176 GNU General Public License for more details.
177
178 You should have received a copy of the GNU General Public License
179 along with this program; if not, write to the Free Software
180 Foundation, Inc., 59 Temple Place - Suite 330,
181 Boston, MA 02111-1307, USA. */
182
183 /* As a special exception, when this file is copied by Bison into a
184 Bison output file, you may use that output file without restriction.
185 This special exception was added by the Free Software Foundation
186 in version 1.24 of Bison. */
187
188 /* This is the parser code that is written into each bison parser
189 when the %semantic_parser declaration is not specified in the grammar.
190 It was written by Richard Stallman by simplifying the hairy parser
191 used when %semantic_parser is specified. */
192
193 #ifndef YYSTACK_USE_ALLOCA
194 #ifdef alloca
195 #define YYSTACK_USE_ALLOCA
196 #else /* alloca not defined */
197 #ifdef __GNUC__
198 #define YYSTACK_USE_ALLOCA
199 #define alloca __builtin_alloca
200 #else /* not GNU C. */
201 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
202 #define YYSTACK_USE_ALLOCA
203 #include <alloca.h>
204 #else /* not sparc */
205 /* We think this test detects Watcom and Microsoft C. */
206 /* This used to test MSDOS, but that is a bad idea
207 since that symbol is in the user namespace. */
208 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
209 #if 0 /* No need for malloc.h, which pollutes the namespace;
210 instead, just don't use alloca. */
211 #include <malloc.h>
212 #endif
213 #else /* not MSDOS, or __TURBOC__ */
214 #if defined(_AIX)
215 /* I don't know what this was needed for, but it pollutes the namespace.
216 So I turned it off. rms, 2 May 1997. */
217 /* #include <malloc.h> */
218 #pragma alloca
219 #define YYSTACK_USE_ALLOCA
220 #else /* not MSDOS, or __TURBOC__, or _AIX */
221 #if 0
222 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
223 and on HPUX 10. Eventually we can turn this on. */
224 #define YYSTACK_USE_ALLOCA
225 #define alloca __builtin_alloca
226 #endif /* __hpux */
227 #endif
228 #endif /* not _AIX */
229 #endif /* not MSDOS, or __TURBOC__ */
230 #endif /* not sparc */
231 #endif /* not GNU C */
232 #endif /* alloca not defined */
233 #endif /* YYSTACK_USE_ALLOCA not defined */
234
235 #ifdef YYSTACK_USE_ALLOCA
236 #define YYSTACK_ALLOC alloca
237 #else
238 #define YYSTACK_ALLOC malloc
239 #endif
240
241 /* Note: there must be only one dollar sign in this file.
242 It is replaced by the list of actions, each action
243 as one case of the switch. */
244
245 #define yyerrok (yyerrstatus = 0)
246 #define yyclearin (yychar = YYEMPTY)
247 #define YYEMPTY -2
248 #define YYEOF 0
249 #define YYACCEPT goto yyacceptlab
250 #define YYABORT goto yyabortlab
251 #define YYERROR goto yyerrlab1
252 /* Like YYERROR except do call yyerror.
253 This remains here temporarily to ease the
254 transition to the new meaning of YYERROR, for GCC.
255 Once GCC version 2 has supplanted version 1, this can go. */
256 #define YYFAIL goto yyerrlab
257 #define YYRECOVERING() (!!yyerrstatus)
258 #define YYBACKUP(token, value) \
259 do \
260 if (yychar == YYEMPTY && yylen == 1) \
261 { yychar = (token), yylval = (value); \
262 yychar1 = YYTRANSLATE (yychar); \
263 YYPOPSTACK; \
264 goto yybackup; \
265 } \
266 else \
267 { yyerror ("syntax error: cannot back up"); YYERROR; } \
268 while (0)
269
270 #define YYTERROR 1
271 #define YYERRCODE 256
272
273 #ifndef YYPURE
274 #define YYLEX yylex()
275 #endif
276
277 #ifdef YYPURE
278 #ifdef YYLSP_NEEDED
279 #ifdef YYLEX_PARAM
280 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
281 #else
282 #define YYLEX yylex(&yylval, &yylloc)
283 #endif
284 #else /* not YYLSP_NEEDED */
285 #ifdef YYLEX_PARAM
286 #define YYLEX yylex(&yylval, YYLEX_PARAM)
287 #else
288 #define YYLEX yylex(&yylval)
289 #endif
290 #endif /* not YYLSP_NEEDED */
291 #endif
292
293 /* If nonreentrant, generate the variables here */
294
295 #ifndef YYPURE
296
297 int yychar; /* the lookahead symbol */
298 YYSTYPE yylval; /* the semantic value of the */
299 /* lookahead symbol */
300
301 #ifdef YYLSP_NEEDED
302 YYLTYPE yylloc; /* location data for the lookahead */
303 /* symbol */
304 #endif
305
306 int yynerrs; /* number of parse errors so far */
307 #endif /* not YYPURE */
308
309 #if YYDEBUG != 0
310 int yydebug; /* nonzero means print parse trace */
311 /* Since this is uninitialized, it does not stop multiple parsers
312 from coexisting. */
313 #endif
314
315 /* YYINITDEPTH indicates the initial size of the parser's stacks */
316
317 #ifndef YYINITDEPTH
318 #define YYINITDEPTH 200
319 #endif
320
321 /* YYMAXDEPTH is the maximum size the stacks can grow to
322 (effective only if the built-in stack extension method is used). */
323
324 #if YYMAXDEPTH == 0
325 #undef YYMAXDEPTH
326 #endif
327
328 #ifndef YYMAXDEPTH
329 #define YYMAXDEPTH 10000
330 #endif
331
332 /* Define __yy_memcpy. Note that the size argument
333 should be passed with type unsigned int, because that is what the non-GCC
334 definitions require. With GCC, __builtin_memcpy takes an arg
335 of type size_t, but it can handle unsigned int. */
336
337 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
338 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
339 #else /* not GNU C or C++ */
340 #ifndef __cplusplus
341
342 /* This is the most reliable way to avoid incompatibilities
343 in available built-in functions on various systems. */
344 static void
345 __yy_memcpy (to, from, count)
346 char *to;
347 char *from;
348 unsigned int count;
349 {
350 register char *f = from;
351 register char *t = to;
352 register int i = count;
353
354 while (i-- > 0)
355 *t++ = *f++;
356 }
357
358 #else /* __cplusplus */
359
360 /* This is the most reliable way to avoid incompatibilities
361 in available built-in functions on various systems. */
362 static void
__yy_memcpy(char * to,char * from,unsigned int count)363 __yy_memcpy (char *to, char *from, unsigned int count)
364 {
365 register char *t = to;
366 register char *f = from;
367 register int i = count;
368
369 while (i-- > 0)
370 *t++ = *f++;
371 }
372
373 #endif
374 #endif
375
376 #line 217 "/usr/lib/bison.simple"
377
378 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
379 into yyparse. The argument should have type void *.
380 It should actually point to an object.
381 Grammar actions can access the variable by casting it
382 to the proper pointer type. */
383
384 #ifdef YYPARSE_PARAM
385 #ifdef __cplusplus
386 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
387 #define YYPARSE_PARAM_DECL
388 #else /* not __cplusplus */
389 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
390 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
391 #endif /* not __cplusplus */
392 #else /* not YYPARSE_PARAM */
393 #define YYPARSE_PARAM_ARG
394 #define YYPARSE_PARAM_DECL
395 #endif /* not YYPARSE_PARAM */
396
397 /* Prevent warning if -Wstrict-prototypes. */
398 #ifdef __GNUC__
399 #ifdef YYPARSE_PARAM
400 int yyparse (void *);
401 #else
402 int yyparse (void);
403 #endif
404 #endif
405
406 int
yyparse(YYPARSE_PARAM_ARG)407 yyparse(YYPARSE_PARAM_ARG)
408 YYPARSE_PARAM_DECL
409 {
410 register int yystate;
411 register int yyn;
412 register short *yyssp;
413 register YYSTYPE *yyvsp;
414 int yyerrstatus; /* number of tokens to shift before error messages enabled */
415 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
416
417 short yyssa[YYINITDEPTH]; /* the state stack */
418 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
419
420 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
421 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
422
423 #ifdef YYLSP_NEEDED
424 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
425 YYLTYPE *yyls = yylsa;
426 YYLTYPE *yylsp;
427
428 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
429 #else
430 #define YYPOPSTACK (yyvsp--, yyssp--)
431 #endif
432
433 int yystacksize = YYINITDEPTH;
434 int yyfree_stacks = 0;
435
436 #ifdef YYPURE
437 int yychar;
438 YYSTYPE yylval;
439 int yynerrs;
440 #ifdef YYLSP_NEEDED
441 YYLTYPE yylloc;
442 #endif
443 #endif
444
445 YYSTYPE yyval; /* the variable used to return */
446 /* semantic values from the action */
447 /* routines */
448
449 int yylen;
450
451 #if YYDEBUG != 0
452 if (yydebug)
453 fprintf(stderr, "Starting parse\n");
454 #endif
455
456 yystate = 0;
457 yyerrstatus = 0;
458 yynerrs = 0;
459 yychar = YYEMPTY; /* Cause a token to be read. */
460
461 /* Initialize stack pointers.
462 Waste one element of value and location stack
463 so that they stay on the same level as the state stack.
464 The wasted elements are never initialized. */
465
466 yyssp = yyss - 1;
467 yyvsp = yyvs;
468 #ifdef YYLSP_NEEDED
469 yylsp = yyls;
470 #endif
471
472 /* Push a new state, which is found in yystate . */
473 /* In all cases, when you get here, the value and location stacks
474 have just been pushed. so pushing a state here evens the stacks. */
475 yynewstate:
476
477 *++yyssp = yystate;
478
479 if (yyssp >= yyss + yystacksize - 1)
480 {
481 /* Give user a chance to reallocate the stack */
482 /* Use copies of these so that the &'s don't force the real ones into memory. */
483 YYSTYPE *yyvs1 = yyvs;
484 short *yyss1 = yyss;
485 #ifdef YYLSP_NEEDED
486 YYLTYPE *yyls1 = yyls;
487 #endif
488
489 /* Get the current used size of the three stacks, in elements. */
490 int size = yyssp - yyss + 1;
491
492 #ifdef yyoverflow
493 /* Each stack pointer address is followed by the size of
494 the data in use in that stack, in bytes. */
495 #ifdef YYLSP_NEEDED
496 /* This used to be a conditional around just the two extra args,
497 but that might be undefined if yyoverflow is a macro. */
498 yyoverflow("parser stack overflow",
499 &yyss1, size * sizeof (*yyssp),
500 &yyvs1, size * sizeof (*yyvsp),
501 &yyls1, size * sizeof (*yylsp),
502 &yystacksize);
503 #else
504 yyoverflow("parser stack overflow",
505 &yyss1, size * sizeof (*yyssp),
506 &yyvs1, size * sizeof (*yyvsp),
507 &yystacksize);
508 #endif
509
510 yyss = yyss1; yyvs = yyvs1;
511 #ifdef YYLSP_NEEDED
512 yyls = yyls1;
513 #endif
514 #else /* no yyoverflow */
515 /* Extend the stack our own way. */
516 if (yystacksize >= YYMAXDEPTH)
517 {
518 yyerror("parser stack overflow");
519 if (yyfree_stacks)
520 {
521 free (yyss);
522 free (yyvs);
523 #ifdef YYLSP_NEEDED
524 free (yyls);
525 #endif
526 }
527 return 2;
528 }
529 yystacksize *= 2;
530 if (yystacksize > YYMAXDEPTH)
531 yystacksize = YYMAXDEPTH;
532 #ifndef YYSTACK_USE_ALLOCA
533 yyfree_stacks = 1;
534 #endif
535 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
536 __yy_memcpy ((char *)yyss, (char *)yyss1,
537 size * (unsigned int) sizeof (*yyssp));
538 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
539 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
540 size * (unsigned int) sizeof (*yyvsp));
541 #ifdef YYLSP_NEEDED
542 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
543 __yy_memcpy ((char *)yyls, (char *)yyls1,
544 size * (unsigned int) sizeof (*yylsp));
545 #endif
546 #endif /* no yyoverflow */
547
548 yyssp = yyss + size - 1;
549 yyvsp = yyvs + size - 1;
550 #ifdef YYLSP_NEEDED
551 yylsp = yyls + size - 1;
552 #endif
553
554 #if YYDEBUG != 0
555 if (yydebug)
556 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
557 #endif
558
559 if (yyssp >= yyss + yystacksize - 1)
560 YYABORT;
561 }
562
563 #if YYDEBUG != 0
564 if (yydebug)
565 fprintf(stderr, "Entering state %d\n", yystate);
566 #endif
567
568 goto yybackup;
569 yybackup:
570
571 /* Do appropriate processing given the current state. */
572 /* Read a lookahead token if we need one and don't already have one. */
573 /* yyresume: */
574
575 /* First try to decide what to do without reference to lookahead token. */
576
577 yyn = yypact[yystate];
578 if (yyn == YYFLAG)
579 goto yydefault;
580
581 /* Not known => get a lookahead token if don't already have one. */
582
583 /* yychar is either YYEMPTY or YYEOF
584 or a valid token in external form. */
585
586 if (yychar == YYEMPTY)
587 {
588 #if YYDEBUG != 0
589 if (yydebug)
590 fprintf(stderr, "Reading a token: ");
591 #endif
592 yychar = YYLEX;
593 }
594
595 /* Convert token to internal form (in yychar1) for indexing tables with */
596
597 if (yychar <= 0) /* This means end of input. */
598 {
599 yychar1 = 0;
600 yychar = YYEOF; /* Don't call YYLEX any more */
601
602 #if YYDEBUG != 0
603 if (yydebug)
604 fprintf(stderr, "Now at end of input.\n");
605 #endif
606 }
607 else
608 {
609 yychar1 = YYTRANSLATE(yychar);
610
611 #if YYDEBUG != 0
612 if (yydebug)
613 {
614 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
615 /* Give the individual parser a way to print the precise meaning
616 of a token, for further debugging info. */
617 #ifdef YYPRINT
618 YYPRINT (stderr, yychar, yylval);
619 #endif
620 fprintf (stderr, ")\n");
621 }
622 #endif
623 }
624
625 yyn += yychar1;
626 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
627 goto yydefault;
628
629 yyn = yytable[yyn];
630
631 /* yyn is what to do for this token type in this state.
632 Negative => reduce, -yyn is rule number.
633 Positive => shift, yyn is new state.
634 New state is final state => don't bother to shift,
635 just return success.
636 0, or most negative number => error. */
637
638 if (yyn < 0)
639 {
640 if (yyn == YYFLAG)
641 goto yyerrlab;
642 yyn = -yyn;
643 goto yyreduce;
644 }
645 else if (yyn == 0)
646 goto yyerrlab;
647
648 if (yyn == YYFINAL)
649 YYACCEPT;
650
651 /* Shift the lookahead token. */
652
653 #if YYDEBUG != 0
654 if (yydebug)
655 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
656 #endif
657
658 /* Discard the token being shifted unless it is eof. */
659 if (yychar != YYEOF)
660 yychar = YYEMPTY;
661
662 *++yyvsp = yylval;
663 #ifdef YYLSP_NEEDED
664 *++yylsp = yylloc;
665 #endif
666
667 /* count tokens shifted since error; after three, turn off error status. */
668 if (yyerrstatus) yyerrstatus--;
669
670 yystate = yyn;
671 goto yynewstate;
672
673 /* Do the default action for the current state. */
674 yydefault:
675
676 yyn = yydefact[yystate];
677 if (yyn == 0)
678 goto yyerrlab;
679
680 /* Do a reduction. yyn is the number of a rule to reduce with. */
681 yyreduce:
682 yylen = yyr2[yyn];
683 if (yylen > 0)
684 yyval = yyvsp[1-yylen]; /* implement default value of the action */
685
686 #if YYDEBUG != 0
687 if (yydebug)
688 {
689 int i;
690
691 fprintf (stderr, "Reducing via rule %d (line %d), ",
692 yyn, yyrline[yyn]);
693
694 /* Print the symbols being reduced, and their result. */
695 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
696 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
697 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
698 }
699 #endif
700
701
702 switch (yyn) {
703
704 case 1:
705 #line 32 "expr.y"
706 { result = yyvsp[0]; ;
707 break;}
708 case 2:
709 #line 36 "expr.y"
710 { yyval = yyvsp[0]; ;
711 break;}
712 case 3:
713 #line 37 "expr.y"
714 { yyval = yyvsp[-1]; ;
715 break;}
716 case 4:
717 #line 38 "expr.y"
718 { yyval = exprNodeDot(yyvsp[-2], yyvsp[0]); ;
719 break;}
720 case 5:
721 #line 39 "expr.y"
722 { yyval = exprNodeArrow(yyvsp[-2], yyvsp[0]); ;
723 break;}
724 case 6:
725 #line 40 "expr.y"
726 { yyval = exprNodeArray(yyvsp[-3], yyvsp[-1]); ;
727 break;}
728 case 7:
729 #line 43 "expr.y"
730 { yyval = yyvsp[0]; ;
731 break;}
732 case 8:
733 #line 44 "expr.y"
734 { yyval = exprNodeStar(yyvsp[0]); ;
735 break;}
736 case 9:
737 #line 45 "expr.y"
738 { yyval = exprNodeAddr(yyvsp[0]); ;
739 break;}
740 case 10:
741 #line 46 "expr.y"
742 { yyval = exprNodeSizeof(yyvsp[-1]); ;
743 break;}
744 case 11:
745 #line 50 "expr.y"
746 { yyval = exprNodeNumber(); ;
747 break;}
748 case 12:
749 #line 54 "expr.y"
750 {yyval = exprNodeIdentifier(); ;
751 break;}
752 }
753 /* the action file gets copied in in place of this dollarsign */
754 #line 543 "/usr/lib/bison.simple"
755
756 yyvsp -= yylen;
757 yyssp -= yylen;
758 #ifdef YYLSP_NEEDED
759 yylsp -= yylen;
760 #endif
761
762 #if YYDEBUG != 0
763 if (yydebug)
764 {
765 short *ssp1 = yyss - 1;
766 fprintf (stderr, "state stack now");
767 while (ssp1 != yyssp)
768 fprintf (stderr, " %d", *++ssp1);
769 fprintf (stderr, "\n");
770 }
771 #endif
772
773 *++yyvsp = yyval;
774
775 #ifdef YYLSP_NEEDED
776 yylsp++;
777 if (yylen == 0)
778 {
779 yylsp->first_line = yylloc.first_line;
780 yylsp->first_column = yylloc.first_column;
781 yylsp->last_line = (yylsp-1)->last_line;
782 yylsp->last_column = (yylsp-1)->last_column;
783 yylsp->text = 0;
784 }
785 else
786 {
787 yylsp->last_line = (yylsp+yylen-1)->last_line;
788 yylsp->last_column = (yylsp+yylen-1)->last_column;
789 }
790 #endif
791
792 /* Now "shift" the result of the reduction.
793 Determine what state that goes to,
794 based on the state we popped back to
795 and the rule number reduced by. */
796
797 yyn = yyr1[yyn];
798
799 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
800 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
801 yystate = yytable[yystate];
802 else
803 yystate = yydefgoto[yyn - YYNTBASE];
804
805 goto yynewstate;
806
807 yyerrlab: /* here on detecting error */
808
809 if (! yyerrstatus)
810 /* If not already recovering from an error, report this error. */
811 {
812 ++yynerrs;
813
814 #ifdef YYERROR_VERBOSE
815 yyn = yypact[yystate];
816
817 if (yyn > YYFLAG && yyn < YYLAST)
818 {
819 int size = 0;
820 char *msg;
821 int x, count;
822
823 count = 0;
824 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
825 for (x = (yyn < 0 ? -yyn : 0);
826 x < (sizeof(yytname) / sizeof(char *)); x++)
827 if (yycheck[x + yyn] == x)
828 size += strlen(yytname[x]) + 15, count++;
829 msg = (char *) malloc(size + 15);
830 if (msg != 0)
831 {
832 strcpy(msg, "parse error");
833
834 if (count < 5)
835 {
836 count = 0;
837 for (x = (yyn < 0 ? -yyn : 0);
838 x < (sizeof(yytname) / sizeof(char *)); x++)
839 if (yycheck[x + yyn] == x)
840 {
841 strcat(msg, count == 0 ? ", expecting `" : " or `");
842 strcat(msg, yytname[x]);
843 strcat(msg, "'");
844 count++;
845 }
846 }
847 yyerror(msg);
848 free(msg);
849 }
850 else
851 yyerror ("parse error; also virtual memory exceeded");
852 }
853 else
854 #endif /* YYERROR_VERBOSE */
855 yyerror("parse error");
856 }
857
858 goto yyerrlab1;
859 yyerrlab1: /* here on error raised explicitly by an action */
860
861 if (yyerrstatus == 3)
862 {
863 /* if just tried and failed to reuse lookahead token after an error, discard it. */
864
865 /* return failure if at end of input */
866 if (yychar == YYEOF)
867 YYABORT;
868
869 #if YYDEBUG != 0
870 if (yydebug)
871 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
872 #endif
873
874 yychar = YYEMPTY;
875 }
876
877 /* Else will try to reuse lookahead token
878 after shifting the error token. */
879
880 yyerrstatus = 3; /* Each real token shifted decrements this */
881
882 goto yyerrhandle;
883
884 yyerrdefault: /* current state does not do anything special for the error token. */
885
886 #if 0
887 /* This is wrong; only states that explicitly want error tokens
888 should shift them. */
889 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
890 if (yyn) goto yydefault;
891 #endif
892
893 yyerrpop: /* pop the current state because it cannot handle the error token */
894
895 if (yyssp == yyss) YYABORT;
896 yyvsp--;
897 yystate = *--yyssp;
898 #ifdef YYLSP_NEEDED
899 yylsp--;
900 #endif
901
902 #if YYDEBUG != 0
903 if (yydebug)
904 {
905 short *ssp1 = yyss - 1;
906 fprintf (stderr, "Error: state stack now");
907 while (ssp1 != yyssp)
908 fprintf (stderr, " %d", *++ssp1);
909 fprintf (stderr, "\n");
910 }
911 #endif
912
913 yyerrhandle:
914
915 yyn = yypact[yystate];
916 if (yyn == YYFLAG)
917 goto yyerrdefault;
918
919 yyn += YYTERROR;
920 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
921 goto yyerrdefault;
922
923 yyn = yytable[yyn];
924 if (yyn < 0)
925 {
926 if (yyn == YYFLAG)
927 goto yyerrpop;
928 yyn = -yyn;
929 goto yyreduce;
930 }
931 else if (yyn == 0)
932 goto yyerrpop;
933
934 if (yyn == YYFINAL)
935 YYACCEPT;
936
937 #if YYDEBUG != 0
938 if (yydebug)
939 fprintf(stderr, "Shifting error token, ");
940 #endif
941
942 *++yyvsp = yylval;
943 #ifdef YYLSP_NEEDED
944 *++yylsp = yylloc;
945 #endif
946
947 yystate = yyn;
948 goto yynewstate;
949
950 yyacceptlab:
951 /* YYACCEPT comes here. */
952 if (yyfree_stacks)
953 {
954 free (yyss);
955 free (yyvs);
956 #ifdef YYLSP_NEEDED
957 free (yyls);
958 #endif
959 }
960 return 0;
961
962 yyabortlab:
963 /* YYABORT comes here. */
964 if (yyfree_stacks)
965 {
966 free (yyss);
967 free (yyvs);
968 #ifdef YYLSP_NEEDED
969 free (yyls);
970 #endif
971 }
972 return 1;
973 }
974 #line 57 "expr.y"
975
976
yyerror(char * s)977 int yyerror(char *s)
978 {
979 return 0;
980 }
981
982 #ifndef SDL
983 extern FILE *yyin;
main(int argc,char ** argv)984 int main(int argc, char **argv)
985 {
986 // yydebug = 1;
987 ++argv, --argc;
988 if(argc > 0)
989 yyin = fopen(argv[0], "r");
990 else
991 yyin = stdin;
992 if(!yyparse())
993 result->print();
994 }
995 #endif
996