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)
58 # define YYSTACK_ALLOC __builtin_alloca
65 /* Pacify GCC's `empty if-body' warning. */
66 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
69 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
70 # define YYSIZE_T std::size_t
73 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
74 # define YYSIZE_T size_t
77 # define YYSTACK_ALLOC YYSTD (malloc)
78 # define YYSTACK_FREE YYSTD (free)
81 /* A type that is properly aligned for any stack member. */
91 /* The size of the maximum gap between one aligned stack and the next. */
92 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
94 /* The size of an array large to enough to hold all stacks, each with
97 # define YYSTACK_BYTES(N) \
98 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
99 + 2 * YYSTACK_GAP_MAX)
101 # define YYSTACK_BYTES(N) \
102 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
106 /* Relocate the TYPE STACK from its old location to the new one. The
107 local variables YYSIZE and YYSTACKSIZE give the old and new number of
108 elements in the stack, and YYPTR gives the new location of the
109 stack. Advance YYPTR to a properly aligned location for the next
111 # define YYSTACK_RELOCATE(Type, Stack) \
114 YYSIZE_T yynewbytes; \
115 yymemcpy ((char *) yyptr, (char *) (Stack), \
116 yysize * (YYSIZE_T) sizeof (Type)); \
117 Stack = &yyptr->Stack; \
118 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
119 yyptr += yynewbytes / sizeof (*yyptr); \
123 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
126 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
127 # define YYSIZE_T __SIZE_TYPE__
129 #if ! defined (YYSIZE_T) && defined (size_t)
130 # define YYSIZE_T size_t
132 #if ! defined (YYSIZE_T)
134 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
135 # define YYSIZE_T std::size_t
138 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
139 # define YYSIZE_T size_t
143 #if ! defined (YYSIZE_T)
144 # define YYSIZE_T unsigned int
147 #define yyerrok (yyerrstatus = 0)
148 #define yyclearin (yychar = YYEMPTY)
151 #define YYACCEPT goto yyacceptlab
152 #define YYABORT goto yyabortlab
153 #define YYERROR goto yyerrlab1
154 /* Like YYERROR except do call yyerror. This remains here temporarily
155 to ease the transition to the new meaning of YYERROR, for GCC.
156 Once GCC version 2 has supplanted version 1, this can go. */
157 #define YYFAIL goto yyerrlab
158 #define YYRECOVERING() (!!yyerrstatus)
159 #define YYBACKUP(Token, Value) \
161 if (yychar == YYEMPTY && yylen == 1) \
165 yychar1 = YYTRANSLATE (yychar); \
171 yyerror ("syntax error: cannot back up"); \
177 #define YYERRCODE 256
180 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
183 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
184 first token. By default, to implement support for ranges, extend
185 its range to the last symbol. */
187 #ifndef YYLLOC_DEFAULT
188 # define YYLLOC_DEFAULT(Current, Rhs, N) \
189 Current.last_line = Rhs[N].last_line; \
190 Current.last_column = Rhs[N].last_column;
194 /* YYLEX -- calling `yylex' with the right arguments. */
199 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
201 # define YYLEX yylex (&yylval, &yylloc)
203 # else /* !YYLSP_NEEDED */
205 # define YYLEX yylex (&yylval, YYLEX_PARAM)
207 # define YYLEX yylex (&yylval)
209 # endif /* !YYLSP_NEEDED */
211 # define YYLEX yylex ()
215 /* Enable debugging if requested. */
220 # include <cstdio.h> /* INFRINGES ON USER NAME SPACE */
222 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
224 # define YYFPRINTF YYSTD (fprintf)
225 # define YYSTDERR YYSTD (stderr)
228 # define YYDPRINTF(Args) \
233 /* Nonzero means print parse trace. [The following comment makes no
234 sense to me. Could someone clarify it? --akim] Since this is
235 uninitialized, it does not stop multiple parsers from coexisting.
239 # define YYDPRINTF(Args)
240 #endif /* !YYDEBUG */
242 /* YYINITDEPTH -- initial size of the parser's stacks. */
244 # define YYINITDEPTH 200
247 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
248 if the built-in stack extension method is used).
250 Do not make this value too large; the results are undefined if
251 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
252 evaluated with infinite-precision integer arithmetic. */
259 # define YYMAXDEPTH 10000
262 #if ! defined (yyoverflow) && ! defined (yymemcpy)
263 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
264 # define yymemcpy __builtin_memcpy
265 # else /* not GNU C or C++ */
267 /* This is the most reliable way to avoid incompatibilities
268 in available built-in functions on various systems. */
270 # if defined (__STDC__) || defined (__cplusplus)
271 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
273 yymemcpy (yyto, yyfrom, yycount)
279 register const char *yyf = yyfrom;
280 register char *yyt = yyto;
281 register YYSIZE_T yyi = yycount;
289 #ifdef YYERROR_VERBOSE
292 # if defined (__GLIBC__) && defined (_STRING_H)
293 # define yystrlen strlen
295 /* Return the length of YYSTR. */
297 # if defined (__STDC__) || defined (__cplusplus)
298 yystrlen (const char *yystr)
304 register const char *yys = yystr;
306 while (*yys++ != '\0')
309 return yys - yystr - 1;
315 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
316 # define yystpcpy stpcpy
318 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
321 # if defined (__STDC__) || defined (__cplusplus)
322 yystpcpy (char *yydest, const char *yysrc)
324 yystpcpy (yydest, yysrc)
329 register char *yyd = yydest;
330 register const char *yys = yysrc;
332 while ((*yyd++ = *yys++) != '\0')
343 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
344 into yyparse. The argument should have type void *.
345 It should actually point to an object.
346 Grammar actions can access the variable by casting it
347 to the proper pointer type. */
351 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
352 # define YYPARSE_PARAM_DECL
353 # else /* !__cplusplus */
354 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
355 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
356 # endif /* !__cplusplus */
357 #else /* !YYPARSE_PARAM */
358 # define YYPARSE_PARAM_ARG
359 # define YYPARSE_PARAM_DECL
360 #endif /* !YYPARSE_PARAM */
362 /* Prevent warning if -Wstrict-prototypes. */
364 # ifdef YYPARSE_PARAM
365 int yyparse (void *);
371 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
372 variables are global, or local to YYPARSE. */
374 #define YY_DECL_NON_LSP_VARIABLES \
375 /* The lookahead symbol. */ \
378 /* The semantic value of the lookahead symbol. */ \
381 /* Number of parse errors so far. */ \
385 # define YY_DECL_VARIABLES \
386 YY_DECL_NON_LSP_VARIABLES \
388 /* Location data for the lookahead symbol. */ \
391 # define YY_DECL_VARIABLES \
392 YY_DECL_NON_LSP_VARIABLES
396 /* If nonreentrant, generate the variables here. */
403 yyparse (YYPARSE_PARAM_ARG)
406 /* If reentrant, generate the variables here. */
411 register int yystate;
414 /* Number of tokens to shift before error messages enabled. */
416 /* Lookahead token as an internal (translated) token number. */
419 /* Three stacks and their tools:
420 `yyss': related to states,
421 `yyvs': related to semantic values,
422 `yyls': related to locations.
424 Refer to the stacks thru separate pointers, to allow yyoverflow
425 to reallocate them elsewhere. */
427 /* The state stack. */
428 short yyssa[YYINITDEPTH];
430 register short *yyssp;
432 /* The semantic value stack. */
433 YYSTYPE yyvsa[YYINITDEPTH];
434 YYSTYPE *yyvs = yyvsa;
435 register YYSTYPE *yyvsp;
438 /* The location stack. */
439 YYLTYPE yylsa[YYINITDEPTH];
440 YYLTYPE *yyls = yylsa;
445 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
447 # define YYPOPSTACK (yyvsp--, yyssp--)
450 YYSIZE_T yystacksize = YYINITDEPTH;
453 /* The variables used to return semantic value and location from the
460 /* When reducing, the number of symbols on the RHS of the reduced
464 YYDPRINTF ((YYSTDERR, "Starting parse\n"));
469 yychar = YYEMPTY; /* Cause a token to be read. */
471 /* Initialize stack pointers.
472 Waste one element of value and location stack
473 so that they stay on the same level as the state stack.
474 The wasted elements are never initialized. */
483 /*------------------------------------------------------------.
484 | yynewstate -- Push a new state, which is found in yystate. |
485 `------------------------------------------------------------*/
487 /* In all cases, when you get here, the value and location stacks
488 have just been pushed. so pushing a state here evens the stacks.
495 if (yyssp >= yyss + yystacksize - 1)
497 /* Get the current used size of the three stacks, in elements. */
498 YYSIZE_T yysize = yyssp - yyss + 1;
502 /* Give user a chance to reallocate the stack. Use copies of
503 these so that the &'s don't force the real ones into
505 YYSTYPE *yyvs1 = yyvs;
508 /* Each stack pointer address is followed by the size of the
509 data in use in that stack, in bytes. */
511 YYLTYPE *yyls1 = yyls;
512 /* This used to be a conditional around just the two extra args,
513 but that might be undefined if yyoverflow is a macro. */
514 yyoverflow ("parser stack overflow",
515 &yyss1, yysize * sizeof (*yyssp),
516 &yyvs1, yysize * sizeof (*yyvsp),
517 &yyls1, yysize * sizeof (*yylsp),
521 yyoverflow ("parser stack overflow",
522 &yyss1, yysize * sizeof (*yyssp),
523 &yyvs1, yysize * sizeof (*yyvsp),
529 #else /* no yyoverflow */
530 /* Extend the stack our own way. */
531 if (yystacksize >= YYMAXDEPTH)
534 if (yystacksize > YYMAXDEPTH)
535 yystacksize = YYMAXDEPTH;
539 union yyalloc *yyptr =
540 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
543 YYSTACK_RELOCATE (short, yyss);
544 YYSTACK_RELOCATE (YYSTYPE, yyvs);
546 YYSTACK_RELOCATE (YYLTYPE, yyls);
548 # undef YYSTACK_RELOCATE
550 YYSTACK_FREE (yyss1);
552 #endif /* no yyoverflow */
554 yyssp = yyss + yysize - 1;
555 yyvsp = yyvs + yysize - 1;
557 yylsp = yyls + yysize - 1;
560 YYDPRINTF ((YYSTDERR, "Stack size increased to %lu\n",
561 (unsigned long int) yystacksize));
563 if (yyssp >= yyss + yystacksize - 1)
567 YYDPRINTF ((YYSTDERR, "Entering state %d\n", yystate));
577 /* Do appropriate processing given the current state. */
578 /* Read a lookahead token if we need one and don't already have one. */
581 /* First try to decide what to do without reference to lookahead token. */
583 yyn = yypact[yystate];
587 /* Not known => get a lookahead token if don't already have one. */
589 /* yychar is either YYEMPTY or YYEOF
590 or a valid token in external form. */
592 if (yychar == YYEMPTY)
594 YYDPRINTF ((YYSTDERR, "Reading a token: "));
598 /* Convert token to internal form (in yychar1) for indexing tables with */
600 if (yychar <= 0) /* This means end of input. */
603 yychar = YYEOF; /* Don't call YYLEX any more */
605 YYDPRINTF ((YYSTDERR, "Now at end of input.\n"));
609 yychar1 = YYTRANSLATE (yychar);
612 /* We have to keep this `#if YYDEBUG', since we use variables
613 which are defined only if `YYDEBUG' is set. */
616 YYFPRINTF (YYSTDERR, "Next token is %d (%s",
617 yychar, yytname[yychar1]);
618 /* Give the individual parser a way to print the precise
619 meaning of a token, for further debugging info. */
621 YYPRINT (YYSTDERR, yychar, yylval);
623 YYFPRINTF (YYSTDERR, ")\n");
629 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
634 /* yyn is what to do for this token type in this state.
635 Negative => reduce, -yyn is rule number.
636 Positive => shift, yyn is new state.
637 New state is final state => don't bother to shift,
639 0, or most negative number => error. */
654 /* Shift the lookahead token. */
655 YYDPRINTF ((YYSTDERR, "Shifting token %d (%s), ",
656 yychar, yytname[yychar1]));
658 /* Discard the token being shifted unless it is eof. */
667 /* Count tokens shifted since error; after three, turn off error
676 /*-----------------------------------------------------------.
677 | yydefault -- do the default action for the current state. |
678 `-----------------------------------------------------------*/
680 yyn = yydefact[yystate];
686 /*-----------------------------.
687 | yyreduce -- Do a reduction. |
688 `-----------------------------*/
690 /* yyn is the number of a rule to reduce with. */
693 /* If YYLEN is nonzero, implement the default value of the action:
696 Otherwise, the following line sets YYVAL to the semantic value of
697 the lookahead token. This behavior is undocumented and Bison
698 users should not rely upon it. Assigning to YYVAL
699 unconditionally makes the parser a bit smaller, and it avoids a
700 GCC warning that YYVAL may be used uninitialized. */
701 yyval = yyvsp[1-yylen];
704 /* Similarly for the default location. Let the user run additional
705 commands if for instance locations are ranges. */
706 yyloc = yylsp[1-yylen];
707 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
711 /* We have to keep this `#if YYDEBUG', since we use variables which
712 are defined only if `YYDEBUG' is set. */
717 YYFPRINTF (YYSTDERR, "Reducing via rule %d (line %d), ",
720 /* Print the symbols being reduced, and their result. */
721 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
722 YYFPRINTF (YYSTDERR, "%s ", yytname[yyrhs[yyi]]);
723 YYFPRINTF (YYSTDERR, " -> %s\n", yytname[yyr1[yyn]]);
726 %% actions /* The action file replaces this line. */
738 short *yyssp1 = yyss - 1;
739 YYFPRINTF (YYSTDERR, "state stack now");
740 while (yyssp1 != yyssp)
741 YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
742 YYFPRINTF (YYSTDERR, "\n");
751 /* Now `shift' the result of the reduction. Determine what state
752 that goes to, based on the state we popped back to and the rule
753 number reduced by. */
757 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
758 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
759 yystate = yytable[yystate];
761 yystate = yydefgoto[yyn - YYNTBASE];
766 /*------------------------------------.
767 | yyerrlab -- here on detecting error |
768 `------------------------------------*/
770 /* If not already recovering from an error, report this error. */
775 #ifdef YYERROR_VERBOSE
776 yyn = yypact[yystate];
778 if (yyn > YYFLAG && yyn < YYLAST)
785 /* Start YYX at -YYN if negative to avoid negative indexes in
787 for (yyx = yyn < 0 ? -yyn : 0;
788 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
789 if (yycheck[yyx + yyn] == yyx)
790 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
791 yysize += yystrlen ("parse error, unexpected ") + 1;
792 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
793 yymsg = (char *) YYSTACK_ALLOC (yysize);
796 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
797 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
802 for (yyx = yyn < 0 ? -yyn : 0;
803 yyx < (int) (sizeof (yytname) / sizeof (char *));
805 if (yycheck[yyx + yyn] == yyx)
807 const char *yyq = ! yycount ? ", expecting " : " or ";
808 yyp = yystpcpy (yyp, yyq);
809 yyp = yystpcpy (yyp, yytname[yyx]);
814 YYSTACK_FREE (yymsg);
817 yyerror ("parse error; also virtual memory exhausted");
820 #endif /* defined (YYERROR_VERBOSE) */
821 yyerror ("parse error");
826 /*--------------------------------------------------.
827 | yyerrlab1 -- error raised explicitly by an action |
828 `--------------------------------------------------*/
830 if (yyerrstatus == 3)
832 /* If just tried and failed to reuse lookahead token after an
833 error, discard it. */
835 /* return failure if at end of input */
838 YYDPRINTF ((YYSTDERR, "Discarding token %d (%s).\n",
839 yychar, yytname[yychar1]));
843 /* Else will try to reuse lookahead token after shifting the error
846 yyerrstatus = 3; /* Each real token shifted decrements this */
851 /*-------------------------------------------------------------------.
852 | yyerrdefault -- current state does not do anything special for the |
854 `-------------------------------------------------------------------*/
857 /* This is wrong; only states that explicitly want error tokens
858 should shift them. */
860 /* If its default is to accept any token, ok. Otherwise pop it. */
861 yyn = yydefact[yystate];
867 /*---------------------------------------------------------------.
868 | yyerrpop -- pop the current state because it cannot handle the |
870 `---------------------------------------------------------------*/
883 short *yyssp1 = yyss - 1;
884 YYFPRINTF (YYSTDERR, "Error: state stack now");
885 while (yyssp1 != yyssp)
886 YYFPRINTF (YYSTDERR, " %d", *++yyssp1);
887 YYFPRINTF (YYSTDERR, "\n");
895 yyn = yypact[yystate];
900 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
917 YYDPRINTF ((YYSTDERR, "Shifting error token, "));
928 /*-------------------------------------.
929 | yyacceptlab -- YYACCEPT comes here. |
930 `-------------------------------------*/
935 /*-----------------------------------.
936 | yyabortlab -- YYABORT comes here. |
937 `-----------------------------------*/
942 /*---------------------------------------------.
943 | yyoverflowab -- parser overflow comes here. |
944 `---------------------------------------------*/
946 yyerror ("parser stack overflow");