1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
3 /* Skeleton output parser for bison,
4 Copyright (C) 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 library symbols; they are noted "INFRINGES ON
36 USER NAME SPACE" below. */
39 # define YYSTD(x) std::x
44 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
46 /* The parser invokes alloca or malloc; define the necessary symbols. */
48 # if YYSTACK_USE_ALLOCA
49 # define YYSTACK_ALLOC alloca
50 # define YYSIZE_T YYSTD (size_t)
52 # ifndef YYSTACK_USE_ALLOCA
53 # if defined (alloca) || defined (_ALLOCA_H)
54 # define YYSTACK_ALLOC alloca
55 # define YYSIZE_T YYSTD (size_t)
57 # if defined (__GNUC__) || defined (_AIX) || defined (__hpux)
58 # define YYSTACK_ALLOC __builtin_alloca
64 # if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun)
65 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
66 # define YYSTACK_ALLOC alloca
67 # define YYSIZE_T YYSTD (size_t)
75 /* Pacify GCC's `empty if-body' warning. */
76 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
79 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
80 # define YYSIZE_T std::size_t
83 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
84 # define YYSIZE_T size_t
87 # define YYSTACK_ALLOC YYSTD (malloc)
88 # define YYSTACK_FREE YYSTD (free)
91 /* A type that is properly aligned for any stack member. */
101 /* The size of the maximum gap between one aligned stack and the next. */
102 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
104 /* The size of an array large to enough to hold all stacks, each with
107 # define YYSTACK_BYTES(N) \
108 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
109 + 2 * YYSTACK_GAP_MAX)
111 # define YYSTACK_BYTES(N) \
112 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
116 /* Relocate the TYPE STACK from its old location to the new one. The
117 local variables YYSIZE and YYSTACKSIZE give the old and new number of
118 elements in the stack, and YYPTR gives the new location of the
119 stack. Advance YYPTR to a properly aligned location for the next
121 # define YYSTACK_RELOCATE(Type, Stack) \
124 YYSIZE_T yynewbytes; \
125 yymemcpy ((char *) yyptr, (char *) (Stack), \
126 yysize * (YYSIZE_T) sizeof (Type)); \
127 Stack = &yyptr->Stack; \
128 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
129 yyptr += yynewbytes / sizeof (*yyptr); \
133 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
136 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
137 # define YYSIZE_T __SIZE_TYPE__
139 #if ! defined (YYSIZE_T) && defined (size_t)
140 # define YYSIZE_T size_t
142 #if ! defined (YYSIZE_T)
144 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
145 # define YYSIZE_T std::size_t
148 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
149 # define YYSIZE_T size_t
153 #if ! defined (YYSIZE_T)
154 # define YYSIZE_T unsigned int
157 #define yyerrok (yyerrstatus = 0)
158 #define yyclearin (yychar = YYEMPTY)
161 #define YYACCEPT goto yyacceptlab
162 #define YYABORT goto yyabortlab
163 #define YYERROR goto yyerrlab1
164 /* Like YYERROR except do call yyerror. This remains here temporarily
165 to ease the transition to the new meaning of YYERROR, for GCC.
166 Once GCC version 2 has supplanted version 1, this can go. */
167 #define YYFAIL goto yyerrlab
168 #define YYRECOVERING() (!!yyerrstatus)
169 #define YYBACKUP(Token, Value) \
171 if (yychar == YYEMPTY && yylen == 1) \
175 yychar1 = YYTRANSLATE (yychar); \
181 yyerror ("syntax error: cannot back up"); \
187 #define YYERRCODE 256
190 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
193 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
194 first token. By default, to implement support for ranges, extend
195 its range to the last symbol. */
197 #ifndef YYLLOC_DEFAULT
198 # define YYLLOC_DEFAULT(Current, Rhs, N) \
199 Current.last_line = Rhs[N].last_line; \
200 Current.last_column = Rhs[N].last_column;
204 /* YYLEX -- calling `yylex' with the right arguments. */
209 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
211 # define YYLEX yylex (&yylval, &yylloc)
213 # else /* !YYLSP_NEEDED */
215 # define YYLEX yylex (&yylval, YYLEX_PARAM)
217 # define YYLEX yylex (&yylval)
219 # endif /* !YYLSP_NEEDED */
221 # define YYLEX yylex ()
225 /* Enable debugging if requested. */
230 # include <cstdio.h> /* INFRINGES ON USER NAME SPACE */
232 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
234 # define YYFPRINTF YYSTD (fprintf)
235 # define YYSTDERR YYSTD (stderr)
238 # define YYDPRINTF(Args) \
243 /* Nonzero means print parse trace. [The following comment makes no
244 sense to me. Could someone clarify it? --akim] Since this is
245 uninitialized, it does not stop multiple parsers from coexisting.
249 # define YYDPRINTF(Args)
250 #endif /* !YYDEBUG */
252 /* YYINITDEPTH -- initial size of the parser's stacks. */
254 # define YYINITDEPTH 200
257 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
258 if the built-in stack extension method is used).
260 Do not make this value too large; the results are undefined if
261 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
262 evaluated with infinite-precision integer arithmetic. */
269 # define YYMAXDEPTH 10000
272 #if ! defined (yyoverflow) && ! defined (yymemcpy)
273 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
274 # define yymemcpy __builtin_memcpy
275 # else /* not GNU C or C++ */
277 /* This is the most reliable way to avoid incompatibilities
278 in available built-in functions on various systems. */
280 # if defined (__STDC__) || defined (__cplusplus)
281 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
283 yymemcpy (yyto, yyfrom, yycount)
289 register const char *yyf = yyfrom;
290 register char *yyt = yyto;
291 register YYSIZE_T yyi = yycount;
299 #ifdef YYERROR_VERBOSE
302 # if defined (__GLIBC__) && defined (_STRING_H)
303 # define yystrlen strlen
305 /* Return the length of YYSTR. */
307 # if defined (__STDC__) || defined (__cplusplus)
308 yystrlen (const char *yystr)
314 register const char *yys = yystr;
316 while (*yys++ != '\0')
319 return yys - yystr - 1;
325 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
326 # define yystpcpy stpcpy
328 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
331 # if defined (__STDC__) || defined (__cplusplus)
332 yystpcpy (char *yydest, const char *yysrc)
334 yystpcpy (yydest, yysrc)
339 register char *yyd = yydest;
340 register const char *yys = yysrc;
342 while ((*yyd++ = *yys++) != '\0')
353 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
354 into yyparse. The argument should have type void *.
355 It should actually point to an object.
356 Grammar actions can access the variable by casting it
357 to the proper pointer type. */
361 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
362 # define YYPARSE_PARAM_DECL
363 # else /* !__cplusplus */
364 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
365 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
366 # endif /* !__cplusplus */
367 #else /* !YYPARSE_PARAM */
368 # define YYPARSE_PARAM_ARG
369 # define YYPARSE_PARAM_DECL
370 #endif /* !YYPARSE_PARAM */
372 /* Prevent warning if -Wstrict-prototypes. */
374 # ifdef YYPARSE_PARAM
375 int yyparse (void *);
381 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
382 variables are global, or local to YYPARSE. */
384 #define YY_DECL_NON_LSP_VARIABLES \
385 /* The lookahead symbol. */ \
388 /* The semantic value of the lookahead symbol. */ \
391 /* Number of parse errors so far. */ \
395 # define YY_DECL_VARIABLES \
396 YY_DECL_NON_LSP_VARIABLES \
398 /* Location data for the lookahead symbol. */ \
401 # define YY_DECL_VARIABLES \
402 YY_DECL_NON_LSP_VARIABLES
406 /* If nonreentrant, generate the variables here. */
413 yyparse (YYPARSE_PARAM_ARG)
416 /* If reentrant, generate the variables here. */
421 register int yystate;
424 /* Number of tokens to shift before error messages enabled. */
426 /* Lookahead token as an internal (translated) token number. */
429 /* Three stacks and their tools:
430 `yyss': related to states,
431 `yyvs': related to semantic values,
432 `yyls': related to locations.
434 Refer to the stacks thru separate pointers, to allow yyoverflow
435 to reallocate them elsewhere. */
437 /* The state stack. */
438 short yyssa[YYINITDEPTH];
440 register short *yyssp;
442 /* The semantic value stack. */
443 YYSTYPE yyvsa[YYINITDEPTH];
444 YYSTYPE *yyvs = yyvsa;
445 register YYSTYPE *yyvsp;
448 /* The location stack. */
449 YYLTYPE yylsa[YYINITDEPTH];
450 YYLTYPE *yyls = yylsa;
455 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
457 # define YYPOPSTACK (yyvsp--, yyssp--)
460 YYSIZE_T yystacksize = YYINITDEPTH;
463 /* The variables used to return semantic value and location from the
470 /* When reducing, the number of symbols on the RHS of the reduced
474 YYDPRINTF ((YYSTDERR, "Starting parse\n"));
479 yychar = YYEMPTY; /* Cause a token to be read. */
481 /* Initialize stack pointers.
482 Waste one element of value and location stack
483 so that they stay on the same level as the state stack.
484 The wasted elements are never initialized. */
493 /*------------------------------------------------------------.
494 | yynewstate -- Push a new state, which is found in yystate. |
495 `------------------------------------------------------------*/
497 /* In all cases, when you get here, the value and location stacks
498 have just been pushed. so pushing a state here evens the stacks.
505 if (yyssp >= yyss + yystacksize - 1)
507 /* Get the current used size of the three stacks, in elements. */
508 YYSIZE_T yysize = yyssp - yyss + 1;
512 /* Give user a chance to reallocate the stack. Use copies of
513 these so that the &'s don't force the real ones into
515 YYSTYPE *yyvs1 = yyvs;
518 /* Each stack pointer address is followed by the size of the
519 data in use in that stack, in bytes. */
521 YYLTYPE *yyls1 = yyls;
522 /* This used to be a conditional around just the two extra args,
523 but that might be undefined if yyoverflow is a macro. */
524 yyoverflow ("parser stack overflow",
525 &yyss1, yysize * sizeof (*yyssp),
526 &yyvs1, yysize * sizeof (*yyvsp),
527 &yyls1, yysize * sizeof (*yylsp),
531 yyoverflow ("parser stack overflow",
532 &yyss1, yysize * sizeof (*yyssp),
533 &yyvs1, yysize * sizeof (*yyvsp),
539 #else /* no yyoverflow */
540 /* Extend the stack our own way. */
541 if (yystacksize >= YYMAXDEPTH)
544 if (yystacksize > YYMAXDEPTH)
545 yystacksize = YYMAXDEPTH;
549 union yyalloc *yyptr =
550 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
553 YYSTACK_RELOCATE (short, yyss);
554 YYSTACK_RELOCATE (YYSTYPE, yyvs);
556 YYSTACK_RELOCATE (YYLTYPE, yyls);
558 # undef YYSTACK_RELOCATE
560 YYSTACK_FREE (yyss1);
562 #endif /* no yyoverflow */
564 yyssp = yyss + yysize - 1;
565 yyvsp = yyvs + yysize - 1;
567 yylsp = yyls + yysize - 1;
570 YYDPRINTF ((YYSTDERR, "Stack size increased to %lu\n",
571 (unsigned long int) yystacksize));
573 if (yyssp >= yyss + yystacksize - 1)
577 YYDPRINTF ((YYSTDERR, "Entering state %d\n", yystate));
587 /* Do appropriate processing given the current state. */
588 /* Read a lookahead token if we need one and don't already have one. */
591 /* First try to decide what to do without reference to lookahead token. */
593 yyn = yypact[yystate];
597 /* Not known => get a lookahead token if don't already have one. */
599 /* yychar is either YYEMPTY or YYEOF
600 or a valid token in external form. */
602 if (yychar == YYEMPTY)
604 YYDPRINTF ((YYSTDERR, "Reading a token: "));
608 /* Convert token to internal form (in yychar1) for indexing tables with */
610 if (yychar <= 0) /* This means end of input. */
613 yychar = YYEOF; /* Don't call YYLEX any more */
615 YYDPRINTF ((YYSTDERR, "Now at end of input.\n"));
619 yychar1 = YYTRANSLATE (yychar);
622 /* We have to keep this `#if YYDEBUG', since we use variables
623 which are defined only if `YYDEBUG' is set. */
626 YYFPRINTF (YYSTDERR, "Next token is %d (%s",
627 yychar, yytname[yychar1]);
628 /* Give the individual parser a way to print the precise
629 meaning of a token, for further debugging info. */
631 YYPRINT (YYSTDERR, yychar, yylval);
633 YYFPRINTF (YYSTDERR, ")\n");
639 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
644 /* yyn is what to do for this token type in this state.
645 Negative => reduce, -yyn is rule number.
646 Positive => shift, yyn is new state.
647 New state is final state => don't bother to shift,
649 0, or most negative number => error. */
664 /* Shift the lookahead token. */
665 YYDPRINTF ((YYSTDERR, "Shifting token %d (%s), ",
666 yychar, yytname[yychar1]));
668 /* Discard the token being shifted unless it is eof. */
677 /* Count tokens shifted since error; after three, turn off error
686 /*-----------------------------------------------------------.
687 | yydefault -- do the default action for the current state. |
688 `-----------------------------------------------------------*/
690 yyn = yydefact[yystate];
696 /*-----------------------------.
697 | yyreduce -- Do a reduction. |
698 `-----------------------------*/
700 /* yyn is the number of a rule to reduce with. */
703 /* If YYLEN is nonzero, implement the default value of the action:
706 Otherwise, the following line sets YYVAL to the semantic value of
707 the lookahead token. This behavior is undocumented and Bison
708 users should not rely upon it. Assigning to YYVAL
709 unconditionally makes the parser a bit smaller, and it avoids a
710 GCC warning that YYVAL may be used uninitialized. */
711 yyval = yyvsp[1-yylen];
714 /* Similarly for the default location. Let the user run additional
715 commands if for instance locations are ranges. */
716 yyloc = yylsp[1-yylen];
717 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
721 /* We have to keep this `#if YYDEBUG', since we use variables which
722 are defined only if `YYDEBUG' is set. */
727 YYFPRINTF (YYSTDERR, "Reducing via rule %d (line %d), ",
730 /* Print the symbols being reduced, and their result. */
731 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
732 YYFPRINTF (YYSTDERR, "%s ", yytname[yyrhs[yyi]]);
733 YYFPRINTF (YYSTDERR, " -> %s\n", yytname[yyr1[yyn]]);
736 %% actions /* The action file replaces this line. */
748 short *yyssp1 = yyss - 1;
749 YYFPRINTF (YYSTDERR, "state stack now");
750 while (yyssp1 != yyssp)
751 YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
752 YYFPRINTF (YYSTDERR, "\n");
761 /* Now `shift' the result of the reduction. Determine what state
762 that goes to, based on the state we popped back to and the rule
763 number reduced by. */
767 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
768 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
769 yystate = yytable[yystate];
771 yystate = yydefgoto[yyn - YYNTBASE];
776 /*------------------------------------.
777 | yyerrlab -- here on detecting error |
778 `------------------------------------*/
780 /* If not already recovering from an error, report this error. */
785 #ifdef YYERROR_VERBOSE
786 yyn = yypact[yystate];
788 if (yyn > YYFLAG && yyn < YYLAST)
795 /* Start YYX at -YYN if negative to avoid negative indexes in
797 for (yyx = yyn < 0 ? -yyn : 0;
798 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
799 if (yycheck[yyx + yyn] == yyx)
800 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
801 yysize += yystrlen ("parse error, unexpected ") + 1;
802 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
803 yymsg = (char *) YYSTACK_ALLOC (yysize);
806 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
807 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
812 for (yyx = yyn < 0 ? -yyn : 0;
813 yyx < (int) (sizeof (yytname) / sizeof (char *));
815 if (yycheck[yyx + yyn] == yyx)
817 const char *yyq = ! yycount ? ", expecting " : " or ";
818 yyp = yystpcpy (yyp, yyq);
819 yyp = yystpcpy (yyp, yytname[yyx]);
824 YYSTACK_FREE (yymsg);
827 yyerror ("parse error; also virtual memory exhausted");
830 #endif /* defined (YYERROR_VERBOSE) */
831 yyerror ("parse error");
836 /*--------------------------------------------------.
837 | yyerrlab1 -- error raised explicitly by an action |
838 `--------------------------------------------------*/
840 if (yyerrstatus == 3)
842 /* If just tried and failed to reuse lookahead token after an
843 error, discard it. */
845 /* return failure if at end of input */
848 YYDPRINTF ((YYSTDERR, "Discarding token %d (%s).\n",
849 yychar, yytname[yychar1]));
853 /* Else will try to reuse lookahead token after shifting the error
856 yyerrstatus = 3; /* Each real token shifted decrements this */
861 /*-------------------------------------------------------------------.
862 | yyerrdefault -- current state does not do anything special for the |
864 `-------------------------------------------------------------------*/
867 /* This is wrong; only states that explicitly want error tokens
868 should shift them. */
870 /* If its default is to accept any token, ok. Otherwise pop it. */
871 yyn = yydefact[yystate];
877 /*---------------------------------------------------------------.
878 | yyerrpop -- pop the current state because it cannot handle the |
880 `---------------------------------------------------------------*/
893 short *yyssp1 = yyss - 1;
894 YYFPRINTF (YYSTDERR, "Error: state stack now");
895 while (yyssp1 != yyssp)
896 YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
897 YYFPRINTF (YYSTDERR, "\n");
905 yyn = yypact[yystate];
910 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
927 YYDPRINTF ((YYSTDERR, "Shifting error token, "));
938 /*-------------------------------------.
939 | yyacceptlab -- YYACCEPT comes here. |
940 `-------------------------------------*/
945 /*-----------------------------------.
946 | yyabortlab -- YYABORT comes here. |
947 `-----------------------------------*/
952 /*---------------------------------------------.
953 | yyoverflowab -- parser overflow comes here. |
954 `---------------------------------------------*/
956 yyerror ("parser stack overflow");