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. */
55 #ifndef YYSTACK_USE_ALLOCA
57 # define YYSTACK_USE_ALLOCA 1
58 # else /* alloca not defined */
60 # define YYSTACK_USE_ALLOCA 1
61 # define alloca __builtin_alloca
62 # else /* not GNU C. */
63 # if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
64 # define YYSTACK_USE_ALLOCA 1
66 # else /* not sparc */
67 /* We think this test detects Watcom and Microsoft C. */
68 /* This used to test MSDOS, but that is a bad idea since that
69 symbol is in the user namespace. */
70 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
72 /* No need for malloc.h, which pollutes the namespace; instead,
73 just don't use alloca. */
76 # else /* not MSDOS, or __TURBOC__ */
78 /* I don't know what this was needed for, but it pollutes the
79 namespace. So I turned it off. rms, 2 May 1997. */
80 /* #include <malloc.h> */
82 # define YYSTACK_USE_ALLOCA 1
83 # else /* not MSDOS, or __TURBOC__, or _AIX */
85 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
86 HPUX 10. Eventually we can turn this on. */
88 # define YYSTACK_USE_ALLOCA 1
89 # define alloca __builtin_alloca
92 # endif /* not _AIX */
93 # endif /* not MSDOS, or __TURBOC__ */
94 # endif /* not sparc */
95 # endif /* not GNU C */
96 # endif /* alloca not defined */
97 #endif /* YYSTACK_USE_ALLOCA not defined */
99 #if YYSTACK_USE_ALLOCA
100 # define YYSTACK_ALLOC alloca
102 # define YYSTACK_ALLOC malloc
105 #define YYBISON 1 /* Identify Bison output. */
106 #define YYPURE %%pure /* Identify pure parsers. */
109 # define YYDEBUG %%debug
113 # define YYSTYPE %%stype
117 typedef struct yyltype
124 # define YYLTYPE %%ltype
127 #ifndef YYERROR_VERBOSE
128 # define YYERROR_VERBOSE %%verbose
134 #define YYFINAL %%final
135 #define YYFLAG %%flag
136 #define YYNTBASE %%ntbase
137 #define YYLAST %%last
139 #define YYNTOKENS %%ntokens
140 #define YYNNTS %%nnts
141 #define YYNRULES %%nrules
142 #define YYNSTATES %%nstates
143 #define YYMAXUTOK %%maxtok
145 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
146 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
148 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
149 static const char yytranslate[] =
155 static const short yyprhs[] =
160 static const short yyrhs[] =
165 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
166 static const short yyrline[] =
172 #if YYDEBUG || YYERROR_VERBOSE
173 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
174 static const char *const yytname[] =
180 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
181 static const short yytoknum[] =
186 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
187 static const short yyr1[] =
192 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
193 static const short yyr2[] =
198 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
199 doesn't specify something else to do. Zero means the default is an
201 static const short yydefact[] =
206 static const short yydefgoto[] =
211 static const short yypact[] =
216 static const short yypgoto[] =
221 static const short yytable[] =
226 static const short yycheck[] =
231 #define yyerrok (yyerrstatus = 0)
232 #define yyclearin (yychar = YYEMPTY)
236 #define YYACCEPT goto yyacceptlab
237 #define YYABORT goto yyabortlab
238 #define YYERROR goto yyerrlab1
240 /* Like YYERROR except do call yyerror. This remains here temporarily
241 to ease the transition to the new meaning of YYERROR, for GCC.
242 Once GCC version 2 has supplanted version 1, this can go. */
244 #define YYFAIL goto yyerrlab
246 #define YYRECOVERING() (!!yyerrstatus)
248 #define YYBACKUP(Token, Value) \
250 if (yychar == YYEMPTY && yylen == 1) \
254 yychar1 = YYTRANSLATE (yychar); \
260 yyerror ("syntax error: cannot back up"); \
266 #define YYERRCODE 256
268 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
271 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
272 first token. By default, to implement support for ranges, extend
273 its range to the last symbol. */
275 #ifndef YYLLOC_DEFAULT
276 # define YYLLOC_DEFAULT(Current, Rhs, N) \
277 Current.last_line = Rhs[N].last_line; \
278 Current.last_column = Rhs[N].last_column;
281 /* Definition of YYLSP_NEEDED. */
282 #define YYLSP_NEEDED %%locations_flag
284 /* YYLEX -- calling `yylex' with the right arguments. */
289 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
291 # define YYLEX yylex (&yylval, &yylloc)
293 # else /* !YYLSP_NEEDED */
295 # define YYLEX yylex (&yylval, YYLEX_PARAM)
297 # define YYLEX yylex (&yylval)
299 # endif /* !YYLSP_NEEDED */
301 # define YYLEX yylex ()
304 /* Enable debugging if requested. */
306 # define YYDPRINTF(Args) \
311 /* Nonzero means print parse trace. [The following comment makes no
312 sense to me. Could someone clarify it? --akim] Since this is
313 uninitialized, it does not stop multiple parsers from coexisting.
317 # define YYDPRINTF(Args)
318 #endif /* !YYDEBUG */
320 /* YYINITDEPTH -- initial size of the parser's stacks. */
322 # define YYINITDEPTH %%initdepth
325 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
326 if the built-in stack extension method is used). */
332 # define YYMAXDEPTH %%maxdepth
337 /* Define __yy_memcpy. Note that the size argument
338 should be passed with type unsigned int, because that is what the non-GCC
339 definitions require. With GCC, __builtin_memcpy takes an arg
340 of type size_t, but it can handle unsigned int. */
342 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
343 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
344 #else /* not GNU C or C++ */
346 /* This is the most reliable way to avoid incompatibilities
347 in available built-in functions on various systems. */
350 __yy_memcpy (to, from, count)
354 # else /* __cplusplus */
355 __yy_memcpy (char *to, const char *from, unsigned int count)
358 register const char *f = from;
359 register char *t = to;
360 register int i = count;
369 #line %%line "%%filename"
371 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
372 into yyparse. The argument should have type void *.
373 It should actually point to an object.
374 Grammar actions can access the variable by casting it
375 to the proper pointer type. */
379 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
380 # define YYPARSE_PARAM_DECL
381 # else /* !__cplusplus */
382 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
383 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
384 # endif /* !__cplusplus */
385 #else /* !YYPARSE_PARAM */
386 # define YYPARSE_PARAM_ARG
387 # define YYPARSE_PARAM_DECL
388 #endif /* !YYPARSE_PARAM */
390 /* Prevent warning if -Wstrict-prototypes. */
392 # ifdef YYPARSE_PARAM
393 int yyparse (void *);
399 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
400 variables are global, or local to YYPARSE. */
402 #define _YY_DECL_VARIABLES \
403 /* The lookahead symbol. */ \
406 /* The semantic value of the lookahead symbol. */ \
409 /* Number of parse errors so far. */ \
413 # define YY_DECL_VARIABLES \
416 /* Location data for the lookahead symbol. */ \
419 # define YY_DECL_VARIABLES \
423 /* If nonreentrant, generate the variables here. */
430 yyparse (YYPARSE_PARAM_ARG)
433 /* If reentrant, generate the variables here. */
438 register int yystate;
440 /* Number of tokens to shift before error messages enabled. */
442 /* Lookahead token as an internal (translated) token number. */
445 /* Three stacks and their tools:
446 `yyss': related to states,
447 `yysv': related to semantic values,
448 `yyls': related to locations.
450 Refer to the stacks thru separate pointers, to allow yyoverflow
451 to reallocate them elsewhere. */
453 /* The state stack. */
454 short yyssa[YYINITDEPTH];
456 register short *yyssp;
458 /* The semantic value stack. */
459 YYSTYPE yyvsa[YYINITDEPTH];
460 YYSTYPE *yyvs = yyvsa;
461 register YYSTYPE *yyvsp;
464 /* The location stack. */
465 YYLTYPE yylsa[YYINITDEPTH];
466 YYLTYPE *yyls = yylsa;
471 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
473 # define YYPOPSTACK (yyvsp--, yyssp--)
476 int yystacksize = YYINITDEPTH;
477 int yyfree_stacks = 0;
479 /* The variables used to return semantic value and location from the
486 /* When reducing, the number of symbols on the RHS of the reduced
490 YYDPRINTF ((stderr, "Starting parse\n"));
495 yychar = YYEMPTY; /* Cause a token to be read. */
497 /* Initialize stack pointers.
498 Waste one element of value and location stack
499 so that they stay on the same level as the state stack.
500 The wasted elements are never initialized. */
509 /*------------------------------------------------------------.
510 | yynewstate -- Push a new state, which is found in yystate. |
511 `------------------------------------------------------------*/
513 /* In all cases, when you get here, the value and location stacks
514 have just been pushed. so pushing a state here evens the stacks.
521 if (yyssp >= yyss + yystacksize - 1)
523 /* Give user a chance to reallocate the stack. Use copies of
524 these so that the &'s don't force the real ones into memory.
526 YYSTYPE *yyvs1 = yyvs;
529 YYLTYPE *yyls1 = yyls;
532 /* Get the current used size of the three stacks, in elements. */
533 int size = yyssp - yyss + 1;
536 /* Each stack pointer address is followed by the size of the
537 data in use in that stack, in bytes. */
539 /* This used to be a conditional around just the two extra args,
540 but that might be undefined if yyoverflow is a macro. */
541 yyoverflow ("parser stack overflow",
542 &yyss1, size * sizeof (*yyssp),
543 &yyvs1, size * sizeof (*yyvsp),
544 &yyls1, size * sizeof (*yylsp),
547 yyoverflow ("parser stack overflow",
548 &yyss1, size * sizeof (*yyssp),
549 &yyvs1, size * sizeof (*yyvsp),
553 yyss = yyss1; yyvs = yyvs1;
557 #else /* no yyoverflow */
558 /* Extend the stack our own way. */
559 if (yystacksize >= YYMAXDEPTH)
561 yyerror ("parser stack overflow");
573 if (yystacksize > YYMAXDEPTH)
574 yystacksize = YYMAXDEPTH;
575 # if !YYSTACK_USE_ALLOCA
578 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
579 __yy_memcpy ((char *)yyss, (char *)yyss1,
580 size * (unsigned int) sizeof (*yyssp));
581 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
582 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
583 size * (unsigned int) sizeof (*yyvsp));
585 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
586 __yy_memcpy ((char *)yyls, (char *)yyls1,
587 size * (unsigned int) sizeof (*yylsp));
589 #endif /* no yyoverflow */
591 yyssp = yyss + size - 1;
592 yyvsp = yyvs + size - 1;
594 yylsp = yyls + size - 1;
597 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
599 if (yyssp >= yyss + yystacksize - 1)
603 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
612 /* Do appropriate processing given the current state. */
613 /* Read a lookahead token if we need one and don't already have one. */
616 /* First try to decide what to do without reference to lookahead token. */
618 yyn = yypact[yystate];
622 /* Not known => get a lookahead token if don't already have one. */
624 /* yychar is either YYEMPTY or YYEOF
625 or a valid token in external form. */
627 if (yychar == YYEMPTY)
629 YYDPRINTF ((stderr, "Reading a token: "));
633 /* Convert token to internal form (in yychar1) for indexing tables with. */
635 if (yychar <= 0) /* This means end of input. */
638 yychar = YYEOF; /* Don't call YYLEX any more. */
640 YYDPRINTF ((stderr, "Now at end of input.\n"));
644 yychar1 = YYTRANSLATE (yychar);
647 /* We have to keep this `#if YYDEBUG', since we use variables
648 which are defined only if `YYDEBUG' is set. */
651 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
652 /* Give the individual parser a way to print the precise
653 meaning of a token, for further debugging info. */
655 YYPRINT (stderr, yychar, yylval);
657 fprintf (stderr, ")\n");
663 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
668 /* yyn is what to do for this token type in this state.
669 Negative => reduce, -yyn is rule number.
670 Positive => shift, yyn is new state.
671 New state is final state => don't bother to shift,
673 0, or most negative number => error. */
688 /* Shift the lookahead token. */
689 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
691 /* Discard the token being shifted unless it is eof. */
700 /* Count tokens shifted since error; after three, turn off error
709 /*-----------------------------------------------------------.
710 | yydefault -- do the default action for the current state. |
711 `-----------------------------------------------------------*/
713 yyn = yydefact[yystate];
719 /*-----------------------------.
720 | yyreduce -- Do a reduction. |
721 `-----------------------------*/
723 /* yyn is the number of a rule to reduce with. */
726 /* If YYLEN is nonzero, implement the default value of the action:
729 Otherwise, the following line sets YYVAL to the semantic value of
730 the lookahead token. This behavior is undocumented and Bison
731 users should not rely upon it. Assigning to YYVAL
732 unconditionally makes the parser a bit smaller, and it avoids a
733 GCC warning that YYVAL may be used uninitialized. */
734 yyval = yyvsp[1-yylen];
737 /* Similarly for the default location. Let the user run additional
738 commands if for instance locations are ranges. */
739 yyloc = yylsp[1-yylen];
740 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
744 /* We have to keep this `#if YYDEBUG', since we use variables which
745 are defined only if `YYDEBUG' is set. */
750 fprintf (stderr, "Reducing via rule %d (line %d), ",
753 /* Print the symbols being reduced, and their result. */
754 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
755 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
756 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
761 %%action /* The action file replaces this line. */
763 #line %%line "%%filename"
774 short *ssp1 = yyss - 1;
775 fprintf (stderr, "state stack now");
776 while (ssp1 != yyssp)
777 fprintf (stderr, " %d", *++ssp1);
778 fprintf (stderr, "\n");
787 /* Now `shift' the result of the reduction. Determine what state
788 that goes to, based on the state we popped back to and the rule
789 number reduced by. */
793 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
794 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
795 yystate = yytable[yystate];
797 yystate = yydefgoto[yyn - YYNTBASE];
802 /*------------------------------------.
803 | yyerrlab -- here on detecting error |
804 `------------------------------------*/
806 /* If not already recovering from an error, report this error. */
812 yyn = yypact[yystate];
814 if (yyn > YYFLAG && yyn < YYLAST)
821 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
822 for (x = (yyn < 0 ? -yyn : 0);
823 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
824 if (yycheck[x + yyn] == x)
825 size += strlen (yytname[x]) + 15, count++;
826 size += strlen ("parse error, unexpected `") + 1;
827 size += strlen (yytname[YYTRANSLATE (yychar)]);
828 msg = (char *) malloc (size);
831 strcpy (msg, "parse error, unexpected `");
832 strcat (msg, yytname[YYTRANSLATE (yychar)]);
838 for (x = (yyn < 0 ? -yyn : 0);
839 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
840 if (yycheck[x + yyn] == x)
842 strcat (msg, count == 0 ? ", expecting `" : " or `");
843 strcat (msg, yytname[x]);
852 yyerror ("parse error; also virtual memory exceeded");
855 #endif /* YYERROR_VERBOSE */
856 yyerror ("parse error");
861 /*----------------------------------------------------.
862 | yyerrlab1 -- error raised explicitly by an action. |
863 `----------------------------------------------------*/
865 if (yyerrstatus == 3)
867 /* If just tried and failed to reuse lookahead token after an
868 error, discard it. */
870 /* Return failure if at end of input. */
873 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
874 yychar, yytname[yychar1]));
878 /* Else will try to reuse lookahead token after shifting the error
881 yyerrstatus = 3; /* Each real token shifted decrements this. */
886 /*-------------------------------------------------------------------.
887 | yyerrdefault -- current state does not do anything special for the |
889 `-------------------------------------------------------------------*/
892 /* This is wrong; only states that explicitly want error tokens
893 should shift them. */
895 /* If its default is to accept any token, ok. Otherwise pop it. */
896 yyn = yydefact[yystate];
902 /*---------------------------------------------------------------.
903 | yyerrpop -- pop the current state because it cannot handle the |
905 `---------------------------------------------------------------*/
918 short *ssp1 = yyss - 1;
919 fprintf (stderr, "Error: state stack now");
920 while (ssp1 != yyssp)
921 fprintf (stderr, " %d", *++ssp1);
922 fprintf (stderr, "\n");
930 yyn = yypact[yystate];
935 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
952 YYDPRINTF ((stderr, "Shifting error token, "));
963 /*-------------------------------------.
964 | yyacceptlab -- YYACCEPT comes here. |
965 `-------------------------------------*/
978 /*-----------------------------------.
979 | yyabortlab -- YYABORT comes here. |
980 `-----------------------------------*/