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. */
42 #ifndef YYSTACK_USE_ALLOCA
44 # define YYSTACK_USE_ALLOCA 1
45 # else /* alloca not defined */
47 # define YYSTACK_USE_ALLOCA 1
48 # define alloca __builtin_alloca
49 # else /* not GNU C. */
50 # if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
51 # define YYSTACK_USE_ALLOCA 1
53 # else /* not sparc */
54 /* We think this test detects Watcom and Microsoft C. */
55 /* This used to test MSDOS, but that is a bad idea since that
56 symbol is in the user namespace. */
57 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
59 /* No need for malloc.h, which pollutes the namespace; instead,
60 just don't use alloca. */
63 # else /* not MSDOS, or __TURBOC__ */
65 /* I don't know what this was needed for, but it pollutes the
66 namespace. So I turned it off. rms, 2 May 1997. */
67 /* #include <malloc.h> */
69 # define YYSTACK_USE_ALLOCA 1
70 # else /* not MSDOS, or __TURBOC__, or _AIX */
72 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
73 HPUX 10. Eventually we can turn this on. */
75 # define YYSTACK_USE_ALLOCA 1
76 # define alloca __builtin_alloca
79 # endif /* not _AIX */
80 # endif /* not MSDOS, or __TURBOC__ */
81 # endif /* not sparc */
82 # endif /* not GNU C */
83 # endif /* alloca not defined */
84 #endif /* YYSTACK_USE_ALLOCA not defined */
86 #if YYSTACK_USE_ALLOCA
87 # define YYSTACK_ALLOC alloca
89 # define YYSTACK_ALLOC malloc
92 #define YYBISON 1 /* Identify Bison output. */
93 #define YYPURE %%pure /* Identify pure parsers. */
96 # define YYDEBUG %%debug
100 # define YYSTYPE %%stype
104 typedef struct yyltype
111 # define YYLTYPE %%ltype
114 #ifndef YYERROR_VERBOSE
115 # define YYERROR_VERBOSE %%verbose
121 #define YYFINAL %%final
122 #define YYFLAG %%flag
123 #define YYNTBASE %%ntbase
124 #define YYLAST %%last
126 #define YYNTOKENS %%ntokens
127 #define YYNNTS %%nnts
128 #define YYNRULES %%nrules
129 #define YYNSTATES %%nstates
130 #define YYMAXUTOK %%maxtok
132 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
133 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
135 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
136 static const char yytranslate[] =
142 static const short yyprhs[] =
147 static const short yyrhs[] =
152 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
153 static const short yyrline[] =
159 #if YYDEBUG || YYERROR_VERBOSE
160 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
161 static const char* const yytname[] =
167 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
168 static const short yytoknum[] =
173 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
174 static const short yyr1[] =
179 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
180 static const short yyr2[] =
185 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
186 doesn't specify something else to do. Zero means the default is an
188 static const short yydefact[] =
193 static const short yydefgoto[] =
198 static const short yypact[] =
203 static const short yypgoto[] =
208 static const short yytable[] =
213 static const short yycheck[] =
218 #define yyerrok (yyerrstatus = 0)
219 #define yyclearin (%%yychar = YYEMPTY)
223 #define YYACCEPT goto yyacceptlab
224 #define YYABORT goto yyabortlab
225 #define YYERROR goto yyerrlab1
227 /* Like YYERROR except do call yyerror. This remains here temporarily
228 to ease the transition to the new meaning of YYERROR, for GCC.
229 Once GCC version 2 has supplanted version 1, this can go. */
231 #define YYFAIL goto yyerrlab
233 #define YYRECOVERING() (!!yyerrstatus)
235 #define YYBACKUP(Token, Value) \
237 if (%%yychar == YYEMPTY && yylen == 1) \
239 %%yychar = (Token); \
240 %%yylval = (Value); \
241 yychar1 = YYTRANSLATE (%%yychar); \
247 %%yyerror ("syntax error: cannot back up"); \
253 #define YYERRCODE 256
255 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
258 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
259 first token. By default, to implement support for ranges, extend
260 its range to the last symbol. */
262 #ifndef YYLLOC_DEFAULT
263 # define YYLLOC_DEFAULT(Current, Rhs, N) \
264 Current.last_line = Rhs[N].last_line; \
265 Current.last_column = Rhs[N].last_column;
268 /* YYLEX -- calling `yylex' with the right arguments. */
273 # define YYLEX %%yylex (&%%yylval, &yylloc, YYLEX_PARAM)
275 # define YYLEX %%yylex (&%%yylval, &yylloc)
277 # else /* !YYLSP_NEEDED */
279 # define YYLEX %%yylex (&%%yylval, YYLEX_PARAM)
281 # define YYLEX %%yylex (&%%yylval)
283 # endif /* !YYLSP_NEEDED */
285 # define YYLEX %%yylex ()
288 /* Enable debugging if requested. */
290 # define YYDPRINTF(Args) \
295 /* Nonzero means print parse trace. [The following comment makes no
296 sense to me. Could someone clarify it? --akim] Since this is
297 uninitialized, it does not stop multiple parsers from coexisting.
301 # define YYDPRINTF(Args)
302 #endif /* !YYDEBUG */
304 /* YYINITDEPTH -- initial size of the parser's stacks. */
306 # define YYINITDEPTH %%initdepth
309 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
310 if the built-in stack extension method is used). */
316 # define YYMAXDEPTH %%maxdepth
321 /* Define __yy_memcpy. Note that the size argument
322 should be passed with type unsigned int, because that is what the non-GCC
323 definitions require. With GCC, __builtin_memcpy takes an arg
324 of type size_t, but it can handle unsigned int. */
326 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
327 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
328 #else /* not GNU C or C++ */
330 /* This is the most reliable way to avoid incompatibilities
331 in available built-in functions on various systems. */
334 __yy_memcpy (to, from, count)
338 # else /* __cplusplus */
339 __yy_memcpy (char *to, const char *from, unsigned int count)
342 register const char *f = from;
343 register char *t = to;
344 register int i = count;
353 #line %%line "%%filename"
355 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
356 into yyparse. The argument should have type void *.
357 It should actually point to an object.
358 Grammar actions can access the variable by casting it
359 to the proper pointer type. */
363 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
364 # define YYPARSE_PARAM_DECL
365 # else /* !__cplusplus */
366 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
367 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
368 # endif /* !__cplusplus */
369 #else /* !YYPARSE_PARAM */
370 # define YYPARSE_PARAM_ARG
371 # define YYPARSE_PARAM_DECL
372 #endif /* !YYPARSE_PARAM */
374 /* Prevent warning if -Wstrict-prototypes. */
376 # ifdef YYPARSE_PARAM
377 int %%yyparse (void *);
379 int %%yyparse (void);
383 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
384 variables are global, or local to YYPARSE. */
386 #define _YY_DECL_VARIABLES \
387 /* The lookahead symbol. */ \
390 /* The semantic value of the lookahead symbol. */ \
393 /* Number of parse errors so far. */ \
397 # define YY_DECL_VARIABLES \
400 /* Location data for the lookahead symbol. */ \
403 # define YY_DECL_VARIABLES \
407 /* If nonreentrant, generate the variables here. */
414 %%yyparse (YYPARSE_PARAM_ARG)
417 /* If reentrant, generate the variables here. */
422 register int yystate;
424 /* Number of tokens to shift before error messages enabled. */
426 /* Lookahead token as an internal (translated) token number. */
429 /* Three stacks and their tools:
430 `yyss': related to states,
431 `yysv': related to semantic values,
432 `yyls': related to locations.
434 Refer to the stacks thru separate pointers, to allow yyoverflow
435 to reallocate them elsewhere. */
437 /* The state stack. */
438 short yyssa[YYINITDEPTH];
440 register short *yyssp;
442 /* The semantic value stack. */
443 YYSTYPE yyvsa[YYINITDEPTH];
444 YYSTYPE *yyvs = yyvsa;
445 register YYSTYPE *yyvsp;
448 /* The location stack. */
449 YYLTYPE yylsa[YYINITDEPTH];
450 YYLTYPE *yyls = yylsa;
455 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
457 # define YYPOPSTACK (yyvsp--, yyssp--)
460 int yystacksize = YYINITDEPTH;
461 int yyfree_stacks = 0;
463 /* The variables used to return semantic value and location from the
470 /* When reducing, the number of symbols on the RHS of the reduced
474 YYDPRINTF ((stderr, "Starting parse\n"));
479 %%yychar = YYEMPTY; /* Cause a token to be read. */
481 /* Initialize stack pointers.
482 Waste one element of value and location stack
483 so that they stay on the same level as the state stack.
484 The wasted elements are never initialized. */
492 /*------------------------------------------------------------.
493 | yynewstate -- Push a new state, which is found in yystate. |
494 `------------------------------------------------------------*/
496 /* In all cases, when you get here, the value and location stacks
497 have just been pushed. so pushing a state here evens the stacks.
501 if (yyssp >= yyss + yystacksize - 1)
503 /* Give user a chance to reallocate the stack. Use copies of
504 these so that the &'s don't force the real ones into memory.
506 YYSTYPE *yyvs1 = yyvs;
509 YYLTYPE *yyls1 = yyls;
512 /* Get the current used size of the three stacks, in elements. */
513 int size = yyssp - yyss + 1;
516 /* Each stack pointer address is followed by the size of the
517 data in use in that stack, in bytes. */
519 /* This used to be a conditional around just the two extra args,
520 but that might be undefined if yyoverflow is a macro. */
521 yyoverflow ("parser stack overflow",
522 &yyss1, size * sizeof (*yyssp),
523 &yyvs1, size * sizeof (*yyvsp),
524 &yyls1, size * sizeof (*yylsp),
527 yyoverflow ("parser stack overflow",
528 &yyss1, size * sizeof (*yyssp),
529 &yyvs1, size * sizeof (*yyvsp),
533 yyss = yyss1; yyvs = yyvs1;
537 #else /* no yyoverflow */
538 /* Extend the stack our own way. */
539 if (yystacksize >= YYMAXDEPTH)
541 %%yyerror ("parser stack overflow");
553 if (yystacksize > YYMAXDEPTH)
554 yystacksize = YYMAXDEPTH;
555 # if !YYSTACK_USE_ALLOCA
558 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
559 __yy_memcpy ((char *)yyss, (char *)yyss1,
560 size * (unsigned int) sizeof (*yyssp));
561 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
562 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
563 size * (unsigned int) sizeof (*yyvsp));
565 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
566 __yy_memcpy ((char *)yyls, (char *)yyls1,
567 size * (unsigned int) sizeof (*yylsp));
569 #endif /* no yyoverflow */
571 yyssp = yyss + size - 1;
572 yyvsp = yyvs + size - 1;
574 yylsp = yyls + size - 1;
577 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
579 if (yyssp >= yyss + yystacksize - 1)
583 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
592 /* Do appropriate processing given the current state. */
593 /* Read a lookahead token if we need one and don't already have one. */
596 /* First try to decide what to do without reference to lookahead token. */
598 yyn = yypact[yystate];
602 /* Not known => get a lookahead token if don't already have one. */
604 /* yychar is either YYEMPTY or YYEOF
605 or a valid token in external form. */
607 if (%%yychar == YYEMPTY)
609 YYDPRINTF ((stderr, "Reading a token: "));
613 /* Convert token to internal form (in yychar1) for indexing tables with */
615 if (%%yychar <= 0) /* This means end of input. */
618 %%yychar = YYEOF; /* Don't call YYLEX any more */
620 YYDPRINTF ((stderr, "Now at end of input.\n"));
624 yychar1 = YYTRANSLATE (%%yychar);
627 /* We have to keep this `#if YYDEBUG', since we use variables
628 which are defined only if `YYDEBUG' is set. */
631 fprintf (stderr, "Next token is %d (%s", %%yychar, yytname[yychar1]);
632 /* Give the individual parser a way to print the precise
633 meaning of a token, for further debugging info. */
635 YYPRINT (stderr, %%yychar, %%yylval);
637 fprintf (stderr, ")\n");
643 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
648 /* yyn is what to do for this token type in this state.
649 Negative => reduce, -yyn is rule number.
650 Positive => shift, yyn is new state.
651 New state is final state => don't bother to shift,
653 0, or most negative number => error. */
668 /* Shift the lookahead token. */
669 YYDPRINTF ((stderr, "Shifting token %d (%s), ", %%yychar, yytname[yychar1]));
671 /* Discard the token being shifted unless it is eof. */
672 if (%%yychar != YYEOF)
680 /* Count tokens shifted since error; after three, turn off error
689 /*-----------------------------------------------------------.
690 | yydefault -- do the default action for the current state. |
691 `-----------------------------------------------------------*/
693 yyn = yydefact[yystate];
699 /*-----------------------------.
700 | yyreduce -- Do a reduction. |
701 `-----------------------------*/
703 /* yyn is the number of a rule to reduce with. */
706 /* If YYLEN is nonzero, implement the default value of the action:
709 Otherwise, the following line sets YYVAL to the semantic value of
710 the lookahead token. This behavior is undocumented and Bison
711 users should not rely upon it. Assigning to YYVAL
712 unconditionally makes the parser a bit smaller, and it avoids a
713 GCC warning that YYVAL may be used uninitialized. */
714 yyval = yyvsp[1-yylen];
717 /* Similarly for the default location. Let the user run additional
718 commands if for instance locations are ranges. */
719 yyloc = yylsp[1-yylen];
720 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
724 /* We have to keep this `#if YYDEBUG', since we use variables which
725 are defined only if `YYDEBUG' is set. */
730 fprintf (stderr, "Reducing via rule %d (line %d), ",
733 /* Print the symbols being reduced, and their result. */
734 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
735 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
736 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
741 %%action /* The action file replaces this line. */
743 #line %%line "%%filename"
754 short *ssp1 = yyss - 1;
755 fprintf (stderr, "state stack now");
756 while (ssp1 != yyssp)
757 fprintf (stderr, " %d", *++ssp1);
758 fprintf (stderr, "\n");
767 /* Now `shift' the result of the reduction. Determine what state
768 that goes to, based on the state we popped back to and the rule
769 number reduced by. */
773 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
774 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
775 yystate = yytable[yystate];
777 yystate = yydefgoto[yyn - YYNTBASE];
782 /*------------------------------------.
783 | yyerrlab -- here on detecting error |
784 `------------------------------------*/
786 /* If not already recovering from an error, report this error. */
792 yyn = yypact[yystate];
794 if (yyn > YYFLAG && yyn < YYLAST)
801 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
802 for (x = (yyn < 0 ? -yyn : 0);
803 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
804 if (yycheck[x + yyn] == x)
805 size += strlen (yytname[x]) + 15, count++;
806 size += strlen ("parse error, unexpected `") + 1;
807 size += strlen (yytname[YYTRANSLATE (%%yychar)]);
808 msg = (char *) malloc (size);
811 strcpy (msg, "parse error, unexpected `");
812 strcat (msg, yytname[YYTRANSLATE (%%yychar)]);
818 for (x = (yyn < 0 ? -yyn : 0);
819 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
820 if (yycheck[x + yyn] == x)
822 strcat (msg, count == 0 ? ", expecting `" : " or `");
823 strcat (msg, yytname[x]);
832 %%yyerror ("parse error; also virtual memory exceeded");
835 #endif /* YYERROR_VERBOSE */
836 %%yyerror ("parse error");
841 /*--------------------------------------------------.
842 | yyerrlab1 -- error raised explicitly by an action |
843 `--------------------------------------------------*/
845 if (yyerrstatus == 3)
847 /* If just tried and failed to reuse lookahead token after an
848 error, discard it. */
850 /* return failure if at end of input */
851 if (%%yychar == YYEOF)
853 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
854 %%yychar, yytname[yychar1]));
858 /* Else will try to reuse lookahead token after shifting the error
861 yyerrstatus = 3; /* Each real token shifted decrements this */
866 /*-------------------------------------------------------------------.
867 | yyerrdefault -- current state does not do anything special for the |
869 `-------------------------------------------------------------------*/
872 /* This is wrong; only states that explicitly want error tokens
873 should shift them. */
875 /* If its default is to accept any token, ok. Otherwise pop it. */
876 yyn = yydefact[yystate];
882 /*---------------------------------------------------------------.
883 | yyerrpop -- pop the current state because it cannot handle the |
885 `---------------------------------------------------------------*/
898 short *ssp1 = yyss - 1;
899 fprintf (stderr, "Error: state stack now");
900 while (ssp1 != yyssp)
901 fprintf (stderr, " %d", *++ssp1);
902 fprintf (stderr, "\n");
910 yyn = yypact[yystate];
915 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
932 YYDPRINTF ((stderr, "Shifting error token, "));
943 /*-------------------------------------.
944 | yyacceptlab -- YYACCEPT comes here. |
945 `-------------------------------------*/
958 /*-----------------------------------.
959 | yyabortlab -- YYABORT comes here. |
960 `-----------------------------------*/