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 1984, 1989, 1990, 2000 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 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
123 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
124 first token. By default, to implement support for ranges, extend
125 its range to the last symbol. */
127 #ifndef YYLLOC_DEFAULT
128 # define YYLLOC_DEFAULT(Current, Last) \
129 Current.last_line = Last.last_line; \
130 Current.last_column = Last.last_column;
134 /* YYLEX -- calling `yylex' with the right arguments. */
139 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
141 # define YYLEX yylex (&yylval, &yylloc)
143 # else /* !YYLSP_NEEDED */
145 # define YYLEX yylex (&yylval, YYLEX_PARAM)
147 # define YYLEX yylex (&yylval)
149 # endif /* !YYLSP_NEEDED */
151 # define YYLEX yylex ()
155 /* Enable debugging if requested. */
157 # define YYDPRINTF(Args) \
162 /* Nonzero means print parse trace. [The following comment makes no
163 sense to me. Could someone clarify it? --akim] Since this is
164 uninitialized, it does not stop multiple parsers from coexisting.
168 # define YYDPRINTF(Args)
169 #endif /* !YYDEBUG */
171 /* YYINITDEPTH -- initial size of the parser's stacks. */
173 # define YYINITDEPTH 200
176 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
177 if the built-in stack extension method is used). */
183 # define YYMAXDEPTH 10000
186 /* Define __yy_memcpy. Note that the size argument
187 should be passed with type unsigned int, because that is what the non-GCC
188 definitions require. With GCC, __builtin_memcpy takes an arg
189 of type size_t, but it can handle unsigned int. */
191 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
192 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
193 #else /* not GNU C or C++ */
196 /* This is the most reliable way to avoid incompatibilities
197 in available built-in functions on various systems. */
199 __yy_memcpy (to, from, count)
204 register char *f = from;
205 register char *t = to;
206 register int i = count;
212 # else /* __cplusplus */
214 /* This is the most reliable way to avoid incompatibilities
215 in available built-in functions on various systems. */
217 __yy_memcpy (char *to, char *from, unsigned int count)
219 register char *t = to;
220 register char *f = from;
221 register int i = count;
232 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
233 into yyparse. The argument should have type void *.
234 It should actually point to an object.
235 Grammar actions can access the variable by casting it
236 to the proper pointer type. */
240 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
241 # define YYPARSE_PARAM_DECL
242 # else /* !__cplusplus */
243 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
244 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
245 # endif /* !__cplusplus */
246 #else /* !YYPARSE_PARAM */
247 # define YYPARSE_PARAM_ARG
248 # define YYPARSE_PARAM_DECL
249 #endif /* !YYPARSE_PARAM */
251 /* Prevent warning if -Wstrict-prototypes. */
253 # ifdef YYPARSE_PARAM
254 int yyparse (void *);
260 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
261 variables are global, or local to YYPARSE. */
263 #define _YY_DECL_VARIABLES \
264 /* The lookahead symbol. */ \
267 /* The semantic value of the lookahead symbol. */ \
270 /* Number of parse errors so far. */ \
274 # define YY_DECL_VARIABLES \
277 /* Location data for the lookahead symbol. */ \
280 # define YY_DECL_VARIABLES \
285 /* If nonreentrant, generate the variables here. */
292 yyparse (YYPARSE_PARAM_ARG)
295 /* If reentrant, generate the variables here. */
300 register int yystate;
302 /* Number of tokens to shift before error messages enabled. */
304 /* Lookahead token as an internal (translated) token number. */
307 /* Three stacks and their tools:
308 `yyss': related to states,
309 `yysv': related to semantic values,
310 `yyls': related to locations.
312 Refer to the stacks thru separate pointers, to allow yyoverflow
313 to reallocate them elsewhere. */
315 /* The state stack. */
316 short yyssa[YYINITDEPTH];
318 register short *yyssp;
320 /* The semantic value stack. */
321 YYSTYPE yyvsa[YYINITDEPTH];
322 YYSTYPE *yyvs = yyvsa;
323 register YYSTYPE *yyvsp;
326 /* The location stack. */
327 YYLTYPE yylsa[YYINITDEPTH];
328 YYLTYPE *yyls = yylsa;
333 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
335 # define YYPOPSTACK (yyvsp--, yyssp--)
338 int yystacksize = YYINITDEPTH;
339 int yyfree_stacks = 0;
342 /* The variables used to return semantic value and location from the
349 /* When reducing, the number of symbols on the RHS of the reduced
353 YYDPRINTF ((stderr, "Starting parse\n"));
358 yychar = YYEMPTY; /* Cause a token to be read. */
360 /* Initialize stack pointers.
361 Waste one element of value and location stack
362 so that they stay on the same level as the state stack.
363 The wasted elements are never initialized. */
372 /*------------------------------------------------------------.
373 | yynewstate -- Push a new state, which is found in yystate. |
374 `------------------------------------------------------------*/
376 /* In all cases, when you get here, the value and location stacks
377 have just been pushed. so pushing a state here evens the stacks.
381 if (yyssp >= yyss + yystacksize - 1)
383 /* Give user a chance to reallocate the stack. Use copies of
384 these so that the &'s don't force the real ones into memory.
386 YYSTYPE *yyvs1 = yyvs;
389 YYLTYPE *yyls1 = yyls;
392 /* Get the current used size of the three stacks, in elements. */
393 int size = yyssp - yyss + 1;
396 /* Each stack pointer address is followed by the size of the
397 data in use in that stack, in bytes. */
399 /* This used to be a conditional around just the two extra args,
400 but that might be undefined if yyoverflow is a macro. */
401 yyoverflow ("parser stack overflow",
402 &yyss1, size * sizeof (*yyssp),
403 &yyvs1, size * sizeof (*yyvsp),
404 &yyls1, size * sizeof (*yylsp),
407 yyoverflow ("parser stack overflow",
408 &yyss1, size * sizeof (*yyssp),
409 &yyvs1, size * sizeof (*yyvsp),
413 yyss = yyss1; yyvs = yyvs1;
417 #else /* no yyoverflow */
418 /* Extend the stack our own way. */
419 if (yystacksize >= YYMAXDEPTH)
421 yyerror ("parser stack overflow");
433 if (yystacksize > YYMAXDEPTH)
434 yystacksize = YYMAXDEPTH;
435 # ifndef YYSTACK_USE_ALLOCA
438 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
439 __yy_memcpy ((char *)yyss, (char *)yyss1,
440 size * (unsigned int) sizeof (*yyssp));
441 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
442 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
443 size * (unsigned int) sizeof (*yyvsp));
445 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
446 __yy_memcpy ((char *)yyls, (char *)yyls1,
447 size * (unsigned int) sizeof (*yylsp));
449 #endif /* no yyoverflow */
451 yyssp = yyss + size - 1;
452 yyvsp = yyvs + size - 1;
454 yylsp = yyls + size - 1;
457 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
459 if (yyssp >= yyss + yystacksize - 1)
463 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
473 /* Do appropriate processing given the current state. */
474 /* Read a lookahead token if we need one and don't already have one. */
477 /* First try to decide what to do without reference to lookahead token. */
479 yyn = yypact[yystate];
483 /* Not known => get a lookahead token if don't already have one. */
485 /* yychar is either YYEMPTY or YYEOF
486 or a valid token in external form. */
488 if (yychar == YYEMPTY)
490 YYDPRINTF ((stderr, "Reading a token: "));
494 /* Convert token to internal form (in yychar1) for indexing tables with */
496 if (yychar <= 0) /* This means end of input. */
499 yychar = YYEOF; /* Don't call YYLEX any more */
501 YYDPRINTF ((stderr, "Now at end of input.\n"));
505 yychar1 = YYTRANSLATE (yychar);
508 /* We have to keep this `#if YYDEBUG', since we use variables
509 which are defined only if `YYDEBUG' is set. */
512 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
513 /* Give the individual parser a way to print the precise
514 meaning of a token, for further debugging info. */
516 YYPRINT (stderr, yychar, yylval);
518 fprintf (stderr, ")\n");
524 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
529 /* yyn is what to do for this token type in this state.
530 Negative => reduce, -yyn is rule number.
531 Positive => shift, yyn is new state.
532 New state is final state => don't bother to shift,
534 0, or most negative number => error. */
549 /* Shift the lookahead token. */
550 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
552 /* Discard the token being shifted unless it is eof. */
561 /* Count tokens shifted since error; after three, turn off error
570 /*-----------------------------------------------------------.
571 | yydefault -- do the default action for the current state. |
572 `-----------------------------------------------------------*/
574 yyn = yydefact[yystate];
580 /*-----------------------------.
581 | yyreduce -- Do a reduction. |
582 `-----------------------------*/
584 /* yyn is the number of a rule to reduce with. */
587 /* If YYLEN is nonzero, implement the default value of the action:
588 `{dollar}{dollar} = {dollar}1'.
590 Otherwise, the following line sets YYVAL to the semantic value of
591 the lookahead token. This behavior is undocumented and Bison
592 users should not rely upon it. Assigning to YYVAL
593 unconditionally makes the parser a bit smaller, and it avoids a
594 GCC warning that YYVAL may be used uninitialized. */
595 yyval = yyvsp[1-yylen];
598 /* Similarly for the default location. Let the user run additional
599 commands if for instance locations are ranges. */
600 yyloc = yylsp[1-yylen];
601 YYLLOC_DEFAULT (yyloc, yylsp[0]);
605 /* We have to keep this `#if YYDEBUG', since we use variables which
606 are defined only if `YYDEBUG' is set. */
611 fprintf (stderr, "Reducing via rule %d (line %d), ",
614 /* Print the symbols being reduced, and their result. */
615 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
616 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
617 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
620 $ /* The action file replaces this line marked with this dollarsign. */
632 short *ssp1 = yyss - 1;
633 fprintf (stderr, "state stack now");
634 while (ssp1 != yyssp)
635 fprintf (stderr, " %d", *++ssp1);
636 fprintf (stderr, "\n");
645 /* Now `shift' the result of the reduction. Determine what state
646 that goes to, based on the state we popped back to and the rule
647 number reduced by. */
651 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
652 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
653 yystate = yytable[yystate];
655 yystate = yydefgoto[yyn - YYNTBASE];
660 /*------------------------------------.
661 | yyerrlab -- here on detecting error |
662 `------------------------------------*/
664 /* If not already recovering from an error, report this error. */
669 #ifdef YYERROR_VERBOSE
670 yyn = yypact[yystate];
672 if (yyn > YYFLAG && yyn < YYLAST)
679 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
680 for (x = (yyn < 0 ? -yyn : 0);
681 x < (sizeof (yytname) / sizeof (char *)); x++)
682 if (yycheck[x + yyn] == x)
683 size += strlen (yytname[x]) + 15, count++;
684 size += strlen ("parse error, unexpected `") + 1;
685 size += strlen (yytname[YYTRANSLATE (yychar)]);
686 msg = (char *) malloc (size);
689 strcpy (msg, "parse error, unexpected `");
690 strcat (msg, yytname[YYTRANSLATE (yychar)]);
696 for (x = (yyn < 0 ? -yyn : 0);
697 x < (sizeof (yytname) / sizeof (char *)); x++)
698 if (yycheck[x + yyn] == x)
700 strcat (msg, count == 0 ? ", expecting `" : " or `");
701 strcat (msg, yytname[x]);
710 yyerror ("parse error; also virtual memory exceeded");
713 #endif /* YYERROR_VERBOSE */
714 yyerror ("parse error");
719 /*--------------------------------------------------.
720 | yyerrlab1 -- error raised explicitly by an action |
721 `--------------------------------------------------*/
723 if (yyerrstatus == 3)
725 /* If just tried and failed to reuse lookahead token after an
726 error, discard it. */
728 /* return failure if at end of input */
731 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
732 yychar, yytname[yychar1]));
736 /* Else will try to reuse lookahead token after shifting the error
739 yyerrstatus = 3; /* Each real token shifted decrements this */
744 /*-------------------------------------------------------------------.
745 | yyerrdefault -- current state does not do anything special for the |
747 `-------------------------------------------------------------------*/
750 /* This is wrong; only states that explicitly want error tokens
751 should shift them. */
753 /* If its default is to accept any token, ok. Otherwise pop it. */
754 yyn = yydefact[yystate];
760 /*---------------------------------------------------------------.
761 | yyerrpop -- pop the current state because it cannot handle the |
763 `---------------------------------------------------------------*/
776 short *ssp1 = yyss - 1;
777 fprintf (stderr, "Error: state stack now");
778 while (ssp1 != yyssp)
779 fprintf (stderr, " %d", *++ssp1);
780 fprintf (stderr, "\n");
788 yyn = yypact[yystate];
793 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
810 YYDPRINTF ((stderr, "Shifting error token, "));
821 /*-------------------------------------.
822 | yyacceptlab -- YYACCEPT comes here. |
823 `-------------------------------------*/
836 /*-----------------------------------.
837 | yyabortlab -- YYABORT comes here. |
838 `-----------------------------------*/