3 /* A Bison parser, made from %%filename
4 by GNU bison %%version. */
6 /* Skeleton output parser for bison,
7 Copyright 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 /* As a special exception, when this file is copied by Bison into a
25 Bison output file, you may use that output file without restriction.
26 This special exception was added by the Free Software Foundation
27 in version 1.24 of Bison. */
29 /* This is the parser code that is written into each bison parser when
30 the %semantic_parser declaration is not specified in the grammar.
31 It was written by Richard Stallman by simplifying the hairy parser
32 used when %semantic_parser is specified. */
34 /* Identify Bison output. */
40 /* Using locations. */
41 #define YYLSP_NEEDED %%locations-flag
43 /* Enabling traces. */
45 # define YYDEBUG %%debug
48 /* Enabling verbose error messages. */
49 #undef YYERROR_VERBOSE
50 #define YYERROR_VERBOSE %%error-verbose
52 /* If name_prefix is specify substitute the variables and functions
54 #define yyparse %%prefix##parse
55 #define yylex %%prefix##lex
56 #define yyerror %%prefix##error
57 #define yylval %%prefix##lval
58 #define yychar %%prefix##char
59 #define yydebug %%prefix##debug
60 #define yynerrs %%prefix##nerrs
63 typedef %%stype yystype;
64 # define YYSTYPE yystype
68 typedef struct yyltype
75 # define YYLTYPE %%ltype
78 /* Copy the user declarations. */
81 #line %%line "%%skeleton"
91 /* All symbols defined below should begin with yy or YY, to avoid
92 infringing on user name space. This should be done even for local
93 variables, as they might otherwise be expanded by user macros.
94 There are some unavoidable exceptions within include files to
95 define necessary C library symbols; they are noted "INFRINGES ON
96 USER NAME SPACE" below. */
98 #if ! defined (yyoverflow) || YYERROR_VERBOSE
100 /* The parser invokes alloca or malloc; define the necessary symbols. */
102 # if YYSTACK_USE_ALLOCA
103 # define YYSTACK_ALLOC alloca
104 # define YYSIZE_T size_t
106 # ifndef YYSTACK_USE_ALLOCA
107 # if defined (alloca) || defined (_ALLOCA_H)
108 # define YYSTACK_ALLOC alloca
109 # define YYSIZE_T size_t
111 # if defined (__GNUC__) || defined (_AIX) || defined (__hpux)
112 # define YYSTACK_ALLOC __builtin_alloca
118 # if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun)
119 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
120 # define YYSTACK_ALLOC alloca
121 # define YYSIZE_T size_t
128 # ifdef YYSTACK_ALLOC
129 /* Pacify GCC's `empty if-body' warning. */
130 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
132 # define YYSTACK_ALLOC malloc
133 # define YYSTACK_FREE(Ptr) free (Ptr)
134 # if defined (__STDC__) || defined (__cplusplus)
135 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
136 # define YYSIZE_T size_t
140 /* A type that is properly aligned for any stack member. */
150 /* The size of the maximum gap between one aligned stack and the next. */
151 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
153 /* The size of an array large to enough to hold all stacks, each with
156 # define YYSTACK_BYTES(N) \
157 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
158 + 2 * YYSTACK_GAP_MAX)
160 # define YYSTACK_BYTES(N) \
161 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
165 /* Relocate the TYPE STACK from its old location to the new one. The
166 local variables YYSIZE and YYSTACKSIZE give the old and new number of
167 elements in the stack, and YYPTR gives the new location of the
168 stack. Advance YYPTR to a properly aligned location for the next
170 # define YYSTACK_RELOCATE(Type, Stack) \
173 YYSIZE_T yynewbytes; \
174 yymemcpy ((char *) yyptr, (char *) (Stack), \
175 yysize * (YYSIZE_T) sizeof (Type)); \
176 Stack = &yyptr->Stack; \
177 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
178 yyptr += yynewbytes / sizeof (*yyptr); \
182 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
187 #define YYFINAL %%final
188 #define YYFLAG %%flag
189 #define YYNTBASE %%ntbase
190 #define YYLAST %%last
192 #define YYNTOKENS %%ntokens
193 #define YYNNTS %%nnts
194 #define YYNRULES %%nrules
195 #define YYNSTATES %%nstates
196 #define YYMAXUTOK %%maxtok
198 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
199 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
201 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
202 static const char yytranslate[] =
208 static const short yyprhs[] =
213 static const short yyrhs[] =
218 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
219 static const short yyrline[] =
225 #if YYDEBUG || YYERROR_VERBOSE
226 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
227 static const char *const yytname[] =
233 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
234 static const short yytoknum[] =
239 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
240 static const short yyr1[] =
245 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
246 static const short yyr2[] =
251 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
252 doesn't specify something else to do. Zero means the default is an
254 static const short yydefact[] =
259 static const short yydefgoto[] =
264 static const short yypact[] =
269 static const short yypgoto[] =
274 static const short yytable[] =
279 static const short yycheck[] =
285 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
286 # define YYSIZE_T __SIZE_TYPE__
288 #if ! defined (YYSIZE_T) && defined (size_t)
289 # define YYSIZE_T size_t
291 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
292 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
293 # define YYSIZE_T size_t
295 #if ! defined (YYSIZE_T)
296 # define YYSIZE_T unsigned int
299 #define yyerrok (yyerrstatus = 0)
300 #define yyclearin (yychar = YYEMPTY)
304 #define YYACCEPT goto yyacceptlab
305 #define YYABORT goto yyabortlab
306 #define YYERROR goto yyerrlab1
308 /* Like YYERROR except do call yyerror. This remains here temporarily
309 to ease the transition to the new meaning of YYERROR, for GCC.
310 Once GCC version 2 has supplanted version 1, this can go. */
312 #define YYFAIL goto yyerrlab
314 #define YYRECOVERING() (!!yyerrstatus)
316 #define YYBACKUP(Token, Value) \
318 if (yychar == YYEMPTY && yylen == 1) \
322 yychar1 = YYTRANSLATE (yychar); \
328 yyerror ("syntax error: cannot back up"); \
334 #define YYERRCODE 256
336 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
339 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
340 first token. By default, to implement support for ranges, extend
341 its range to the last symbol. */
343 #ifndef YYLLOC_DEFAULT
344 # define YYLLOC_DEFAULT(Current, Rhs, N) \
345 Current.last_line = Rhs[N].last_line; \
346 Current.last_column = Rhs[N].last_column;
349 /* YYLEX -- calling `yylex' with the right arguments. */
354 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
356 # define YYLEX yylex (&yylval, &yylloc)
358 # else /* !YYLSP_NEEDED */
360 # define YYLEX yylex (&yylval, YYLEX_PARAM)
362 # define YYLEX yylex (&yylval)
364 # endif /* !YYLSP_NEEDED */
366 # define YYLEX yylex ()
369 /* Enable debugging if requested. */
372 # define YYDPRINTF(Args) \
377 /* Nonzero means print parse trace. [The following comment makes no
378 sense to me. Could someone clarify it? --akim] Since this is
379 uninitialized, it does not stop multiple parsers from coexisting.
383 # define YYDPRINTF(Args)
384 #endif /* !YYDEBUG */
386 /* YYINITDEPTH -- initial size of the parser's stacks. */
388 # define YYINITDEPTH %%initdepth
391 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
392 if the built-in stack extension method is used).
394 Do not make this value too large; the results are undefined if
395 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
396 evaluated with infinite-precision integer arithmetic. */
403 # define YYMAXDEPTH %%maxdepth
408 #if ! defined (yyoverflow) && ! defined (yymemcpy)
409 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
410 # define yymemcpy __builtin_memcpy
411 # else /* not GNU C or C++ */
413 /* This is the most reliable way to avoid incompatibilities
414 in available built-in functions on various systems. */
416 # if defined (__STDC__) || defined (__cplusplus)
417 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
419 yymemcpy (yyto, yyfrom, yycount)
425 register const char *yyf = yyfrom;
426 register char *yyt = yyto;
427 register YYSIZE_T yyi = yycount;
438 # if defined (__GLIBC__) && defined (_STRING_H)
439 # define yystrlen strlen
441 /* Return the length of YYSTR. */
443 # if defined (__STDC__) || defined (__cplusplus)
444 yystrlen (const char *yystr)
450 register const char *yys = yystr;
452 while (*yys++ != '\0')
455 return yys - yystr - 1;
461 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
462 # define yystpcpy stpcpy
464 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
467 # if defined (__STDC__) || defined (__cplusplus)
468 yystpcpy (char *yydest, const char *yysrc)
470 yystpcpy (yydest, yysrc)
475 register char *yyd = yydest;
476 register const char *yys = yysrc;
478 while ((*yyd++ = *yys++) != '\0')
486 #endif /* !YYERROR_VERBOSE */
490 #line %%line "%%skeleton"
492 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
493 into yyparse. The argument should have type void *.
494 It should actually point to an object.
495 Grammar actions can access the variable by casting it
496 to the proper pointer type. */
500 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
501 # define YYPARSE_PARAM_DECL
502 # else /* !__cplusplus */
503 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
504 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
505 # endif /* !__cplusplus */
506 #else /* !YYPARSE_PARAM */
507 # define YYPARSE_PARAM_ARG
508 # define YYPARSE_PARAM_DECL
509 #endif /* !YYPARSE_PARAM */
511 /* Prevent warning if -Wstrict-prototypes. */
513 # ifdef YYPARSE_PARAM
514 int yyparse (void *);
520 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
521 variables are global, or local to YYPARSE. */
523 #define YY_DECL_NON_LSP_VARIABLES \
524 /* The lookahead symbol. */ \
527 /* The semantic value of the lookahead symbol. */ \
530 /* Number of parse errors so far. */ \
534 # define YY_DECL_VARIABLES \
535 YY_DECL_NON_LSP_VARIABLES \
537 /* Location data for the lookahead symbol. */ \
540 # define YY_DECL_VARIABLES \
541 YY_DECL_NON_LSP_VARIABLES
544 /* If nonreentrant, generate the variables here. */
551 yyparse (YYPARSE_PARAM_ARG)
554 /* If reentrant, generate the variables here. */
559 register int yystate;
562 /* Number of tokens to shift before error messages enabled. */
564 /* Lookahead token as an internal (translated) token number. */
567 /* Three stacks and their tools:
568 `yyss': related to states,
569 `yyvs': related to semantic values,
570 `yyls': related to locations.
572 Refer to the stacks thru separate pointers, to allow yyoverflow
573 to reallocate them elsewhere. */
575 /* The state stack. */
576 short yyssa[YYINITDEPTH];
578 register short *yyssp;
580 /* The semantic value stack. */
581 YYSTYPE yyvsa[YYINITDEPTH];
582 YYSTYPE *yyvs = yyvsa;
583 register YYSTYPE *yyvsp;
586 /* The location stack. */
587 YYLTYPE yylsa[YYINITDEPTH];
588 YYLTYPE *yyls = yylsa;
593 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
595 # define YYPOPSTACK (yyvsp--, yyssp--)
598 YYSIZE_T yystacksize = YYINITDEPTH;
600 /* The variables used to return semantic value and location from the
607 /* When reducing, the number of symbols on the RHS of the reduced
611 YYDPRINTF ((stderr, "Starting parse\n"));
616 yychar = YYEMPTY; /* Cause a token to be read. */
618 /* Initialize stack pointers.
619 Waste one element of value and location stack
620 so that they stay on the same level as the state stack.
621 The wasted elements are never initialized. */
630 /*------------------------------------------------------------.
631 | yynewstate -- Push a new state, which is found in yystate. |
632 `------------------------------------------------------------*/
634 /* In all cases, when you get here, the value and location stacks
635 have just been pushed. so pushing a state here evens the stacks.
642 if (yyssp >= yyss + yystacksize - 1)
644 /* Get the current used size of the three stacks, in elements. */
645 YYSIZE_T yysize = yyssp - yyss + 1;
649 /* Give user a chance to reallocate the stack. Use copies of
650 these so that the &'s don't force the real ones into
652 YYSTYPE *yyvs1 = yyvs;
655 /* Each stack pointer address is followed by the size of the
656 data in use in that stack, in bytes. */
658 YYLTYPE *yyls1 = yyls;
659 /* This used to be a conditional around just the two extra args,
660 but that might be undefined if yyoverflow is a macro. */
661 yyoverflow ("parser stack overflow",
662 &yyss1, yysize * sizeof (*yyssp),
663 &yyvs1, yysize * sizeof (*yyvsp),
664 &yyls1, yysize * sizeof (*yylsp),
668 yyoverflow ("parser stack overflow",
669 &yyss1, yysize * sizeof (*yyssp),
670 &yyvs1, yysize * sizeof (*yyvsp),
676 #else /* no yyoverflow */
677 /* Extend the stack our own way. */
678 if (yystacksize >= YYMAXDEPTH)
681 if (yystacksize > YYMAXDEPTH)
682 yystacksize = YYMAXDEPTH;
686 union yyalloc *yyptr =
687 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
690 YYSTACK_RELOCATE (short, yyss);
691 YYSTACK_RELOCATE (YYSTYPE, yyvs);
693 YYSTACK_RELOCATE (YYLTYPE, yyls);
695 # undef YYSTACK_RELOCATE
697 YYSTACK_FREE (yyss1);
699 #endif /* no yyoverflow */
701 yyssp = yyss + yysize - 1;
702 yyvsp = yyvs + yysize - 1;
704 yylsp = yyls + yysize - 1;
707 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
708 (unsigned long int) yystacksize));
710 if (yyssp >= yyss + yystacksize - 1)
714 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
723 /* Do appropriate processing given the current state. */
724 /* Read a lookahead token if we need one and don't already have one. */
727 /* First try to decide what to do without reference to lookahead token. */
729 yyn = yypact[yystate];
733 /* Not known => get a lookahead token if don't already have one. */
735 /* yychar is either YYEMPTY or YYEOF
736 or a valid token in external form. */
738 if (yychar == YYEMPTY)
740 YYDPRINTF ((stderr, "Reading a token: "));
744 /* Convert token to internal form (in yychar1) for indexing tables with. */
746 if (yychar <= 0) /* This means end of input. */
749 yychar = YYEOF; /* Don't call YYLEX any more. */
751 YYDPRINTF ((stderr, "Now at end of input.\n"));
755 yychar1 = YYTRANSLATE (yychar);
758 /* We have to keep this `#if YYDEBUG', since we use variables
759 which are defined only if `YYDEBUG' is set. */
762 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
763 /* Give the individual parser a way to print the precise
764 meaning of a token, for further debugging info. */
766 YYPRINT (stderr, yychar, yylval);
768 fprintf (stderr, ")\n");
774 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
779 /* yyn is what to do for this token type in this state.
780 Negative => reduce, -yyn is rule number.
781 Positive => shift, yyn is new state.
782 New state is final state => don't bother to shift,
784 0, or most negative number => error. */
799 /* Shift the lookahead token. */
800 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
802 /* Discard the token being shifted unless it is eof. */
811 /* Count tokens shifted since error; after three, turn off error
820 /*-----------------------------------------------------------.
821 | yydefault -- do the default action for the current state. |
822 `-----------------------------------------------------------*/
824 yyn = yydefact[yystate];
830 /*-----------------------------.
831 | yyreduce -- Do a reduction. |
832 `-----------------------------*/
834 /* yyn is the number of a rule to reduce with. */
837 /* If YYLEN is nonzero, implement the default value of the action:
840 Otherwise, the following line sets YYVAL to the semantic value of
841 the lookahead token. This behavior is undocumented and Bison
842 users should not rely upon it. Assigning to YYVAL
843 unconditionally makes the parser a bit smaller, and it avoids a
844 GCC warning that YYVAL may be used uninitialized. */
845 yyval = yyvsp[1-yylen];
848 /* Similarly for the default location. Let the user run additional
849 commands if for instance locations are ranges. */
850 yyloc = yylsp[1-yylen];
851 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
855 /* We have to keep this `#if YYDEBUG', since we use variables which
856 are defined only if `YYDEBUG' is set. */
861 fprintf (stderr, "Reducing via rule %d (line %d), ",
864 /* Print the symbols being reduced, and their result. */
865 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
866 fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
867 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
874 #line %%line "%%skeleton"
885 short *yyssp1 = yyss - 1;
886 fprintf (stderr, "state stack now");
887 while (yyssp1 != yyssp)
888 fprintf (stderr, " %d", *++yyssp1);
889 fprintf (stderr, "\n");
898 /* Now `shift' the result of the reduction. Determine what state
899 that goes to, based on the state we popped back to and the rule
900 number reduced by. */
904 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
905 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
906 yystate = yytable[yystate];
908 yystate = yydefgoto[yyn - YYNTBASE];
913 /*------------------------------------.
914 | yyerrlab -- here on detecting error |
915 `------------------------------------*/
917 /* If not already recovering from an error, report this error. */
923 yyn = yypact[yystate];
925 if (yyn > YYFLAG && yyn < YYLAST)
932 /* Start YYX at -YYN if negative to avoid negative indexes in
934 for (yyx = yyn < 0 ? -yyn : 0;
935 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
936 if (yycheck[yyx + yyn] == yyx)
937 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
938 yysize += yystrlen ("parse error, unexpected ") + 1;
939 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
940 yymsg = (char *) YYSTACK_ALLOC (yysize);
943 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
944 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
949 for (yyx = yyn < 0 ? -yyn : 0;
950 yyx < (int) (sizeof (yytname) / sizeof (char *));
952 if (yycheck[yyx + yyn] == yyx)
954 const char *yyq = ! yycount ? ", expecting " : " or ";
955 yyp = yystpcpy (yyp, yyq);
956 yyp = yystpcpy (yyp, yytname[yyx]);
961 YYSTACK_FREE (yymsg);
964 yyerror ("parse error; also virtual memory exhausted");
967 #endif /* defined (YYERROR_VERBOSE) */
968 yyerror ("parse error");
973 /*----------------------------------------------------.
974 | yyerrlab1 -- error raised explicitly by an action. |
975 `----------------------------------------------------*/
977 if (yyerrstatus == 3)
979 /* If just tried and failed to reuse lookahead token after an
980 error, discard it. */
982 /* Return failure if at end of input. */
985 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
986 yychar, yytname[yychar1]));
990 /* Else will try to reuse lookahead token after shifting the error
993 yyerrstatus = 3; /* Each real token shifted decrements this. */
998 /*-------------------------------------------------------------------.
999 | yyerrdefault -- current state does not do anything special for the |
1001 `-------------------------------------------------------------------*/
1004 /* This is wrong; only states that explicitly want error tokens
1005 should shift them. */
1007 /* If its default is to accept any token, ok. Otherwise pop it. */
1008 yyn = yydefact[yystate];
1014 /*---------------------------------------------------------------.
1015 | yyerrpop -- pop the current state because it cannot handle the |
1017 `---------------------------------------------------------------*/
1030 short *yyssp1 = yyss - 1;
1031 fprintf (stderr, "Error: state stack now");
1032 while (yyssp1 != yyssp)
1033 fprintf (stderr, " %d", *++yyssp1);
1034 fprintf (stderr, "\n");
1042 yyn = yypact[yystate];
1047 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1064 YYDPRINTF ((stderr, "Shifting error token, "));
1075 /*-------------------------------------.
1076 | yyacceptlab -- YYACCEPT comes here. |
1077 `-------------------------------------*/
1082 /*-----------------------------------.
1083 | yyabortlab -- YYABORT comes here. |
1084 `-----------------------------------*/
1089 /*---------------------------------------------.
1090 | yyoverflowab -- parser overflow comes here. |
1091 `---------------------------------------------*/
1093 yyerror ("parser stack overflow");
1100 YYSTACK_FREE (yyss);