1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
3 /* This file comes from bison-@bison_version@. */
5 /* Skeleton output parser for bison,
6 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* As a special exception, when this file is copied by Bison into a
24 Bison output file, you may use that output file without restriction.
25 This special exception was added by the Free Software Foundation
26 in version 1.24 of Bison. */
28 /* This is the parser code that is written into each bison parser
29 when the %semantic_parser declaration is not specified in the grammar.
30 It was written by Richard Stallman by simplifying the hairy parser
31 used when %semantic_parser is specified. */
33 #ifndef YYSTACK_USE_ALLOCA
35 #define YYSTACK_USE_ALLOCA
36 #else /* alloca not defined */
38 #define YYSTACK_USE_ALLOCA
39 #define alloca __builtin_alloca
40 #else /* not GNU C. */
41 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
42 #define YYSTACK_USE_ALLOCA
45 /* We think this test detects Watcom and Microsoft C. */
46 /* This used to test MSDOS, but that is a bad idea
47 since that symbol is in the user namespace. */
48 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
49 #if 0 /* No need for malloc.h, which pollutes the namespace;
50 instead, just don't use alloca. */
53 #else /* not MSDOS, or __TURBOC__ */
55 /* I don't know what this was needed for, but it pollutes the namespace.
56 So I turned it off. rms, 2 May 1997. */
57 /* #include <malloc.h> */
59 #define YYSTACK_USE_ALLOCA
60 #else /* not MSDOS, or __TURBOC__, or _AIX */
62 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
63 and on HPUX 10. Eventually we can turn this on. */
64 #define YYSTACK_USE_ALLOCA
65 #define alloca __builtin_alloca
69 #endif /* not MSDOS, or __TURBOC__ */
70 #endif /* not sparc */
71 #endif /* not GNU C */
72 #endif /* alloca not defined */
73 #endif /* YYSTACK_USE_ALLOCA not defined */
75 #ifdef YYSTACK_USE_ALLOCA
76 #define YYSTACK_ALLOC alloca
78 #define YYSTACK_ALLOC malloc
81 /* Note: there must be only one dollar sign in this file.
82 It is replaced by the list of actions, each action
83 as one case of the switch. */
85 #define yyerrok (yyerrstatus = 0)
86 #define yyclearin (yychar = YYEMPTY)
89 #define YYACCEPT goto yyacceptlab
90 #define YYABORT goto yyabortlab
91 #define YYERROR goto yyerrlab1
92 /* Like YYERROR except do call yyerror.
93 This remains here temporarily to ease the
94 transition to the new meaning of YYERROR, for GCC.
95 Once GCC version 2 has supplanted version 1, this can go. */
96 #define YYFAIL goto yyerrlab
97 #define YYRECOVERING() (!!yyerrstatus)
98 #define YYBACKUP(token, value) \
100 if (yychar == YYEMPTY && yylen == 1) \
101 { yychar = (token), yylval = (value); \
102 yychar1 = YYTRANSLATE (yychar); \
107 { yyerror ("syntax error: cannot back up"); YYERROR; } \
111 #define YYERRCODE 256
114 #define YYLEX yylex()
120 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
122 #define YYLEX yylex(&yylval, &yylloc)
124 #else /* not YYLSP_NEEDED */
126 #define YYLEX yylex(&yylval, YYLEX_PARAM)
128 #define YYLEX yylex(&yylval)
130 #endif /* not YYLSP_NEEDED */
133 /* If nonreentrant, generate the variables here */
137 int yychar; /* the lookahead symbol */
138 YYSTYPE yylval; /* the semantic value of the */
139 /* lookahead symbol */
142 YYLTYPE yylloc; /* location data for the lookahead */
146 int yynerrs; /* number of parse errors so far */
147 #endif /* not YYPURE */
150 int yydebug; /* nonzero means print parse trace */
151 /* Since this is uninitialized, it does not stop multiple parsers
155 /* YYINITDEPTH indicates the initial size of the parser's stacks */
158 #define YYINITDEPTH 200
161 /* YYMAXDEPTH is the maximum size the stacks can grow to
162 (effective only if the built-in stack extension method is used). */
169 #define YYMAXDEPTH 10000
172 /* Define __yy_memcpy. Note that the size argument
173 should be passed with type unsigned int, because that is what the non-GCC
174 definitions require. With GCC, __builtin_memcpy takes an arg
175 of type size_t, but it can handle unsigned int. */
177 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
178 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
179 #else /* not GNU C or C++ */
182 /* This is the most reliable way to avoid incompatibilities
183 in available built-in functions on various systems. */
185 __yy_memcpy (to, from, count)
190 register char *f = from;
191 register char *t = to;
192 register int i = count;
198 #else /* __cplusplus */
200 /* This is the most reliable way to avoid incompatibilities
201 in available built-in functions on various systems. */
203 __yy_memcpy (char *to, char *from, unsigned int count)
205 register char *t = to;
206 register char *f = from;
207 register int i = count;
216 #line 217 "bison.simple"
218 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
219 into yyparse. The argument should have type void *.
220 It should actually point to an object.
221 Grammar actions can access the variable by casting it
222 to the proper pointer type. */
226 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
227 #define YYPARSE_PARAM_DECL
228 #else /* not __cplusplus */
229 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
230 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
231 #endif /* not __cplusplus */
232 #else /* not YYPARSE_PARAM */
233 #define YYPARSE_PARAM_ARG
234 #define YYPARSE_PARAM_DECL
235 #endif /* not YYPARSE_PARAM */
237 /* Prevent warning if -Wstrict-prototypes. */
240 int yyparse (void *);
247 yyparse(YYPARSE_PARAM_ARG)
250 register int yystate;
252 register short *yyssp;
253 register YYSTYPE *yyvsp;
254 int yyerrstatus; /* number of tokens to shift before error messages enabled */
255 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
257 short yyssa[YYINITDEPTH]; /* the state stack */
258 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
260 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
261 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
264 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
265 YYLTYPE *yyls = yylsa;
268 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
270 #define YYPOPSTACK (yyvsp--, yyssp--)
273 int yystacksize = YYINITDEPTH;
274 int yyfree_stacks = 0;
285 YYSTYPE yyval; /* the variable used to return */
286 /* semantic values from the action */
293 fprintf(stderr, "Starting parse\n");
299 yychar = YYEMPTY; /* Cause a token to be read. */
301 /* Initialize stack pointers.
302 Waste one element of value and location stack
303 so that they stay on the same level as the state stack.
304 The wasted elements are never initialized. */
312 /* Push a new state, which is found in yystate . */
313 /* In all cases, when you get here, the value and location stacks
314 have just been pushed. so pushing a state here evens the stacks. */
319 if (yyssp >= yyss + yystacksize - 1)
321 /* Give user a chance to reallocate the stack */
322 /* Use copies of these so that the &'s don't force the real ones into memory. */
323 YYSTYPE *yyvs1 = yyvs;
326 YYLTYPE *yyls1 = yyls;
329 /* Get the current used size of the three stacks, in elements. */
330 int size = yyssp - yyss + 1;
333 /* Each stack pointer address is followed by the size of
334 the data in use in that stack, in bytes. */
336 /* This used to be a conditional around just the two extra args,
337 but that might be undefined if yyoverflow is a macro. */
338 yyoverflow("parser stack overflow",
339 &yyss1, size * sizeof (*yyssp),
340 &yyvs1, size * sizeof (*yyvsp),
341 &yyls1, size * sizeof (*yylsp),
344 yyoverflow("parser stack overflow",
345 &yyss1, size * sizeof (*yyssp),
346 &yyvs1, size * sizeof (*yyvsp),
350 yyss = yyss1; yyvs = yyvs1;
354 #else /* no yyoverflow */
355 /* Extend the stack our own way. */
356 if (yystacksize >= YYMAXDEPTH)
358 yyerror("parser stack overflow");
370 if (yystacksize > YYMAXDEPTH)
371 yystacksize = YYMAXDEPTH;
372 #ifndef YYSTACK_USE_ALLOCA
375 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
376 __yy_memcpy ((char *)yyss, (char *)yyss1,
377 size * (unsigned int) sizeof (*yyssp));
378 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
379 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
380 size * (unsigned int) sizeof (*yyvsp));
382 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
383 __yy_memcpy ((char *)yyls, (char *)yyls1,
384 size * (unsigned int) sizeof (*yylsp));
386 #endif /* no yyoverflow */
388 yyssp = yyss + size - 1;
389 yyvsp = yyvs + size - 1;
391 yylsp = yyls + size - 1;
396 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
399 if (yyssp >= yyss + yystacksize - 1)
405 fprintf(stderr, "Entering state %d\n", yystate);
411 /* Do appropriate processing given the current state. */
412 /* Read a lookahead token if we need one and don't already have one. */
415 /* First try to decide what to do without reference to lookahead token. */
417 yyn = yypact[yystate];
421 /* Not known => get a lookahead token if don't already have one. */
423 /* yychar is either YYEMPTY or YYEOF
424 or a valid token in external form. */
426 if (yychar == YYEMPTY)
430 fprintf(stderr, "Reading a token: ");
435 /* Convert token to internal form (in yychar1) for indexing tables with */
437 if (yychar <= 0) /* This means end of input. */
440 yychar = YYEOF; /* Don't call YYLEX any more */
444 fprintf(stderr, "Now at end of input.\n");
449 yychar1 = YYTRANSLATE(yychar);
454 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
455 /* Give the individual parser a way to print the precise meaning
456 of a token, for further debugging info. */
458 YYPRINT (stderr, yychar, yylval);
460 fprintf (stderr, ")\n");
466 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
471 /* yyn is what to do for this token type in this state.
472 Negative => reduce, -yyn is rule number.
473 Positive => shift, yyn is new state.
474 New state is final state => don't bother to shift,
476 0, or most negative number => error. */
491 /* Shift the lookahead token. */
495 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
498 /* Discard the token being shifted unless it is eof. */
507 /* count tokens shifted since error; after three, turn off error status. */
508 if (yyerrstatus) yyerrstatus--;
513 /* Do the default action for the current state. */
516 yyn = yydefact[yystate];
520 /* Do a reduction. yyn is the number of a rule to reduce with. */
524 yyval = yyvsp[1-yylen]; /* implement default value of the action */
531 fprintf (stderr, "Reducing via rule %d (line %d), ",
534 /* Print the symbols being reduced, and their result. */
535 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
536 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
537 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
541 $ /* the action file gets copied in in place of this dollarsign */
542 #line 543 "bison.simple"
553 short *ssp1 = yyss - 1;
554 fprintf (stderr, "state stack now");
555 while (ssp1 != yyssp)
556 fprintf (stderr, " %d", *++ssp1);
557 fprintf (stderr, "\n");
567 yylsp->first_line = yylloc.first_line;
568 yylsp->first_column = yylloc.first_column;
569 yylsp->last_line = (yylsp-1)->last_line;
570 yylsp->last_column = (yylsp-1)->last_column;
575 yylsp->last_line = (yylsp+yylen-1)->last_line;
576 yylsp->last_column = (yylsp+yylen-1)->last_column;
580 /* Now "shift" the result of the reduction.
581 Determine what state that goes to,
582 based on the state we popped back to
583 and the rule number reduced by. */
587 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
588 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
589 yystate = yytable[yystate];
591 yystate = yydefgoto[yyn - YYNTBASE];
595 yyerrlab: /* here on detecting error */
598 /* If not already recovering from an error, report this error. */
602 #ifdef YYERROR_VERBOSE
603 yyn = yypact[yystate];
605 if (yyn > YYFLAG && yyn < YYLAST)
612 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
613 for (x = (yyn < 0 ? -yyn : 0);
614 x < (sizeof(yytname) / sizeof(char *)); x++)
615 if (yycheck[x + yyn] == x)
616 size += strlen(yytname[x]) + 15, count++;
617 msg = (char *) malloc(size + 15);
620 strcpy(msg, "parse error");
625 for (x = (yyn < 0 ? -yyn : 0);
626 x < (sizeof(yytname) / sizeof(char *)); x++)
627 if (yycheck[x + yyn] == x)
629 strcat(msg, count == 0 ? ", expecting `" : " or `");
630 strcat(msg, yytname[x]);
639 yyerror ("parse error; also virtual memory exceeded");
642 #endif /* YYERROR_VERBOSE */
643 yyerror("parse error");
647 yyerrlab1: /* here on error raised explicitly by an action */
649 if (yyerrstatus == 3)
651 /* if just tried and failed to reuse lookahead token after an error, discard it. */
653 /* return failure if at end of input */
659 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
665 /* Else will try to reuse lookahead token
666 after shifting the error token. */
668 yyerrstatus = 3; /* Each real token shifted decrements this */
672 yyerrdefault: /* current state does not do anything special for the error token. */
675 /* This is wrong; only states that explicitly want error tokens
676 should shift them. */
677 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
678 if (yyn) goto yydefault;
681 yyerrpop: /* pop the current state because it cannot handle the error token */
683 if (yyssp == yyss) YYABORT;
693 short *ssp1 = yyss - 1;
694 fprintf (stderr, "Error: state stack now");
695 while (ssp1 != yyssp)
696 fprintf (stderr, " %d", *++ssp1);
697 fprintf (stderr, "\n");
703 yyn = yypact[yystate];
708 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
727 fprintf(stderr, "Shifting error token, ");
739 /* YYACCEPT comes here. */
751 /* YYABORT comes here. */