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
155 #define YYFINAL %%final
156 #define YYFLAG %%flag
157 #define YYNTBASE %%ntbase
158 #define YYLAST %%last
160 #define YYNTOKENS %%ntokens
161 #define YYNNTS %%nnts
162 #define YYNRULES %%nrules
163 #define YYNSTATES %%nstates
164 #define YYMAXUTOK %%maxtok
166 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
167 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
169 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
170 static const char yytranslate[] =
176 static const short yyprhs[] =
181 static const short yyrhs[] =
186 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
187 static const short yyrline[] =
194 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
195 static const char *const yytname[] =
201 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
202 static const short yytoknum[] =
207 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
208 static const short yyr1[] =
213 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
214 static const short yyr2[] =
219 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
220 doesn't specify something else to do. Zero means the default is an
222 static const short yydefact[] =
227 static const short yydefgoto[] =
232 static const short yypact[] =
237 static const short yypgoto[] =
242 static const short yytable[] =
247 static const short yycheck[] =
252 #define yyerrok (yyerrstatus = 0)
253 #define yyclearin (yychar = YYEMPTY)
257 #define YYACCEPT goto yyacceptlab
258 #define YYABORT goto yyabortlab
259 #define YYERROR goto yyerrlab1
261 /* Like YYERROR except do call yyerror. This remains here temporarily
262 to ease the transition to the new meaning of YYERROR, for GCC.
263 Once GCC version 2 has supplanted version 1, this can go. */
265 #define YYFAIL goto yyerrlab
267 #define YYRECOVERING() (!!yyerrstatus)
269 #define YYBACKUP(Token, Value) \
271 if (yychar == YYEMPTY && yylen == 1) \
275 yychar1 = YYTRANSLATE (yychar); \
281 yyerror ("syntax error: cannot back up"); \
287 #define YYERRCODE 256
289 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
292 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
293 first token. By default, to implement support for ranges, extend
294 its range to the last symbol. */
296 #ifndef YYLLOC_DEFAULT
297 # define YYLLOC_DEFAULT(Current, Rhs, N) \
298 Current.last_line = Rhs[N].last_line; \
299 Current.last_column = Rhs[N].last_column;
302 /* Definition of YYLSP_NEEDED. */
303 #define YYLSP_NEEDED %%locations_flag
305 /* YYLEX -- calling `yylex' with the right arguments. */
310 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
312 # define YYLEX yylex (&yylval, &yylloc)
314 # else /* !YYLSP_NEEDED */
316 # define YYLEX yylex (&yylval, YYLEX_PARAM)
318 # define YYLEX yylex (&yylval)
320 # endif /* !YYLSP_NEEDED */
322 # define YYLEX yylex ()
325 /* Enable debugging if requested. */
327 # define YYDPRINTF(Args) \
332 /* Nonzero means print parse trace. [The following comment makes no
333 sense to me. Could someone clarify it? --akim] Since this is
334 uninitialized, it does not stop multiple parsers from coexisting.
338 # define YYDPRINTF(Args)
339 #endif /* !YYDEBUG */
341 /* YYINITDEPTH -- initial size of the parser's stacks. */
343 # define YYINITDEPTH %%initdepth
346 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
347 if the built-in stack extension method is used). */
353 # define YYMAXDEPTH %%maxdepth
358 /* Define __yy_memcpy. Note that the size argument
359 should be passed with type unsigned int, because that is what the non-GCC
360 definitions require. With GCC, __builtin_memcpy takes an arg
361 of type size_t, but it can handle unsigned int. */
363 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
364 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
365 #else /* not GNU C or C++ */
367 /* This is the most reliable way to avoid incompatibilities
368 in available built-in functions on various systems. */
371 __yy_memcpy (to, from, count)
375 # else /* __cplusplus */
376 __yy_memcpy (char *to, const char *from, unsigned int count)
379 register const char *f = from;
380 register char *t = to;
381 register int i = count;
390 #line %%line "%%skeleton"
392 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
393 into yyparse. The argument should have type void *.
394 It should actually point to an object.
395 Grammar actions can access the variable by casting it
396 to the proper pointer type. */
400 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
401 # define YYPARSE_PARAM_DECL
402 # else /* !__cplusplus */
403 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
404 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
405 # endif /* !__cplusplus */
406 #else /* !YYPARSE_PARAM */
407 # define YYPARSE_PARAM_ARG
408 # define YYPARSE_PARAM_DECL
409 #endif /* !YYPARSE_PARAM */
411 /* Prevent warning if -Wstrict-prototypes. */
413 # ifdef YYPARSE_PARAM
414 int yyparse (void *);
420 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
421 variables are global, or local to YYPARSE. */
423 #define _YY_DECL_VARIABLES \
424 /* The lookahead symbol. */ \
427 /* The semantic value of the lookahead symbol. */ \
430 /* Number of parse errors so far. */ \
434 # define YY_DECL_VARIABLES \
437 /* Location data for the lookahead symbol. */ \
440 # define YY_DECL_VARIABLES \
444 /* If nonreentrant, generate the variables here. */
451 yyparse (YYPARSE_PARAM_ARG)
454 /* If reentrant, generate the variables here. */
459 register int yystate;
461 /* Number of tokens to shift before error messages enabled. */
463 /* Lookahead token as an internal (translated) token number. */
466 /* Three stacks and their tools:
467 `yyss': related to states,
468 `yyvs': related to semantic values,
469 `yyls': related to locations.
471 Refer to the stacks thru separate pointers, to allow yyoverflow
472 to reallocate them elsewhere. */
474 /* The state stack. */
475 short yyssa[YYINITDEPTH];
477 register short *yyssp;
479 /* The semantic value stack. */
480 YYSTYPE yyvsa[YYINITDEPTH];
481 YYSTYPE *yyvs = yyvsa;
482 register YYSTYPE *yyvsp;
485 /* The location stack. */
486 YYLTYPE yylsa[YYINITDEPTH];
487 YYLTYPE *yyls = yylsa;
492 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
494 # define YYPOPSTACK (yyvsp--, yyssp--)
497 int yystacksize = YYINITDEPTH;
498 int yyfree_stacks = 0;
500 /* The variables used to return semantic value and location from the
507 /* When reducing, the number of symbols on the RHS of the reduced
511 YYDPRINTF ((stderr, "Starting parse\n"));
516 yychar = YYEMPTY; /* Cause a token to be read. */
518 /* Initialize stack pointers.
519 Waste one element of value and location stack
520 so that they stay on the same level as the state stack.
521 The wasted elements are never initialized. */
530 /*------------------------------------------------------------.
531 | yynewstate -- Push a new state, which is found in yystate. |
532 `------------------------------------------------------------*/
534 /* In all cases, when you get here, the value and location stacks
535 have just been pushed. so pushing a state here evens the stacks.
542 if (yyssp >= yyss + yystacksize - 1)
544 /* Get the current used size of the three stacks, in elements. */
545 int size = yyssp - yyss + 1;
549 /* Give user a chance to reallocate the stack. Use copies of
550 these so that the &'s don't force the real ones into
552 YYSTYPE *yyvs1 = yyvs;
555 /* Each stack pointer address is followed by the size of the
556 data in use in that stack, in bytes. */
558 YYLTYPE *yyls1 = yyls;
559 /* This used to be a conditional around just the two extra args,
560 but that might be undefined if yyoverflow is a macro. */
561 yyoverflow ("parser stack overflow",
562 &yyss1, size * sizeof (*yyssp),
563 &yyvs1, size * sizeof (*yyvsp),
564 &yyls1, size * sizeof (*yylsp),
568 yyoverflow ("parser stack overflow",
569 &yyss1, size * sizeof (*yyssp),
570 &yyvs1, size * sizeof (*yyvsp),
576 #else /* no yyoverflow */
577 /* Extend the stack our own way. */
578 if (yystacksize >= YYMAXDEPTH)
580 yyerror ("parser stack overflow");
592 if (yystacksize > YYMAXDEPTH)
593 yystacksize = YYMAXDEPTH;
595 YYSTACK_REALLOC (short, yyss, yyssa);
596 YYSTACK_REALLOC (YYSTYPE, yyvs, yyvsa);
598 YYSTACK_REALLOC (YYLTYPE, yyls, yylsa);
600 #endif /* no yyoverflow */
602 yyssp = yyss + size - 1;
603 yyvsp = yyvs + size - 1;
605 yylsp = yyls + size - 1;
608 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
610 if (yyssp >= yyss + yystacksize - 1)
614 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
623 /* Do appropriate processing given the current state. */
624 /* Read a lookahead token if we need one and don't already have one. */
627 /* First try to decide what to do without reference to lookahead token. */
629 yyn = yypact[yystate];
633 /* Not known => get a lookahead token if don't already have one. */
635 /* yychar is either YYEMPTY or YYEOF
636 or a valid token in external form. */
638 if (yychar == YYEMPTY)
640 YYDPRINTF ((stderr, "Reading a token: "));
644 /* Convert token to internal form (in yychar1) for indexing tables with. */
646 if (yychar <= 0) /* This means end of input. */
649 yychar = YYEOF; /* Don't call YYLEX any more. */
651 YYDPRINTF ((stderr, "Now at end of input.\n"));
655 yychar1 = YYTRANSLATE (yychar);
658 /* We have to keep this `#if YYDEBUG', since we use variables
659 which are defined only if `YYDEBUG' is set. */
662 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
663 /* Give the individual parser a way to print the precise
664 meaning of a token, for further debugging info. */
666 YYPRINT (stderr, yychar, yylval);
668 fprintf (stderr, ")\n");
674 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
679 /* yyn is what to do for this token type in this state.
680 Negative => reduce, -yyn is rule number.
681 Positive => shift, yyn is new state.
682 New state is final state => don't bother to shift,
684 0, or most negative number => error. */
699 /* Shift the lookahead token. */
700 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
702 /* Discard the token being shifted unless it is eof. */
711 /* Count tokens shifted since error; after three, turn off error
720 /*-----------------------------------------------------------.
721 | yydefault -- do the default action for the current state. |
722 `-----------------------------------------------------------*/
724 yyn = yydefact[yystate];
730 /*-----------------------------.
731 | yyreduce -- Do a reduction. |
732 `-----------------------------*/
734 /* yyn is the number of a rule to reduce with. */
737 /* If YYLEN is nonzero, implement the default value of the action:
740 Otherwise, the following line sets YYVAL to the semantic value of
741 the lookahead token. This behavior is undocumented and Bison
742 users should not rely upon it. Assigning to YYVAL
743 unconditionally makes the parser a bit smaller, and it avoids a
744 GCC warning that YYVAL may be used uninitialized. */
745 yyval = yyvsp[1-yylen];
748 /* Similarly for the default location. Let the user run additional
749 commands if for instance locations are ranges. */
750 yyloc = yylsp[1-yylen];
751 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
755 /* We have to keep this `#if YYDEBUG', since we use variables which
756 are defined only if `YYDEBUG' is set. */
761 fprintf (stderr, "Reducing via rule %d (line %d), ",
764 /* Print the symbols being reduced, and their result. */
765 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
766 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
767 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
774 #line %%line "%%skeleton"
785 short *ssp1 = yyss - 1;
786 fprintf (stderr, "state stack now");
787 while (ssp1 != yyssp)
788 fprintf (stderr, " %d", *++ssp1);
789 fprintf (stderr, "\n");
798 /* Now `shift' the result of the reduction. Determine what state
799 that goes to, based on the state we popped back to and the rule
800 number reduced by. */
804 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
805 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
806 yystate = yytable[yystate];
808 yystate = yydefgoto[yyn - YYNTBASE];
813 /*------------------------------------.
814 | yyerrlab -- here on detecting error |
815 `------------------------------------*/
817 /* If not already recovering from an error, report this error. */
823 yyn = yypact[yystate];
825 if (yyn > YYFLAG && yyn < YYLAST)
832 /* Start X at -YYN if negative to avoid negative indexes in
834 for (x = yyn < 0 ? -yyn : 0;
835 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
836 if (yycheck[x + yyn] == x)
837 size += strlen (yytname[x]) + 15, count++;
838 size += strlen ("parse error, unexpected ") + 1;
839 size += strlen (yytname[YYTRANSLATE (yychar)]);
840 msg = (char *) malloc (size);
843 strcpy (msg, "parse error, unexpected ");
844 strcat (msg, yytname[YYTRANSLATE (yychar)]);
849 for (x = yyn < 0 ? -yyn : 0;
850 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
851 if (yycheck[x + yyn] == x)
853 strcat (msg, count == 0 ? ", expecting " : " or ");
854 strcat (msg, yytname[x]);
862 yyerror ("parse error; also virtual memory exhausted");
865 #endif /* %%ERROR_VERBOSE */
866 yyerror ("parse error");
871 /*----------------------------------------------------.
872 | yyerrlab1 -- error raised explicitly by an action. |
873 `----------------------------------------------------*/
875 if (yyerrstatus == 3)
877 /* If just tried and failed to reuse lookahead token after an
878 error, discard it. */
880 /* Return failure if at end of input. */
883 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
884 yychar, yytname[yychar1]));
888 /* Else will try to reuse lookahead token after shifting the error
891 yyerrstatus = 3; /* Each real token shifted decrements this. */
896 /*-------------------------------------------------------------------.
897 | yyerrdefault -- current state does not do anything special for the |
899 `-------------------------------------------------------------------*/
902 /* This is wrong; only states that explicitly want error tokens
903 should shift them. */
905 /* If its default is to accept any token, ok. Otherwise pop it. */
906 yyn = yydefact[yystate];
912 /*---------------------------------------------------------------.
913 | yyerrpop -- pop the current state because it cannot handle the |
915 `---------------------------------------------------------------*/
928 short *ssp1 = yyss - 1;
929 fprintf (stderr, "Error: state stack now");
930 while (ssp1 != yyssp)
931 fprintf (stderr, " %d", *++ssp1);
932 fprintf (stderr, "\n");
940 yyn = yypact[yystate];
945 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
962 YYDPRINTF ((stderr, "Shifting error token, "));
973 /*-------------------------------------.
974 | yyacceptlab -- YYACCEPT comes here. |
975 `-------------------------------------*/
988 /*-----------------------------------.
989 | yyabortlab -- YYABORT comes here. |
990 `-----------------------------------*/
1003 #line %%input_line "%%filename"