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
44 # else /* not sparc */
45 /* We think this test detects Watcom and Microsoft C. */
46 /* This used to test MSDOS, but that is a bad idea since that
47 symbol is in the user namespace. */
48 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
50 /* No need for malloc.h, which pollutes the namespace; instead,
51 just don't use alloca. */
54 # else /* not MSDOS, or __TURBOC__ */
56 /* I don't know what this was needed for, but it pollutes the
57 namespace. So I turned it off. rms, 2 May 1997. */
58 /* #include <malloc.h> */
60 # define YYSTACK_USE_ALLOCA
61 # else /* not MSDOS, or __TURBOC__, or _AIX */
63 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
64 HPUX 10. Eventually we can turn this on. */
66 # define YYSTACK_USE_ALLOCA
67 # define alloca __builtin_alloca
70 # endif /* not _AIX */
71 # endif /* not MSDOS, or __TURBOC__ */
72 # endif /* not sparc */
73 # endif /* not GNU C */
74 # endif /* alloca not defined */
75 #endif /* YYSTACK_USE_ALLOCA not defined */
77 #ifdef YYSTACK_USE_ALLOCA
78 # define YYSTACK_ALLOC alloca
80 # define YYSTACK_ALLOC malloc
83 /* Note: there must be only one dollar sign in this file.
84 It is replaced by the list of actions, each action
85 as one case of the switch. */
87 #define yyerrok (yyerrstatus = 0)
88 #define yyclearin (yychar = YYEMPTY)
91 #define YYACCEPT goto yyacceptlab
92 #define YYABORT goto yyabortlab
93 #define YYERROR goto yyerrlab1
94 /* Like YYERROR except do call yyerror.
95 This remains here temporarily to ease the
96 transition to the new meaning of YYERROR, for GCC.
97 Once GCC version 2 has supplanted version 1, this can go. */
98 #define YYFAIL goto yyerrlab
99 #define YYRECOVERING() (!!yyerrstatus)
100 #define YYBACKUP(token, value) \
102 if (yychar == YYEMPTY && yylen == 1) \
103 { yychar = (token), yylval = (value); \
104 yychar1 = YYTRANSLATE (yychar); \
109 { yyerror ("syntax error: cannot back up"); YYERROR; } \
113 #define YYERRCODE 256
116 # define YYLEX yylex()
122 # define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
124 # define YYLEX yylex(&yylval, &yylloc)
126 # else /* not YYLSP_NEEDED */
128 # define YYLEX yylex(&yylval, YYLEX_PARAM)
130 # define YYLEX yylex(&yylval)
132 # endif /* not YYLSP_NEEDED */
135 /* If nonreentrant, generate the variables here */
139 int yychar; /* the lookahead symbol */
140 YYSTYPE yylval; /* the semantic value of the */
141 /* lookahead symbol */
144 YYLTYPE yylloc; /* location data for the lookahead */
148 int yynerrs; /* number of parse errors so far */
149 #endif /* not YYPURE */
153 int yydebug; /* nonzero means print parse trace */
155 /* [The following comment makes no sense to me. Could someone
156 clarify it? --akim] Since this is uninitialized, it does not
157 stop multiple parsers from coexisting. */
159 /* To avoid crippling this file with `#if YYDEBUG', define `yydebug'
160 as `0', so that the `if (yydebug)' be removed as dead code. */
164 /* YYINITDEPTH indicates the initial size of the parser's stacks */
167 # define YYINITDEPTH 200
170 /* YYMAXDEPTH is the maximum size the stacks can grow to
171 (effective only if the built-in stack extension method is used). */
178 # define YYMAXDEPTH 10000
181 /* Define __yy_memcpy. Note that the size argument
182 should be passed with type unsigned int, because that is what the non-GCC
183 definitions require. With GCC, __builtin_memcpy takes an arg
184 of type size_t, but it can handle unsigned int. */
186 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
187 # define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
188 #else /* not GNU C or C++ */
191 /* This is the most reliable way to avoid incompatibilities
192 in available built-in functions on various systems. */
194 __yy_memcpy (to, from, count)
199 register char *f = from;
200 register char *t = to;
201 register int i = count;
207 # else /* __cplusplus */
209 /* This is the most reliable way to avoid incompatibilities
210 in available built-in functions on various systems. */
212 __yy_memcpy (char *to, char *from, unsigned int count)
214 register char *t = to;
215 register char *f = from;
216 register int i = count;
225 #line 217 "bison.simple"
227 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
228 into yyparse. The argument should have type void *.
229 It should actually point to an object.
230 Grammar actions can access the variable by casting it
231 to the proper pointer type. */
235 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
236 # define YYPARSE_PARAM_DECL
237 # else /* not __cplusplus */
238 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
239 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
240 # endif /* not __cplusplus */
241 #else /* not YYPARSE_PARAM */
242 # define YYPARSE_PARAM_ARG
243 # define YYPARSE_PARAM_DECL
244 #endif /* not YYPARSE_PARAM */
246 /* Prevent warning if -Wstrict-prototypes. */
248 # ifdef YYPARSE_PARAM
249 int yyparse (void *);
256 yyparse(YYPARSE_PARAM_ARG)
259 register int yystate;
261 /* Number of tokens to shift before error messages enabled. */
263 /* Lookahead token as an internal (translated) token number. */
266 /* Three stacks and their tools:
267 `yyss': related to states,
268 `yysv': related to semantic values,
269 `yyls': related to locations.
271 Refer to the stacks thru separate pointers, to allow yyoverflow
272 to reallocate them elsewhere. */
274 /* The state stack. */
275 short yyssa[YYINITDEPTH];
277 register short *yyssp;
279 /* The semantic value stack. */
280 YYSTYPE yyvsa[YYINITDEPTH];
281 YYSTYPE *yyvs = yyvsa;
282 register YYSTYPE *yyvsp;
285 /* The location stack. */
286 YYLTYPE yylsa[YYINITDEPTH];
287 YYLTYPE *yyls = yylsa;
292 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
294 # define YYPOPSTACK (yyvsp--, yyssp--)
297 int yystacksize = YYINITDEPTH;
298 int yyfree_stacks = 0;
310 /* The variable used to return semantic values from the action
317 fprintf (stderr, "Starting parse\n");
322 yychar = YYEMPTY; /* Cause a token to be read. */
324 /* Initialize stack pointers.
325 Waste one element of value and location stack
326 so that they stay on the same level as the state stack.
327 The wasted elements are never initialized. */
335 /* Push a new state, which is found in yystate . */
336 /* In all cases, when you get here, the value and location stacks
337 have just been pushed. so pushing a state here evens the stacks. */
342 if (yyssp >= yyss + yystacksize - 1)
344 /* Give user a chance to reallocate the stack */
345 /* Use copies of these so that the &'s don't force the real ones into memory. */
346 YYSTYPE *yyvs1 = yyvs;
349 YYLTYPE *yyls1 = yyls;
352 /* Get the current used size of the three stacks, in elements. */
353 int size = yyssp - yyss + 1;
356 /* Each stack pointer address is followed by the size of
357 the data in use in that stack, in bytes. */
359 /* This used to be a conditional around just the two extra args,
360 but that might be undefined if yyoverflow is a macro. */
361 yyoverflow ("parser stack overflow",
362 &yyss1, size * sizeof (*yyssp),
363 &yyvs1, size * sizeof (*yyvsp),
364 &yyls1, size * sizeof (*yylsp),
367 yyoverflow ("parser stack overflow",
368 &yyss1, size * sizeof (*yyssp),
369 &yyvs1, size * sizeof (*yyvsp),
373 yyss = yyss1; yyvs = yyvs1;
377 #else /* no yyoverflow */
378 /* Extend the stack our own way. */
379 if (yystacksize >= YYMAXDEPTH)
381 yyerror("parser stack overflow");
393 if (yystacksize > YYMAXDEPTH)
394 yystacksize = YYMAXDEPTH;
395 # ifndef YYSTACK_USE_ALLOCA
398 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
399 __yy_memcpy ((char *)yyss, (char *)yyss1,
400 size * (unsigned int) sizeof (*yyssp));
401 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
402 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
403 size * (unsigned int) sizeof (*yyvsp));
405 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
406 __yy_memcpy ((char *)yyls, (char *)yyls1,
407 size * (unsigned int) sizeof (*yylsp));
409 #endif /* no yyoverflow */
411 yyssp = yyss + size - 1;
412 yyvsp = yyvs + size - 1;
414 yylsp = yyls + size - 1;
418 fprintf (stderr, "Stack size increased to %d\n", yystacksize);
420 if (yyssp >= yyss + yystacksize - 1)
425 fprintf (stderr, "Entering state %d\n", yystate);
430 /* Do appropriate processing given the current state. */
431 /* Read a lookahead token if we need one and don't already have one. */
434 /* First try to decide what to do without reference to lookahead token. */
436 yyn = yypact[yystate];
440 /* Not known => get a lookahead token if don't already have one. */
442 /* yychar is either YYEMPTY or YYEOF
443 or a valid token in external form. */
445 if (yychar == YYEMPTY)
448 fprintf (stderr, "Reading a token: ");
452 /* Convert token to internal form (in yychar1) for indexing tables with */
454 if (yychar <= 0) /* This means end of input. */
457 yychar = YYEOF; /* Don't call YYLEX any more */
460 fprintf (stderr, "Now at end of input.\n");
464 yychar1 = YYTRANSLATE(yychar);
468 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
469 /* Give the individual parser a way to print the precise meaning
470 of a token, for further debugging info. */
472 YYPRINT (stderr, yychar, yylval);
474 fprintf (stderr, ")\n");
479 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
484 /* yyn is what to do for this token type in this state.
485 Negative => reduce, -yyn is rule number.
486 Positive => shift, yyn is new state.
487 New state is final state => don't bother to shift,
489 0, or most negative number => error. */
504 /* Shift the lookahead token. */
507 fprintf (stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
509 /* Discard the token being shifted unless it is eof. */
518 /* count tokens shifted since error; after three, turn off error status. */
519 if (yyerrstatus) yyerrstatus--;
524 /* Do the default action for the current state. */
527 yyn = yydefact[yystate];
531 /* Do a reduction. yyn is the number of a rule to reduce with. */
535 yyval = yyvsp[1-yylen]; /* implement default value of the action */
538 /* We have to keep this `#if YYDEBUG', since we use variables which
539 are defined only if `YYDEBUG' is set. */
544 fprintf (stderr, "Reducing via rule %d (line %d), ",
547 /* Print the symbols being reduced, and their result. */
548 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
549 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
550 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
553 $ /* the action file gets copied in in place of this dollarsign */
554 #line 543 "bison.simple"
564 short *ssp1 = yyss - 1;
565 fprintf (stderr, "state stack now");
566 while (ssp1 != yyssp)
567 fprintf (stderr, " %d", *++ssp1);
568 fprintf (stderr, "\n");
577 yylsp->first_line = yylloc.first_line;
578 yylsp->first_column = yylloc.first_column;
579 yylsp->last_line = (yylsp-1)->last_line;
580 yylsp->last_column = (yylsp-1)->last_column;
585 yylsp->last_line = (yylsp+yylen-1)->last_line;
586 yylsp->last_column = (yylsp+yylen-1)->last_column;
590 /* Now "shift" the result of the reduction.
591 Determine what state that goes to,
592 based on the state we popped back to
593 and the rule number reduced by. */
597 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
598 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
599 yystate = yytable[yystate];
601 yystate = yydefgoto[yyn - YYNTBASE];
605 yyerrlab: /* here on detecting error */
608 /* If not already recovering from an error, report this error. */
612 #ifdef YYERROR_VERBOSE
613 yyn = yypact[yystate];
615 if (yyn > YYFLAG && yyn < YYLAST)
622 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
623 for (x = (yyn < 0 ? -yyn : 0);
624 x < (sizeof(yytname) / sizeof(char *)); x++)
625 if (yycheck[x + yyn] == x)
626 size += strlen(yytname[x]) + 15, count++;
627 msg = (char *) malloc(size + 15);
630 strcpy(msg, "parse error");
635 for (x = (yyn < 0 ? -yyn : 0);
636 x < (sizeof(yytname) / sizeof(char *)); x++)
637 if (yycheck[x + yyn] == x)
639 strcat(msg, count == 0 ? ", expecting `" : " or `");
640 strcat(msg, yytname[x]);
649 yyerror ("parse error; also virtual memory exceeded");
652 #endif /* YYERROR_VERBOSE */
653 yyerror("parse error");
657 yyerrlab1: /* here on error raised explicitly by an action */
659 if (yyerrstatus == 3)
661 /* if just tried and failed to reuse lookahead token after an error, discard it. */
663 /* return failure if at end of input */
668 fprintf (stderr, "Discarding token %d (%s).\n",
669 yychar, yytname[yychar1]);
674 /* Else will try to reuse lookahead token
675 after shifting the error token. */
677 yyerrstatus = 3; /* Each real token shifted decrements this */
681 yyerrdefault: /* current state does not do anything special for the error token. */
684 /* This is wrong; only states that explicitly want error tokens
685 should shift them. */
686 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
687 if (yyn) goto yydefault;
690 yyerrpop: /* pop the current state because it cannot handle the error token */
692 if (yyssp == yyss) YYABORT;
701 short *ssp1 = yyss - 1;
702 fprintf (stderr, "Error: state stack now");
703 while (ssp1 != yyssp)
704 fprintf (stderr, " %d", *++ssp1);
705 fprintf (stderr, "\n");
710 yyn = yypact[yystate];
715 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
733 fprintf (stderr, "Shifting error token, ");
744 /* YYACCEPT comes here. */
756 /* YYABORT comes here. */