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. */
28 #define alloca __builtin_alloca
29 #else /* not GNU C. */
30 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
33 #if defined (MSDOS) && !defined (__TURBOC__)
35 #else /* not MSDOS, or __TURBOC__ */
39 #else /* not MSDOS, __TURBOC__, or _AIX */
43 void *alloca (unsigned int);
45 #else /* not __cplusplus */
47 #endif /* not __cplusplus */
50 #endif /* not MSDOS, or __TURBOC__ */
51 #endif /* not sparc. */
52 #endif /* not GNU C. */
53 #endif /* alloca not defined. */
55 /* This is the parser code that is written into each bison parser
56 when the %semantic_parser declaration is not specified in the grammar.
57 It was written by Richard Stallman by simplifying the hairy parser
58 used when %semantic_parser is specified. */
60 /* Note: there must be only one dollar sign in this file.
61 It is replaced by the list of actions, each action
62 as one case of the switch. */
64 #define yyerrok (yyerrstatus = 0)
65 #define yyclearin (yychar = YYEMPTY)
68 #define YYACCEPT return(0)
69 #define YYABORT return(1)
70 #define YYERROR goto yyerrlab1
71 /* Like YYERROR except do call yyerror.
72 This remains here temporarily to ease the
73 transition to the new meaning of YYERROR, for GCC.
74 Once GCC version 2 has supplanted version 1, this can go. */
75 #define YYFAIL goto yyerrlab
76 #define YYRECOVERING() (!!yyerrstatus)
77 #define YYBACKUP(token, value) \
79 if (yychar == YYEMPTY && yylen == 1) \
80 { yychar = (token), yylval = (value); \
81 yychar1 = YYTRANSLATE (yychar); \
86 { yyerror ("syntax error: cannot back up"); YYERROR; } \
99 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
101 #define YYLEX yylex(&yylval, &yylloc)
103 #else /* not YYLSP_NEEDED */
105 #define YYLEX yylex(&yylval, YYLEX_PARAM)
107 #define YYLEX yylex(&yylval)
109 #endif /* not YYLSP_NEEDED */
112 /* If nonreentrant, generate the variables here */
116 int yychar; /* the lookahead symbol */
117 YYSTYPE yylval; /* the semantic value of the */
118 /* lookahead symbol */
121 YYLTYPE yylloc; /* location data for the lookahead */
125 int yynerrs; /* number of parse errors so far */
126 #endif /* not YYPURE */
129 int yydebug; /* nonzero means print parse trace */
130 /* Since this is uninitialized, it does not stop multiple parsers
134 /* YYINITDEPTH indicates the initial size of the parser's stacks */
137 #define YYINITDEPTH 200
140 /* YYMAXDEPTH is the maximum size the stacks can grow to
141 (effective only if the built-in stack extension method is used). */
148 #define YYMAXDEPTH 10000
151 /* Prevent warning if -Wstrict-prototypes. */
156 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
157 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
158 #else /* not GNU C or C++ */
161 /* This is the most reliable way to avoid incompatibilities
162 in available built-in functions on various systems. */
164 __yy_memcpy (to, from, count)
169 register char *f = from;
170 register char *t = to;
171 register int i = count;
177 #else /* __cplusplus */
179 /* This is the most reliable way to avoid incompatibilities
180 in available built-in functions on various systems. */
182 __yy_memcpy (char *to, char *from, int count)
184 register char *t = to;
185 register char *f = from;
186 register int i = count;
195 #line 196 "bison.simple"
197 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
198 into yyparse. The argument should have type void *.
199 It should actually point to an object.
200 Grammar actions can access the variable by casting it
201 to the proper pointer type. */
205 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
206 #define YYPARSE_PARAM_DECL
207 #else /* not __cplusplus */
208 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
209 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
210 #endif /* not __cplusplus */
211 #else /* not YYPARSE_PARAM */
212 #define YYPARSE_PARAM_ARG
213 #define YYPARSE_PARAM_DECL
214 #endif /* not YYPARSE_PARAM */
217 yyparse(YYPARSE_PARAM_ARG)
220 register int yystate;
222 register short *yyssp;
223 register YYSTYPE *yyvsp;
224 int yyerrstatus; /* number of tokens to shift before error messages enabled */
225 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
227 short yyssa[YYINITDEPTH]; /* the state stack */
228 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
230 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
231 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
234 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
235 YYLTYPE *yyls = yylsa;
238 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
240 #define YYPOPSTACK (yyvsp--, yyssp--)
243 int yystacksize = YYINITDEPTH;
254 YYSTYPE yyval; /* the variable used to return */
255 /* semantic values from the action */
262 fprintf(stderr, "Starting parse\n");
268 yychar = YYEMPTY; /* Cause a token to be read. */
270 /* Initialize stack pointers.
271 Waste one element of value and location stack
272 so that they stay on the same level as the state stack.
273 The wasted elements are never initialized. */
281 /* Push a new state, which is found in yystate . */
282 /* In all cases, when you get here, the value and location stacks
283 have just been pushed. so pushing a state here evens the stacks. */
288 if (yyssp >= yyss + yystacksize - 1)
290 /* Give user a chance to reallocate the stack */
291 /* Use copies of these so that the &'s don't force the real ones into memory. */
292 YYSTYPE *yyvs1 = yyvs;
295 YYLTYPE *yyls1 = yyls;
298 /* Get the current used size of the three stacks, in elements. */
299 int size = yyssp - yyss + 1;
302 /* Each stack pointer address is followed by the size of
303 the data in use in that stack, in bytes. */
305 /* This used to be a conditional around just the two extra args,
306 but that might be undefined if yyoverflow is a macro. */
307 yyoverflow("parser stack overflow",
308 &yyss1, size * sizeof (*yyssp),
309 &yyvs1, size * sizeof (*yyvsp),
310 &yyls1, size * sizeof (*yylsp),
313 yyoverflow("parser stack overflow",
314 &yyss1, size * sizeof (*yyssp),
315 &yyvs1, size * sizeof (*yyvsp),
319 yyss = yyss1; yyvs = yyvs1;
323 #else /* no yyoverflow */
324 /* Extend the stack our own way. */
325 if (yystacksize >= YYMAXDEPTH)
327 yyerror("parser stack overflow");
331 if (yystacksize > YYMAXDEPTH)
332 yystacksize = YYMAXDEPTH;
333 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
334 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
335 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
336 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
338 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
339 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
341 #endif /* no yyoverflow */
343 yyssp = yyss + size - 1;
344 yyvsp = yyvs + size - 1;
346 yylsp = yyls + size - 1;
351 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
354 if (yyssp >= yyss + yystacksize - 1)
360 fprintf(stderr, "Entering state %d\n", yystate);
366 /* Do appropriate processing given the current state. */
367 /* Read a lookahead token if we need one and don't already have one. */
370 /* First try to decide what to do without reference to lookahead token. */
372 yyn = yypact[yystate];
376 /* Not known => get a lookahead token if don't already have one. */
378 /* yychar is either YYEMPTY or YYEOF
379 or a valid token in external form. */
381 if (yychar == YYEMPTY)
385 fprintf(stderr, "Reading a token: ");
390 /* Convert token to internal form (in yychar1) for indexing tables with */
392 if (yychar <= 0) /* This means end of input. */
395 yychar = YYEOF; /* Don't call YYLEX any more */
399 fprintf(stderr, "Now at end of input.\n");
404 yychar1 = YYTRANSLATE(yychar);
409 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
410 /* Give the individual parser a way to print the precise meaning
411 of a token, for further debugging info. */
413 YYPRINT (stderr, yychar, yylval);
415 fprintf (stderr, ")\n");
421 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
426 /* yyn is what to do for this token type in this state.
427 Negative => reduce, -yyn is rule number.
428 Positive => shift, yyn is new state.
429 New state is final state => don't bother to shift,
431 0, or most negative number => error. */
446 /* Shift the lookahead token. */
450 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
453 /* Discard the token being shifted unless it is eof. */
462 /* count tokens shifted since error; after three, turn off error status. */
463 if (yyerrstatus) yyerrstatus--;
468 /* Do the default action for the current state. */
471 yyn = yydefact[yystate];
475 /* Do a reduction. yyn is the number of a rule to reduce with. */
479 yyval = yyvsp[1-yylen]; /* implement default value of the action */
486 fprintf (stderr, "Reducing via rule %d (line %d), ",
489 /* Print the symbols being reduced, and their result. */
490 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
491 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
492 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
496 $ /* the action file gets copied in in place of this dollarsign */
497 #line 498 "bison.simple"
508 short *ssp1 = yyss - 1;
509 fprintf (stderr, "state stack now");
510 while (ssp1 != yyssp)
511 fprintf (stderr, " %d", *++ssp1);
512 fprintf (stderr, "\n");
522 yylsp->first_line = yylloc.first_line;
523 yylsp->first_column = yylloc.first_column;
524 yylsp->last_line = (yylsp-1)->last_line;
525 yylsp->last_column = (yylsp-1)->last_column;
530 yylsp->last_line = (yylsp+yylen-1)->last_line;
531 yylsp->last_column = (yylsp+yylen-1)->last_column;
535 /* Now "shift" the result of the reduction.
536 Determine what state that goes to,
537 based on the state we popped back to
538 and the rule number reduced by. */
542 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
543 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
544 yystate = yytable[yystate];
546 yystate = yydefgoto[yyn - YYNTBASE];
550 yyerrlab: /* here on detecting error */
553 /* If not already recovering from an error, report this error. */
557 #ifdef YYERROR_VERBOSE
558 yyn = yypact[yystate];
560 if (yyn > YYFLAG && yyn < YYLAST)
567 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
568 for (x = (yyn < 0 ? -yyn : 0);
569 x < (sizeof(yytname) / sizeof(char *)); x++)
570 if (yycheck[x + yyn] == x)
571 size += strlen(yytname[x]) + 15, count++;
572 msg = (char *) malloc(size + 15);
575 strcpy(msg, "parse error");
580 for (x = (yyn < 0 ? -yyn : 0);
581 x < (sizeof(yytname) / sizeof(char *)); x++)
582 if (yycheck[x + yyn] == x)
584 strcat(msg, count == 0 ? ", expecting `" : " or `");
585 strcat(msg, yytname[x]);
594 yyerror ("parse error; also virtual memory exceeded");
597 #endif /* YYERROR_VERBOSE */
598 yyerror("parse error");
602 yyerrlab1: /* here on error raised explicitly by an action */
604 if (yyerrstatus == 3)
606 /* if just tried and failed to reuse lookahead token after an error, discard it. */
608 /* return failure if at end of input */
614 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
620 /* Else will try to reuse lookahead token
621 after shifting the error token. */
623 yyerrstatus = 3; /* Each real token shifted decrements this */
627 yyerrdefault: /* current state does not do anything special for the error token. */
630 /* This is wrong; only states that explicitly want error tokens
631 should shift them. */
632 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
633 if (yyn) goto yydefault;
636 yyerrpop: /* pop the current state because it cannot handle the error token */
638 if (yyssp == yyss) YYABORT;
648 short *ssp1 = yyss - 1;
649 fprintf (stderr, "Error: state stack now");
650 while (ssp1 != yyssp)
651 fprintf (stderr, " %d", *++ssp1);
652 fprintf (stderr, "\n");
658 yyn = yypact[yystate];
663 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
682 fprintf(stderr, "Shifting error token, ");