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> /* INFRINGES ON USER NAME SPACE */
222 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
224 # define YYFPRINTF YYSTD (fprintf)
227 # define YYDPRINTF(Args) \
232 /* Nonzero means print parse trace. [The following comment makes no
233 sense to me. Could someone clarify it? --akim] Since this is
234 uninitialized, it does not stop multiple parsers from coexisting.
238 # define YYDPRINTF(Args)
239 #endif /* !YYDEBUG */
241 /* YYINITDEPTH -- initial size of the parser's stacks. */
243 # define YYINITDEPTH 200
246 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
247 if the built-in stack extension method is used).
249 Do not make this value too large; the results are undefined if
250 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
251 evaluated with infinite-precision integer arithmetic. */
258 # define YYMAXDEPTH 10000
261 #if ! defined (yyoverflow) && ! defined (yymemcpy)
262 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
263 # define yymemcpy __builtin_memcpy
264 # else /* not GNU C or C++ */
266 /* This is the most reliable way to avoid incompatibilities
267 in available built-in functions on various systems. */
269 # if defined (__STDC__) || defined (__cplusplus)
270 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
272 yymemcpy (yyto, yyfrom, yycount)
278 register const char *yyf = yyfrom;
279 register char *yyt = yyto;
280 register YYSIZE_T yyi = yycount;
288 #ifdef YYERROR_VERBOSE
291 # if defined (__GLIBC__) && defined (_STRING_H)
292 # define yystrlen strlen
294 /* Return the length of YYSTR. */
296 # if defined (__STDC__) || defined (__cplusplus)
297 yystrlen (const char *yystr)
303 register const char *yys = yystr;
305 while (*yys++ != '\0')
308 return yys - yystr - 1;
314 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
315 # define yystpcpy stpcpy
317 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
320 # if defined (__STDC__) || defined (__cplusplus)
321 yystpcpy (char *yydest, const char *yysrc)
323 yystpcpy (yydest, yysrc)
328 register char *yyd = yydest;
329 register const char *yys = yysrc;
331 while ((*yyd++ = *yys++) != '\0')
342 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
343 into yyparse. The argument should have type void *.
344 It should actually point to an object.
345 Grammar actions can access the variable by casting it
346 to the proper pointer type. */
350 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
351 # define YYPARSE_PARAM_DECL
352 # else /* !__cplusplus */
353 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
354 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
355 # endif /* !__cplusplus */
356 #else /* !YYPARSE_PARAM */
357 # define YYPARSE_PARAM_ARG
358 # define YYPARSE_PARAM_DECL
359 #endif /* !YYPARSE_PARAM */
361 /* Prevent warning if -Wstrict-prototypes. */
363 # ifdef YYPARSE_PARAM
364 int yyparse (void *);
370 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
371 variables are global, or local to YYPARSE. */
373 #define YY_DECL_NON_LSP_VARIABLES \
374 /* The lookahead symbol. */ \
377 /* The semantic value of the lookahead symbol. */ \
380 /* Number of parse errors so far. */ \
384 # define YY_DECL_VARIABLES \
385 YY_DECL_NON_LSP_VARIABLES \
387 /* Location data for the lookahead symbol. */ \
390 # define YY_DECL_VARIABLES \
391 YY_DECL_NON_LSP_VARIABLES
395 /* If nonreentrant, generate the variables here. */
402 yyparse (YYPARSE_PARAM_ARG)
405 /* If reentrant, generate the variables here. */
410 register int yystate;
413 /* Number of tokens to shift before error messages enabled. */
415 /* Lookahead token as an internal (translated) token number. */
418 /* Three stacks and their tools:
419 `yyss': related to states,
420 `yyvs': related to semantic values,
421 `yyls': related to locations.
423 Refer to the stacks thru separate pointers, to allow yyoverflow
424 to reallocate them elsewhere. */
426 /* The state stack. */
427 short yyssa[YYINITDEPTH];
429 register short *yyssp;
431 /* The semantic value stack. */
432 YYSTYPE yyvsa[YYINITDEPTH];
433 YYSTYPE *yyvs = yyvsa;
434 register YYSTYPE *yyvsp;
437 /* The location stack. */
438 YYLTYPE yylsa[YYINITDEPTH];
439 YYLTYPE *yyls = yylsa;
444 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
446 # define YYPOPSTACK (yyvsp--, yyssp--)
449 YYSIZE_T yystacksize = YYINITDEPTH;
452 /* The variables used to return semantic value and location from the
459 /* When reducing, the number of symbols on the RHS of the reduced
463 YYDPRINTF ((stderr, "Starting parse\n"));
468 yychar = YYEMPTY; /* Cause a token to be read. */
470 /* Initialize stack pointers.
471 Waste one element of value and location stack
472 so that they stay on the same level as the state stack.
473 The wasted elements are never initialized. */
482 /*------------------------------------------------------------.
483 | yynewstate -- Push a new state, which is found in yystate. |
484 `------------------------------------------------------------*/
486 /* In all cases, when you get here, the value and location stacks
487 have just been pushed. so pushing a state here evens the stacks.
494 if (yyssp >= yyss + yystacksize - 1)
496 /* Get the current used size of the three stacks, in elements. */
497 YYSIZE_T yysize = yyssp - yyss + 1;
501 /* Give user a chance to reallocate the stack. Use copies of
502 these so that the &'s don't force the real ones into
504 YYSTYPE *yyvs1 = yyvs;
507 /* Each stack pointer address is followed by the size of the
508 data in use in that stack, in bytes. */
510 YYLTYPE *yyls1 = yyls;
511 /* This used to be a conditional around just the two extra args,
512 but that might be undefined if yyoverflow is a macro. */
513 yyoverflow ("parser stack overflow",
514 &yyss1, yysize * sizeof (*yyssp),
515 &yyvs1, yysize * sizeof (*yyvsp),
516 &yyls1, yysize * sizeof (*yylsp),
520 yyoverflow ("parser stack overflow",
521 &yyss1, yysize * sizeof (*yyssp),
522 &yyvs1, yysize * sizeof (*yyvsp),
528 #else /* no yyoverflow */
529 /* Extend the stack our own way. */
530 if (yystacksize >= YYMAXDEPTH)
533 if (yystacksize > YYMAXDEPTH)
534 yystacksize = YYMAXDEPTH;
538 union yyalloc *yyptr =
539 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
542 YYSTACK_RELOCATE (short, yyss);
543 YYSTACK_RELOCATE (YYSTYPE, yyvs);
545 YYSTACK_RELOCATE (YYLTYPE, yyls);
547 # undef YYSTACK_RELOCATE
549 YYSTACK_FREE (yyss1);
551 #endif /* no yyoverflow */
553 yyssp = yyss + yysize - 1;
554 yyvsp = yyvs + yysize - 1;
556 yylsp = yyls + yysize - 1;
559 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
560 (unsigned long int) yystacksize));
562 if (yyssp >= yyss + yystacksize - 1)
566 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
576 /* Do appropriate processing given the current state. */
577 /* Read a lookahead token if we need one and don't already have one. */
580 /* First try to decide what to do without reference to lookahead token. */
582 yyn = yypact[yystate];
586 /* Not known => get a lookahead token if don't already have one. */
588 /* yychar is either YYEMPTY or YYEOF
589 or a valid token in external form. */
591 if (yychar == YYEMPTY)
593 YYDPRINTF ((stderr, "Reading a token: "));
597 /* Convert token to internal form (in yychar1) for indexing tables with */
599 if (yychar <= 0) /* This means end of input. */
602 yychar = YYEOF; /* Don't call YYLEX any more */
604 YYDPRINTF ((stderr, "Now at end of input.\n"));
608 yychar1 = YYTRANSLATE (yychar);
611 /* We have to keep this `#if YYDEBUG', since we use variables
612 which are defined only if `YYDEBUG' is set. */
615 YYFPRINTF (stderr, "Next token is %d (%s",
616 yychar, yytname[yychar1]);
617 /* Give the individual parser a way to print the precise
618 meaning of a token, for further debugging info. */
620 YYPRINT (stderr, yychar, yylval);
622 YYFPRINTF (stderr, ")\n");
628 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
633 /* yyn is what to do for this token type in this state.
634 Negative => reduce, -yyn is rule number.
635 Positive => shift, yyn is new state.
636 New state is final state => don't bother to shift,
638 0, or most negative number => error. */
653 /* Shift the lookahead token. */
654 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
655 yychar, yytname[yychar1]));
657 /* Discard the token being shifted unless it is eof. */
666 /* Count tokens shifted since error; after three, turn off error
675 /*-----------------------------------------------------------.
676 | yydefault -- do the default action for the current state. |
677 `-----------------------------------------------------------*/
679 yyn = yydefact[yystate];
685 /*-----------------------------.
686 | yyreduce -- Do a reduction. |
687 `-----------------------------*/
689 /* yyn is the number of a rule to reduce with. */
692 /* If YYLEN is nonzero, implement the default value of the action:
695 Otherwise, the following line sets YYVAL to the semantic value of
696 the lookahead token. This behavior is undocumented and Bison
697 users should not rely upon it. Assigning to YYVAL
698 unconditionally makes the parser a bit smaller, and it avoids a
699 GCC warning that YYVAL may be used uninitialized. */
700 yyval = yyvsp[1-yylen];
703 /* Similarly for the default location. Let the user run additional
704 commands if for instance locations are ranges. */
705 yyloc = yylsp[1-yylen];
706 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
710 /* We have to keep this `#if YYDEBUG', since we use variables which
711 are defined only if `YYDEBUG' is set. */
716 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
719 /* Print the symbols being reduced, and their result. */
720 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
721 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
722 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
725 %% actions /* The action file replaces this line. */
737 short *yyssp1 = yyss - 1;
738 YYFPRINTF (stderr, "state stack now");
739 while (yyssp1 != yyssp)
740 YYFPRINTF (stderr, " %d", *++yyssp1);
741 YYFPRINTF (stderr, "\n");
750 /* Now `shift' the result of the reduction. Determine what state
751 that goes to, based on the state we popped back to and the rule
752 number reduced by. */
756 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
757 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
758 yystate = yytable[yystate];
760 yystate = yydefgoto[yyn - YYNTBASE];
765 /*------------------------------------.
766 | yyerrlab -- here on detecting error |
767 `------------------------------------*/
769 /* If not already recovering from an error, report this error. */
774 #ifdef YYERROR_VERBOSE
775 yyn = yypact[yystate];
777 if (yyn > YYFLAG && yyn < YYLAST)
784 /* Start YYX at -YYN if negative to avoid negative indexes in
786 for (yyx = yyn < 0 ? -yyn : 0;
787 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
788 if (yycheck[yyx + yyn] == yyx)
789 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
790 yysize += yystrlen ("parse error, unexpected ") + 1;
791 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
792 yymsg = (char *) YYSTACK_ALLOC (yysize);
795 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
796 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
801 for (yyx = yyn < 0 ? -yyn : 0;
802 yyx < (int) (sizeof (yytname) / sizeof (char *));
804 if (yycheck[yyx + yyn] == yyx)
806 const char *yyq = ! yycount ? ", expecting " : " or ";
807 yyp = yystpcpy (yyp, yyq);
808 yyp = yystpcpy (yyp, yytname[yyx]);
813 YYSTACK_FREE (yymsg);
816 yyerror ("parse error; also virtual memory exhausted");
819 #endif /* defined (YYERROR_VERBOSE) */
820 yyerror ("parse error");
825 /*--------------------------------------------------.
826 | yyerrlab1 -- error raised explicitly by an action |
827 `--------------------------------------------------*/
829 if (yyerrstatus == 3)
831 /* If just tried and failed to reuse lookahead token after an
832 error, discard it. */
834 /* return failure if at end of input */
837 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
838 yychar, yytname[yychar1]));
842 /* Else will try to reuse lookahead token after shifting the error
845 yyerrstatus = 3; /* Each real token shifted decrements this */
850 /*-------------------------------------------------------------------.
851 | yyerrdefault -- current state does not do anything special for the |
853 `-------------------------------------------------------------------*/
856 /* This is wrong; only states that explicitly want error tokens
857 should shift them. */
859 /* If its default is to accept any token, ok. Otherwise pop it. */
860 yyn = yydefact[yystate];
866 /*---------------------------------------------------------------.
867 | yyerrpop -- pop the current state because it cannot handle the |
869 `---------------------------------------------------------------*/
882 short *yyssp1 = yyss - 1;
883 YYFPRINTF (stderr, "Error: state stack now");
884 while (yyssp1 != yyssp)
885 YYFPRINTF (stderr, " %d", *++yyssp1);
886 YYFPRINTF (stderr, "\n");
894 yyn = yypact[yystate];
899 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
916 YYDPRINTF ((stderr, "Shifting error token, "));
927 /*-------------------------------------.
928 | yyacceptlab -- YYACCEPT comes here. |
929 `-------------------------------------*/
934 /*-----------------------------------.
935 | yyabortlab -- YYABORT comes here. |
936 `-----------------------------------*/
941 /*---------------------------------------------.
942 | yyoverflowab -- parser overflow comes here. |
943 `---------------------------------------------*/
945 yyerror ("parser stack overflow");