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. */
36 /* If name_prefix is specify substitute the variables and functions
38 #define yyparse %%prefix##parse
39 #define yylex %%prefix##lex
40 #define yyerror %%prefix##error
41 #define yylval %%prefix##lval
42 #define yychar %%prefix##char
43 #define yydebug %%prefix##debug
44 #define yynerrs %%prefix##nerrs
46 /* Copy the user declarations. */
47 #line %%input-line "%%filename"
50 #line %%line "%%skeleton"
57 #ifndef YYSTACK_USE_ALLOCA
59 # define YYSTACK_USE_ALLOCA 1
60 # else /* alloca not defined */
62 # define YYSTACK_USE_ALLOCA 1
63 # define alloca __builtin_alloca
64 # else /* not GNU C. */
65 # if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
66 # define YYSTACK_USE_ALLOCA 1
68 # else /* not sparc */
69 /* We think this test detects Watcom and Microsoft C. */
70 /* This used to test MSDOS, but that is a bad idea since that
71 symbol is in the user namespace. */
72 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
74 /* No need for malloc.h, which pollutes the namespace; instead,
75 just don't use alloca. */
78 # else /* not MSDOS, or __TURBOC__ */
80 /* I don't know what this was needed for, but it pollutes the
81 namespace. So I turned it off. rms, 2 May 1997. */
82 /* #include <malloc.h> */
84 # define YYSTACK_USE_ALLOCA 1
85 # else /* not MSDOS, or __TURBOC__, or _AIX */
87 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
88 HPUX 10. Eventually we can turn this on. */
90 # define YYSTACK_USE_ALLOCA 1
91 # define alloca __builtin_alloca
94 # endif /* not _AIX */
95 # endif /* not MSDOS, or __TURBOC__ */
96 # endif /* not sparc */
97 # endif /* not GNU C */
98 # endif /* alloca not defined */
99 #endif /* YYSTACK_USE_ALLOCA not defined */
101 #ifndef YYSTACK_USE_ALLOCA
102 # define YYSTACK_USE_ALLOCA 0
105 /* Realloc WHAT from SIZE to YYSTACKSIZE elements of TYPE.
106 If WHAT was malloc'ed (not the original automatic ARRAY), free it. */
107 #if YYSTACK_USE_ALLOCA
108 # define YYSTACK_REALLOC(Type, What, Array) \
111 What = (Type *) alloca (yystacksize * sizeof (Type)); \
112 __yy_memcpy ((char *) What, (char *) old, \
113 (size) * (unsigned int) sizeof (Type)); \
116 # define YYSTACK_REALLOC(Type, What, Array) \
119 What = (Type *) malloc (yystacksize * sizeof (Type)); \
120 __yy_memcpy ((char *) What, (char *) old, \
121 (size) * (unsigned int) sizeof (Type)); \
128 #define YYBISON 1 /* Identify Bison output. */
129 #define YYPURE %%pure /* Identify pure parsers. */
132 # define YYDEBUG %%debug
135 #line %%input-line "%%filename"
137 typedef %%stype yystype;
138 # define YYSTYPE yystype
142 typedef struct yyltype
149 # define YYLTYPE %%ltype
152 #ifdef YYERROR_VERBOSE
153 # undef YYERROR_VERBOSE
156 #define YYERROR_VERBOSE %%error-verbose
161 #define YYFINAL %%final
162 #define YYFLAG %%flag
163 #define YYNTBASE %%ntbase
164 #define YYLAST %%last
166 #define YYNTOKENS %%ntokens
167 #define YYNNTS %%nnts
168 #define YYNRULES %%nrules
169 #define YYNSTATES %%nstates
170 #define YYMAXUTOK %%maxtok
172 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
173 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
175 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
176 static const char yytranslate[] =
182 static const short yyprhs[] =
187 static const short yyrhs[] =
192 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
193 static const short yyrline[] =
199 #if YYDEBUG || YYERROR_VERBOSE
200 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
201 static const char *const yytname[] =
207 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
208 static const short yytoknum[] =
213 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
214 static const short yyr1[] =
219 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
220 static const short yyr2[] =
225 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
226 doesn't specify something else to do. Zero means the default is an
228 static const short yydefact[] =
233 static const short yydefgoto[] =
238 static const short yypact[] =
243 static const short yypgoto[] =
248 static const short yytable[] =
253 static const short yycheck[] =
258 #define yyerrok (yyerrstatus = 0)
259 #define yyclearin (yychar = YYEMPTY)
263 #define YYACCEPT goto yyacceptlab
264 #define YYABORT goto yyabortlab
265 #define YYERROR goto yyerrlab1
267 /* Like YYERROR except do call yyerror. This remains here temporarily
268 to ease the transition to the new meaning of YYERROR, for GCC.
269 Once GCC version 2 has supplanted version 1, this can go. */
271 #define YYFAIL goto yyerrlab
273 #define YYRECOVERING() (!!yyerrstatus)
275 #define YYBACKUP(Token, Value) \
277 if (yychar == YYEMPTY && yylen == 1) \
281 yychar1 = YYTRANSLATE (yychar); \
287 yyerror ("syntax error: cannot back up"); \
293 #define YYERRCODE 256
295 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
298 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
299 first token. By default, to implement support for ranges, extend
300 its range to the last symbol. */
302 #ifndef YYLLOC_DEFAULT
303 # define YYLLOC_DEFAULT(Current, Rhs, N) \
304 Current.last_line = Rhs[N].last_line; \
305 Current.last_column = Rhs[N].last_column;
308 /* Definition of YYLSP_NEEDED. */
309 #define YYLSP_NEEDED %%locations-flag
311 /* YYLEX -- calling `yylex' with the right arguments. */
316 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
318 # define YYLEX yylex (&yylval, &yylloc)
320 # else /* !YYLSP_NEEDED */
322 # define YYLEX yylex (&yylval, YYLEX_PARAM)
324 # define YYLEX yylex (&yylval)
326 # endif /* !YYLSP_NEEDED */
328 # define YYLEX yylex ()
331 /* Enable debugging if requested. */
333 # define YYDPRINTF(Args) \
338 /* Nonzero means print parse trace. [The following comment makes no
339 sense to me. Could someone clarify it? --akim] Since this is
340 uninitialized, it does not stop multiple parsers from coexisting.
344 # define YYDPRINTF(Args)
345 #endif /* !YYDEBUG */
347 /* YYINITDEPTH -- initial size of the parser's stacks. */
349 # define YYINITDEPTH %%initdepth
352 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
353 if the built-in stack extension method is used). */
359 # define YYMAXDEPTH %%maxdepth
364 /* Define __yy_memcpy. Note that the size argument
365 should be passed with type unsigned int, because that is what the non-GCC
366 definitions require. With GCC, __builtin_memcpy takes an arg
367 of type size_t, but it can handle unsigned int. */
369 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
370 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
371 #else /* not GNU C or C++ */
373 /* This is the most reliable way to avoid incompatibilities
374 in available built-in functions on various systems. */
377 __yy_memcpy (to, from, count)
381 # else /* __cplusplus */
382 __yy_memcpy (char *to, const char *from, unsigned int count)
385 register const char *f = from;
386 register char *t = to;
387 register int i = count;
396 #line %%line "%%skeleton"
398 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
399 into yyparse. The argument should have type void *.
400 It should actually point to an object.
401 Grammar actions can access the variable by casting it
402 to the proper pointer type. */
406 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
407 # define YYPARSE_PARAM_DECL
408 # else /* !__cplusplus */
409 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
410 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
411 # endif /* !__cplusplus */
412 #else /* !YYPARSE_PARAM */
413 # define YYPARSE_PARAM_ARG
414 # define YYPARSE_PARAM_DECL
415 #endif /* !YYPARSE_PARAM */
417 /* Prevent warning if -Wstrict-prototypes. */
419 # ifdef YYPARSE_PARAM
420 int yyparse (void *);
426 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
427 variables are global, or local to YYPARSE. */
429 #define _YY_DECL_VARIABLES \
430 /* The lookahead symbol. */ \
433 /* The semantic value of the lookahead symbol. */ \
436 /* Number of parse errors so far. */ \
440 # define YY_DECL_VARIABLES \
443 /* Location data for the lookahead symbol. */ \
446 # define YY_DECL_VARIABLES \
450 /* If nonreentrant, generate the variables here. */
457 yyparse (YYPARSE_PARAM_ARG)
460 /* If reentrant, generate the variables here. */
465 register int yystate;
467 /* Number of tokens to shift before error messages enabled. */
469 /* Lookahead token as an internal (translated) token number. */
472 /* Three stacks and their tools:
473 `yyss': related to states,
474 `yyvs': related to semantic values,
475 `yyls': related to locations.
477 Refer to the stacks thru separate pointers, to allow yyoverflow
478 to reallocate them elsewhere. */
480 /* The state stack. */
481 short yyssa[YYINITDEPTH];
483 register short *yyssp;
485 /* The semantic value stack. */
486 YYSTYPE yyvsa[YYINITDEPTH];
487 YYSTYPE *yyvs = yyvsa;
488 register YYSTYPE *yyvsp;
491 /* The location stack. */
492 YYLTYPE yylsa[YYINITDEPTH];
493 YYLTYPE *yyls = yylsa;
498 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
500 # define YYPOPSTACK (yyvsp--, yyssp--)
503 int yystacksize = YYINITDEPTH;
504 int yyfree_stacks = 0;
506 /* The variables used to return semantic value and location from the
513 /* When reducing, the number of symbols on the RHS of the reduced
517 YYDPRINTF ((stderr, "Starting parse\n"));
522 yychar = YYEMPTY; /* Cause a token to be read. */
524 /* Initialize stack pointers.
525 Waste one element of value and location stack
526 so that they stay on the same level as the state stack.
527 The wasted elements are never initialized. */
536 /*------------------------------------------------------------.
537 | yynewstate -- Push a new state, which is found in yystate. |
538 `------------------------------------------------------------*/
540 /* In all cases, when you get here, the value and location stacks
541 have just been pushed. so pushing a state here evens the stacks.
548 if (yyssp >= yyss + yystacksize - 1)
550 /* Get the current used size of the three stacks, in elements. */
551 int size = yyssp - yyss + 1;
555 /* Give user a chance to reallocate the stack. Use copies of
556 these so that the &'s don't force the real ones into
558 YYSTYPE *yyvs1 = yyvs;
561 /* Each stack pointer address is followed by the size of the
562 data in use in that stack, in bytes. */
564 YYLTYPE *yyls1 = yyls;
565 /* This used to be a conditional around just the two extra args,
566 but that might be undefined if yyoverflow is a macro. */
567 yyoverflow ("parser stack overflow",
568 &yyss1, size * sizeof (*yyssp),
569 &yyvs1, size * sizeof (*yyvsp),
570 &yyls1, size * sizeof (*yylsp),
574 yyoverflow ("parser stack overflow",
575 &yyss1, size * sizeof (*yyssp),
576 &yyvs1, size * sizeof (*yyvsp),
582 #else /* no yyoverflow */
583 /* Extend the stack our own way. */
584 if (yystacksize >= YYMAXDEPTH)
586 yyerror ("parser stack overflow");
598 if (yystacksize > YYMAXDEPTH)
599 yystacksize = YYMAXDEPTH;
601 YYSTACK_REALLOC (short, yyss, yyssa);
602 YYSTACK_REALLOC (YYSTYPE, yyvs, yyvsa);
604 YYSTACK_REALLOC (YYLTYPE, yyls, yylsa);
606 #endif /* no yyoverflow */
608 yyssp = yyss + size - 1;
609 yyvsp = yyvs + size - 1;
611 yylsp = yyls + size - 1;
614 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
616 if (yyssp >= yyss + yystacksize - 1)
620 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
629 /* Do appropriate processing given the current state. */
630 /* Read a lookahead token if we need one and don't already have one. */
633 /* First try to decide what to do without reference to lookahead token. */
635 yyn = yypact[yystate];
639 /* Not known => get a lookahead token if don't already have one. */
641 /* yychar is either YYEMPTY or YYEOF
642 or a valid token in external form. */
644 if (yychar == YYEMPTY)
646 YYDPRINTF ((stderr, "Reading a token: "));
650 /* Convert token to internal form (in yychar1) for indexing tables with. */
652 if (yychar <= 0) /* This means end of input. */
655 yychar = YYEOF; /* Don't call YYLEX any more. */
657 YYDPRINTF ((stderr, "Now at end of input.\n"));
661 yychar1 = YYTRANSLATE (yychar);
664 /* We have to keep this `#if YYDEBUG', since we use variables
665 which are defined only if `YYDEBUG' is set. */
668 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
669 /* Give the individual parser a way to print the precise
670 meaning of a token, for further debugging info. */
672 YYPRINT (stderr, yychar, yylval);
674 fprintf (stderr, ")\n");
680 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
685 /* yyn is what to do for this token type in this state.
686 Negative => reduce, -yyn is rule number.
687 Positive => shift, yyn is new state.
688 New state is final state => don't bother to shift,
690 0, or most negative number => error. */
705 /* Shift the lookahead token. */
706 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
708 /* Discard the token being shifted unless it is eof. */
717 /* Count tokens shifted since error; after three, turn off error
726 /*-----------------------------------------------------------.
727 | yydefault -- do the default action for the current state. |
728 `-----------------------------------------------------------*/
730 yyn = yydefact[yystate];
736 /*-----------------------------.
737 | yyreduce -- Do a reduction. |
738 `-----------------------------*/
740 /* yyn is the number of a rule to reduce with. */
743 /* If YYLEN is nonzero, implement the default value of the action:
746 Otherwise, the following line sets YYVAL to the semantic value of
747 the lookahead token. This behavior is undocumented and Bison
748 users should not rely upon it. Assigning to YYVAL
749 unconditionally makes the parser a bit smaller, and it avoids a
750 GCC warning that YYVAL may be used uninitialized. */
751 yyval = yyvsp[1-yylen];
754 /* Similarly for the default location. Let the user run additional
755 commands if for instance locations are ranges. */
756 yyloc = yylsp[1-yylen];
757 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
761 /* We have to keep this `#if YYDEBUG', since we use variables which
762 are defined only if `YYDEBUG' is set. */
767 fprintf (stderr, "Reducing via rule %d (line %d), ",
770 /* Print the symbols being reduced, and their result. */
771 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
772 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
773 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
780 #line %%line "%%skeleton"
791 short *ssp1 = yyss - 1;
792 fprintf (stderr, "state stack now");
793 while (ssp1 != yyssp)
794 fprintf (stderr, " %d", *++ssp1);
795 fprintf (stderr, "\n");
804 /* Now `shift' the result of the reduction. Determine what state
805 that goes to, based on the state we popped back to and the rule
806 number reduced by. */
810 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
811 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
812 yystate = yytable[yystate];
814 yystate = yydefgoto[yyn - YYNTBASE];
819 /*------------------------------------.
820 | yyerrlab -- here on detecting error |
821 `------------------------------------*/
823 /* If not already recovering from an error, report this error. */
829 yyn = yypact[yystate];
831 if (yyn > YYFLAG && yyn < YYLAST)
838 /* Start X at -YYN if negative to avoid negative indexes in
840 for (x = yyn < 0 ? -yyn : 0;
841 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
842 if (yycheck[x + yyn] == x)
843 size += strlen (yytname[x]) + 15, count++;
844 size += strlen ("parse error, unexpected ") + 1;
845 size += strlen (yytname[YYTRANSLATE (yychar)]);
846 msg = (char *) malloc (size);
849 strcpy (msg, "parse error, unexpected ");
850 strcat (msg, yytname[YYTRANSLATE (yychar)]);
855 for (x = yyn < 0 ? -yyn : 0;
856 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
857 if (yycheck[x + yyn] == x)
859 strcat (msg, count == 0 ? ", expecting " : " or ");
860 strcat (msg, yytname[x]);
868 yyerror ("parse error; also virtual memory exhausted");
871 #endif /* YYERROR_VERBOSE */
872 yyerror ("parse error");
877 /*----------------------------------------------------.
878 | yyerrlab1 -- error raised explicitly by an action. |
879 `----------------------------------------------------*/
881 if (yyerrstatus == 3)
883 /* If just tried and failed to reuse lookahead token after an
884 error, discard it. */
886 /* Return failure if at end of input. */
889 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
890 yychar, yytname[yychar1]));
894 /* Else will try to reuse lookahead token after shifting the error
897 yyerrstatus = 3; /* Each real token shifted decrements this. */
902 /*-------------------------------------------------------------------.
903 | yyerrdefault -- current state does not do anything special for the |
905 `-------------------------------------------------------------------*/
908 /* This is wrong; only states that explicitly want error tokens
909 should shift them. */
911 /* If its default is to accept any token, ok. Otherwise pop it. */
912 yyn = yydefact[yystate];
918 /*---------------------------------------------------------------.
919 | yyerrpop -- pop the current state because it cannot handle the |
921 `---------------------------------------------------------------*/
934 short *ssp1 = yyss - 1;
935 fprintf (stderr, "Error: state stack now");
936 while (ssp1 != yyssp)
937 fprintf (stderr, " %d", *++ssp1);
938 fprintf (stderr, "\n");
946 yyn = yypact[yystate];
951 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
968 YYDPRINTF ((stderr, "Shifting error token, "));
979 /*-------------------------------------.
980 | yyacceptlab -- YYACCEPT comes here. |
981 `-------------------------------------*/
994 /*-----------------------------------.
995 | yyabortlab -- YYABORT comes here. |
996 `-----------------------------------*/
1009 #line %%input-line "%%filename"