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 #if YYSTACK_USE_ALLOCA
102 # define YYSTACK_ALLOC alloca
104 # define YYSTACK_ALLOC malloc
107 #define YYBISON 1 /* Identify Bison output. */
108 #define YYPURE %%pure /* Identify pure parsers. */
111 # define YYDEBUG %%debug
114 #line %%input_line "%%filename"
116 typedef %%stype YYSTYPE;
120 typedef struct yyltype
127 # define YYLTYPE %%ltype
130 #ifndef YYERROR_VERBOSE
131 # define YYERROR_VERBOSE %%verbose
137 #define YYFINAL %%final
138 #define YYFLAG %%flag
139 #define YYNTBASE %%ntbase
140 #define YYLAST %%last
142 #define YYNTOKENS %%ntokens
143 #define YYNNTS %%nnts
144 #define YYNRULES %%nrules
145 #define YYNSTATES %%nstates
146 #define YYMAXUTOK %%maxtok
148 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
149 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
151 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
152 static const char yytranslate[] =
158 static const short yyprhs[] =
163 static const short yyrhs[] =
168 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
169 static const short yyrline[] =
175 #if YYDEBUG || YYERROR_VERBOSE
176 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
177 static const char *const yytname[] =
183 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
184 static const short yytoknum[] =
189 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
190 static const short yyr1[] =
195 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
196 static const short yyr2[] =
201 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
202 doesn't specify something else to do. Zero means the default is an
204 static const short yydefact[] =
209 static const short yydefgoto[] =
214 static const short yypact[] =
219 static const short yypgoto[] =
224 static const short yytable[] =
229 static const short yycheck[] =
234 #define yyerrok (yyerrstatus = 0)
235 #define yyclearin (yychar = YYEMPTY)
239 #define YYACCEPT goto yyacceptlab
240 #define YYABORT goto yyabortlab
241 #define YYERROR goto yyerrlab1
243 /* Like YYERROR except do call yyerror. This remains here temporarily
244 to ease the transition to the new meaning of YYERROR, for GCC.
245 Once GCC version 2 has supplanted version 1, this can go. */
247 #define YYFAIL goto yyerrlab
249 #define YYRECOVERING() (!!yyerrstatus)
251 #define YYBACKUP(Token, Value) \
253 if (yychar == YYEMPTY && yylen == 1) \
257 yychar1 = YYTRANSLATE (yychar); \
263 yyerror ("syntax error: cannot back up"); \
269 #define YYERRCODE 256
271 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
274 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
275 first token. By default, to implement support for ranges, extend
276 its range to the last symbol. */
278 #ifndef YYLLOC_DEFAULT
279 # define YYLLOC_DEFAULT(Current, Rhs, N) \
280 Current.last_line = Rhs[N].last_line; \
281 Current.last_column = Rhs[N].last_column;
284 /* Definition of YYLSP_NEEDED. */
285 #define YYLSP_NEEDED %%locations_flag
287 /* YYLEX -- calling `yylex' with the right arguments. */
292 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
294 # define YYLEX yylex (&yylval, &yylloc)
296 # else /* !YYLSP_NEEDED */
298 # define YYLEX yylex (&yylval, YYLEX_PARAM)
300 # define YYLEX yylex (&yylval)
302 # endif /* !YYLSP_NEEDED */
304 # define YYLEX yylex ()
307 /* Enable debugging if requested. */
309 # define YYDPRINTF(Args) \
314 /* Nonzero means print parse trace. [The following comment makes no
315 sense to me. Could someone clarify it? --akim] Since this is
316 uninitialized, it does not stop multiple parsers from coexisting.
320 # define YYDPRINTF(Args)
321 #endif /* !YYDEBUG */
323 /* YYINITDEPTH -- initial size of the parser's stacks. */
325 # define YYINITDEPTH %%initdepth
328 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
329 if the built-in stack extension method is used). */
335 # define YYMAXDEPTH %%maxdepth
340 /* Define __yy_memcpy. Note that the size argument
341 should be passed with type unsigned int, because that is what the non-GCC
342 definitions require. With GCC, __builtin_memcpy takes an arg
343 of type size_t, but it can handle unsigned int. */
345 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
346 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
347 #else /* not GNU C or C++ */
349 /* This is the most reliable way to avoid incompatibilities
350 in available built-in functions on various systems. */
353 __yy_memcpy (to, from, count)
357 # else /* __cplusplus */
358 __yy_memcpy (char *to, const char *from, unsigned int count)
361 register const char *f = from;
362 register char *t = to;
363 register int i = count;
372 #line %%line "%%skeleton"
374 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
375 into yyparse. The argument should have type void *.
376 It should actually point to an object.
377 Grammar actions can access the variable by casting it
378 to the proper pointer type. */
382 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
383 # define YYPARSE_PARAM_DECL
384 # else /* !__cplusplus */
385 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
386 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
387 # endif /* !__cplusplus */
388 #else /* !YYPARSE_PARAM */
389 # define YYPARSE_PARAM_ARG
390 # define YYPARSE_PARAM_DECL
391 #endif /* !YYPARSE_PARAM */
393 /* Prevent warning if -Wstrict-prototypes. */
395 # ifdef YYPARSE_PARAM
396 int yyparse (void *);
402 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
403 variables are global, or local to YYPARSE. */
405 #define _YY_DECL_VARIABLES \
406 /* The lookahead symbol. */ \
409 /* The semantic value of the lookahead symbol. */ \
412 /* Number of parse errors so far. */ \
416 # define YY_DECL_VARIABLES \
419 /* Location data for the lookahead symbol. */ \
422 # define YY_DECL_VARIABLES \
426 /* If nonreentrant, generate the variables here. */
433 yyparse (YYPARSE_PARAM_ARG)
436 /* If reentrant, generate the variables here. */
441 register int yystate;
443 /* Number of tokens to shift before error messages enabled. */
445 /* Lookahead token as an internal (translated) token number. */
448 /* Three stacks and their tools:
449 `yyss': related to states,
450 `yysv': related to semantic values,
451 `yyls': related to locations.
453 Refer to the stacks thru separate pointers, to allow yyoverflow
454 to reallocate them elsewhere. */
456 /* The state stack. */
457 short yyssa[YYINITDEPTH];
459 register short *yyssp;
461 /* The semantic value stack. */
462 YYSTYPE yyvsa[YYINITDEPTH];
463 YYSTYPE *yyvs = yyvsa;
464 register YYSTYPE *yyvsp;
467 /* The location stack. */
468 YYLTYPE yylsa[YYINITDEPTH];
469 YYLTYPE *yyls = yylsa;
474 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
476 # define YYPOPSTACK (yyvsp--, yyssp--)
479 int yystacksize = YYINITDEPTH;
480 int yyfree_stacks = 0;
482 /* The variables used to return semantic value and location from the
489 /* When reducing, the number of symbols on the RHS of the reduced
493 YYDPRINTF ((stderr, "Starting parse\n"));
498 yychar = YYEMPTY; /* Cause a token to be read. */
500 /* Initialize stack pointers.
501 Waste one element of value and location stack
502 so that they stay on the same level as the state stack.
503 The wasted elements are never initialized. */
512 /*------------------------------------------------------------.
513 | yynewstate -- Push a new state, which is found in yystate. |
514 `------------------------------------------------------------*/
516 /* In all cases, when you get here, the value and location stacks
517 have just been pushed. so pushing a state here evens the stacks.
524 if (yyssp >= yyss + yystacksize - 1)
526 /* Give user a chance to reallocate the stack. Use copies of
527 these so that the &'s don't force the real ones into memory.
529 YYSTYPE *yyvs1 = yyvs;
532 YYLTYPE *yyls1 = yyls;
535 /* Get the current used size of the three stacks, in elements. */
536 int size = yyssp - yyss + 1;
539 /* Each stack pointer address is followed by the size of the
540 data in use in that stack, in bytes. */
542 /* This used to be a conditional around just the two extra args,
543 but that might be undefined if yyoverflow is a macro. */
544 yyoverflow ("parser stack overflow",
545 &yyss1, size * sizeof (*yyssp),
546 &yyvs1, size * sizeof (*yyvsp),
547 &yyls1, size * sizeof (*yylsp),
550 yyoverflow ("parser stack overflow",
551 &yyss1, size * sizeof (*yyssp),
552 &yyvs1, size * sizeof (*yyvsp),
556 yyss = yyss1; yyvs = yyvs1;
560 #else /* no yyoverflow */
561 /* Extend the stack our own way. */
562 if (yystacksize >= YYMAXDEPTH)
564 yyerror ("parser stack overflow");
576 if (yystacksize > YYMAXDEPTH)
577 yystacksize = YYMAXDEPTH;
578 # if !YYSTACK_USE_ALLOCA
581 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
582 __yy_memcpy ((char *)yyss, (char *)yyss1,
583 size * (unsigned int) sizeof (*yyssp));
584 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
585 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
586 size * (unsigned int) sizeof (*yyvsp));
588 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
589 __yy_memcpy ((char *)yyls, (char *)yyls1,
590 size * (unsigned int) sizeof (*yylsp));
592 #endif /* no yyoverflow */
594 yyssp = yyss + size - 1;
595 yyvsp = yyvs + size - 1;
597 yylsp = yyls + size - 1;
600 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
602 if (yyssp >= yyss + yystacksize - 1)
606 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
615 /* Do appropriate processing given the current state. */
616 /* Read a lookahead token if we need one and don't already have one. */
619 /* First try to decide what to do without reference to lookahead token. */
621 yyn = yypact[yystate];
625 /* Not known => get a lookahead token if don't already have one. */
627 /* yychar is either YYEMPTY or YYEOF
628 or a valid token in external form. */
630 if (yychar == YYEMPTY)
632 YYDPRINTF ((stderr, "Reading a token: "));
636 /* Convert token to internal form (in yychar1) for indexing tables with. */
638 if (yychar <= 0) /* This means end of input. */
641 yychar = YYEOF; /* Don't call YYLEX any more. */
643 YYDPRINTF ((stderr, "Now at end of input.\n"));
647 yychar1 = YYTRANSLATE (yychar);
650 /* We have to keep this `#if YYDEBUG', since we use variables
651 which are defined only if `YYDEBUG' is set. */
654 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
655 /* Give the individual parser a way to print the precise
656 meaning of a token, for further debugging info. */
658 YYPRINT (stderr, yychar, yylval);
660 fprintf (stderr, ")\n");
666 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
671 /* yyn is what to do for this token type in this state.
672 Negative => reduce, -yyn is rule number.
673 Positive => shift, yyn is new state.
674 New state is final state => don't bother to shift,
676 0, or most negative number => error. */
691 /* Shift the lookahead token. */
692 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
694 /* Discard the token being shifted unless it is eof. */
703 /* Count tokens shifted since error; after three, turn off error
712 /*-----------------------------------------------------------.
713 | yydefault -- do the default action for the current state. |
714 `-----------------------------------------------------------*/
716 yyn = yydefact[yystate];
722 /*-----------------------------.
723 | yyreduce -- Do a reduction. |
724 `-----------------------------*/
726 /* yyn is the number of a rule to reduce with. */
729 /* If YYLEN is nonzero, implement the default value of the action:
732 Otherwise, the following line sets YYVAL to the semantic value of
733 the lookahead token. This behavior is undocumented and Bison
734 users should not rely upon it. Assigning to YYVAL
735 unconditionally makes the parser a bit smaller, and it avoids a
736 GCC warning that YYVAL may be used uninitialized. */
737 yyval = yyvsp[1-yylen];
740 /* Similarly for the default location. Let the user run additional
741 commands if for instance locations are ranges. */
742 yyloc = yylsp[1-yylen];
743 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
747 /* We have to keep this `#if YYDEBUG', since we use variables which
748 are defined only if `YYDEBUG' is set. */
753 fprintf (stderr, "Reducing via rule %d (line %d), ",
756 /* Print the symbols being reduced, and their result. */
757 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
758 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
759 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
766 #line %%line "%%skeleton"
777 short *ssp1 = yyss - 1;
778 fprintf (stderr, "state stack now");
779 while (ssp1 != yyssp)
780 fprintf (stderr, " %d", *++ssp1);
781 fprintf (stderr, "\n");
790 /* Now `shift' the result of the reduction. Determine what state
791 that goes to, based on the state we popped back to and the rule
792 number reduced by. */
796 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
797 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
798 yystate = yytable[yystate];
800 yystate = yydefgoto[yyn - YYNTBASE];
805 /*------------------------------------.
806 | yyerrlab -- here on detecting error |
807 `------------------------------------*/
809 /* If not already recovering from an error, report this error. */
815 yyn = yypact[yystate];
817 if (yyn > YYFLAG && yyn < YYLAST)
824 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
825 for (x = (yyn < 0 ? -yyn : 0);
826 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
827 if (yycheck[x + yyn] == x)
828 size += strlen (yytname[x]) + 15, count++;
829 size += strlen ("parse error, unexpected `") + 1;
830 size += strlen (yytname[YYTRANSLATE (yychar)]);
831 msg = (char *) malloc (size);
834 strcpy (msg, "parse error, unexpected `");
835 strcat (msg, yytname[YYTRANSLATE (yychar)]);
841 for (x = (yyn < 0 ? -yyn : 0);
842 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
843 if (yycheck[x + yyn] == x)
845 strcat (msg, count == 0 ? ", expecting `" : " or `");
846 strcat (msg, yytname[x]);
855 yyerror ("parse error; also virtual memory exceeded");
858 #endif /* YYERROR_VERBOSE */
859 yyerror ("parse error");
864 /*----------------------------------------------------.
865 | yyerrlab1 -- error raised explicitly by an action. |
866 `----------------------------------------------------*/
868 if (yyerrstatus == 3)
870 /* If just tried and failed to reuse lookahead token after an
871 error, discard it. */
873 /* Return failure if at end of input. */
876 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
877 yychar, yytname[yychar1]));
881 /* Else will try to reuse lookahead token after shifting the error
884 yyerrstatus = 3; /* Each real token shifted decrements this. */
889 /*-------------------------------------------------------------------.
890 | yyerrdefault -- current state does not do anything special for the |
892 `-------------------------------------------------------------------*/
895 /* This is wrong; only states that explicitly want error tokens
896 should shift them. */
898 /* If its default is to accept any token, ok. Otherwise pop it. */
899 yyn = yydefact[yystate];
905 /*---------------------------------------------------------------.
906 | yyerrpop -- pop the current state because it cannot handle the |
908 `---------------------------------------------------------------*/
921 short *ssp1 = yyss - 1;
922 fprintf (stderr, "Error: state stack now");
923 while (ssp1 != yyssp)
924 fprintf (stderr, " %d", *++ssp1);
925 fprintf (stderr, "\n");
933 yyn = yypact[yystate];
938 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
955 YYDPRINTF ((stderr, "Shifting error token, "));
966 /*-------------------------------------.
967 | yyacceptlab -- YYACCEPT comes here. |
968 `-------------------------------------*/
981 /*-----------------------------------.
982 | yyabortlab -- YYABORT comes here. |
983 `-----------------------------------*/
996 #line %%input_line "%%filename"