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 when
29 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. This remains here temporarily
95 to ease the transition to the new meaning of YYERROR, for GCC.
96 Once GCC version 2 has supplanted version 1, this can go. */
97 #define YYFAIL goto yyerrlab
98 #define YYRECOVERING() (!!yyerrstatus)
99 #define YYBACKUP(Token, Value) \
101 if (yychar == YYEMPTY && yylen == 1) \
105 yychar1 = YYTRANSLATE (yychar); \
111 yyerror ("syntax error: cannot back up"); \
117 #define YYERRCODE 256
120 # define YYLEX yylex ()
126 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
128 # define YYLEX yylex (&yylval, &yylloc)
130 # else /* !YYLSP_NEEDED */
132 # define YYLEX yylex (&yylval, YYLEX_PARAM)
134 # define YYLEX yylex (&yylval)
136 # endif /* !YYLSP_NEEDED */
139 /* If nonreentrant, generate the variables here. */
142 /* The lookahead symbol. */
145 /* The semantic value of the lookahead symbol. */
149 /* Location data for the lookahead symbol. */
153 /* Number of parse errors so far. */
157 /* Enable debugging if requested. */
159 # define YYDPRINTF(Args) \
164 /* Nonzero means print parse trace. [The following comment makes no
165 sense to me. Could someone clarify it? --akim] Since this is
166 uninitialized, it does not stop multiple parsers from coexisting.
170 # define YYDPRINTF(Args)
171 #endif /* !YYDEBUG */
173 /* YYINITDEPTH -- initial size of the parser's stacks. */
175 # define YYINITDEPTH 200
178 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
179 if the built-in stack extension method is used). */
185 # define YYMAXDEPTH 10000
188 /* Define __yy_memcpy. Note that the size argument
189 should be passed with type unsigned int, because that is what the non-GCC
190 definitions require. With GCC, __builtin_memcpy takes an arg
191 of type size_t, but it can handle unsigned int. */
193 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
194 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
195 #else /* not GNU C or C++ */
198 /* This is the most reliable way to avoid incompatibilities
199 in available built-in functions on various systems. */
201 __yy_memcpy (to, from, count)
206 register char *f = from;
207 register char *t = to;
208 register int i = count;
214 # else /* __cplusplus */
216 /* This is the most reliable way to avoid incompatibilities
217 in available built-in functions on various systems. */
219 __yy_memcpy (char *to, char *from, unsigned int count)
221 register char *t = to;
222 register char *f = from;
223 register int i = count;
234 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
235 into yyparse. The argument should have type void *.
236 It should actually point to an object.
237 Grammar actions can access the variable by casting it
238 to the proper pointer type. */
242 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
243 # define YYPARSE_PARAM_DECL
244 # else /* !__cplusplus */
245 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
246 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
247 # endif /* !__cplusplus */
248 #else /* !YYPARSE_PARAM */
249 # define YYPARSE_PARAM_ARG
250 # define YYPARSE_PARAM_DECL
251 #endif /* !YYPARSE_PARAM */
253 /* Prevent warning if -Wstrict-prototypes. */
255 # ifdef YYPARSE_PARAM
256 int yyparse (void *);
263 yyparse (YYPARSE_PARAM_ARG)
266 register int yystate;
268 /* Number of tokens to shift before error messages enabled. */
270 /* Lookahead token as an internal (translated) token number. */
273 /* Three stacks and their tools:
274 `yyss': related to states,
275 `yysv': related to semantic values,
276 `yyls': related to locations.
278 Refer to the stacks thru separate pointers, to allow yyoverflow
279 to reallocate them elsewhere. */
281 /* The state stack. */
282 short yyssa[YYINITDEPTH];
284 register short *yyssp;
286 /* The semantic value stack. */
287 YYSTYPE yyvsa[YYINITDEPTH];
288 YYSTYPE *yyvs = yyvsa;
289 register YYSTYPE *yyvsp;
292 /* The location stack. */
293 YYLTYPE yylsa[YYINITDEPTH];
294 YYLTYPE *yyls = yylsa;
299 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
301 # define YYPOPSTACK (yyvsp--, yyssp--)
304 int yystacksize = YYINITDEPTH;
305 int yyfree_stacks = 0;
317 /* The variables used to return semantic value and location from the
324 /* When reducing, the number of symbols on the RHS of the reduced
328 YYDPRINTF ((stderr, "Starting parse\n"));
333 yychar = YYEMPTY; /* Cause a token to be read. */
335 /* Initialize stack pointers.
336 Waste one element of value and location stack
337 so that they stay on the same level as the state stack.
338 The wasted elements are never initialized. */
347 /*------------------------------------------------------------.
348 | yynewstate -- Push a new state, which is found in yystate. |
349 `------------------------------------------------------------*/
351 /* In all cases, when you get here, the value and location stacks
352 have just been pushed. so pushing a state here evens the stacks.
356 if (yyssp >= yyss + yystacksize - 1)
358 /* Give user a chance to reallocate the stack. Use copies of
359 these so that the &'s don't force the real ones into memory.
361 YYSTYPE *yyvs1 = yyvs;
364 YYLTYPE *yyls1 = yyls;
367 /* Get the current used size of the three stacks, in elements. */
368 int size = yyssp - yyss + 1;
371 /* Each stack pointer address is followed by the size of
372 the data in use in that stack, in bytes. */
374 /* This used to be a conditional around just the two extra args,
375 but that might be undefined if yyoverflow is a macro. */
376 yyoverflow ("parser stack overflow",
377 &yyss1, size * sizeof (*yyssp),
378 &yyvs1, size * sizeof (*yyvsp),
379 &yyls1, size * sizeof (*yylsp),
382 yyoverflow ("parser stack overflow",
383 &yyss1, size * sizeof (*yyssp),
384 &yyvs1, size * sizeof (*yyvsp),
388 yyss = yyss1; yyvs = yyvs1;
392 #else /* no yyoverflow */
393 /* Extend the stack our own way. */
394 if (yystacksize >= YYMAXDEPTH)
396 yyerror ("parser stack overflow");
408 if (yystacksize > YYMAXDEPTH)
409 yystacksize = YYMAXDEPTH;
410 # ifndef YYSTACK_USE_ALLOCA
413 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
414 __yy_memcpy ((char *)yyss, (char *)yyss1,
415 size * (unsigned int) sizeof (*yyssp));
416 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
417 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
418 size * (unsigned int) sizeof (*yyvsp));
420 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
421 __yy_memcpy ((char *)yyls, (char *)yyls1,
422 size * (unsigned int) sizeof (*yylsp));
424 #endif /* no yyoverflow */
426 yyssp = yyss + size - 1;
427 yyvsp = yyvs + size - 1;
429 yylsp = yyls + size - 1;
432 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
434 if (yyssp >= yyss + yystacksize - 1)
438 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
448 /* Do appropriate processing given the current state. */
449 /* Read a lookahead token if we need one and don't already have one. */
452 /* First try to decide what to do without reference to lookahead token. */
454 yyn = yypact[yystate];
458 /* Not known => get a lookahead token if don't already have one. */
460 /* yychar is either YYEMPTY or YYEOF
461 or a valid token in external form. */
463 if (yychar == YYEMPTY)
465 YYDPRINTF ((stderr, "Reading a token: "));
469 /* Convert token to internal form (in yychar1) for indexing tables with */
471 if (yychar <= 0) /* This means end of input. */
474 yychar = YYEOF; /* Don't call YYLEX any more */
476 YYDPRINTF ((stderr, "Now at end of input.\n"));
480 yychar1 = YYTRANSLATE (yychar);
483 /* We have to keep this `#if YYDEBUG', since we use variables
484 which are defined only if `YYDEBUG' is set. */
487 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
488 /* Give the individual parser a way to print the precise
489 meaning of a token, for further debugging info. */
491 YYPRINT (stderr, yychar, yylval);
493 fprintf (stderr, ")\n");
499 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
504 /* yyn is what to do for this token type in this state.
505 Negative => reduce, -yyn is rule number.
506 Positive => shift, yyn is new state.
507 New state is final state => don't bother to shift,
509 0, or most negative number => error. */
524 /* Shift the lookahead token. */
525 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
527 /* Discard the token being shifted unless it is eof. */
536 /* Count tokens shifted since error; after three, turn off error
545 /*-----------------------------------------------------------.
546 | yydefault -- do the default action for the current state. |
547 `-----------------------------------------------------------*/
549 yyn = yydefact[yystate];
555 /*-----------------------------.
556 | yyreduce -- Do a reduction. |
557 `-----------------------------*/
559 /* yyn is the number of a rule to reduce with. */
562 /* If YYLEN is nonzero, implement the default value of the action:
563 `{dollar}{dollar} = {dollar}1'.
565 Otherwise, the following line sets YYVAL to the semantic value of
566 the lookahead token. This behavior is undocumented and Bison
567 users should not rely upon it. Assigning to YYVAL
568 unconditionally makes the parser a bit smaller, and it avoids a
569 GCC warning that YYVAL may be used uninitialized. */
570 yyval = yyvsp[1-yylen];
572 /* Implement default location. If the rhs is empty, extend YYLOC to
573 YYLLOC, which corresponds to the current token, otherwise
574 implement `@{dollar} = Starts at @1, ends at @YYLEN'. */
577 yyloc = yylsp[1-yylen];
578 yyloc.last_line = yylsp[0].last_line;
579 yyloc.last_column = yylsp[0].last_column;
583 yyloc.last_line = yylsp[0].last_line;
584 yyloc.last_column = yylsp[0].last_column;
590 /* We have to keep this `#if YYDEBUG', since we use variables which
591 are defined only if `YYDEBUG' is set. */
596 fprintf (stderr, "Reducing via rule %d (line %d), ",
599 /* Print the symbols being reduced, and their result. */
600 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
601 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
602 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
605 $ /* The action file replaces this line marked with this dollarsign. */
617 short *ssp1 = yyss - 1;
618 fprintf (stderr, "state stack now");
619 while (ssp1 != yyssp)
620 fprintf (stderr, " %d", *++ssp1);
621 fprintf (stderr, "\n");
630 /* Now `shift' the result of the reduction. Determine what state
631 that goes to, based on the state we popped back to and the rule
632 number reduced by. */
636 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
637 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
638 yystate = yytable[yystate];
640 yystate = yydefgoto[yyn - YYNTBASE];
645 /*------------------------------------.
646 | yyerrlab -- here on detecting error |
647 `------------------------------------*/
649 /* If not already recovering from an error, report this error. */
654 #ifdef YYERROR_VERBOSE
655 yyn = yypact[yystate];
657 if (yyn > YYFLAG && yyn < YYLAST)
664 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
665 for (x = (yyn < 0 ? -yyn : 0);
666 x < (sizeof (yytname) / sizeof (char *)); x++)
667 if (yycheck[x + yyn] == x)
668 size += strlen (yytname[x]) + 15, count++;
669 size += strlen ("parse error, unexpected `") + 1;
670 size += strlen (yytname[YYTRANSLATE (yychar)]);
671 msg = (char *) malloc (size);
674 strcpy (msg, "parse error, unexpected `");
675 strcat (msg, yytname[YYTRANSLATE (yychar)]);
681 for (x = (yyn < 0 ? -yyn : 0);
682 x < (sizeof (yytname) / sizeof (char *)); x++)
683 if (yycheck[x + yyn] == x)
685 strcat (msg, count == 0 ? ", expecting `" : " or `");
686 strcat (msg, yytname[x]);
695 yyerror ("parse error; also virtual memory exceeded");
698 #endif /* YYERROR_VERBOSE */
699 yyerror ("parse error");
704 /*--------------------------------------------------.
705 | yyerrlab1 -- error raised explicitly by an action |
706 `--------------------------------------------------*/
708 if (yyerrstatus == 3)
710 /* If just tried and failed to reuse lookahead token after an
711 error, discard it. */
713 /* return failure if at end of input */
716 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
717 yychar, yytname[yychar1]));
721 /* Else will try to reuse lookahead token after shifting the error
724 yyerrstatus = 3; /* Each real token shifted decrements this */
729 /*-------------------------------------------------------------------.
730 | yyerrdefault -- current state does not do anything special for the |
732 `-------------------------------------------------------------------*/
735 /* This is wrong; only states that explicitly want error tokens
736 should shift them. */
738 /* If its default is to accept any token, ok. Otherwise pop it. */
739 yyn = yydefact[yystate];
745 /*---------------------------------------------------------------.
746 | yyerrpop -- pop the current state because it cannot handle the |
748 `---------------------------------------------------------------*/
761 short *ssp1 = yyss - 1;
762 fprintf (stderr, "Error: state stack now");
763 while (ssp1 != yyssp)
764 fprintf (stderr, " %d", *++ssp1);
765 fprintf (stderr, "\n");
773 yyn = yypact[yystate];
778 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
795 YYDPRINTF ((stderr, "Shifting error token, "));
806 /*-------------------------------------.
807 | yyacceptlab -- YYACCEPT comes here. |
808 `-------------------------------------*/
821 /*-----------------------------------.
822 | yyabortlab -- YYABORT comes here. |
823 `-----------------------------------*/