1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
3 /* Skeleton output parser for bison,
4 Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, 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 when
27 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. */
31 /* All symbols defined below should begin with yy or YY, to avoid
32 infringing on user name space. This should be done even for local
33 variables, as they might otherwise be expanded by user macros.
34 There are some unavoidable exceptions within include files to
35 define necessary C library symbols; they are noted "INFRINGES ON
36 USER NAME SPACE" below. */
38 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
40 /* The parser invokes alloca or malloc; define the necessary symbols. */
42 # if YYSTACK_USE_ALLOCA
43 # define YYSTACK_ALLOC alloca
44 # define YYSIZE_T size_t
46 # ifndef YYSTACK_USE_ALLOCA
47 # if defined (alloca) || defined (_ALLOCA_H)
48 # define YYSTACK_ALLOC alloca
49 # define YYSIZE_T size_t
51 # if defined (__GNUC__) || defined (_AIX) || defined (__hpux)
52 # define YYSTACK_ALLOC __builtin_alloca
58 # if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun)
59 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
60 # define YYSTACK_ALLOC alloca
61 # define YYSIZE_T size_t
69 /* Pacify GCC's `empty if-body' warning. */
70 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
72 # define YYSTACK_ALLOC malloc
73 # define YYSTACK_FREE(Ptr) free (Ptr)
74 # if defined (__STDC__) || defined (__cplusplus)
75 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
76 # define YYSIZE_T size_t
80 /* A type that is properly aligned for any stack member. */
90 /* The size of the maximum gap between one aligned stack and the next. */
91 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
93 /* The size of an array large to enough to hold all stacks, each with
96 # define YYSTACK_BYTES(N) \
97 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
98 + 2 * YYSTACK_GAP_MAX)
100 # define YYSTACK_BYTES(N) \
101 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
105 /* Relocate the TYPE STACK from its old location to the new one. The
106 local variables YYSIZE and YYSTACKSIZE give the old and new number of
107 elements in the stack, and YYPTR gives the new location of the
108 stack. Advance YYPTR to a properly aligned location for the next
110 # define YYSTACK_RELOCATE(Type, Stack) \
113 YYSIZE_T yynewbytes; \
114 yymemcpy ((char *) yyptr, (char *) (Stack), \
115 yysize * (YYSIZE_T) sizeof (Type)); \
116 Stack = &yyptr->Stack; \
117 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
118 yyptr += yynewbytes / sizeof (*yyptr); \
122 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
125 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
126 # define YYSIZE_T __SIZE_TYPE__
128 #if ! defined (YYSIZE_T) && defined (size_t)
129 # define YYSIZE_T size_t
131 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
132 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
133 # define YYSIZE_T size_t
135 #if ! defined (YYSIZE_T)
136 # define YYSIZE_T unsigned int
139 #define yyerrok (yyerrstatus = 0)
140 #define yyclearin (yychar = YYEMPTY)
143 #define YYACCEPT goto yyacceptlab
144 #define YYABORT goto yyabortlab
145 #define YYERROR goto yyerrlab1
146 /* Like YYERROR except do call yyerror. This remains here temporarily
147 to ease the transition to the new meaning of YYERROR, for GCC.
148 Once GCC version 2 has supplanted version 1, this can go. */
149 #define YYFAIL goto yyerrlab
150 #define YYRECOVERING() (!!yyerrstatus)
151 #define YYBACKUP(Token, Value) \
153 if (yychar == YYEMPTY && yylen == 1) \
157 yychar1 = YYTRANSLATE (yychar); \
163 yyerror ("syntax error: cannot back up"); \
169 #define YYERRCODE 256
172 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
175 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
176 first token. By default, to implement support for ranges, extend
177 its range to the last symbol. */
179 #ifndef YYLLOC_DEFAULT
180 # define YYLLOC_DEFAULT(Current, Rhs, N) \
181 Current.last_line = Rhs[N].last_line; \
182 Current.last_column = Rhs[N].last_column;
186 /* YYLEX -- calling `yylex' with the right arguments. */
191 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
193 # define YYLEX yylex (&yylval, &yylloc)
195 # else /* !YYLSP_NEEDED */
197 # define YYLEX yylex (&yylval, YYLEX_PARAM)
199 # define YYLEX yylex (&yylval)
201 # endif /* !YYLSP_NEEDED */
203 # define YYLEX yylex ()
207 /* Enable debugging if requested. */
210 # define YYDPRINTF(Args) \
215 /* Nonzero means print parse trace. [The following comment makes no
216 sense to me. Could someone clarify it? --akim] Since this is
217 uninitialized, it does not stop multiple parsers from coexisting.
221 # define YYDPRINTF(Args)
222 #endif /* !YYDEBUG */
224 /* YYINITDEPTH -- initial size of the parser's stacks. */
226 # define YYINITDEPTH 200
229 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
230 if the built-in stack extension method is used).
232 Do not make this value too large; the results are undefined if
233 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
234 evaluated with infinite-precision integer arithmetic. */
241 # define YYMAXDEPTH 10000
244 #if ! defined (yyoverflow) && ! defined (yymemcpy)
245 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
246 # define yymemcpy __builtin_memcpy
247 # else /* not GNU C or C++ */
249 /* This is the most reliable way to avoid incompatibilities
250 in available built-in functions on various systems. */
252 # if defined (__STDC__) || defined (__cplusplus)
253 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
255 yymemcpy (yyto, yyfrom, yycount)
261 register const char *yyf = yyfrom;
262 register char *yyt = yyto;
263 register YYSIZE_T yyi = yycount;
271 #ifdef YYERROR_VERBOSE
274 # if defined (__GLIBC__) && defined (_STRING_H)
275 # define yystrlen strlen
277 /* Return the length of YYSTR. */
279 # if defined (__STDC__) || defined (__cplusplus)
280 yystrlen (const char *yystr)
286 register const char *yys = yystr;
288 while (*yys++ != '\0')
291 return yys - yystr - 1;
297 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
298 # define yystpcpy stpcpy
300 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
303 # if defined (__STDC__) || defined (__cplusplus)
304 yystpcpy (char *yydest, const char *yysrc)
306 yystpcpy (yydest, yysrc)
311 register char *yyd = yydest;
312 register const char *yys = yysrc;
314 while ((*yyd++ = *yys++) != '\0')
325 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
326 into yyparse. The argument should have type void *.
327 It should actually point to an object.
328 Grammar actions can access the variable by casting it
329 to the proper pointer type. */
333 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
334 # define YYPARSE_PARAM_DECL
335 # else /* !__cplusplus */
336 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
337 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
338 # endif /* !__cplusplus */
339 #else /* !YYPARSE_PARAM */
340 # define YYPARSE_PARAM_ARG
341 # define YYPARSE_PARAM_DECL
342 #endif /* !YYPARSE_PARAM */
344 /* Prevent warning if -Wstrict-prototypes. */
346 # ifdef YYPARSE_PARAM
347 int yyparse (void *);
353 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
354 variables are global, or local to YYPARSE. */
356 #define YY_DECL_NON_LSP_VARIABLES \
357 /* The lookahead symbol. */ \
360 /* The semantic value of the lookahead symbol. */ \
363 /* Number of parse errors so far. */ \
367 # define YY_DECL_VARIABLES \
368 YY_DECL_NON_LSP_VARIABLES \
370 /* Location data for the lookahead symbol. */ \
373 # define YY_DECL_VARIABLES \
374 YY_DECL_NON_LSP_VARIABLES
378 /* If nonreentrant, generate the variables here. */
385 yyparse (YYPARSE_PARAM_ARG)
388 /* If reentrant, generate the variables here. */
393 register int yystate;
396 /* Number of tokens to shift before error messages enabled. */
398 /* Lookahead token as an internal (translated) token number. */
401 /* Three stacks and their tools:
402 `yyss': related to states,
403 `yyvs': related to semantic values,
404 `yyls': related to locations.
406 Refer to the stacks thru separate pointers, to allow yyoverflow
407 to reallocate them elsewhere. */
409 /* The state stack. */
410 short yyssa[YYINITDEPTH];
412 register short *yyssp;
414 /* The semantic value stack. */
415 YYSTYPE yyvsa[YYINITDEPTH];
416 YYSTYPE *yyvs = yyvsa;
417 register YYSTYPE *yyvsp;
420 /* The location stack. */
421 YYLTYPE yylsa[YYINITDEPTH];
422 YYLTYPE *yyls = yylsa;
427 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
429 # define YYPOPSTACK (yyvsp--, yyssp--)
432 YYSIZE_T yystacksize = YYINITDEPTH;
435 /* The variables used to return semantic value and location from the
442 /* When reducing, the number of symbols on the RHS of the reduced
446 YYDPRINTF ((stderr, "Starting parse\n"));
451 yychar = YYEMPTY; /* Cause a token to be read. */
453 /* Initialize stack pointers.
454 Waste one element of value and location stack
455 so that they stay on the same level as the state stack.
456 The wasted elements are never initialized. */
465 /*------------------------------------------------------------.
466 | yynewstate -- Push a new state, which is found in yystate. |
467 `------------------------------------------------------------*/
469 /* In all cases, when you get here, the value and location stacks
470 have just been pushed. so pushing a state here evens the stacks.
477 if (yyssp >= yyss + yystacksize - 1)
479 /* Get the current used size of the three stacks, in elements. */
480 YYSIZE_T yysize = yyssp - yyss + 1;
484 /* Give user a chance to reallocate the stack. Use copies of
485 these so that the &'s don't force the real ones into
487 YYSTYPE *yyvs1 = yyvs;
490 /* Each stack pointer address is followed by the size of the
491 data in use in that stack, in bytes. */
493 YYLTYPE *yyls1 = yyls;
494 /* This used to be a conditional around just the two extra args,
495 but that might be undefined if yyoverflow is a macro. */
496 yyoverflow ("parser stack overflow",
497 &yyss1, yysize * sizeof (*yyssp),
498 &yyvs1, yysize * sizeof (*yyvsp),
499 &yyls1, yysize * sizeof (*yylsp),
503 yyoverflow ("parser stack overflow",
504 &yyss1, yysize * sizeof (*yyssp),
505 &yyvs1, yysize * sizeof (*yyvsp),
511 #else /* no yyoverflow */
512 /* Extend the stack our own way. */
513 if (yystacksize >= YYMAXDEPTH)
516 if (yystacksize > YYMAXDEPTH)
517 yystacksize = YYMAXDEPTH;
521 union yyalloc *yyptr =
522 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
525 YYSTACK_RELOCATE (short, yyss);
526 YYSTACK_RELOCATE (YYSTYPE, yyvs);
528 YYSTACK_RELOCATE (YYLTYPE, yyls);
530 # undef YYSTACK_RELOCATE
532 YYSTACK_FREE (yyss1);
534 #endif /* no yyoverflow */
536 yyssp = yyss + yysize - 1;
537 yyvsp = yyvs + yysize - 1;
539 yylsp = yyls + yysize - 1;
542 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
543 (unsigned long int) yystacksize));
545 if (yyssp >= yyss + yystacksize - 1)
549 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
559 /* Do appropriate processing given the current state. */
560 /* Read a lookahead token if we need one and don't already have one. */
563 /* First try to decide what to do without reference to lookahead token. */
565 yyn = yypact[yystate];
569 /* Not known => get a lookahead token if don't already have one. */
571 /* yychar is either YYEMPTY or YYEOF
572 or a valid token in external form. */
574 if (yychar == YYEMPTY)
576 YYDPRINTF ((stderr, "Reading a token: "));
580 /* Convert token to internal form (in yychar1) for indexing tables with */
582 if (yychar <= 0) /* This means end of input. */
585 yychar = YYEOF; /* Don't call YYLEX any more */
587 YYDPRINTF ((stderr, "Now at end of input.\n"));
591 yychar1 = YYTRANSLATE (yychar);
594 /* We have to keep this `#if YYDEBUG', since we use variables
595 which are defined only if `YYDEBUG' is set. */
598 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
599 /* Give the individual parser a way to print the precise
600 meaning of a token, for further debugging info. */
602 YYPRINT (stderr, yychar, yylval);
604 fprintf (stderr, ")\n");
610 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
615 /* yyn is what to do for this token type in this state.
616 Negative => reduce, -yyn is rule number.
617 Positive => shift, yyn is new state.
618 New state is final state => don't bother to shift,
620 0, or most negative number => error. */
635 /* Shift the lookahead token. */
636 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
638 /* Discard the token being shifted unless it is eof. */
647 /* Count tokens shifted since error; after three, turn off error
656 /*-----------------------------------------------------------.
657 | yydefault -- do the default action for the current state. |
658 `-----------------------------------------------------------*/
660 yyn = yydefact[yystate];
666 /*-----------------------------.
667 | yyreduce -- Do a reduction. |
668 `-----------------------------*/
670 /* yyn is the number of a rule to reduce with. */
673 /* If YYLEN is nonzero, implement the default value of the action:
676 Otherwise, the following line sets YYVAL to the semantic value of
677 the lookahead token. This behavior is undocumented and Bison
678 users should not rely upon it. Assigning to YYVAL
679 unconditionally makes the parser a bit smaller, and it avoids a
680 GCC warning that YYVAL may be used uninitialized. */
681 yyval = yyvsp[1-yylen];
684 /* Similarly for the default location. Let the user run additional
685 commands if for instance locations are ranges. */
686 yyloc = yylsp[1-yylen];
687 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
691 /* We have to keep this `#if YYDEBUG', since we use variables which
692 are defined only if `YYDEBUG' is set. */
697 fprintf (stderr, "Reducing via rule %d (line %d), ",
700 /* Print the symbols being reduced, and their result. */
701 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
702 fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
703 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
706 %% actions /* The action file replaces this line. */
718 short *yyssp1 = yyss - 1;
719 fprintf (stderr, "state stack now");
720 while (yyssp1 != yyssp)
721 fprintf (stderr, " %d", *++yyssp1);
722 fprintf (stderr, "\n");
731 /* Now `shift' the result of the reduction. Determine what state
732 that goes to, based on the state we popped back to and the rule
733 number reduced by. */
737 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
738 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
739 yystate = yytable[yystate];
741 yystate = yydefgoto[yyn - YYNTBASE];
746 /*------------------------------------.
747 | yyerrlab -- here on detecting error |
748 `------------------------------------*/
750 /* If not already recovering from an error, report this error. */
755 #ifdef YYERROR_VERBOSE
756 yyn = yypact[yystate];
758 if (yyn > YYFLAG && yyn < YYLAST)
765 /* Start YYX at -YYN if negative to avoid negative indexes in
767 for (yyx = yyn < 0 ? -yyn : 0;
768 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
769 if (yycheck[yyx + yyn] == yyx)
770 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
771 yysize += yystrlen ("parse error, unexpected ") + 1;
772 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
773 yymsg = (char *) YYSTACK_ALLOC (yysize);
776 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
777 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
782 for (yyx = yyn < 0 ? -yyn : 0;
783 yyx < (int) (sizeof (yytname) / sizeof (char *));
785 if (yycheck[yyx + yyn] == yyx)
787 const char *yyq = ! yycount ? ", expecting " : " or ";
788 yyp = yystpcpy (yyp, yyq);
789 yyp = yystpcpy (yyp, yytname[yyx]);
794 YYSTACK_FREE (yymsg);
797 yyerror ("parse error; also virtual memory exhausted");
800 #endif /* defined (YYERROR_VERBOSE) */
801 yyerror ("parse error");
806 /*--------------------------------------------------.
807 | yyerrlab1 -- error raised explicitly by an action |
808 `--------------------------------------------------*/
810 if (yyerrstatus == 3)
812 /* If just tried and failed to reuse lookahead token after an
813 error, discard it. */
815 /* return failure if at end of input */
818 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
819 yychar, yytname[yychar1]));
823 /* Else will try to reuse lookahead token after shifting the error
826 yyerrstatus = 3; /* Each real token shifted decrements this */
831 /*-------------------------------------------------------------------.
832 | yyerrdefault -- current state does not do anything special for the |
834 `-------------------------------------------------------------------*/
837 /* This is wrong; only states that explicitly want error tokens
838 should shift them. */
840 /* If its default is to accept any token, ok. Otherwise pop it. */
841 yyn = yydefact[yystate];
847 /*---------------------------------------------------------------.
848 | yyerrpop -- pop the current state because it cannot handle the |
850 `---------------------------------------------------------------*/
863 short *yyssp1 = yyss - 1;
864 fprintf (stderr, "Error: state stack now");
865 while (yyssp1 != yyssp)
866 fprintf (stderr, " %d", *++yyssp1);
867 fprintf (stderr, "\n");
875 yyn = yypact[yystate];
880 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
897 YYDPRINTF ((stderr, "Shifting error token, "));
908 /*-------------------------------------.
909 | yyacceptlab -- YYACCEPT comes here. |
910 `-------------------------------------*/
915 /*-----------------------------------.
916 | yyabortlab -- YYABORT comes here. |
917 `-----------------------------------*/
922 /*---------------------------------------------.
923 | yyoverflowab -- parser overflow comes here. |
924 `---------------------------------------------*/
926 yyerror ("parser stack overflow");