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 #if YYSTACK_USE_ALLOCA
106 # define YYSTACK_ALLOC alloca
107 # define YYSTACK_FREE(Ptr) /* empty */
109 # define YYSTACK_ALLOC malloc
110 # define YYSTACK_FREE(Ptr) free (Ptr)
113 /* A type that is properly aligned for any stack member. */
123 /* The size of the maximum gap between one aligned stack and the next. */
124 #define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
126 /* The size of an array large to enough to hold all stacks, each with
129 # define YYSTACK_BYTES(N) \
130 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
131 + 2 * YYSTACK_GAP_MAX)
133 # define YYSTACK_BYTES(N) \
134 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
138 /* Relocate the TYPE STACK from its old location to the new one. The
139 local variables SIZE and YYSTACKSIZE give the old and new number of
140 elements in the stack, and YYPTR gives the new location of the
141 stack. Advance YYPTR to a properly aligned location for the next
143 #define YYSTACK_RELOCATE(Type, Stack) \
147 __yy_memcpy (yyptr, (char *) (Stack), size * sizeof (Type)); \
148 (Stack) = (Type *) yyptr; \
149 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
150 yynewbytes -= yynewbytes % sizeof (union yyalloc); \
151 yyptr += yynewbytes; \
155 #define YYBISON 1 /* Identify Bison output. */
156 #define YYPURE %%pure /* Identify pure parsers. */
159 # define YYDEBUG %%debug
162 #line %%input-line "%%filename"
164 typedef %%stype yystype;
165 # define YYSTYPE yystype
169 typedef struct yyltype
176 # define YYLTYPE %%ltype
179 #ifdef YYERROR_VERBOSE
180 # undef YYERROR_VERBOSE
183 #define YYERROR_VERBOSE %%error-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[] =
285 #define yyerrok (yyerrstatus = 0)
286 #define yyclearin (yychar = YYEMPTY)
290 #define YYACCEPT goto yyacceptlab
291 #define YYABORT goto yyabortlab
292 #define YYERROR goto yyerrlab1
294 /* Like YYERROR except do call yyerror. This remains here temporarily
295 to ease the transition to the new meaning of YYERROR, for GCC.
296 Once GCC version 2 has supplanted version 1, this can go. */
298 #define YYFAIL goto yyerrlab
300 #define YYRECOVERING() (!!yyerrstatus)
302 #define YYBACKUP(Token, Value) \
304 if (yychar == YYEMPTY && yylen == 1) \
308 yychar1 = YYTRANSLATE (yychar); \
314 yyerror ("syntax error: cannot back up"); \
320 #define YYERRCODE 256
322 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
325 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
326 first token. By default, to implement support for ranges, extend
327 its range to the last symbol. */
329 #ifndef YYLLOC_DEFAULT
330 # define YYLLOC_DEFAULT(Current, Rhs, N) \
331 Current.last_line = Rhs[N].last_line; \
332 Current.last_column = Rhs[N].last_column;
335 /* Definition of YYLSP_NEEDED. */
336 #define YYLSP_NEEDED %%locations-flag
338 /* YYLEX -- calling `yylex' with the right arguments. */
343 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
345 # define YYLEX yylex (&yylval, &yylloc)
347 # else /* !YYLSP_NEEDED */
349 # define YYLEX yylex (&yylval, YYLEX_PARAM)
351 # define YYLEX yylex (&yylval)
353 # endif /* !YYLSP_NEEDED */
355 # define YYLEX yylex ()
358 /* Enable debugging if requested. */
360 # define YYDPRINTF(Args) \
365 /* Nonzero means print parse trace. [The following comment makes no
366 sense to me. Could someone clarify it? --akim] Since this is
367 uninitialized, it does not stop multiple parsers from coexisting.
371 # define YYDPRINTF(Args)
372 #endif /* !YYDEBUG */
374 /* YYINITDEPTH -- initial size of the parser's stacks. */
376 # define YYINITDEPTH %%initdepth
379 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
380 if the built-in stack extension method is used).
382 Do not make this value too large; the results are undefined if
383 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
384 evaluated with infinite-precision integer arithmetic. */
391 # define YYMAXDEPTH %%maxdepth
396 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
397 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
398 #else /* not GNU C or C++ */
400 /* This is the most reliable way to avoid incompatibilities
401 in available built-in functions on various systems. */
404 __yy_memcpy (to, from, count)
408 # else /* __cplusplus */
409 __yy_memcpy (char *to, const char *from, size_t count)
412 register const char *f = from;
413 register char *t = to;
414 register size_t i = count;
423 #line %%line "%%skeleton"
425 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
426 into yyparse. The argument should have type void *.
427 It should actually point to an object.
428 Grammar actions can access the variable by casting it
429 to the proper pointer type. */
433 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
434 # define YYPARSE_PARAM_DECL
435 # else /* !__cplusplus */
436 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
437 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
438 # endif /* !__cplusplus */
439 #else /* !YYPARSE_PARAM */
440 # define YYPARSE_PARAM_ARG
441 # define YYPARSE_PARAM_DECL
442 #endif /* !YYPARSE_PARAM */
444 /* Prevent warning if -Wstrict-prototypes. */
446 # ifdef YYPARSE_PARAM
447 int yyparse (void *);
453 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
454 variables are global, or local to YYPARSE. */
456 #define _YY_DECL_VARIABLES \
457 /* The lookahead symbol. */ \
460 /* The semantic value of the lookahead symbol. */ \
463 /* Number of parse errors so far. */ \
467 # define YY_DECL_VARIABLES \
470 /* Location data for the lookahead symbol. */ \
473 # define YY_DECL_VARIABLES \
477 /* If nonreentrant, generate the variables here. */
484 yyparse (YYPARSE_PARAM_ARG)
487 /* If reentrant, generate the variables here. */
492 register int yystate;
495 /* Number of tokens to shift before error messages enabled. */
497 /* Lookahead token as an internal (translated) token number. */
500 /* Three stacks and their tools:
501 `yyss': related to states,
502 `yyvs': related to semantic values,
503 `yyls': related to locations.
505 Refer to the stacks thru separate pointers, to allow yyoverflow
506 to reallocate them elsewhere. */
508 /* The state stack. */
509 short yyssa[YYINITDEPTH];
511 register short *yyssp;
513 /* The semantic value stack. */
514 YYSTYPE yyvsa[YYINITDEPTH];
515 YYSTYPE *yyvs = yyvsa;
516 register YYSTYPE *yyvsp;
519 /* The location stack. */
520 YYLTYPE yylsa[YYINITDEPTH];
521 YYLTYPE *yyls = yylsa;
526 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
528 # define YYPOPSTACK (yyvsp--, yyssp--)
531 size_t yystacksize = YYINITDEPTH;
533 /* The variables used to return semantic value and location from the
540 /* When reducing, the number of symbols on the RHS of the reduced
544 YYDPRINTF ((stderr, "Starting parse\n"));
549 yychar = YYEMPTY; /* Cause a token to be read. */
551 /* Initialize stack pointers.
552 Waste one element of value and location stack
553 so that they stay on the same level as the state stack.
554 The wasted elements are never initialized. */
563 /*------------------------------------------------------------.
564 | yynewstate -- Push a new state, which is found in yystate. |
565 `------------------------------------------------------------*/
567 /* In all cases, when you get here, the value and location stacks
568 have just been pushed. so pushing a state here evens the stacks.
575 if (yyssp >= yyss + yystacksize - 1)
577 /* Get the current used size of the three stacks, in elements. */
578 size_t size = yyssp - yyss + 1;
582 /* Give user a chance to reallocate the stack. Use copies of
583 these so that the &'s don't force the real ones into
585 YYSTYPE *yyvs1 = yyvs;
588 /* Each stack pointer address is followed by the size of the
589 data in use in that stack, in bytes. */
591 YYLTYPE *yyls1 = yyls;
592 /* This used to be a conditional around just the two extra args,
593 but that might be undefined if yyoverflow is a macro. */
594 yyoverflow ("parser stack overflow",
595 &yyss1, size * sizeof (*yyssp),
596 &yyvs1, size * sizeof (*yyvsp),
597 &yyls1, size * sizeof (*yylsp),
601 yyoverflow ("parser stack overflow",
602 &yyss1, size * sizeof (*yyssp),
603 &yyvs1, size * sizeof (*yyvsp),
609 #else /* no yyoverflow */
610 /* Extend the stack our own way. */
611 if (yystacksize >= YYMAXDEPTH)
614 if (yystacksize > YYMAXDEPTH)
615 yystacksize = YYMAXDEPTH;
619 char *yyptr = (char *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
622 YYSTACK_RELOCATE (short, yyss);
623 YYSTACK_RELOCATE (YYSTYPE, yyvs);
625 YYSTACK_RELOCATE (YYLTYPE, yyls);
627 # undef YYSTACK_RELOCATE
629 YYSTACK_FREE (yyss1);
631 #endif /* no yyoverflow */
633 yyssp = yyss + size - 1;
634 yyvsp = yyvs + size - 1;
636 yylsp = yyls + size - 1;
639 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
640 (unsigned long int) yystacksize));
642 if (yyssp >= yyss + yystacksize - 1)
646 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
655 /* Do appropriate processing given the current state. */
656 /* Read a lookahead token if we need one and don't already have one. */
659 /* First try to decide what to do without reference to lookahead token. */
661 yyn = yypact[yystate];
665 /* Not known => get a lookahead token if don't already have one. */
667 /* yychar is either YYEMPTY or YYEOF
668 or a valid token in external form. */
670 if (yychar == YYEMPTY)
672 YYDPRINTF ((stderr, "Reading a token: "));
676 /* Convert token to internal form (in yychar1) for indexing tables with. */
678 if (yychar <= 0) /* This means end of input. */
681 yychar = YYEOF; /* Don't call YYLEX any more. */
683 YYDPRINTF ((stderr, "Now at end of input.\n"));
687 yychar1 = YYTRANSLATE (yychar);
690 /* We have to keep this `#if YYDEBUG', since we use variables
691 which are defined only if `YYDEBUG' is set. */
694 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
695 /* Give the individual parser a way to print the precise
696 meaning of a token, for further debugging info. */
698 YYPRINT (stderr, yychar, yylval);
700 fprintf (stderr, ")\n");
706 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
711 /* yyn is what to do for this token type in this state.
712 Negative => reduce, -yyn is rule number.
713 Positive => shift, yyn is new state.
714 New state is final state => don't bother to shift,
716 0, or most negative number => error. */
731 /* Shift the lookahead token. */
732 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
734 /* Discard the token being shifted unless it is eof. */
743 /* Count tokens shifted since error; after three, turn off error
752 /*-----------------------------------------------------------.
753 | yydefault -- do the default action for the current state. |
754 `-----------------------------------------------------------*/
756 yyn = yydefact[yystate];
762 /*-----------------------------.
763 | yyreduce -- Do a reduction. |
764 `-----------------------------*/
766 /* yyn is the number of a rule to reduce with. */
769 /* If YYLEN is nonzero, implement the default value of the action:
772 Otherwise, the following line sets YYVAL to the semantic value of
773 the lookahead token. This behavior is undocumented and Bison
774 users should not rely upon it. Assigning to YYVAL
775 unconditionally makes the parser a bit smaller, and it avoids a
776 GCC warning that YYVAL may be used uninitialized. */
777 yyval = yyvsp[1-yylen];
780 /* Similarly for the default location. Let the user run additional
781 commands if for instance locations are ranges. */
782 yyloc = yylsp[1-yylen];
783 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
787 /* We have to keep this `#if YYDEBUG', since we use variables which
788 are defined only if `YYDEBUG' is set. */
793 fprintf (stderr, "Reducing via rule %d (line %d), ",
796 /* Print the symbols being reduced, and their result. */
797 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
798 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
799 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
806 #line %%line "%%skeleton"
817 short *ssp1 = yyss - 1;
818 fprintf (stderr, "state stack now");
819 while (ssp1 != yyssp)
820 fprintf (stderr, " %d", *++ssp1);
821 fprintf (stderr, "\n");
830 /* Now `shift' the result of the reduction. Determine what state
831 that goes to, based on the state we popped back to and the rule
832 number reduced by. */
836 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
837 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
838 yystate = yytable[yystate];
840 yystate = yydefgoto[yyn - YYNTBASE];
845 /*------------------------------------.
846 | yyerrlab -- here on detecting error |
847 `------------------------------------*/
849 /* If not already recovering from an error, report this error. */
855 yyn = yypact[yystate];
857 if (yyn > YYFLAG && yyn < YYLAST)
864 /* Start X at -YYN if negative to avoid negative indexes in
866 for (x = yyn < 0 ? -yyn : 0;
867 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
868 if (yycheck[x + yyn] == x)
869 size += strlen (yytname[x]) + 15, count++;
870 size += strlen ("parse error, unexpected ") + 1;
871 size += strlen (yytname[YYTRANSLATE (yychar)]);
872 msg = (char *) malloc (size);
875 strcpy (msg, "parse error, unexpected ");
876 strcat (msg, yytname[YYTRANSLATE (yychar)]);
881 for (x = yyn < 0 ? -yyn : 0;
882 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
883 if (yycheck[x + yyn] == x)
885 strcat (msg, count == 0 ? ", expecting " : " or ");
886 strcat (msg, yytname[x]);
894 yyerror ("parse error; also virtual memory exhausted");
897 #endif /* YYERROR_VERBOSE */
898 yyerror ("parse error");
903 /*----------------------------------------------------.
904 | yyerrlab1 -- error raised explicitly by an action. |
905 `----------------------------------------------------*/
907 if (yyerrstatus == 3)
909 /* If just tried and failed to reuse lookahead token after an
910 error, discard it. */
912 /* Return failure if at end of input. */
915 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
916 yychar, yytname[yychar1]));
920 /* Else will try to reuse lookahead token after shifting the error
923 yyerrstatus = 3; /* Each real token shifted decrements this. */
928 /*-------------------------------------------------------------------.
929 | yyerrdefault -- current state does not do anything special for the |
931 `-------------------------------------------------------------------*/
934 /* This is wrong; only states that explicitly want error tokens
935 should shift them. */
937 /* If its default is to accept any token, ok. Otherwise pop it. */
938 yyn = yydefact[yystate];
944 /*---------------------------------------------------------------.
945 | yyerrpop -- pop the current state because it cannot handle the |
947 `---------------------------------------------------------------*/
960 short *ssp1 = yyss - 1;
961 fprintf (stderr, "Error: state stack now");
962 while (ssp1 != yyssp)
963 fprintf (stderr, " %d", *++ssp1);
964 fprintf (stderr, "\n");
972 yyn = yypact[yystate];
977 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
994 YYDPRINTF ((stderr, "Shifting error token, "));
1005 /*-------------------------------------.
1006 | yyacceptlab -- YYACCEPT comes here. |
1007 `-------------------------------------*/
1012 /*-----------------------------------.
1013 | yyabortlab -- YYABORT comes here. |
1014 `-----------------------------------*/
1019 /*---------------------------------------------.
1020 | yyoverflowab -- parser overflow comes here. |
1021 `---------------------------------------------*/
1023 yyerror ("parser stack overflow");
1030 YYSTACK_FREE (yyss);
1035 #line %%input-line "%%filename"