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 /* Relocate the TYPE STACK from its old location to the new one. The
167 local variables YYSIZE and YYSTACKSIZE give the old and new number of
168 elements in the stack, and YYPTR gives the new location of the
169 stack. Advance YYPTR to a properly aligned location for the next
171 # define YYSTACK_RELOCATE(Type, Stack) \
174 YYSIZE_T yynewbytes; \
175 yymemcpy ((char *) yyptr, (char *) (Stack), \
176 yysize * (YYSIZE_T) sizeof (Type)); \
177 Stack = &yyptr->Stack; \
178 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
179 yyptr += yynewbytes / sizeof (*yyptr); \
183 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
188 #define YYFINAL %%final
189 #define YYFLAG %%flag
190 #define YYNTBASE %%ntbase
191 #define YYLAST %%last
193 #define YYNTOKENS %%ntokens
194 #define YYNNTS %%nnts
195 #define YYNRULES %%nrules
196 #define YYNSTATES %%nstates
197 #define YYMAXUTOK %%maxtok
199 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
200 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
202 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
203 static const char yytranslate[] =
209 static const short yyprhs[] =
214 static const short yyrhs[] =
219 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
220 static const short yyrline[] =
226 #if YYDEBUG || YYERROR_VERBOSE
227 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
228 static const char *const yytname[] =
234 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
235 static const short yytoknum[] =
240 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
241 static const short yyr1[] =
246 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
247 static const short yyr2[] =
252 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
253 doesn't specify something else to do. Zero means the default is an
255 static const short yydefact[] =
260 static const short yydefgoto[] =
265 static const short yypact[] =
270 static const short yypgoto[] =
275 static const short yytable[] =
280 static const short yycheck[] =
286 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
287 # define YYSIZE_T __SIZE_TYPE__
289 #if ! defined (YYSIZE_T) && defined (size_t)
290 # define YYSIZE_T size_t
292 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
293 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
294 # define YYSIZE_T size_t
296 #if ! defined (YYSIZE_T)
297 # define YYSIZE_T unsigned int
300 #define yyerrok (yyerrstatus = 0)
301 #define yyclearin (yychar = YYEMPTY)
305 #define YYACCEPT goto yyacceptlab
306 #define YYABORT goto yyabortlab
307 #define YYERROR goto yyerrlab1
309 /* Like YYERROR except do call yyerror. This remains here temporarily
310 to ease the transition to the new meaning of YYERROR, for GCC.
311 Once GCC version 2 has supplanted version 1, this can go. */
313 #define YYFAIL goto yyerrlab
315 #define YYRECOVERING() (!!yyerrstatus)
317 #define YYBACKUP(Token, Value) \
319 if (yychar == YYEMPTY && yylen == 1) \
323 yychar1 = YYTRANSLATE (yychar); \
329 yyerror ("syntax error: cannot back up"); \
335 #define YYERRCODE 256
337 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
340 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
341 first token. By default, to implement support for ranges, extend
342 its range to the last symbol. */
344 #ifndef YYLLOC_DEFAULT
345 # define YYLLOC_DEFAULT(Current, Rhs, N) \
346 Current.last_line = Rhs[N].last_line; \
347 Current.last_column = Rhs[N].last_column;
350 /* YYLEX -- calling `yylex' with the right arguments. */
355 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
357 # define YYLEX yylex (&yylval, &yylloc)
359 # else /* !YYLSP_NEEDED */
361 # define YYLEX yylex (&yylval, YYLEX_PARAM)
363 # define YYLEX yylex (&yylval)
365 # endif /* !YYLSP_NEEDED */
367 # define YYLEX yylex ()
370 /* Enable debugging if requested. */
373 # define YYDPRINTF(Args) \
378 /* Nonzero means print parse trace. [The following comment makes no
379 sense to me. Could someone clarify it? --akim] Since this is
380 uninitialized, it does not stop multiple parsers from coexisting.
384 # define YYDPRINTF(Args)
385 #endif /* !YYDEBUG */
387 /* YYINITDEPTH -- initial size of the parser's stacks. */
389 # define YYINITDEPTH %%initdepth
392 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
393 if the built-in stack extension method is used).
395 Do not make this value too large; the results are undefined if
396 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
397 evaluated with infinite-precision integer arithmetic. */
404 # define YYMAXDEPTH %%maxdepth
409 #if ! defined (yyoverflow) && ! defined (yymemcpy)
410 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
411 # define yymemcpy __builtin_memcpy
412 # else /* not GNU C or C++ */
414 /* This is the most reliable way to avoid incompatibilities
415 in available built-in functions on various systems. */
417 # if defined (__STDC__) || defined (__cplusplus)
418 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
420 yymemcpy (yyto, yyfrom, yycount)
426 register const char *yyf = yyfrom;
427 register char *yyt = yyto;
428 register YYSIZE_T yyi = yycount;
439 # if defined (__GLIBC__) && defined (_STRING_H)
440 # define yystrlen strlen
442 /* Return the length of YYSTR. */
444 # if defined (__STDC__) || defined (__cplusplus)
445 yystrlen (const char *yystr)
451 register const char *yys = yystr;
453 while (*yys++ != '\0')
456 return yys - yystr - 1;
462 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
463 # define yystpcpy stpcpy
465 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
468 # if defined (__STDC__) || defined (__cplusplus)
469 yystpcpy (char *yydest, const char *yysrc)
471 yystpcpy (yydest, yysrc)
476 register char *yyd = yydest;
477 register const char *yys = yysrc;
479 while ((*yyd++ = *yys++) != '\0')
487 #endif /* !YYERROR_VERBOSE */
491 #line %%line "%%skeleton"
493 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
494 into yyparse. The argument should have type void *.
495 It should actually point to an object.
496 Grammar actions can access the variable by casting it
497 to the proper pointer type. */
501 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
502 # define YYPARSE_PARAM_DECL
503 # else /* !__cplusplus */
504 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
505 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
506 # endif /* !__cplusplus */
507 #else /* !YYPARSE_PARAM */
508 # define YYPARSE_PARAM_ARG
509 # define YYPARSE_PARAM_DECL
510 #endif /* !YYPARSE_PARAM */
512 /* Prevent warning if -Wstrict-prototypes. */
514 # ifdef YYPARSE_PARAM
515 int yyparse (void *);
521 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
522 variables are global, or local to YYPARSE. */
524 #define YY_DECL_NON_LSP_VARIABLES \
525 /* The lookahead symbol. */ \
528 /* The semantic value of the lookahead symbol. */ \
531 /* Number of parse errors so far. */ \
535 # define YY_DECL_VARIABLES \
536 YY_DECL_NON_LSP_VARIABLES \
538 /* Location data for the lookahead symbol. */ \
541 # define YY_DECL_VARIABLES \
542 YY_DECL_NON_LSP_VARIABLES
545 /* If nonreentrant, generate the variables here. */
552 yyparse (YYPARSE_PARAM_ARG)
555 /* If reentrant, generate the variables here. */
560 register int yystate;
563 /* Number of tokens to shift before error messages enabled. */
565 /* Lookahead token as an internal (translated) token number. */
568 /* Three stacks and their tools:
569 `yyss': related to states,
570 `yyvs': related to semantic values,
571 `yyls': related to locations.
573 Refer to the stacks thru separate pointers, to allow yyoverflow
574 to reallocate them elsewhere. */
576 /* The state stack. */
577 short yyssa[YYINITDEPTH];
579 register short *yyssp;
581 /* The semantic value stack. */
582 YYSTYPE yyvsa[YYINITDEPTH];
583 YYSTYPE *yyvs = yyvsa;
584 register YYSTYPE *yyvsp;
587 /* The location stack. */
588 YYLTYPE yylsa[YYINITDEPTH];
589 YYLTYPE *yyls = yylsa;
594 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
596 # define YYPOPSTACK (yyvsp--, yyssp--)
599 YYSIZE_T yystacksize = YYINITDEPTH;
601 /* The variables used to return semantic value and location from the
608 /* When reducing, the number of symbols on the RHS of the reduced
612 YYDPRINTF ((stderr, "Starting parse\n"));
617 yychar = YYEMPTY; /* Cause a token to be read. */
619 /* Initialize stack pointers.
620 Waste one element of value and location stack
621 so that they stay on the same level as the state stack.
622 The wasted elements are never initialized. */
631 /*------------------------------------------------------------.
632 | yynewstate -- Push a new state, which is found in yystate. |
633 `------------------------------------------------------------*/
635 /* In all cases, when you get here, the value and location stacks
636 have just been pushed. so pushing a state here evens the stacks.
643 if (yyssp >= yyss + yystacksize - 1)
645 /* Get the current used size of the three stacks, in elements. */
646 YYSIZE_T yysize = yyssp - yyss + 1;
650 /* Give user a chance to reallocate the stack. Use copies of
651 these so that the &'s don't force the real ones into
653 YYSTYPE *yyvs1 = yyvs;
656 /* Each stack pointer address is followed by the size of the
657 data in use in that stack, in bytes. */
659 YYLTYPE *yyls1 = yyls;
660 /* This used to be a conditional around just the two extra args,
661 but that might be undefined if yyoverflow is a macro. */
662 yyoverflow ("parser stack overflow",
663 &yyss1, yysize * sizeof (*yyssp),
664 &yyvs1, yysize * sizeof (*yyvsp),
665 &yyls1, yysize * sizeof (*yylsp),
669 yyoverflow ("parser stack overflow",
670 &yyss1, yysize * sizeof (*yyssp),
671 &yyvs1, yysize * sizeof (*yyvsp),
677 #else /* no yyoverflow */
678 /* Extend the stack our own way. */
679 if (yystacksize >= YYMAXDEPTH)
682 if (yystacksize > YYMAXDEPTH)
683 yystacksize = YYMAXDEPTH;
687 union yyalloc *yyptr =
688 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
691 YYSTACK_RELOCATE (short, yyss);
692 YYSTACK_RELOCATE (YYSTYPE, yyvs);
694 YYSTACK_RELOCATE (YYLTYPE, yyls);
696 # undef YYSTACK_RELOCATE
698 YYSTACK_FREE (yyss1);
700 #endif /* no yyoverflow */
702 yyssp = yyss + yysize - 1;
703 yyvsp = yyvs + yysize - 1;
705 yylsp = yyls + yysize - 1;
708 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
709 (unsigned long int) yystacksize));
711 if (yyssp >= yyss + yystacksize - 1)
715 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
724 /* Do appropriate processing given the current state. */
725 /* Read a lookahead token if we need one and don't already have one. */
728 /* First try to decide what to do without reference to lookahead token. */
730 yyn = yypact[yystate];
734 /* Not known => get a lookahead token if don't already have one. */
736 /* yychar is either YYEMPTY or YYEOF
737 or a valid token in external form. */
739 if (yychar == YYEMPTY)
741 YYDPRINTF ((stderr, "Reading a token: "));
745 /* Convert token to internal form (in yychar1) for indexing tables with. */
747 if (yychar <= 0) /* This means end of input. */
750 yychar = YYEOF; /* Don't call YYLEX any more. */
752 YYDPRINTF ((stderr, "Now at end of input.\n"));
756 yychar1 = YYTRANSLATE (yychar);
759 /* We have to keep this `#if YYDEBUG', since we use variables
760 which are defined only if `YYDEBUG' is set. */
763 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
764 /* Give the individual parser a way to print the precise
765 meaning of a token, for further debugging info. */
767 YYPRINT (stderr, yychar, yylval);
769 fprintf (stderr, ")\n");
775 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
780 /* yyn is what to do for this token type in this state.
781 Negative => reduce, -yyn is rule number.
782 Positive => shift, yyn is new state.
783 New state is final state => don't bother to shift,
785 0, or most negative number => error. */
800 /* Shift the lookahead token. */
801 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
803 /* Discard the token being shifted unless it is eof. */
812 /* Count tokens shifted since error; after three, turn off error
821 /*-----------------------------------------------------------.
822 | yydefault -- do the default action for the current state. |
823 `-----------------------------------------------------------*/
825 yyn = yydefact[yystate];
831 /*-----------------------------.
832 | yyreduce -- Do a reduction. |
833 `-----------------------------*/
835 /* yyn is the number of a rule to reduce with. */
838 /* If YYLEN is nonzero, implement the default value of the action:
841 Otherwise, the following line sets YYVAL to the semantic value of
842 the lookahead token. This behavior is undocumented and Bison
843 users should not rely upon it. Assigning to YYVAL
844 unconditionally makes the parser a bit smaller, and it avoids a
845 GCC warning that YYVAL may be used uninitialized. */
846 yyval = yyvsp[1-yylen];
849 /* Similarly for the default location. Let the user run additional
850 commands if for instance locations are ranges. */
851 yyloc = yylsp[1-yylen];
852 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
856 /* We have to keep this `#if YYDEBUG', since we use variables which
857 are defined only if `YYDEBUG' is set. */
862 fprintf (stderr, "Reducing via rule %d (line %d), ",
865 /* Print the symbols being reduced, and their result. */
866 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
867 fprintf (stderr, "%s ", yytname[yyrhs[yyi]]);
868 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
875 #line %%line "%%skeleton"
886 short *yyssp1 = yyss - 1;
887 fprintf (stderr, "state stack now");
888 while (yyssp1 != yyssp)
889 fprintf (stderr, " %d", *++yyssp1);
890 fprintf (stderr, "\n");
899 /* Now `shift' the result of the reduction. Determine what state
900 that goes to, based on the state we popped back to and the rule
901 number reduced by. */
905 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
906 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
907 yystate = yytable[yystate];
909 yystate = yydefgoto[yyn - YYNTBASE];
914 /*------------------------------------.
915 | yyerrlab -- here on detecting error |
916 `------------------------------------*/
918 /* If not already recovering from an error, report this error. */
924 yyn = yypact[yystate];
926 if (yyn > YYFLAG && yyn < YYLAST)
933 /* Start YYX at -YYN if negative to avoid negative indexes in
935 for (yyx = yyn < 0 ? -yyn : 0;
936 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
937 if (yycheck[yyx + yyn] == yyx)
938 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
939 yysize += yystrlen ("parse error, unexpected ") + 1;
940 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
941 yymsg = (char *) YYSTACK_ALLOC (yysize);
944 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
945 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
950 for (yyx = yyn < 0 ? -yyn : 0;
951 yyx < (int) (sizeof (yytname) / sizeof (char *));
953 if (yycheck[yyx + yyn] == yyx)
955 const char *yyq = ! yycount ? ", expecting " : " or ";
956 yyp = yystpcpy (yyp, yyq);
957 yyp = yystpcpy (yyp, yytname[yyx]);
962 YYSTACK_FREE (yymsg);
965 yyerror ("parse error; also virtual memory exhausted");
968 #endif /* defined (YYERROR_VERBOSE) */
969 yyerror ("parse error");
974 /*----------------------------------------------------.
975 | yyerrlab1 -- error raised explicitly by an action. |
976 `----------------------------------------------------*/
978 if (yyerrstatus == 3)
980 /* If just tried and failed to reuse lookahead token after an
981 error, discard it. */
983 /* Return failure if at end of input. */
986 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
987 yychar, yytname[yychar1]));
991 /* Else will try to reuse lookahead token after shifting the error
994 yyerrstatus = 3; /* Each real token shifted decrements this. */
999 /*-------------------------------------------------------------------.
1000 | yyerrdefault -- current state does not do anything special for the |
1002 `-------------------------------------------------------------------*/
1005 /* This is wrong; only states that explicitly want error tokens
1006 should shift them. */
1008 /* If its default is to accept any token, ok. Otherwise pop it. */
1009 yyn = yydefact[yystate];
1015 /*---------------------------------------------------------------.
1016 | yyerrpop -- pop the current state because it cannot handle the |
1018 `---------------------------------------------------------------*/
1031 short *yyssp1 = yyss - 1;
1032 fprintf (stderr, "Error: state stack now");
1033 while (yyssp1 != yyssp)
1034 fprintf (stderr, " %d", *++yyssp1);
1035 fprintf (stderr, "\n");
1043 yyn = yypact[yystate];
1048 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1065 YYDPRINTF ((stderr, "Shifting error token, "));
1076 /*-------------------------------------.
1077 | yyacceptlab -- YYACCEPT comes here. |
1078 `-------------------------------------*/
1083 /*-----------------------------------.
1084 | yyabortlab -- YYABORT comes here. |
1085 `-----------------------------------*/
1090 /*---------------------------------------------.
1091 | yyoverflowab -- parser overflow comes here. |
1092 `---------------------------------------------*/
1094 yyerror ("parser stack overflow");
1101 YYSTACK_FREE (yyss);
1106 #line %%input-line "%%filename"