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. */
79 #line %%input-line "%%filename"
82 #line %%line "%%skeleton"
92 /* All symbols defined below should begin with yy or YY, to avoid
93 infringing on user name space. This should be done even for local
94 variables, as they might otherwise be expanded by user macros.
95 There are some unavoidable exceptions within include files to
96 define necessary C library symbols; they are noted "INFRINGES ON
97 USER NAME SPACE" below. */
99 #if ! defined (yyoverflow) || YYERROR_VERBOSE
101 /* The parser invokes alloca or malloc; define the necessary symbols. */
103 # if YYSTACK_USE_ALLOCA
104 # define YYSTACK_ALLOC alloca
105 # define YYSIZE_T size_t
107 # ifndef YYSTACK_USE_ALLOCA
108 # if defined (alloca) || defined (_ALLOCA_H)
109 # define YYSTACK_ALLOC alloca
110 # define YYSIZE_T size_t
112 # if defined (__GNUC__) || defined (_AIX) || defined (__hpux)
113 # define YYSTACK_ALLOC __builtin_alloca
119 # if defined (__sgi) || defined (__sparc__) || defined (__sparc) || defined (__sun)
120 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
121 # define YYSTACK_ALLOC alloca
122 # define YYSIZE_T size_t
129 # ifdef YYSTACK_ALLOC
130 /* Pacify GCC's `empty if-body' warning. */
131 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
133 # define YYSTACK_ALLOC malloc
134 # define YYSTACK_FREE(Ptr) free (Ptr)
135 # if defined (__STDC__) || defined (__cplusplus)
136 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
137 # define YYSIZE_T size_t
141 /* A type that is properly aligned for any stack member. */
151 /* The size of the maximum gap between one aligned stack and the next. */
152 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
154 /* The size of an array large to enough to hold all stacks, each with
157 # define YYSTACK_BYTES(N) \
158 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
159 + 2 * YYSTACK_GAP_MAX)
161 # define YYSTACK_BYTES(N) \
162 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
166 # if defined (__STDC__) || defined (__cplusplus)
167 # define YYPOINTER void *
169 # define YYPOINTER char *
172 /* Relocate the TYPE STACK from its old location to the new one. The
173 local variables YYSIZE and YYSTACKSIZE give the old and new number of
174 elements in the stack, and YYPTR gives the new location of the
175 stack. Advance YYPTR to a properly aligned location for the next
177 # define YYSTACK_RELOCATE(Type, Stack) \
180 YYSIZE_T yynewbytes; \
181 yymemcpy (yyptr, (char *) (Stack), \
182 yysize * (YYSIZE_T) sizeof (Type)); \
183 (Stack) = (Type *) (YYPOINTER) yyptr; \
184 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
185 yynewbytes -= yynewbytes % sizeof (union yyalloc); \
186 yyptr += yynewbytes; \
190 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
195 #define YYFINAL %%final
196 #define YYFLAG %%flag
197 #define YYNTBASE %%ntbase
198 #define YYLAST %%last
200 #define YYNTOKENS %%ntokens
201 #define YYNNTS %%nnts
202 #define YYNRULES %%nrules
203 #define YYNSTATES %%nstates
204 #define YYMAXUTOK %%maxtok
206 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
207 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
209 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
210 static const char yytranslate[] =
216 static const short yyprhs[] =
221 static const short yyrhs[] =
226 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
227 static const short yyrline[] =
233 #if YYDEBUG || YYERROR_VERBOSE
234 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
235 static const char *const yytname[] =
241 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
242 static const short yytoknum[] =
247 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
248 static const short yyr1[] =
253 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
254 static const short yyr2[] =
259 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
260 doesn't specify something else to do. Zero means the default is an
262 static const short yydefact[] =
267 static const short yydefgoto[] =
272 static const short yypact[] =
277 static const short yypgoto[] =
282 static const short yytable[] =
287 static const short yycheck[] =
293 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
294 # define YYSIZE_T __SIZE_TYPE__
296 #if ! defined (YYSIZE_T) && defined (size_t)
297 # define YYSIZE_T size_t
299 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
300 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
301 # define YYSIZE_T size_t
303 #if ! defined (YYSIZE_T)
304 # define YYSIZE_T unsigned int
307 #define yyerrok (yyerrstatus = 0)
308 #define yyclearin (yychar = YYEMPTY)
312 #define YYACCEPT goto yyacceptlab
313 #define YYABORT goto yyabortlab
314 #define YYERROR goto yyerrlab1
316 /* Like YYERROR except do call yyerror. This remains here temporarily
317 to ease the transition to the new meaning of YYERROR, for GCC.
318 Once GCC version 2 has supplanted version 1, this can go. */
320 #define YYFAIL goto yyerrlab
322 #define YYRECOVERING() (!!yyerrstatus)
324 #define YYBACKUP(Token, Value) \
326 if (yychar == YYEMPTY && yylen == 1) \
330 yychar1 = YYTRANSLATE (yychar); \
336 yyerror ("syntax error: cannot back up"); \
342 #define YYERRCODE 256
344 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
347 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
348 first token. By default, to implement support for ranges, extend
349 its range to the last symbol. */
351 #ifndef YYLLOC_DEFAULT
352 # define YYLLOC_DEFAULT(Current, Rhs, N) \
353 Current.last_line = Rhs[N].last_line; \
354 Current.last_column = Rhs[N].last_column;
357 /* YYLEX -- calling `yylex' with the right arguments. */
362 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
364 # define YYLEX yylex (&yylval, &yylloc)
366 # else /* !YYLSP_NEEDED */
368 # define YYLEX yylex (&yylval, YYLEX_PARAM)
370 # define YYLEX yylex (&yylval)
372 # endif /* !YYLSP_NEEDED */
374 # define YYLEX yylex ()
377 /* Enable debugging if requested. */
380 # define YYDPRINTF(Args) \
385 /* Nonzero means print parse trace. [The following comment makes no
386 sense to me. Could someone clarify it? --akim] Since this is
387 uninitialized, it does not stop multiple parsers from coexisting.
391 # define YYDPRINTF(Args)
392 #endif /* !YYDEBUG */
394 /* YYINITDEPTH -- initial size of the parser's stacks. */
396 # define YYINITDEPTH %%initdepth
399 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
400 if the built-in stack extension method is used).
402 Do not make this value too large; the results are undefined if
403 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
404 evaluated with infinite-precision integer arithmetic. */
411 # define YYMAXDEPTH %%maxdepth
416 #if ! defined (yyoverflow) && ! defined (yymemcpy)
417 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
418 # define yymemcpy __builtin_memcpy
419 # else /* not GNU C or C++ */
421 /* This is the most reliable way to avoid incompatibilities
422 in available built-in functions on various systems. */
424 # if defined (__STDC__) || defined (__cplusplus)
425 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
427 yymemcpy (yyto, yyfrom, yycount)
433 register const char *yyf = yyfrom;
434 register char *yyt = yyto;
435 register YYSIZE_T yyi = yycount;
446 # if defined (__GLIBC__) && defined (_STRING_H)
447 # define yystrlen strlen
449 /* Return the length of YYSTR. */
451 # if defined (__STDC__) || defined (__cplusplus)
452 yystrlen (const char *yystr)
458 register const char *yys = yystr;
460 while (*yys++ != '\0')
463 return yys - yystr - 1;
469 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
470 # define yystpcpy stpcpy
472 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
475 # if defined (__STDC__) || defined (__cplusplus)
476 yystpcpy (char *yydest, const char *yysrc)
478 yystpcpy (yydest, yysrc)
483 register char *yyd = yydest;
484 register const char *yys = yysrc;
486 while ((*yyd++ = *yys++) != '\0')
494 #endif /* !YYERROR_VERBOSE */
498 #line %%line "%%skeleton"
500 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
501 into yyparse. The argument should have type void *.
502 It should actually point to an object.
503 Grammar actions can access the variable by casting it
504 to the proper pointer type. */
508 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
509 # define YYPARSE_PARAM_DECL
510 # else /* !__cplusplus */
511 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
512 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
513 # endif /* !__cplusplus */
514 #else /* !YYPARSE_PARAM */
515 # define YYPARSE_PARAM_ARG
516 # define YYPARSE_PARAM_DECL
517 #endif /* !YYPARSE_PARAM */
519 /* Prevent warning if -Wstrict-prototypes. */
521 # ifdef YYPARSE_PARAM
522 int yyparse (void *);
528 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
529 variables are global, or local to YYPARSE. */
531 #define YY_DECL_NON_LSP_VARIABLES \
532 /* The lookahead symbol. */ \
535 /* The semantic value of the lookahead symbol. */ \
538 /* Number of parse errors so far. */ \
542 # define YY_DECL_VARIABLES \
543 YY_DECL_NON_LSP_VARIABLES \
545 /* Location data for the lookahead symbol. */ \
548 # define YY_DECL_VARIABLES \
549 YY_DECL_NON_LSP_VARIABLES
552 /* If nonreentrant, generate the variables here. */
559 yyparse (YYPARSE_PARAM_ARG)
562 /* If reentrant, generate the variables here. */
567 register int yystate;
570 /* Number of tokens to shift before error messages enabled. */
572 /* Lookahead token as an internal (translated) token number. */
575 /* Three stacks and their tools:
576 `yyss': related to states,
577 `yyvs': related to semantic values,
578 `yyls': related to locations.
580 Refer to the stacks thru separate pointers, to allow yyoverflow
581 to reallocate them elsewhere. */
583 /* The state stack. */
584 short yyssa[YYINITDEPTH];
586 register short *yyssp;
588 /* The semantic value stack. */
589 YYSTYPE yyvsa[YYINITDEPTH];
590 YYSTYPE *yyvs = yyvsa;
591 register YYSTYPE *yyvsp;
594 /* The location stack. */
595 YYLTYPE yylsa[YYINITDEPTH];
596 YYLTYPE *yyls = yylsa;
601 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
603 # define YYPOPSTACK (yyvsp--, yyssp--)
606 YYSIZE_T yystacksize = YYINITDEPTH;
608 /* The variables used to return semantic value and location from the
615 /* When reducing, the number of symbols on the RHS of the reduced
619 YYDPRINTF ((stderr, "Starting parse\n"));
624 yychar = YYEMPTY; /* Cause a token to be read. */
626 /* Initialize stack pointers.
627 Waste one element of value and location stack
628 so that they stay on the same level as the state stack.
629 The wasted elements are never initialized. */
638 /*------------------------------------------------------------.
639 | yynewstate -- Push a new state, which is found in yystate. |
640 `------------------------------------------------------------*/
642 /* In all cases, when you get here, the value and location stacks
643 have just been pushed. so pushing a state here evens the stacks.
650 if (yyssp >= yyss + yystacksize - 1)
652 /* Get the current used size of the three stacks, in elements. */
653 YYSIZE_T yysize = yyssp - yyss + 1;
657 /* Give user a chance to reallocate the stack. Use copies of
658 these so that the &'s don't force the real ones into
660 YYSTYPE *yyvs1 = yyvs;
663 /* Each stack pointer address is followed by the size of the
664 data in use in that stack, in bytes. */
666 YYLTYPE *yyls1 = yyls;
667 /* This used to be a conditional around just the two extra args,
668 but that might be undefined if yyoverflow is a macro. */
669 yyoverflow ("parser stack overflow",
670 &yyss1, yysize * sizeof (*yyssp),
671 &yyvs1, yysize * sizeof (*yyvsp),
672 &yyls1, yysize * sizeof (*yylsp),
676 yyoverflow ("parser stack overflow",
677 &yyss1, yysize * sizeof (*yyssp),
678 &yyvs1, yysize * sizeof (*yyvsp),
684 #else /* no yyoverflow */
685 /* Extend the stack our own way. */
686 if (yystacksize >= YYMAXDEPTH)
689 if (yystacksize > YYMAXDEPTH)
690 yystacksize = YYMAXDEPTH;
694 char *yyptr = (char *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
697 YYSTACK_RELOCATE (short, yyss);
698 YYSTACK_RELOCATE (YYSTYPE, yyvs);
700 YYSTACK_RELOCATE (YYLTYPE, yyls);
702 # undef YYSTACK_RELOCATE
704 YYSTACK_FREE (yyss1);
706 #endif /* no yyoverflow */
708 yyssp = yyss + yysize - 1;
709 yyvsp = yyvs + yysize - 1;
711 yylsp = yyls + yysize - 1;
714 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
715 (unsigned long int) yystacksize));
717 if (yyssp >= yyss + yystacksize - 1)
721 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
730 /* Do appropriate processing given the current state. */
731 /* Read a lookahead token if we need one and don't already have one. */
734 /* First try to decide what to do without reference to lookahead token. */
736 yyn = yypact[yystate];
740 /* Not known => get a lookahead token if don't already have one. */
742 /* yychar is either YYEMPTY or YYEOF
743 or a valid token in external form. */
745 if (yychar == YYEMPTY)
747 YYDPRINTF ((stderr, "Reading a token: "));
751 /* Convert token to internal form (in yychar1) for indexing tables with. */
753 if (yychar <= 0) /* This means end of input. */
756 yychar = YYEOF; /* Don't call YYLEX any more. */
758 YYDPRINTF ((stderr, "Now at end of input.\n"));
762 yychar1 = YYTRANSLATE (yychar);
765 /* We have to keep this `#if YYDEBUG', since we use variables
766 which are defined only if `YYDEBUG' is set. */
769 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
770 /* Give the individual parser a way to print the precise
771 meaning of a token, for further debugging info. */
773 YYPRINT (stderr, yychar, yylval);
775 fprintf (stderr, ")\n");
781 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
786 /* yyn is what to do for this token type in this state.
787 Negative => reduce, -yyn is rule number.
788 Positive => shift, yyn is new state.
789 New state is final state => don't bother to shift,
791 0, or most negative number => error. */
806 /* Shift the lookahead token. */
807 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
809 /* Discard the token being shifted unless it is eof. */
818 /* Count tokens shifted since error; after three, turn off error
827 /*-----------------------------------------------------------.
828 | yydefault -- do the default action for the current state. |
829 `-----------------------------------------------------------*/
831 yyn = yydefact[yystate];
837 /*-----------------------------.
838 | yyreduce -- Do a reduction. |
839 `-----------------------------*/
841 /* yyn is the number of a rule to reduce with. */
844 /* If YYLEN is nonzero, implement the default value of the action:
847 Otherwise, the following line sets YYVAL to the semantic value of
848 the lookahead token. This behavior is undocumented and Bison
849 users should not rely upon it. Assigning to YYVAL
850 unconditionally makes the parser a bit smaller, and it avoids a
851 GCC warning that YYVAL may be used uninitialized. */
852 yyval = yyvsp[1-yylen];
855 /* Similarly for the default location. Let the user run additional
856 commands if for instance locations are ranges. */
857 yyloc = yylsp[1-yylen];
858 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
862 /* We have to keep this `#if YYDEBUG', since we use variables which
863 are defined only if `YYDEBUG' is set. */
868 fprintf (stderr, "Reducing via rule %d (line %d), ",
871 /* Print the symbols being reduced, and their result. */
872 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
873 fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
874 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
881 #line %%line "%%skeleton"
892 short *yyssp1 = yyss - 1;
893 fprintf (stderr, "state stack now");
894 while (yyssp1 != yyssp)
895 fprintf (stderr, " %d", *++yyssp1);
896 fprintf (stderr, "\n");
905 /* Now `shift' the result of the reduction. Determine what state
906 that goes to, based on the state we popped back to and the rule
907 number reduced by. */
911 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
912 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
913 yystate = yytable[yystate];
915 yystate = yydefgoto[yyn - YYNTBASE];
920 /*------------------------------------.
921 | yyerrlab -- here on detecting error |
922 `------------------------------------*/
924 /* If not already recovering from an error, report this error. */
930 yyn = yypact[yystate];
932 if (yyn > YYFLAG && yyn < YYLAST)
939 /* Start YYX at -YYN if negative to avoid negative indexes in
941 for (yyx = yyn < 0 ? -yyn : 0;
942 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
943 if (yycheck[yyx + yyn] == yyx)
944 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
945 yysize += yystrlen ("parse error, unexpected ") + 1;
946 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
947 yymsg = (char *) YYSTACK_ALLOC (yysize);
950 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
951 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
956 for (yyx = yyn < 0 ? -yyn : 0;
957 yyx < (int) (sizeof (yytname) / sizeof (char *));
959 if (yycheck[yyx + yyn] == yyx)
961 const char *yyq = ! yycount ? ", expecting " : " or ";
962 yyp = yystpcpy (yyp, yyq);
963 yyp = yystpcpy (yyp, yytname[yyx]);
968 YYSTACK_FREE (yymsg);
971 yyerror ("parse error; also virtual memory exhausted");
974 #endif /* defined (YYERROR_VERBOSE) */
975 yyerror ("parse error");
980 /*----------------------------------------------------.
981 | yyerrlab1 -- error raised explicitly by an action. |
982 `----------------------------------------------------*/
984 if (yyerrstatus == 3)
986 /* If just tried and failed to reuse lookahead token after an
987 error, discard it. */
989 /* Return failure if at end of input. */
992 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
993 yychar, yytname[yychar1]));
997 /* Else will try to reuse lookahead token after shifting the error
1000 yyerrstatus = 3; /* Each real token shifted decrements this. */
1005 /*-------------------------------------------------------------------.
1006 | yyerrdefault -- current state does not do anything special for the |
1008 `-------------------------------------------------------------------*/
1011 /* This is wrong; only states that explicitly want error tokens
1012 should shift them. */
1014 /* If its default is to accept any token, ok. Otherwise pop it. */
1015 yyn = yydefact[yystate];
1021 /*---------------------------------------------------------------.
1022 | yyerrpop -- pop the current state because it cannot handle the |
1024 `---------------------------------------------------------------*/
1037 short *yyssp1 = yyss - 1;
1038 fprintf (stderr, "Error: state stack now");
1039 while (yyssp1 != yyssp)
1040 fprintf (stderr, " %d", *++yyssp1);
1041 fprintf (stderr, "\n");
1049 yyn = yypact[yystate];
1054 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1071 YYDPRINTF ((stderr, "Shifting error token, "));
1082 /*-------------------------------------.
1083 | yyacceptlab -- YYACCEPT comes here. |
1084 `-------------------------------------*/
1089 /*-----------------------------------.
1090 | yyabortlab -- YYABORT comes here. |
1091 `-----------------------------------*/
1096 /*---------------------------------------------.
1097 | yyoverflowab -- parser overflow comes here. |
1098 `---------------------------------------------*/
1100 yyerror ("parser stack overflow");
1107 YYSTACK_FREE (yyss);
1112 #line %%input-line "%%filename"