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 /* Pacify GCC's `empty if-body' warning. */
108 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
110 # define YYSTACK_ALLOC malloc
111 # define YYSTACK_FREE(Ptr) free (Ptr)
114 /* A type that is properly aligned for any stack member. */
124 /* The size of the maximum gap between one aligned stack and the next. */
125 #define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
127 /* The size of an array large to enough to hold all stacks, each with
130 # define YYSTACK_BYTES(N) \
131 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
132 + 2 * YYSTACK_GAP_MAX)
134 # define YYSTACK_BYTES(N) \
135 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
139 /* Relocate the TYPE STACK from its old location to the new one. The
140 local variables SIZE and YYSTACKSIZE give the old and new number of
141 elements in the stack, and YYPTR gives the new location of the
142 stack. Advance YYPTR to a properly aligned location for the next
144 #define YYSTACK_RELOCATE(Type, Stack) \
148 __yy_memcpy (yyptr, (char *) (Stack), size * sizeof (Type)); \
149 (Stack) = (Type *) yyptr; \
150 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
151 yynewbytes -= yynewbytes % sizeof (union yyalloc); \
152 yyptr += yynewbytes; \
156 #define YYBISON 1 /* Identify Bison output. */
157 #define YYPURE %%pure /* Identify pure parsers. */
160 # define YYDEBUG %%debug
163 #line %%input-line "%%filename"
165 typedef %%stype yystype;
166 # define YYSTYPE yystype
170 typedef struct yyltype
177 # define YYLTYPE %%ltype
180 #ifdef YYERROR_VERBOSE
181 # undef YYERROR_VERBOSE
184 #define YYERROR_VERBOSE %%error-verbose
189 #define YYFINAL %%final
190 #define YYFLAG %%flag
191 #define YYNTBASE %%ntbase
192 #define YYLAST %%last
194 #define YYNTOKENS %%ntokens
195 #define YYNNTS %%nnts
196 #define YYNRULES %%nrules
197 #define YYNSTATES %%nstates
198 #define YYMAXUTOK %%maxtok
200 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
201 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
203 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
204 static const char yytranslate[] =
210 static const short yyprhs[] =
215 static const short yyrhs[] =
220 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
221 static const short yyrline[] =
227 #if YYDEBUG || YYERROR_VERBOSE
228 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
229 static const char *const yytname[] =
235 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
236 static const short yytoknum[] =
241 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
242 static const short yyr1[] =
247 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
248 static const short yyr2[] =
253 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
254 doesn't specify something else to do. Zero means the default is an
256 static const short yydefact[] =
261 static const short yydefgoto[] =
266 static const short yypact[] =
271 static const short yypgoto[] =
276 static const short yytable[] =
281 static const short yycheck[] =
286 #define yyerrok (yyerrstatus = 0)
287 #define yyclearin (yychar = YYEMPTY)
291 #define YYACCEPT goto yyacceptlab
292 #define YYABORT goto yyabortlab
293 #define YYERROR goto yyerrlab1
295 /* Like YYERROR except do call yyerror. This remains here temporarily
296 to ease the transition to the new meaning of YYERROR, for GCC.
297 Once GCC version 2 has supplanted version 1, this can go. */
299 #define YYFAIL goto yyerrlab
301 #define YYRECOVERING() (!!yyerrstatus)
303 #define YYBACKUP(Token, Value) \
305 if (yychar == YYEMPTY && yylen == 1) \
309 yychar1 = YYTRANSLATE (yychar); \
315 yyerror ("syntax error: cannot back up"); \
321 #define YYERRCODE 256
323 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
326 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
327 first token. By default, to implement support for ranges, extend
328 its range to the last symbol. */
330 #ifndef YYLLOC_DEFAULT
331 # define YYLLOC_DEFAULT(Current, Rhs, N) \
332 Current.last_line = Rhs[N].last_line; \
333 Current.last_column = Rhs[N].last_column;
336 /* Definition of YYLSP_NEEDED. */
337 #define YYLSP_NEEDED %%locations-flag
339 /* YYLEX -- calling `yylex' with the right arguments. */
344 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
346 # define YYLEX yylex (&yylval, &yylloc)
348 # else /* !YYLSP_NEEDED */
350 # define YYLEX yylex (&yylval, YYLEX_PARAM)
352 # define YYLEX yylex (&yylval)
354 # endif /* !YYLSP_NEEDED */
356 # define YYLEX yylex ()
359 /* Enable debugging if requested. */
361 # define YYDPRINTF(Args) \
366 /* Nonzero means print parse trace. [The following comment makes no
367 sense to me. Could someone clarify it? --akim] Since this is
368 uninitialized, it does not stop multiple parsers from coexisting.
372 # define YYDPRINTF(Args)
373 #endif /* !YYDEBUG */
375 /* YYINITDEPTH -- initial size of the parser's stacks. */
377 # define YYINITDEPTH %%initdepth
380 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
381 if the built-in stack extension method is used).
383 Do not make this value too large; the results are undefined if
384 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
385 evaluated with infinite-precision integer arithmetic. */
392 # define YYMAXDEPTH %%maxdepth
397 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
398 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
399 #else /* not GNU C or C++ */
401 /* This is the most reliable way to avoid incompatibilities
402 in available built-in functions on various systems. */
405 __yy_memcpy (to, from, count)
409 # else /* __cplusplus */
410 __yy_memcpy (char *to, const char *from, size_t count)
413 register const char *f = from;
414 register char *t = to;
415 register size_t i = count;
424 #line %%line "%%skeleton"
426 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
427 into yyparse. The argument should have type void *.
428 It should actually point to an object.
429 Grammar actions can access the variable by casting it
430 to the proper pointer type. */
434 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
435 # define YYPARSE_PARAM_DECL
436 # else /* !__cplusplus */
437 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
438 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
439 # endif /* !__cplusplus */
440 #else /* !YYPARSE_PARAM */
441 # define YYPARSE_PARAM_ARG
442 # define YYPARSE_PARAM_DECL
443 #endif /* !YYPARSE_PARAM */
445 /* Prevent warning if -Wstrict-prototypes. */
447 # ifdef YYPARSE_PARAM
448 int yyparse (void *);
454 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
455 variables are global, or local to YYPARSE. */
457 #define _YY_DECL_VARIABLES \
458 /* The lookahead symbol. */ \
461 /* The semantic value of the lookahead symbol. */ \
464 /* Number of parse errors so far. */ \
468 # define YY_DECL_VARIABLES \
471 /* Location data for the lookahead symbol. */ \
474 # define YY_DECL_VARIABLES \
478 /* If nonreentrant, generate the variables here. */
485 yyparse (YYPARSE_PARAM_ARG)
488 /* If reentrant, generate the variables here. */
493 register int yystate;
496 /* Number of tokens to shift before error messages enabled. */
498 /* Lookahead token as an internal (translated) token number. */
501 /* Three stacks and their tools:
502 `yyss': related to states,
503 `yyvs': related to semantic values,
504 `yyls': related to locations.
506 Refer to the stacks thru separate pointers, to allow yyoverflow
507 to reallocate them elsewhere. */
509 /* The state stack. */
510 short yyssa[YYINITDEPTH];
512 register short *yyssp;
514 /* The semantic value stack. */
515 YYSTYPE yyvsa[YYINITDEPTH];
516 YYSTYPE *yyvs = yyvsa;
517 register YYSTYPE *yyvsp;
520 /* The location stack. */
521 YYLTYPE yylsa[YYINITDEPTH];
522 YYLTYPE *yyls = yylsa;
527 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
529 # define YYPOPSTACK (yyvsp--, yyssp--)
532 size_t yystacksize = YYINITDEPTH;
534 /* The variables used to return semantic value and location from the
541 /* When reducing, the number of symbols on the RHS of the reduced
545 YYDPRINTF ((stderr, "Starting parse\n"));
550 yychar = YYEMPTY; /* Cause a token to be read. */
552 /* Initialize stack pointers.
553 Waste one element of value and location stack
554 so that they stay on the same level as the state stack.
555 The wasted elements are never initialized. */
564 /*------------------------------------------------------------.
565 | yynewstate -- Push a new state, which is found in yystate. |
566 `------------------------------------------------------------*/
568 /* In all cases, when you get here, the value and location stacks
569 have just been pushed. so pushing a state here evens the stacks.
576 if (yyssp >= yyss + yystacksize - 1)
578 /* Get the current used size of the three stacks, in elements. */
579 size_t size = yyssp - yyss + 1;
583 /* Give user a chance to reallocate the stack. Use copies of
584 these so that the &'s don't force the real ones into
586 YYSTYPE *yyvs1 = yyvs;
589 /* Each stack pointer address is followed by the size of the
590 data in use in that stack, in bytes. */
592 YYLTYPE *yyls1 = yyls;
593 /* This used to be a conditional around just the two extra args,
594 but that might be undefined if yyoverflow is a macro. */
595 yyoverflow ("parser stack overflow",
596 &yyss1, size * sizeof (*yyssp),
597 &yyvs1, size * sizeof (*yyvsp),
598 &yyls1, size * sizeof (*yylsp),
602 yyoverflow ("parser stack overflow",
603 &yyss1, size * sizeof (*yyssp),
604 &yyvs1, size * sizeof (*yyvsp),
610 #else /* no yyoverflow */
611 /* Extend the stack our own way. */
612 if (yystacksize >= YYMAXDEPTH)
615 if (yystacksize > YYMAXDEPTH)
616 yystacksize = YYMAXDEPTH;
620 char *yyptr = (char *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
623 YYSTACK_RELOCATE (short, yyss);
624 YYSTACK_RELOCATE (YYSTYPE, yyvs);
626 YYSTACK_RELOCATE (YYLTYPE, yyls);
628 # undef YYSTACK_RELOCATE
630 YYSTACK_FREE (yyss1);
632 #endif /* no yyoverflow */
634 yyssp = yyss + size - 1;
635 yyvsp = yyvs + size - 1;
637 yylsp = yyls + size - 1;
640 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
641 (unsigned long int) yystacksize));
643 if (yyssp >= yyss + yystacksize - 1)
647 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
656 /* Do appropriate processing given the current state. */
657 /* Read a lookahead token if we need one and don't already have one. */
660 /* First try to decide what to do without reference to lookahead token. */
662 yyn = yypact[yystate];
666 /* Not known => get a lookahead token if don't already have one. */
668 /* yychar is either YYEMPTY or YYEOF
669 or a valid token in external form. */
671 if (yychar == YYEMPTY)
673 YYDPRINTF ((stderr, "Reading a token: "));
677 /* Convert token to internal form (in yychar1) for indexing tables with. */
679 if (yychar <= 0) /* This means end of input. */
682 yychar = YYEOF; /* Don't call YYLEX any more. */
684 YYDPRINTF ((stderr, "Now at end of input.\n"));
688 yychar1 = YYTRANSLATE (yychar);
691 /* We have to keep this `#if YYDEBUG', since we use variables
692 which are defined only if `YYDEBUG' is set. */
695 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
696 /* Give the individual parser a way to print the precise
697 meaning of a token, for further debugging info. */
699 YYPRINT (stderr, yychar, yylval);
701 fprintf (stderr, ")\n");
707 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
712 /* yyn is what to do for this token type in this state.
713 Negative => reduce, -yyn is rule number.
714 Positive => shift, yyn is new state.
715 New state is final state => don't bother to shift,
717 0, or most negative number => error. */
732 /* Shift the lookahead token. */
733 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
735 /* Discard the token being shifted unless it is eof. */
744 /* Count tokens shifted since error; after three, turn off error
753 /*-----------------------------------------------------------.
754 | yydefault -- do the default action for the current state. |
755 `-----------------------------------------------------------*/
757 yyn = yydefact[yystate];
763 /*-----------------------------.
764 | yyreduce -- Do a reduction. |
765 `-----------------------------*/
767 /* yyn is the number of a rule to reduce with. */
770 /* If YYLEN is nonzero, implement the default value of the action:
773 Otherwise, the following line sets YYVAL to the semantic value of
774 the lookahead token. This behavior is undocumented and Bison
775 users should not rely upon it. Assigning to YYVAL
776 unconditionally makes the parser a bit smaller, and it avoids a
777 GCC warning that YYVAL may be used uninitialized. */
778 yyval = yyvsp[1-yylen];
781 /* Similarly for the default location. Let the user run additional
782 commands if for instance locations are ranges. */
783 yyloc = yylsp[1-yylen];
784 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
788 /* We have to keep this `#if YYDEBUG', since we use variables which
789 are defined only if `YYDEBUG' is set. */
794 fprintf (stderr, "Reducing via rule %d (line %d), ",
797 /* Print the symbols being reduced, and their result. */
798 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
799 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
800 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
807 #line %%line "%%skeleton"
818 short *ssp1 = yyss - 1;
819 fprintf (stderr, "state stack now");
820 while (ssp1 != yyssp)
821 fprintf (stderr, " %d", *++ssp1);
822 fprintf (stderr, "\n");
831 /* Now `shift' the result of the reduction. Determine what state
832 that goes to, based on the state we popped back to and the rule
833 number reduced by. */
837 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
838 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
839 yystate = yytable[yystate];
841 yystate = yydefgoto[yyn - YYNTBASE];
846 /*------------------------------------.
847 | yyerrlab -- here on detecting error |
848 `------------------------------------*/
850 /* If not already recovering from an error, report this error. */
856 yyn = yypact[yystate];
858 if (yyn > YYFLAG && yyn < YYLAST)
865 /* Start X at -YYN if negative to avoid negative indexes in
867 for (x = yyn < 0 ? -yyn : 0;
868 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
869 if (yycheck[x + yyn] == x)
870 size += strlen (yytname[x]) + 15, count++;
871 size += strlen ("parse error, unexpected ") + 1;
872 size += strlen (yytname[YYTRANSLATE (yychar)]);
873 msg = (char *) malloc (size);
876 strcpy (msg, "parse error, unexpected ");
877 strcat (msg, yytname[YYTRANSLATE (yychar)]);
882 for (x = yyn < 0 ? -yyn : 0;
883 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
884 if (yycheck[x + yyn] == x)
886 strcat (msg, count == 0 ? ", expecting " : " or ");
887 strcat (msg, yytname[x]);
895 yyerror ("parse error; also virtual memory exhausted");
898 #endif /* YYERROR_VERBOSE */
899 yyerror ("parse error");
904 /*----------------------------------------------------.
905 | yyerrlab1 -- error raised explicitly by an action. |
906 `----------------------------------------------------*/
908 if (yyerrstatus == 3)
910 /* If just tried and failed to reuse lookahead token after an
911 error, discard it. */
913 /* Return failure if at end of input. */
916 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
917 yychar, yytname[yychar1]));
921 /* Else will try to reuse lookahead token after shifting the error
924 yyerrstatus = 3; /* Each real token shifted decrements this. */
929 /*-------------------------------------------------------------------.
930 | yyerrdefault -- current state does not do anything special for the |
932 `-------------------------------------------------------------------*/
935 /* This is wrong; only states that explicitly want error tokens
936 should shift them. */
938 /* If its default is to accept any token, ok. Otherwise pop it. */
939 yyn = yydefact[yystate];
945 /*---------------------------------------------------------------.
946 | yyerrpop -- pop the current state because it cannot handle the |
948 `---------------------------------------------------------------*/
961 short *ssp1 = yyss - 1;
962 fprintf (stderr, "Error: state stack now");
963 while (ssp1 != yyssp)
964 fprintf (stderr, " %d", *++ssp1);
965 fprintf (stderr, "\n");
973 yyn = yypact[yystate];
978 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
995 YYDPRINTF ((stderr, "Shifting error token, "));
1006 /*-------------------------------------.
1007 | yyacceptlab -- YYACCEPT comes here. |
1008 `-------------------------------------*/
1013 /*-----------------------------------.
1014 | yyabortlab -- YYABORT comes here. |
1015 `-----------------------------------*/
1020 /*---------------------------------------------.
1021 | yyoverflowab -- parser overflow comes here. |
1022 `---------------------------------------------*/
1024 yyerror ("parser stack overflow");
1031 YYSTACK_FREE (yyss);
1036 #line %%input-line "%%filename"