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 # if defined (__STDC__) || defined (__cplusplus)
106 # define YYPOINTER void *
108 # define YYPOINTER char *
111 /* Relocate the TYPE STACK from its old location to the new one. The
112 local variables YYSIZE and YYSTACKSIZE give the old and new number of
113 elements in the stack, and YYPTR gives the new location of the
114 stack. Advance YYPTR to a properly aligned location for the next
116 # define YYSTACK_RELOCATE(Type, Stack) \
119 YYSIZE_T yynewbytes; \
120 yymemcpy (yyptr, (char *) (Stack), \
121 yysize * (YYSIZE_T) sizeof (Type)); \
122 (Stack) = (Type *) (YYPOINTER) yyptr; \
123 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
124 yynewbytes -= yynewbytes % sizeof (union yyalloc); \
125 yyptr += yynewbytes; \
129 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
132 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
133 # define YYSIZE_T __SIZE_TYPE__
135 #if ! defined (YYSIZE_T) && defined (size_t)
136 # define YYSIZE_T size_t
138 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
139 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
140 # define YYSIZE_T size_t
142 #if ! defined (YYSIZE_T)
143 # define YYSIZE_T unsigned int
146 #define yyerrok (yyerrstatus = 0)
147 #define yyclearin (yychar = YYEMPTY)
150 #define YYACCEPT goto yyacceptlab
151 #define YYABORT goto yyabortlab
152 #define YYERROR goto yyerrlab1
153 /* Like YYERROR except do call yyerror. This remains here temporarily
154 to ease the transition to the new meaning of YYERROR, for GCC.
155 Once GCC version 2 has supplanted version 1, this can go. */
156 #define YYFAIL goto yyerrlab
157 #define YYRECOVERING() (!!yyerrstatus)
158 #define YYBACKUP(Token, Value) \
160 if (yychar == YYEMPTY && yylen == 1) \
164 yychar1 = YYTRANSLATE (yychar); \
170 yyerror ("syntax error: cannot back up"); \
176 #define YYERRCODE 256
179 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
182 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
183 first token. By default, to implement support for ranges, extend
184 its range to the last symbol. */
186 #ifndef YYLLOC_DEFAULT
187 # define YYLLOC_DEFAULT(Current, Rhs, N) \
188 Current.last_line = Rhs[N].last_line; \
189 Current.last_column = Rhs[N].last_column;
193 /* YYLEX -- calling `yylex' with the right arguments. */
198 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
200 # define YYLEX yylex (&yylval, &yylloc)
202 # else /* !YYLSP_NEEDED */
204 # define YYLEX yylex (&yylval, YYLEX_PARAM)
206 # define YYLEX yylex (&yylval)
208 # endif /* !YYLSP_NEEDED */
210 # define YYLEX yylex ()
214 /* Enable debugging if requested. */
217 # define YYDPRINTF(Args) \
222 /* Nonzero means print parse trace. [The following comment makes no
223 sense to me. Could someone clarify it? --akim] Since this is
224 uninitialized, it does not stop multiple parsers from coexisting.
228 # define YYDPRINTF(Args)
229 #endif /* !YYDEBUG */
231 /* YYINITDEPTH -- initial size of the parser's stacks. */
233 # define YYINITDEPTH 200
236 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
237 if the built-in stack extension method is used).
239 Do not make this value too large; the results are undefined if
240 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
241 evaluated with infinite-precision integer arithmetic. */
248 # define YYMAXDEPTH 10000
251 #if ! defined (yyoverflow) && ! defined (yymemcpy)
252 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
253 # define yymemcpy __builtin_memcpy
254 # else /* not GNU C or C++ */
256 /* This is the most reliable way to avoid incompatibilities
257 in available built-in functions on various systems. */
259 # if defined (__STDC__) || defined (__cplusplus)
260 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
262 yymemcpy (yyto, yyfrom, yycount)
268 register const char *yyf = yyfrom;
269 register char *yyt = yyto;
270 register YYSIZE_T yyi = yycount;
278 #ifdef YYERROR_VERBOSE
281 # if defined (__GLIBC__) && defined (_STRING_H)
282 # define yystrlen strlen
284 /* Return the length of YYSTR. */
286 # if defined (__STDC__) || defined (__cplusplus)
287 yystrlen (const char *yystr)
293 register const char *yys = yystr;
295 while (*yys++ != '\0')
298 return yys - yystr - 1;
304 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
305 # define yystpcpy stpcpy
307 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
310 # if defined (__STDC__) || defined (__cplusplus)
311 yystpcpy (char *yydest, const char *yysrc)
313 yystpcpy (yydest, yysrc)
318 register char *yyd = yydest;
319 register const char *yys = yysrc;
321 while ((*yyd++ = *yys++) != '\0')
332 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
333 into yyparse. The argument should have type void *.
334 It should actually point to an object.
335 Grammar actions can access the variable by casting it
336 to the proper pointer type. */
340 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
341 # define YYPARSE_PARAM_DECL
342 # else /* !__cplusplus */
343 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
344 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
345 # endif /* !__cplusplus */
346 #else /* !YYPARSE_PARAM */
347 # define YYPARSE_PARAM_ARG
348 # define YYPARSE_PARAM_DECL
349 #endif /* !YYPARSE_PARAM */
351 /* Prevent warning if -Wstrict-prototypes. */
353 # ifdef YYPARSE_PARAM
354 int yyparse (void *);
360 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
361 variables are global, or local to YYPARSE. */
363 #define YY_DECL_NON_LSP_VARIABLES \
364 /* The lookahead symbol. */ \
367 /* The semantic value of the lookahead symbol. */ \
370 /* Number of parse errors so far. */ \
374 # define YY_DECL_VARIABLES \
375 YY_DECL_NON_LSP_VARIABLES \
377 /* Location data for the lookahead symbol. */ \
380 # define YY_DECL_VARIABLES \
381 YY_DECL_NON_LSP_VARIABLES
385 /* If nonreentrant, generate the variables here. */
392 yyparse (YYPARSE_PARAM_ARG)
395 /* If reentrant, generate the variables here. */
400 register int yystate;
403 /* Number of tokens to shift before error messages enabled. */
405 /* Lookahead token as an internal (translated) token number. */
408 /* Three stacks and their tools:
409 `yyss': related to states,
410 `yyvs': related to semantic values,
411 `yyls': related to locations.
413 Refer to the stacks thru separate pointers, to allow yyoverflow
414 to reallocate them elsewhere. */
416 /* The state stack. */
417 short yyssa[YYINITDEPTH];
419 register short *yyssp;
421 /* The semantic value stack. */
422 YYSTYPE yyvsa[YYINITDEPTH];
423 YYSTYPE *yyvs = yyvsa;
424 register YYSTYPE *yyvsp;
427 /* The location stack. */
428 YYLTYPE yylsa[YYINITDEPTH];
429 YYLTYPE *yyls = yylsa;
434 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
436 # define YYPOPSTACK (yyvsp--, yyssp--)
439 YYSIZE_T yystacksize = YYINITDEPTH;
442 /* The variables used to return semantic value and location from the
449 /* When reducing, the number of symbols on the RHS of the reduced
453 YYDPRINTF ((stderr, "Starting parse\n"));
458 yychar = YYEMPTY; /* Cause a token to be read. */
460 /* Initialize stack pointers.
461 Waste one element of value and location stack
462 so that they stay on the same level as the state stack.
463 The wasted elements are never initialized. */
472 /*------------------------------------------------------------.
473 | yynewstate -- Push a new state, which is found in yystate. |
474 `------------------------------------------------------------*/
476 /* In all cases, when you get here, the value and location stacks
477 have just been pushed. so pushing a state here evens the stacks.
484 if (yyssp >= yyss + yystacksize - 1)
486 /* Get the current used size of the three stacks, in elements. */
487 YYSIZE_T yysize = yyssp - yyss + 1;
491 /* Give user a chance to reallocate the stack. Use copies of
492 these so that the &'s don't force the real ones into
494 YYSTYPE *yyvs1 = yyvs;
497 /* Each stack pointer address is followed by the size of the
498 data in use in that stack, in bytes. */
500 YYLTYPE *yyls1 = yyls;
501 /* This used to be a conditional around just the two extra args,
502 but that might be undefined if yyoverflow is a macro. */
503 yyoverflow ("parser stack overflow",
504 &yyss1, yysize * sizeof (*yyssp),
505 &yyvs1, yysize * sizeof (*yyvsp),
506 &yyls1, yysize * sizeof (*yylsp),
510 yyoverflow ("parser stack overflow",
511 &yyss1, yysize * sizeof (*yyssp),
512 &yyvs1, yysize * sizeof (*yyvsp),
518 #else /* no yyoverflow */
519 /* Extend the stack our own way. */
520 if (yystacksize >= YYMAXDEPTH)
523 if (yystacksize > YYMAXDEPTH)
524 yystacksize = YYMAXDEPTH;
528 char *yyptr = (char *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
531 YYSTACK_RELOCATE (short, yyss);
532 YYSTACK_RELOCATE (YYSTYPE, yyvs);
534 YYSTACK_RELOCATE (YYLTYPE, yyls);
536 # undef YYSTACK_RELOCATE
538 YYSTACK_FREE (yyss1);
540 #endif /* no yyoverflow */
542 yyssp = yyss + yysize - 1;
543 yyvsp = yyvs + yysize - 1;
545 yylsp = yyls + yysize - 1;
548 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
549 (unsigned long int) yystacksize));
551 if (yyssp >= yyss + yystacksize - 1)
555 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
565 /* Do appropriate processing given the current state. */
566 /* Read a lookahead token if we need one and don't already have one. */
569 /* First try to decide what to do without reference to lookahead token. */
571 yyn = yypact[yystate];
575 /* Not known => get a lookahead token if don't already have one. */
577 /* yychar is either YYEMPTY or YYEOF
578 or a valid token in external form. */
580 if (yychar == YYEMPTY)
582 YYDPRINTF ((stderr, "Reading a token: "));
586 /* Convert token to internal form (in yychar1) for indexing tables with */
588 if (yychar <= 0) /* This means end of input. */
591 yychar = YYEOF; /* Don't call YYLEX any more */
593 YYDPRINTF ((stderr, "Now at end of input.\n"));
597 yychar1 = YYTRANSLATE (yychar);
600 /* We have to keep this `#if YYDEBUG', since we use variables
601 which are defined only if `YYDEBUG' is set. */
604 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
605 /* Give the individual parser a way to print the precise
606 meaning of a token, for further debugging info. */
608 YYPRINT (stderr, yychar, yylval);
610 fprintf (stderr, ")\n");
616 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
621 /* yyn is what to do for this token type in this state.
622 Negative => reduce, -yyn is rule number.
623 Positive => shift, yyn is new state.
624 New state is final state => don't bother to shift,
626 0, or most negative number => error. */
641 /* Shift the lookahead token. */
642 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
644 /* Discard the token being shifted unless it is eof. */
653 /* Count tokens shifted since error; after three, turn off error
662 /*-----------------------------------------------------------.
663 | yydefault -- do the default action for the current state. |
664 `-----------------------------------------------------------*/
666 yyn = yydefact[yystate];
672 /*-----------------------------.
673 | yyreduce -- Do a reduction. |
674 `-----------------------------*/
676 /* yyn is the number of a rule to reduce with. */
679 /* If YYLEN is nonzero, implement the default value of the action:
682 Otherwise, the following line sets YYVAL to the semantic value of
683 the lookahead token. This behavior is undocumented and Bison
684 users should not rely upon it. Assigning to YYVAL
685 unconditionally makes the parser a bit smaller, and it avoids a
686 GCC warning that YYVAL may be used uninitialized. */
687 yyval = yyvsp[1-yylen];
690 /* Similarly for the default location. Let the user run additional
691 commands if for instance locations are ranges. */
692 yyloc = yylsp[1-yylen];
693 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
697 /* We have to keep this `#if YYDEBUG', since we use variables which
698 are defined only if `YYDEBUG' is set. */
703 fprintf (stderr, "Reducing via rule %d (line %d), ",
706 /* Print the symbols being reduced, and their result. */
707 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
708 fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
709 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
712 %% actions /* The action file replaces this line. */
724 short *yyssp1 = yyss - 1;
725 fprintf (stderr, "state stack now");
726 while (yyssp1 != yyssp)
727 fprintf (stderr, " %d", *++yyssp1);
728 fprintf (stderr, "\n");
737 /* Now `shift' the result of the reduction. Determine what state
738 that goes to, based on the state we popped back to and the rule
739 number reduced by. */
743 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
744 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
745 yystate = yytable[yystate];
747 yystate = yydefgoto[yyn - YYNTBASE];
752 /*------------------------------------.
753 | yyerrlab -- here on detecting error |
754 `------------------------------------*/
756 /* If not already recovering from an error, report this error. */
761 #ifdef YYERROR_VERBOSE
762 yyn = yypact[yystate];
764 if (yyn > YYFLAG && yyn < YYLAST)
771 /* Start YYX at -YYN if negative to avoid negative indexes in
773 for (yyx = yyn < 0 ? -yyn : 0;
774 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
775 if (yycheck[yyx + yyn] == yyx)
776 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
777 yysize += yystrlen ("parse error, unexpected ") + 1;
778 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
779 yymsg = (char *) YYSTACK_ALLOC (yysize);
782 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
783 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
788 for (yyx = yyn < 0 ? -yyn : 0;
789 yyx < (int) (sizeof (yytname) / sizeof (char *));
791 if (yycheck[yyx + yyn] == yyx)
793 const char *yyq = ! yycount ? ", expecting " : " or ";
794 yyp = yystpcpy (yyp, yyq);
795 yyp = yystpcpy (yyp, yytname[yyx]);
800 YYSTACK_FREE (yymsg);
803 yyerror ("parse error; also virtual memory exhausted");
806 #endif /* defined (YYERROR_VERBOSE) */
807 yyerror ("parse error");
812 /*--------------------------------------------------.
813 | yyerrlab1 -- error raised explicitly by an action |
814 `--------------------------------------------------*/
816 if (yyerrstatus == 3)
818 /* If just tried and failed to reuse lookahead token after an
819 error, discard it. */
821 /* return failure if at end of input */
824 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
825 yychar, yytname[yychar1]));
829 /* Else will try to reuse lookahead token after shifting the error
832 yyerrstatus = 3; /* Each real token shifted decrements this */
837 /*-------------------------------------------------------------------.
838 | yyerrdefault -- current state does not do anything special for the |
840 `-------------------------------------------------------------------*/
843 /* This is wrong; only states that explicitly want error tokens
844 should shift them. */
846 /* If its default is to accept any token, ok. Otherwise pop it. */
847 yyn = yydefact[yystate];
853 /*---------------------------------------------------------------.
854 | yyerrpop -- pop the current state because it cannot handle the |
856 `---------------------------------------------------------------*/
869 short *yyssp1 = yyss - 1;
870 fprintf (stderr, "Error: state stack now");
871 while (yyssp1 != yyssp)
872 fprintf (stderr, " %d", *++yyssp1);
873 fprintf (stderr, "\n");
881 yyn = yypact[yystate];
886 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
903 YYDPRINTF ((stderr, "Shifting error token, "));
914 /*-------------------------------------.
915 | yyacceptlab -- YYACCEPT comes here. |
916 `-------------------------------------*/
921 /*-----------------------------------.
922 | yyabortlab -- YYABORT comes here. |
923 `-----------------------------------*/
928 /*---------------------------------------------.
929 | yyoverflowab -- parser overflow comes here. |
930 `---------------------------------------------*/
932 yyerror ("parser stack overflow");