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) || (defined (__sun) && defined (__i386))
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 (_MSDOS_)) && !defined (__TURBOC__)
42 #else /* not MSDOS, or __TURBOC__ */
46 #else /* not MSDOS, or __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 /* Define __yy_memcpy. Note that the size argument
154 should be passed with type unsigned int, because that is what the non-GCC
155 definitions require. With GCC, __builtin_memcpy takes an arg
156 of type size_t, but it can handle unsigned int. */
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, unsigned 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 */
218 /* Prevent warning if -Wstrict-prototypes. */
221 int yyparse (void *);
228 yyparse(YYPARSE_PARAM_ARG)
231 register int yystate;
233 register short *yyssp;
234 register YYSTYPE *yyvsp;
235 int yyerrstatus; /* number of tokens to shift before error messages enabled */
236 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
238 short yyssa[YYINITDEPTH]; /* the state stack */
239 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
241 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
242 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
245 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
246 YYLTYPE *yyls = yylsa;
249 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
251 #define YYPOPSTACK (yyvsp--, yyssp--)
254 int yystacksize = YYINITDEPTH;
265 YYSTYPE yyval; /* the variable used to return */
266 /* semantic values from the action */
273 fprintf(stderr, "Starting parse\n");
279 yychar = YYEMPTY; /* Cause a token to be read. */
281 /* Initialize stack pointers.
282 Waste one element of value and location stack
283 so that they stay on the same level as the state stack.
284 The wasted elements are never initialized. */
292 /* Push a new state, which is found in yystate . */
293 /* In all cases, when you get here, the value and location stacks
294 have just been pushed. so pushing a state here evens the stacks. */
299 if (yyssp >= yyss + yystacksize - 1)
301 /* Give user a chance to reallocate the stack */
302 /* Use copies of these so that the &'s don't force the real ones into memory. */
303 YYSTYPE *yyvs1 = yyvs;
306 YYLTYPE *yyls1 = yyls;
309 /* Get the current used size of the three stacks, in elements. */
310 int size = yyssp - yyss + 1;
313 /* Each stack pointer address is followed by the size of
314 the data in use in that stack, in bytes. */
316 /* This used to be a conditional around just the two extra args,
317 but that might be undefined if yyoverflow is a macro. */
318 yyoverflow("parser stack overflow",
319 &yyss1, size * sizeof (*yyssp),
320 &yyvs1, size * sizeof (*yyvsp),
321 &yyls1, size * sizeof (*yylsp),
324 yyoverflow("parser stack overflow",
325 &yyss1, size * sizeof (*yyssp),
326 &yyvs1, size * sizeof (*yyvsp),
330 yyss = yyss1; yyvs = yyvs1;
334 #else /* no yyoverflow */
335 /* Extend the stack our own way. */
336 if (yystacksize >= YYMAXDEPTH)
338 yyerror("parser stack overflow");
342 if (yystacksize > YYMAXDEPTH)
343 yystacksize = YYMAXDEPTH;
344 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
345 __yy_memcpy ((char *)yyss, (char *)yyss1,
346 size * (unsigned int) sizeof (*yyssp));
347 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
348 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
349 size * (unsigned int) sizeof (*yyvsp));
351 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
352 __yy_memcpy ((char *)yyls, (char *)yyls1,
353 size * (unsigned int) sizeof (*yylsp));
355 #endif /* no yyoverflow */
357 yyssp = yyss + size - 1;
358 yyvsp = yyvs + size - 1;
360 yylsp = yyls + size - 1;
365 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
368 if (yyssp >= yyss + yystacksize - 1)
374 fprintf(stderr, "Entering state %d\n", yystate);
380 /* Do appropriate processing given the current state. */
381 /* Read a lookahead token if we need one and don't already have one. */
384 /* First try to decide what to do without reference to lookahead token. */
386 yyn = yypact[yystate];
390 /* Not known => get a lookahead token if don't already have one. */
392 /* yychar is either YYEMPTY or YYEOF
393 or a valid token in external form. */
395 if (yychar == YYEMPTY)
399 fprintf(stderr, "Reading a token: ");
404 /* Convert token to internal form (in yychar1) for indexing tables with */
406 if (yychar <= 0) /* This means end of input. */
409 yychar = YYEOF; /* Don't call YYLEX any more */
413 fprintf(stderr, "Now at end of input.\n");
418 yychar1 = YYTRANSLATE(yychar);
423 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
424 /* Give the individual parser a way to print the precise meaning
425 of a token, for further debugging info. */
427 YYPRINT (stderr, yychar, yylval);
429 fprintf (stderr, ")\n");
435 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
440 /* yyn is what to do for this token type in this state.
441 Negative => reduce, -yyn is rule number.
442 Positive => shift, yyn is new state.
443 New state is final state => don't bother to shift,
445 0, or most negative number => error. */
460 /* Shift the lookahead token. */
464 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
467 /* Discard the token being shifted unless it is eof. */
476 /* count tokens shifted since error; after three, turn off error status. */
477 if (yyerrstatus) yyerrstatus--;
482 /* Do the default action for the current state. */
485 yyn = yydefact[yystate];
489 /* Do a reduction. yyn is the number of a rule to reduce with. */
493 yyval = yyvsp[1-yylen]; /* implement default value of the action */
500 fprintf (stderr, "Reducing via rule %d (line %d), ",
503 /* Print the symbols being reduced, and their result. */
504 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
505 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
506 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
510 $ /* the action file gets copied in in place of this dollarsign */
511 #line 498 "bison.simple"
522 short *ssp1 = yyss - 1;
523 fprintf (stderr, "state stack now");
524 while (ssp1 != yyssp)
525 fprintf (stderr, " %d", *++ssp1);
526 fprintf (stderr, "\n");
536 yylsp->first_line = yylloc.first_line;
537 yylsp->first_column = yylloc.first_column;
538 yylsp->last_line = (yylsp-1)->last_line;
539 yylsp->last_column = (yylsp-1)->last_column;
544 yylsp->last_line = (yylsp+yylen-1)->last_line;
545 yylsp->last_column = (yylsp+yylen-1)->last_column;
549 /* Now "shift" the result of the reduction.
550 Determine what state that goes to,
551 based on the state we popped back to
552 and the rule number reduced by. */
556 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
557 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
558 yystate = yytable[yystate];
560 yystate = yydefgoto[yyn - YYNTBASE];
564 yyerrlab: /* here on detecting error */
567 /* If not already recovering from an error, report this error. */
571 #ifdef YYERROR_VERBOSE
572 yyn = yypact[yystate];
574 if (yyn > YYFLAG && yyn < YYLAST)
581 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
582 for (x = (yyn < 0 ? -yyn : 0);
583 x < (sizeof(yytname) / sizeof(char *)); x++)
584 if (yycheck[x + yyn] == x)
585 size += strlen(yytname[x]) + 15, count++;
586 msg = (char *) malloc(size + 15);
589 strcpy(msg, "parse error");
594 for (x = (yyn < 0 ? -yyn : 0);
595 x < (sizeof(yytname) / sizeof(char *)); x++)
596 if (yycheck[x + yyn] == x)
598 strcat(msg, count == 0 ? ", expecting `" : " or `");
599 strcat(msg, yytname[x]);
608 yyerror ("parse error; also virtual memory exceeded");
611 #endif /* YYERROR_VERBOSE */
612 yyerror("parse error");
616 yyerrlab1: /* here on error raised explicitly by an action */
618 if (yyerrstatus == 3)
620 /* if just tried and failed to reuse lookahead token after an error, discard it. */
622 /* return failure if at end of input */
628 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
634 /* Else will try to reuse lookahead token
635 after shifting the error token. */
637 yyerrstatus = 3; /* Each real token shifted decrements this */
641 yyerrdefault: /* current state does not do anything special for the error token. */
644 /* This is wrong; only states that explicitly want error tokens
645 should shift them. */
646 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
647 if (yyn) goto yydefault;
650 yyerrpop: /* pop the current state because it cannot handle the error token */
652 if (yyssp == yyss) YYABORT;
662 short *ssp1 = yyss - 1;
663 fprintf (stderr, "Error: state stack now");
664 while (ssp1 != yyssp)
665 fprintf (stderr, " %d", *++ssp1);
666 fprintf (stderr, "\n");
672 yyn = yypact[yystate];
677 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
696 fprintf(stderr, "Shifting error token, ");