1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
3 /* Skeleton output parser for bison,
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* As a special exception, when this file is copied by Bison into a
24 Bison output file, you may use that output file without restriction.
25 This special exception was added by the Free Software Foundation
26 in version 1.24 of Bison. */
28 /* This is the parser code that is written into each bison parser when
29 the %semantic_parser declaration is not specified in the grammar.
30 It was written by Richard Stallman by simplifying the hairy parser
31 used when %semantic_parser is specified. */
33 /* All symbols defined below should begin with yy or YY, to avoid
34 infringing on user name space. This should be done even for local
35 variables, as they might otherwise be expanded by user macros.
36 There are some unavoidable exceptions within include files to
37 define necessary library symbols; they are noted "INFRINGES ON
38 USER NAME SPACE" below. */
40 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
42 /* The parser invokes alloca or malloc; define the necessary symbols. */
44 # if YYSTACK_USE_ALLOCA
45 # define YYSTACK_ALLOC alloca
47 # ifndef YYSTACK_USE_ALLOCA
48 # if defined (alloca) || defined (_ALLOCA_H)
49 # define YYSTACK_ALLOC alloca
52 # define YYSTACK_ALLOC __builtin_alloca
59 /* Pacify GCC's `empty if-body' warning. */
60 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
62 # if defined (__STDC__) || defined (__cplusplus)
63 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
64 # define YYSIZE_T size_t
66 # define YYSTACK_ALLOC malloc
67 # define YYSTACK_FREE free
70 /* A type that is properly aligned for any stack member. */
80 /* The size of the maximum gap between one aligned stack and the next. */
81 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
83 /* The size of an array large to enough to hold all stacks, each with
86 # define YYSTACK_BYTES(N) \
87 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
88 + 2 * YYSTACK_GAP_MAX)
90 # define YYSTACK_BYTES(N) \
91 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
95 /* Relocate the TYPE STACK from its old location to the new one. The
96 local variables YYSIZE and YYSTACKSIZE give the old and new number of
97 elements in the stack, and YYPTR gives the new location of the
98 stack. Advance YYPTR to a properly aligned location for the next
100 # define YYSTACK_RELOCATE(Type, Stack) \
103 YYSIZE_T yynewbytes; \
104 yymemcpy ((char *) yyptr, (char *) (Stack), \
105 yysize * (YYSIZE_T) sizeof (Type)); \
106 Stack = &yyptr->Stack; \
107 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
108 yyptr += yynewbytes / sizeof (*yyptr); \
112 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
115 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
116 # define YYSIZE_T __SIZE_TYPE__
118 #if ! defined (YYSIZE_T) && defined (size_t)
119 # define YYSIZE_T size_t
121 #if ! defined (YYSIZE_T)
122 # if defined (__STDC__) || defined (__cplusplus)
123 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
124 # define YYSIZE_T size_t
127 #if ! defined (YYSIZE_T)
128 # define YYSIZE_T unsigned int
131 #define yyerrok (yyerrstatus = 0)
132 #define yyclearin (yychar = YYEMPTY)
135 #define YYACCEPT goto yyacceptlab
136 #define YYABORT goto yyabortlab
137 #define YYERROR goto yyerrlab1
138 /* Like YYERROR except do call yyerror. This remains here temporarily
139 to ease the transition to the new meaning of YYERROR, for GCC.
140 Once GCC version 2 has supplanted version 1, this can go. */
141 #define YYFAIL goto yyerrlab
142 #define YYRECOVERING() (!!yyerrstatus)
143 #define YYBACKUP(Token, Value) \
145 if (yychar == YYEMPTY && yylen == 1) \
149 yychar1 = YYTRANSLATE (yychar); \
155 yyerror ("syntax error: cannot back up"); \
161 #define YYERRCODE 256
164 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
167 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
168 first token. By default, to implement support for ranges, extend
169 its range to the last symbol. */
171 #ifndef YYLLOC_DEFAULT
172 # define YYLLOC_DEFAULT(Current, Rhs, N) \
173 Current.last_line = Rhs[N].last_line; \
174 Current.last_column = Rhs[N].last_column;
178 /* YYLEX -- calling `yylex' with the right arguments. */
183 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
185 # define YYLEX yylex (&yylval, &yylloc)
187 # else /* !YYLSP_NEEDED */
189 # define YYLEX yylex (&yylval, YYLEX_PARAM)
191 # define YYLEX yylex (&yylval)
193 # endif /* !YYLSP_NEEDED */
195 # define YYLEX yylex ()
199 /* Enable debugging if requested. */
203 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
204 # define YYFPRINTF fprintf
207 # define YYDPRINTF(Args) \
212 /* Nonzero means print parse trace. [The following comment makes no
213 sense to me. Could someone clarify it? --akim] Since this is
214 uninitialized, it does not stop multiple parsers from coexisting.
218 # define YYDPRINTF(Args)
219 #endif /* !YYDEBUG */
221 /* YYINITDEPTH -- initial size of the parser's stacks. */
223 # define YYINITDEPTH 200
226 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
227 if the built-in stack extension method is used).
229 Do not make this value too large; the results are undefined if
230 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
231 evaluated with infinite-precision integer arithmetic. */
238 # define YYMAXDEPTH 10000
241 #if ! defined (yyoverflow) && ! defined (yymemcpy)
242 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
243 # define yymemcpy __builtin_memcpy
244 # else /* not GNU C or C++ */
246 /* This is the most reliable way to avoid incompatibilities
247 in available built-in functions on various systems. */
249 # if defined (__STDC__) || defined (__cplusplus)
250 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
252 yymemcpy (yyto, yyfrom, yycount)
258 register const char *yyf = yyfrom;
259 register char *yyt = yyto;
260 register YYSIZE_T yyi = yycount;
268 #ifdef YYERROR_VERBOSE
271 # if defined (__GLIBC__) && defined (_STRING_H)
272 # define yystrlen strlen
274 /* Return the length of YYSTR. */
276 # if defined (__STDC__) || defined (__cplusplus)
277 yystrlen (const char *yystr)
283 register const char *yys = yystr;
285 while (*yys++ != '\0')
288 return yys - yystr - 1;
294 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
295 # define yystpcpy stpcpy
297 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
300 # if defined (__STDC__) || defined (__cplusplus)
301 yystpcpy (char *yydest, const char *yysrc)
303 yystpcpy (yydest, yysrc)
308 register char *yyd = yydest;
309 register const char *yys = yysrc;
311 while ((*yyd++ = *yys++) != '\0')
322 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
323 into yyparse. The argument should have type void *.
324 It should actually point to an object.
325 Grammar actions can access the variable by casting it
326 to the proper pointer type. */
329 # if defined (__STDC__) || defined (__cplusplus)
330 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
331 # define YYPARSE_PARAM_DECL
333 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
334 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
336 #else /* !YYPARSE_PARAM */
337 # define YYPARSE_PARAM_ARG
338 # define YYPARSE_PARAM_DECL
339 #endif /* !YYPARSE_PARAM */
341 /* Prevent warning if -Wstrict-prototypes. */
343 # ifdef YYPARSE_PARAM
344 int yyparse (void *);
350 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
351 variables are global, or local to YYPARSE. */
353 #define YY_DECL_NON_LSP_VARIABLES \
354 /* The lookahead symbol. */ \
357 /* The semantic value of the lookahead symbol. */ \
360 /* Number of parse errors so far. */ \
364 # define YY_DECL_VARIABLES \
365 YY_DECL_NON_LSP_VARIABLES \
367 /* Location data for the lookahead symbol. */ \
370 # define YY_DECL_VARIABLES \
371 YY_DECL_NON_LSP_VARIABLES
375 /* If nonreentrant, generate the variables here. */
382 yyparse (YYPARSE_PARAM_ARG)
385 /* If reentrant, generate the variables here. */
390 register int yystate;
393 /* Number of tokens to shift before error messages enabled. */
395 /* Lookahead token as an internal (translated) token number. */
398 /* Three stacks and their tools:
399 `yyss': related to states,
400 `yyvs': related to semantic values,
401 `yyls': related to locations.
403 Refer to the stacks thru separate pointers, to allow yyoverflow
404 to reallocate them elsewhere. */
406 /* The state stack. */
407 short yyssa[YYINITDEPTH];
409 register short *yyssp;
411 /* The semantic value stack. */
412 YYSTYPE yyvsa[YYINITDEPTH];
413 YYSTYPE *yyvs = yyvsa;
414 register YYSTYPE *yyvsp;
417 /* The location stack. */
418 YYLTYPE yylsa[YYINITDEPTH];
419 YYLTYPE *yyls = yylsa;
424 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
426 # define YYPOPSTACK (yyvsp--, yyssp--)
429 YYSIZE_T yystacksize = YYINITDEPTH;
432 /* The variables used to return semantic value and location from the
439 /* When reducing, the number of symbols on the RHS of the reduced
443 YYDPRINTF ((stderr, "Starting parse\n"));
448 yychar = YYEMPTY; /* Cause a token to be read. */
450 /* Initialize stack pointers.
451 Waste one element of value and location stack
452 so that they stay on the same level as the state stack.
453 The wasted elements are never initialized. */
462 /*------------------------------------------------------------.
463 | yynewstate -- Push a new state, which is found in yystate. |
464 `------------------------------------------------------------*/
466 /* In all cases, when you get here, the value and location stacks
467 have just been pushed. so pushing a state here evens the stacks.
474 if (yyssp >= yyss + yystacksize - 1)
476 /* Get the current used size of the three stacks, in elements. */
477 YYSIZE_T yysize = yyssp - yyss + 1;
481 /* Give user a chance to reallocate the stack. Use copies of
482 these so that the &'s don't force the real ones into
484 YYSTYPE *yyvs1 = yyvs;
487 /* Each stack pointer address is followed by the size of the
488 data in use in that stack, in bytes. */
490 YYLTYPE *yyls1 = yyls;
491 /* This used to be a conditional around just the two extra args,
492 but that might be undefined if yyoverflow is a macro. */
493 yyoverflow ("parser stack overflow",
494 &yyss1, yysize * sizeof (*yyssp),
495 &yyvs1, yysize * sizeof (*yyvsp),
496 &yyls1, yysize * sizeof (*yylsp),
500 yyoverflow ("parser stack overflow",
501 &yyss1, yysize * sizeof (*yyssp),
502 &yyvs1, yysize * sizeof (*yyvsp),
508 #else /* no yyoverflow */
509 /* Extend the stack our own way. */
510 if (yystacksize >= YYMAXDEPTH)
513 if (yystacksize > YYMAXDEPTH)
514 yystacksize = YYMAXDEPTH;
518 union yyalloc *yyptr =
519 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
522 YYSTACK_RELOCATE (short, yyss);
523 YYSTACK_RELOCATE (YYSTYPE, yyvs);
525 YYSTACK_RELOCATE (YYLTYPE, yyls);
527 # undef YYSTACK_RELOCATE
529 YYSTACK_FREE (yyss1);
531 #endif /* no yyoverflow */
533 yyssp = yyss + yysize - 1;
534 yyvsp = yyvs + yysize - 1;
536 yylsp = yyls + yysize - 1;
539 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
540 (unsigned long int) yystacksize));
542 if (yyssp >= yyss + yystacksize - 1)
546 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
556 /* Do appropriate processing given the current state. */
557 /* Read a lookahead token if we need one and don't already have one. */
560 /* First try to decide what to do without reference to lookahead token. */
562 yyn = yypact[yystate];
566 /* Not known => get a lookahead token if don't already have one. */
568 /* yychar is either YYEMPTY or YYEOF
569 or a valid token in external form. */
571 if (yychar == YYEMPTY)
573 YYDPRINTF ((stderr, "Reading a token: "));
577 /* Convert token to internal form (in yychar1) for indexing tables with */
579 if (yychar <= 0) /* This means end of input. */
582 yychar = YYEOF; /* Don't call YYLEX any more */
584 YYDPRINTF ((stderr, "Now at end of input.\n"));
588 yychar1 = YYTRANSLATE (yychar);
591 /* We have to keep this `#if YYDEBUG', since we use variables
592 which are defined only if `YYDEBUG' is set. */
595 YYFPRINTF (stderr, "Next token is %d (%s",
596 yychar, yytname[yychar1]);
597 /* Give the individual parser a way to print the precise
598 meaning of a token, for further debugging info. */
600 YYPRINT (stderr, yychar, yylval);
602 YYFPRINTF (stderr, ")\n");
608 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
613 /* yyn is what to do for this token type in this state.
614 Negative => reduce, -yyn is rule number.
615 Positive => shift, yyn is new state.
616 New state is final state => don't bother to shift,
618 0, or most negative number => error. */
633 /* Shift the lookahead token. */
634 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
635 yychar, yytname[yychar1]));
637 /* Discard the token being shifted unless it is eof. */
646 /* Count tokens shifted since error; after three, turn off error
655 /*-----------------------------------------------------------.
656 | yydefault -- do the default action for the current state. |
657 `-----------------------------------------------------------*/
659 yyn = yydefact[yystate];
665 /*-----------------------------.
666 | yyreduce -- Do a reduction. |
667 `-----------------------------*/
669 /* yyn is the number of a rule to reduce with. */
672 /* If YYLEN is nonzero, implement the default value of the action:
675 Otherwise, the following line sets YYVAL to the semantic value of
676 the lookahead token. This behavior is undocumented and Bison
677 users should not rely upon it. Assigning to YYVAL
678 unconditionally makes the parser a bit smaller, and it avoids a
679 GCC warning that YYVAL may be used uninitialized. */
680 yyval = yyvsp[1-yylen];
683 /* Similarly for the default location. Let the user run additional
684 commands if for instance locations are ranges. */
685 yyloc = yylsp[1-yylen];
686 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
690 /* We have to keep this `#if YYDEBUG', since we use variables which
691 are defined only if `YYDEBUG' is set. */
696 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
699 /* Print the symbols being reduced, and their result. */
700 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
701 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
702 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
705 %% actions /* The action file replaces this line. */
717 short *yyssp1 = yyss - 1;
718 YYFPRINTF (stderr, "state stack now");
719 while (yyssp1 != yyssp)
720 YYFPRINTF (stderr, " %d", *++yyssp1);
721 YYFPRINTF (stderr, "\n");
730 /* Now `shift' the result of the reduction. Determine what state
731 that goes to, based on the state we popped back to and the rule
732 number reduced by. */
736 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
737 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
738 yystate = yytable[yystate];
740 yystate = yydefgoto[yyn - YYNTBASE];
745 /*------------------------------------.
746 | yyerrlab -- here on detecting error |
747 `------------------------------------*/
749 /* If not already recovering from an error, report this error. */
754 #ifdef YYERROR_VERBOSE
755 yyn = yypact[yystate];
757 if (yyn > YYFLAG && yyn < YYLAST)
764 /* Start YYX at -YYN if negative to avoid negative indexes in
766 for (yyx = yyn < 0 ? -yyn : 0;
767 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
768 if (yycheck[yyx + yyn] == yyx)
769 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
770 yysize += yystrlen ("parse error, unexpected ") + 1;
771 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
772 yymsg = (char *) YYSTACK_ALLOC (yysize);
775 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
776 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
781 for (yyx = yyn < 0 ? -yyn : 0;
782 yyx < (int) (sizeof (yytname) / sizeof (char *));
784 if (yycheck[yyx + yyn] == yyx)
786 const char *yyq = ! yycount ? ", expecting " : " or ";
787 yyp = yystpcpy (yyp, yyq);
788 yyp = yystpcpy (yyp, yytname[yyx]);
793 YYSTACK_FREE (yymsg);
796 yyerror ("parse error; also virtual memory exhausted");
799 #endif /* defined (YYERROR_VERBOSE) */
800 yyerror ("parse error");
805 /*--------------------------------------------------.
806 | yyerrlab1 -- error raised explicitly by an action |
807 `--------------------------------------------------*/
809 if (yyerrstatus == 3)
811 /* If just tried and failed to reuse lookahead token after an
812 error, discard it. */
814 /* return failure if at end of input */
817 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
818 yychar, yytname[yychar1]));
822 /* Else will try to reuse lookahead token after shifting the error
825 yyerrstatus = 3; /* Each real token shifted decrements this */
830 /*-------------------------------------------------------------------.
831 | yyerrdefault -- current state does not do anything special for the |
833 `-------------------------------------------------------------------*/
836 /* This is wrong; only states that explicitly want error tokens
837 should shift them. */
839 /* If its default is to accept any token, ok. Otherwise pop it. */
840 yyn = yydefact[yystate];
846 /*---------------------------------------------------------------.
847 | yyerrpop -- pop the current state because it cannot handle the |
849 `---------------------------------------------------------------*/
862 short *yyssp1 = yyss - 1;
863 YYFPRINTF (stderr, "Error: state stack now");
864 while (yyssp1 != yyssp)
865 YYFPRINTF (stderr, " %d", *++yyssp1);
866 YYFPRINTF (stderr, "\n");
874 yyn = yypact[yystate];
879 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
896 YYDPRINTF ((stderr, "Shifting error token, "));
907 /*-------------------------------------.
908 | yyacceptlab -- YYACCEPT comes here. |
909 `-------------------------------------*/
914 /*-----------------------------------.
915 | yyabortlab -- YYABORT comes here. |
916 `-----------------------------------*/
921 /*---------------------------------------------.
922 | yyoverflowab -- parser overflow comes here. |
923 `---------------------------------------------*/
925 yyerror ("parser stack overflow");