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., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 /* As a special exception, when this file is copied by Bison into a
23 Bison output file, you may use that output file without restriction.
24 This special exception was added by the Free Software Foundation
25 in version 1.24 of Bison. */
27 /* This is the parser code that is written into each bison parser
28 when the %semantic_parser declaration is not specified in the grammar.
29 It was written by Richard Stallman by simplifying the hairy parser
30 used when %semantic_parser is specified. */
32 #ifndef YYSTACK_USE_ALLOCA
34 #define YYSTACK_USE_ALLOCA
35 #else /* alloca not defined */
37 #define YYSTACK_USE_ALLOCA
38 #define alloca __builtin_alloca
39 #else /* not GNU C. */
40 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
41 #define YYSTACK_USE_ALLOCA
44 /* We think this test detects Watcom and Microsoft C. */
45 /* This used to test MSDOS, but that is a bad idea
46 since that symbol is in the user namespace. */
47 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
48 #if 0 /* No need for malloc.h, which pollutes the namespace;
49 instead, just don't use alloca. */
52 #else /* not MSDOS, or __TURBOC__ */
54 /* I don't know what this was needed for, but it pollutes the namespace.
55 So I turned it off. rms, 2 May 1997. */
56 /* #include <malloc.h> */
58 #define YYSTACK_USE_ALLOCA
59 #else /* not MSDOS, or __TURBOC__, or _AIX */
61 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
62 and on HPUX 10. Eventually we can turn this on. */
63 #define YYSTACK_USE_ALLOCA
64 #define alloca __builtin_alloca
68 #endif /* not MSDOS, or __TURBOC__ */
69 #endif /* not sparc */
70 #endif /* not GNU C */
71 #endif /* alloca not defined */
72 #endif /* YYSTACK_USE_ALLOCA not defined */
74 #ifdef YYSTACK_USE_ALLOCA
75 #define YYSTACK_ALLOC alloca
77 #define YYSTACK_ALLOC malloc
80 /* Note: there must be only one dollar sign in this file.
81 It is replaced by the list of actions, each action
82 as one case of the switch. */
84 #define yyerrok (yyerrstatus = 0)
85 #define yyclearin (yychar = YYEMPTY)
88 #define YYACCEPT goto yyacceptlab
89 #define YYABORT goto yyabortlab
90 #define YYERROR goto yyerrlab1
91 /* Like YYERROR except do call yyerror.
92 This remains here temporarily to ease the
93 transition to the new meaning of YYERROR, for GCC.
94 Once GCC version 2 has supplanted version 1, this can go. */
95 #define YYFAIL goto yyerrlab
96 #define YYRECOVERING() (!!yyerrstatus)
97 #define YYBACKUP(token, value) \
99 if (yychar == YYEMPTY && yylen == 1) \
100 { yychar = (token), yylval = (value); \
101 yychar1 = YYTRANSLATE (yychar); \
106 { yyerror ("syntax error: cannot back up"); YYERROR; } \
110 #define YYERRCODE 256
113 #define YYLEX yylex()
119 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
121 #define YYLEX yylex(&yylval, &yylloc)
123 #else /* not YYLSP_NEEDED */
125 #define YYLEX yylex(&yylval, YYLEX_PARAM)
127 #define YYLEX yylex(&yylval)
129 #endif /* not YYLSP_NEEDED */
132 /* If nonreentrant, generate the variables here */
136 int yychar; /* the lookahead symbol */
137 YYSTYPE yylval; /* the semantic value of the */
138 /* lookahead symbol */
141 YYLTYPE yylloc; /* location data for the lookahead */
145 int yynerrs; /* number of parse errors so far */
146 #endif /* not YYPURE */
149 int yydebug; /* nonzero means print parse trace */
150 /* Since this is uninitialized, it does not stop multiple parsers
154 /* YYINITDEPTH indicates the initial size of the parser's stacks */
157 #define YYINITDEPTH 200
160 /* YYMAXDEPTH is the maximum size the stacks can grow to
161 (effective only if the built-in stack extension method is used). */
168 #define YYMAXDEPTH 10000
171 /* Define __yy_memcpy. Note that the size argument
172 should be passed with type unsigned int, because that is what the non-GCC
173 definitions require. With GCC, __builtin_memcpy takes an arg
174 of type size_t, but it can handle unsigned int. */
176 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
177 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
178 #else /* not GNU C or C++ */
181 /* This is the most reliable way to avoid incompatibilities
182 in available built-in functions on various systems. */
184 __yy_memcpy (to, from, count)
189 register char *f = from;
190 register char *t = to;
191 register int i = count;
197 #else /* __cplusplus */
199 /* This is the most reliable way to avoid incompatibilities
200 in available built-in functions on various systems. */
202 __yy_memcpy (char *to, char *from, unsigned int count)
204 register char *t = to;
205 register char *f = from;
206 register int i = count;
215 #line 216 "bison.simple"
217 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
218 into yyparse. The argument should have type void *.
219 It should actually point to an object.
220 Grammar actions can access the variable by casting it
221 to the proper pointer type. */
225 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
226 #define YYPARSE_PARAM_DECL
227 #else /* not __cplusplus */
228 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
229 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
230 #endif /* not __cplusplus */
231 #else /* not YYPARSE_PARAM */
232 #define YYPARSE_PARAM_ARG
233 #define YYPARSE_PARAM_DECL
234 #endif /* not YYPARSE_PARAM */
236 /* Prevent warning if -Wstrict-prototypes. */
239 int yyparse (void *);
246 yyparse(YYPARSE_PARAM_ARG)
249 register int yystate;
251 register short *yyssp;
252 register YYSTYPE *yyvsp;
253 int yyerrstatus; /* number of tokens to shift before error messages enabled */
254 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
256 short yyssa[YYINITDEPTH]; /* the state stack */
257 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
259 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
260 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
263 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
264 YYLTYPE *yyls = yylsa;
267 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
269 #define YYPOPSTACK (yyvsp--, yyssp--)
272 int yystacksize = YYINITDEPTH;
273 int yyfree_stacks = 0;
284 YYSTYPE yyval; /* the variable used to return */
285 /* semantic values from the action */
292 fprintf(stderr, "Starting parse\n");
298 yychar = YYEMPTY; /* Cause a token to be read. */
300 /* Initialize stack pointers.
301 Waste one element of value and location stack
302 so that they stay on the same level as the state stack.
303 The wasted elements are never initialized. */
311 /* Push a new state, which is found in yystate . */
312 /* In all cases, when you get here, the value and location stacks
313 have just been pushed. so pushing a state here evens the stacks. */
318 if (yyssp >= yyss + yystacksize - 1)
320 /* Give user a chance to reallocate the stack */
321 /* Use copies of these so that the &'s don't force the real ones into memory. */
322 YYSTYPE *yyvs1 = yyvs;
325 YYLTYPE *yyls1 = yyls;
328 /* Get the current used size of the three stacks, in elements. */
329 int size = yyssp - yyss + 1;
332 /* Each stack pointer address is followed by the size of
333 the data in use in that stack, in bytes. */
335 /* This used to be a conditional around just the two extra args,
336 but that might be undefined if yyoverflow is a macro. */
337 yyoverflow("parser stack overflow",
338 &yyss1, size * sizeof (*yyssp),
339 &yyvs1, size * sizeof (*yyvsp),
340 &yyls1, size * sizeof (*yylsp),
343 yyoverflow("parser stack overflow",
344 &yyss1, size * sizeof (*yyssp),
345 &yyvs1, size * sizeof (*yyvsp),
349 yyss = yyss1; yyvs = yyvs1;
353 #else /* no yyoverflow */
354 /* Extend the stack our own way. */
355 if (yystacksize >= YYMAXDEPTH)
357 yyerror("parser stack overflow");
369 if (yystacksize > YYMAXDEPTH)
370 yystacksize = YYMAXDEPTH;
371 #ifndef YYSTACK_USE_ALLOCA
374 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
375 __yy_memcpy ((char *)yyss, (char *)yyss1,
376 size * (unsigned int) sizeof (*yyssp));
377 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
378 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
379 size * (unsigned int) sizeof (*yyvsp));
381 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
382 __yy_memcpy ((char *)yyls, (char *)yyls1,
383 size * (unsigned int) sizeof (*yylsp));
385 #endif /* no yyoverflow */
387 yyssp = yyss + size - 1;
388 yyvsp = yyvs + size - 1;
390 yylsp = yyls + size - 1;
395 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
398 if (yyssp >= yyss + yystacksize - 1)
404 fprintf(stderr, "Entering state %d\n", yystate);
410 /* Do appropriate processing given the current state. */
411 /* Read a lookahead token if we need one and don't already have one. */
414 /* First try to decide what to do without reference to lookahead token. */
416 yyn = yypact[yystate];
420 /* Not known => get a lookahead token if don't already have one. */
422 /* yychar is either YYEMPTY or YYEOF
423 or a valid token in external form. */
425 if (yychar == YYEMPTY)
429 fprintf(stderr, "Reading a token: ");
434 /* Convert token to internal form (in yychar1) for indexing tables with */
436 if (yychar <= 0) /* This means end of input. */
439 yychar = YYEOF; /* Don't call YYLEX any more */
443 fprintf(stderr, "Now at end of input.\n");
448 yychar1 = YYTRANSLATE(yychar);
453 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
454 /* Give the individual parser a way to print the precise meaning
455 of a token, for further debugging info. */
457 YYPRINT (stderr, yychar, yylval);
459 fprintf (stderr, ")\n");
465 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
470 /* yyn is what to do for this token type in this state.
471 Negative => reduce, -yyn is rule number.
472 Positive => shift, yyn is new state.
473 New state is final state => don't bother to shift,
475 0, or most negative number => error. */
490 /* Shift the lookahead token. */
494 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
497 /* Discard the token being shifted unless it is eof. */
506 /* count tokens shifted since error; after three, turn off error status. */
507 if (yyerrstatus) yyerrstatus--;
512 /* Do the default action for the current state. */
515 yyn = yydefact[yystate];
519 /* Do a reduction. yyn is the number of a rule to reduce with. */
523 yyval = yyvsp[1-yylen]; /* implement default value of the action */
530 fprintf (stderr, "Reducing via rule %d (line %d), ",
533 /* Print the symbols being reduced, and their result. */
534 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
535 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
536 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
540 $ /* the action file gets copied in in place of this dollarsign */
541 #line 542 "bison.simple"
552 short *ssp1 = yyss - 1;
553 fprintf (stderr, "state stack now");
554 while (ssp1 != yyssp)
555 fprintf (stderr, " %d", *++ssp1);
556 fprintf (stderr, "\n");
566 yylsp->first_line = yylloc.first_line;
567 yylsp->first_column = yylloc.first_column;
568 yylsp->last_line = (yylsp-1)->last_line;
569 yylsp->last_column = (yylsp-1)->last_column;
574 yylsp->last_line = (yylsp+yylen-1)->last_line;
575 yylsp->last_column = (yylsp+yylen-1)->last_column;
579 /* Now "shift" the result of the reduction.
580 Determine what state that goes to,
581 based on the state we popped back to
582 and the rule number reduced by. */
586 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
587 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
588 yystate = yytable[yystate];
590 yystate = yydefgoto[yyn - YYNTBASE];
594 yyerrlab: /* here on detecting error */
597 /* If not already recovering from an error, report this error. */
601 #ifdef YYERROR_VERBOSE
602 yyn = yypact[yystate];
604 if (yyn > YYFLAG && yyn < YYLAST)
611 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
612 for (x = (yyn < 0 ? -yyn : 0);
613 x < (sizeof(yytname) / sizeof(char *)); x++)
614 if (yycheck[x + yyn] == x)
615 size += strlen(yytname[x]) + 15, count++;
616 msg = (char *) malloc(size + 15);
619 strcpy(msg, "parse error");
624 for (x = (yyn < 0 ? -yyn : 0);
625 x < (sizeof(yytname) / sizeof(char *)); x++)
626 if (yycheck[x + yyn] == x)
628 strcat(msg, count == 0 ? ", expecting `" : " or `");
629 strcat(msg, yytname[x]);
638 yyerror ("parse error; also virtual memory exceeded");
641 #endif /* YYERROR_VERBOSE */
642 yyerror("parse error");
646 yyerrlab1: /* here on error raised explicitly by an action */
648 if (yyerrstatus == 3)
650 /* if just tried and failed to reuse lookahead token after an error, discard it. */
652 /* return failure if at end of input */
658 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
664 /* Else will try to reuse lookahead token
665 after shifting the error token. */
667 yyerrstatus = 3; /* Each real token shifted decrements this */
671 yyerrdefault: /* current state does not do anything special for the error token. */
674 /* This is wrong; only states that explicitly want error tokens
675 should shift them. */
676 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
677 if (yyn) goto yydefault;
680 yyerrpop: /* pop the current state because it cannot handle the error token */
682 if (yyssp == yyss) YYABORT;
692 short *ssp1 = yyss - 1;
693 fprintf (stderr, "Error: state stack now");
694 while (ssp1 != yyssp)
695 fprintf (stderr, " %d", *++ssp1);
696 fprintf (stderr, "\n");
702 yyn = yypact[yystate];
707 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
726 fprintf(stderr, "Shifting error token, ");
738 /* YYACCEPT comes here. */
750 /* YYABORT comes here. */