view src/sdl/expr.cpp @ 506:130ba9f49db5

added function to slice up an image into an appropriate representation for the GB.
author Robert McIntyre <rlm@mit.edu>
date Wed, 20 Jun 2012 16:50:36 -0500
parents f9f4f1b99eed
children
line wrap: on
line source

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