1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
4 /* Skeleton output parser for bison,
5 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* This is the parser code that is written into each bison parser
27 when the %semantic_parser declaration is not specified in the grammar.
28 It was written by Richard Stallman by simplifying the hairy parser
29 used when %semantic_parser is specified. */
33 #define alloca __builtin_alloca
34 #else /* not GNU C. */
35 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
38 /* This used to test MSDOS, but that is a bad idea
39 since that is in the user namespace. */
40 #if defined (_MSDOS_) && !defined (__TURBOC__)
42 #else /* not _MSDOS_, or __TURBOC__ */
46 #else /* not MSDOS, __TURBOC__, or _AIX */
50 void *alloca (unsigned int);
52 #else /* not __cplusplus */
54 #endif /* not __cplusplus */
57 #endif /* not _MSDOS_, or __TURBOC__ */
58 #endif /* not sparc. */
59 #endif /* not GNU C. */
60 #endif /* alloca not defined. */
62 /* Note: there must be only one dollar sign in this file.
63 It is replaced by the list of actions, each action
64 as one case of the switch. */
66 #define yyerrok (yyerrstatus = 0)
67 #define yyclearin (yychar = YYEMPTY)
70 #define YYACCEPT return(0)
71 #define YYABORT return(1)
72 #define YYERROR goto yyerrlab1
73 /* Like YYERROR except do call yyerror.
74 This remains here temporarily to ease the
75 transition to the new meaning of YYERROR, for GCC.
76 Once GCC version 2 has supplanted version 1, this can go. */
77 #define YYFAIL goto yyerrlab
78 #define YYRECOVERING() (!!yyerrstatus)
79 #define YYBACKUP(token, value) \
81 if (yychar == YYEMPTY && yylen == 1) \
82 { yychar = (token), yylval = (value); \
83 yychar1 = YYTRANSLATE (yychar); \
88 { yyerror ("syntax error: cannot back up"); YYERROR; } \
101 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
103 #define YYLEX yylex(&yylval, &yylloc)
105 #else /* not YYLSP_NEEDED */
107 #define YYLEX yylex(&yylval, YYLEX_PARAM)
109 #define YYLEX yylex(&yylval)
111 #endif /* not YYLSP_NEEDED */
114 /* If nonreentrant, generate the variables here */
118 int yychar; /* the lookahead symbol */
119 YYSTYPE yylval; /* the semantic value of the */
120 /* lookahead symbol */
123 YYLTYPE yylloc; /* location data for the lookahead */
127 int yynerrs; /* number of parse errors so far */
128 #endif /* not YYPURE */
131 int yydebug; /* nonzero means print parse trace */
132 /* Since this is uninitialized, it does not stop multiple parsers
136 /* YYINITDEPTH indicates the initial size of the parser's stacks */
139 #define YYINITDEPTH 200
142 /* YYMAXDEPTH is the maximum size the stacks can grow to
143 (effective only if the built-in stack extension method is used). */
150 #define YYMAXDEPTH 10000
153 /* Prevent warning if -Wstrict-prototypes. */
158 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
159 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
160 #else /* not GNU C or C++ */
163 /* This is the most reliable way to avoid incompatibilities
164 in available built-in functions on various systems. */
166 __yy_memcpy (to, from, count)
171 register char *f = from;
172 register char *t = to;
173 register int i = count;
179 #else /* __cplusplus */
181 /* This is the most reliable way to avoid incompatibilities
182 in available built-in functions on various systems. */
184 __yy_memcpy (char *to, char *from, int count)
186 register char *t = to;
187 register char *f = from;
188 register int i = count;
197 #line 196 "bison.simple"
199 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
200 into yyparse. The argument should have type void *.
201 It should actually point to an object.
202 Grammar actions can access the variable by casting it
203 to the proper pointer type. */
207 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
208 #define YYPARSE_PARAM_DECL
209 #else /* not __cplusplus */
210 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
211 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
212 #endif /* not __cplusplus */
213 #else /* not YYPARSE_PARAM */
214 #define YYPARSE_PARAM_ARG
215 #define YYPARSE_PARAM_DECL
216 #endif /* not YYPARSE_PARAM */
219 yyparse(YYPARSE_PARAM_ARG)
222 register int yystate;
224 register short *yyssp;
225 register YYSTYPE *yyvsp;
226 int yyerrstatus; /* number of tokens to shift before error messages enabled */
227 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
229 short yyssa[YYINITDEPTH]; /* the state stack */
230 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
232 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
233 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
236 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
237 YYLTYPE *yyls = yylsa;
240 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
242 #define YYPOPSTACK (yyvsp--, yyssp--)
245 int yystacksize = YYINITDEPTH;
256 YYSTYPE yyval; /* the variable used to return */
257 /* semantic values from the action */
264 fprintf(stderr, "Starting parse\n");
270 yychar = YYEMPTY; /* Cause a token to be read. */
272 /* Initialize stack pointers.
273 Waste one element of value and location stack
274 so that they stay on the same level as the state stack.
275 The wasted elements are never initialized. */
283 /* Push a new state, which is found in yystate . */
284 /* In all cases, when you get here, the value and location stacks
285 have just been pushed. so pushing a state here evens the stacks. */
290 if (yyssp >= yyss + yystacksize - 1)
292 /* Give user a chance to reallocate the stack */
293 /* Use copies of these so that the &'s don't force the real ones into memory. */
294 YYSTYPE *yyvs1 = yyvs;
297 YYLTYPE *yyls1 = yyls;
300 /* Get the current used size of the three stacks, in elements. */
301 int size = yyssp - yyss + 1;
304 /* Each stack pointer address is followed by the size of
305 the data in use in that stack, in bytes. */
307 /* This used to be a conditional around just the two extra args,
308 but that might be undefined if yyoverflow is a macro. */
309 yyoverflow("parser stack overflow",
310 &yyss1, size * sizeof (*yyssp),
311 &yyvs1, size * sizeof (*yyvsp),
312 &yyls1, size * sizeof (*yylsp),
315 yyoverflow("parser stack overflow",
316 &yyss1, size * sizeof (*yyssp),
317 &yyvs1, size * sizeof (*yyvsp),
321 yyss = yyss1; yyvs = yyvs1;
325 #else /* no yyoverflow */
326 /* Extend the stack our own way. */
327 if (yystacksize >= YYMAXDEPTH)
329 yyerror("parser stack overflow");
333 if (yystacksize > YYMAXDEPTH)
334 yystacksize = YYMAXDEPTH;
335 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
336 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
337 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
338 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
340 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
341 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
343 #endif /* no yyoverflow */
345 yyssp = yyss + size - 1;
346 yyvsp = yyvs + size - 1;
348 yylsp = yyls + size - 1;
353 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
356 if (yyssp >= yyss + yystacksize - 1)
362 fprintf(stderr, "Entering state %d\n", yystate);
368 /* Do appropriate processing given the current state. */
369 /* Read a lookahead token if we need one and don't already have one. */
372 /* First try to decide what to do without reference to lookahead token. */
374 yyn = yypact[yystate];
378 /* Not known => get a lookahead token if don't already have one. */
380 /* yychar is either YYEMPTY or YYEOF
381 or a valid token in external form. */
383 if (yychar == YYEMPTY)
387 fprintf(stderr, "Reading a token: ");
392 /* Convert token to internal form (in yychar1) for indexing tables with */
394 if (yychar <= 0) /* This means end of input. */
397 yychar = YYEOF; /* Don't call YYLEX any more */
401 fprintf(stderr, "Now at end of input.\n");
406 yychar1 = YYTRANSLATE(yychar);
411 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
412 /* Give the individual parser a way to print the precise meaning
413 of a token, for further debugging info. */
415 YYPRINT (stderr, yychar, yylval);
417 fprintf (stderr, ")\n");
423 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
428 /* yyn is what to do for this token type in this state.
429 Negative => reduce, -yyn is rule number.
430 Positive => shift, yyn is new state.
431 New state is final state => don't bother to shift,
433 0, or most negative number => error. */
448 /* Shift the lookahead token. */
452 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
455 /* Discard the token being shifted unless it is eof. */
464 /* count tokens shifted since error; after three, turn off error status. */
465 if (yyerrstatus) yyerrstatus--;
470 /* Do the default action for the current state. */
473 yyn = yydefact[yystate];
477 /* Do a reduction. yyn is the number of a rule to reduce with. */
481 yyval = yyvsp[1-yylen]; /* implement default value of the action */
488 fprintf (stderr, "Reducing via rule %d (line %d), ",
491 /* Print the symbols being reduced, and their result. */
492 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
493 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
494 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
498 $ /* the action file gets copied in in place of this dollarsign */
499 #line 498 "bison.simple"
510 short *ssp1 = yyss - 1;
511 fprintf (stderr, "state stack now");
512 while (ssp1 != yyssp)
513 fprintf (stderr, " %d", *++ssp1);
514 fprintf (stderr, "\n");
524 yylsp->first_line = yylloc.first_line;
525 yylsp->first_column = yylloc.first_column;
526 yylsp->last_line = (yylsp-1)->last_line;
527 yylsp->last_column = (yylsp-1)->last_column;
532 yylsp->last_line = (yylsp+yylen-1)->last_line;
533 yylsp->last_column = (yylsp+yylen-1)->last_column;
537 /* Now "shift" the result of the reduction.
538 Determine what state that goes to,
539 based on the state we popped back to
540 and the rule number reduced by. */
544 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
545 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
546 yystate = yytable[yystate];
548 yystate = yydefgoto[yyn - YYNTBASE];
552 yyerrlab: /* here on detecting error */
555 /* If not already recovering from an error, report this error. */
559 #ifdef YYERROR_VERBOSE
560 yyn = yypact[yystate];
562 if (yyn > YYFLAG && yyn < YYLAST)
569 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
570 for (x = (yyn < 0 ? -yyn : 0);
571 x < (sizeof(yytname) / sizeof(char *)); x++)
572 if (yycheck[x + yyn] == x)
573 size += strlen(yytname[x]) + 15, count++;
574 msg = (char *) malloc(size + 15);
577 strcpy(msg, "parse error");
582 for (x = (yyn < 0 ? -yyn : 0);
583 x < (sizeof(yytname) / sizeof(char *)); x++)
584 if (yycheck[x + yyn] == x)
586 strcat(msg, count == 0 ? ", expecting `" : " or `");
587 strcat(msg, yytname[x]);
596 yyerror ("parse error; also virtual memory exceeded");
599 #endif /* YYERROR_VERBOSE */
600 yyerror("parse error");
604 yyerrlab1: /* here on error raised explicitly by an action */
606 if (yyerrstatus == 3)
608 /* if just tried and failed to reuse lookahead token after an error, discard it. */
610 /* return failure if at end of input */
616 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
622 /* Else will try to reuse lookahead token
623 after shifting the error token. */
625 yyerrstatus = 3; /* Each real token shifted decrements this */
629 yyerrdefault: /* current state does not do anything special for the error token. */
632 /* This is wrong; only states that explicitly want error tokens
633 should shift them. */
634 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
635 if (yyn) goto yydefault;
638 yyerrpop: /* pop the current state because it cannot handle the error token */
640 if (yyssp == yyss) YYABORT;
650 short *ssp1 = yyss - 1;
651 fprintf (stderr, "Error: state stack now");
652 while (ssp1 != yyssp)
653 fprintf (stderr, " %d", *++ssp1);
654 fprintf (stderr, "\n");
660 yyn = yypact[yystate];
665 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
684 fprintf(stderr, "Shifting error token, ");