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. */
34 #define YYBISON 1 /* Identify Bison output. */
35 #define YYPURE %%pure /* Identify pure parsers. */
39 /* If name_prefix is specify substitute the variables and functions
41 #define yyparse %%prefix##parse
42 #define yylex %%prefix##lex
43 #define yyerror %%prefix##error
44 #define yylval %%prefix##lval
45 #define yychar %%prefix##char
46 #define yydebug %%prefix##debug
47 #define yynerrs %%prefix##nerrs
49 /* Copy the user declarations. */
50 #line %%input-line "%%filename"
53 #line %%line "%%skeleton"
60 #ifndef YYSTACK_USE_ALLOCA
62 # define YYSTACK_USE_ALLOCA 1
63 # else /* alloca not defined */
65 # define YYSTACK_USE_ALLOCA 1
66 # define alloca __builtin_alloca
67 # else /* not GNU C. */
68 # if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
69 # define YYSTACK_USE_ALLOCA 1
71 # else /* not sparc */
72 /* We think this test detects Watcom and Microsoft C. */
73 /* This used to test MSDOS, but that is a bad idea since that
74 symbol is in the user namespace. */
75 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
77 /* No need for malloc.h, which pollutes the namespace; instead,
78 just don't use alloca. */
81 # else /* not MSDOS, or __TURBOC__ */
83 /* I don't know what this was needed for, but it pollutes the
84 namespace. So I turned it off. rms, 2 May 1997. */
85 /* #include <malloc.h> */
87 # define YYSTACK_USE_ALLOCA 1
88 # else /* not MSDOS, or __TURBOC__, or _AIX */
90 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
91 HPUX 10. Eventually we can turn this on. */
93 # define YYSTACK_USE_ALLOCA 1
94 # define alloca __builtin_alloca
97 # endif /* not _AIX */
98 # endif /* not MSDOS, or __TURBOC__ */
99 # endif /* not sparc */
100 # endif /* not GNU C */
101 # endif /* alloca not defined */
102 #endif /* YYSTACK_USE_ALLOCA not defined */
104 #ifndef YYSTACK_USE_ALLOCA
105 # define YYSTACK_USE_ALLOCA 0
108 #if YYSTACK_USE_ALLOCA
109 # define YYSTACK_ALLOC alloca
110 /* Pacify GCC's `empty if-body' warning. */
111 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
113 # define YYSTACK_ALLOC malloc
114 # define YYSTACK_FREE(Ptr) free (Ptr)
117 #line %%input-line "%%filename"
119 typedef %%stype yystype;
120 # define YYSTYPE yystype
124 typedef struct yyltype
131 # define YYLTYPE %%ltype
134 #line %%line "%%skeleton"
135 /* A type that is properly aligned for any stack member. */
145 /* The size of the maximum gap between one aligned stack and the next. */
146 #define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
148 /* The size of an array large to enough to hold all stacks, each with
151 # define YYSTACK_BYTES(N) \
152 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
153 + 2 * YYSTACK_GAP_MAX)
155 # define YYSTACK_BYTES(N) \
156 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
160 /* Relocate the TYPE STACK from its old location to the new one. The
161 local variables SIZE and YYSTACKSIZE give the old and new number of
162 elements in the stack, and YYPTR gives the new location of the
163 stack. Advance YYPTR to a properly aligned location for the next
165 #define YYSTACK_RELOCATE(Type, Stack) \
169 __yy_memcpy (yyptr, (char *) (Stack), size * sizeof (Type)); \
170 (Stack) = (Type *) yyptr; \
171 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
172 yynewbytes -= yynewbytes % sizeof (union yyalloc); \
173 yyptr += yynewbytes; \
178 # define YYDEBUG %%debug
181 #ifdef YYERROR_VERBOSE
182 # undef YYERROR_VERBOSE
185 #define YYERROR_VERBOSE %%error-verbose
190 #define YYFINAL %%final
191 #define YYFLAG %%flag
192 #define YYNTBASE %%ntbase
193 #define YYLAST %%last
195 #define YYNTOKENS %%ntokens
196 #define YYNNTS %%nnts
197 #define YYNRULES %%nrules
198 #define YYNSTATES %%nstates
199 #define YYMAXUTOK %%maxtok
201 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
202 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
204 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
205 static const char yytranslate[] =
211 static const short yyprhs[] =
216 static const short yyrhs[] =
221 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
222 static const short yyrline[] =
228 #if YYDEBUG || YYERROR_VERBOSE
229 /* YYTNME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
230 static const char *const yytname[] =
236 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
237 static const short yytoknum[] =
242 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
243 static const short yyr1[] =
248 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
249 static const short yyr2[] =
254 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
255 doesn't specify something else to do. Zero means the default is an
257 static const short yydefact[] =
262 static const short yydefgoto[] =
267 static const short yypact[] =
272 static const short yypgoto[] =
277 static const short yytable[] =
282 static const short yycheck[] =
287 #define yyerrok (yyerrstatus = 0)
288 #define yyclearin (yychar = YYEMPTY)
292 #define YYACCEPT goto yyacceptlab
293 #define YYABORT goto yyabortlab
294 #define YYERROR goto yyerrlab1
296 /* Like YYERROR except do call yyerror. This remains here temporarily
297 to ease the transition to the new meaning of YYERROR, for GCC.
298 Once GCC version 2 has supplanted version 1, this can go. */
300 #define YYFAIL goto yyerrlab
302 #define YYRECOVERING() (!!yyerrstatus)
304 #define YYBACKUP(Token, Value) \
306 if (yychar == YYEMPTY && yylen == 1) \
310 yychar1 = YYTRANSLATE (yychar); \
316 yyerror ("syntax error: cannot back up"); \
322 #define YYERRCODE 256
324 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
327 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
328 first token. By default, to implement support for ranges, extend
329 its range to the last symbol. */
331 #ifndef YYLLOC_DEFAULT
332 # define YYLLOC_DEFAULT(Current, Rhs, N) \
333 Current.last_line = Rhs[N].last_line; \
334 Current.last_column = Rhs[N].last_column;
337 /* Definition of YYLSP_NEEDED. */
338 #define YYLSP_NEEDED %%locations-flag
340 /* YYLEX -- calling `yylex' with the right arguments. */
345 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
347 # define YYLEX yylex (&yylval, &yylloc)
349 # else /* !YYLSP_NEEDED */
351 # define YYLEX yylex (&yylval, YYLEX_PARAM)
353 # define YYLEX yylex (&yylval)
355 # endif /* !YYLSP_NEEDED */
357 # define YYLEX yylex ()
360 /* Enable debugging if requested. */
362 # define YYDPRINTF(Args) \
367 /* Nonzero means print parse trace. [The following comment makes no
368 sense to me. Could someone clarify it? --akim] Since this is
369 uninitialized, it does not stop multiple parsers from coexisting.
373 # define YYDPRINTF(Args)
374 #endif /* !YYDEBUG */
376 /* YYINITDEPTH -- initial size of the parser's stacks. */
378 # define YYINITDEPTH %%initdepth
381 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
382 if the built-in stack extension method is used).
384 Do not make this value too large; the results are undefined if
385 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
386 evaluated with infinite-precision integer arithmetic. */
393 # define YYMAXDEPTH %%maxdepth
398 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
399 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
400 #else /* not GNU C or C++ */
402 /* This is the most reliable way to avoid incompatibilities
403 in available built-in functions on various systems. */
406 __yy_memcpy (to, from, count)
410 # else /* __cplusplus */
411 __yy_memcpy (char *to, const char *from, size_t count)
414 register const char *f = from;
415 register char *t = to;
416 register size_t i = count;
425 #line %%line "%%skeleton"
427 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
428 into yyparse. The argument should have type void *.
429 It should actually point to an object.
430 Grammar actions can access the variable by casting it
431 to the proper pointer type. */
435 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
436 # define YYPARSE_PARAM_DECL
437 # else /* !__cplusplus */
438 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
439 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
440 # endif /* !__cplusplus */
441 #else /* !YYPARSE_PARAM */
442 # define YYPARSE_PARAM_ARG
443 # define YYPARSE_PARAM_DECL
444 #endif /* !YYPARSE_PARAM */
446 /* Prevent warning if -Wstrict-prototypes. */
448 # ifdef YYPARSE_PARAM
449 int yyparse (void *);
455 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
456 variables are global, or local to YYPARSE. */
458 #define _YY_DECL_VARIABLES \
459 /* The lookahead symbol. */ \
462 /* The semantic value of the lookahead symbol. */ \
465 /* Number of parse errors so far. */ \
469 # define YY_DECL_VARIABLES \
472 /* Location data for the lookahead symbol. */ \
475 # define YY_DECL_VARIABLES \
479 /* If nonreentrant, generate the variables here. */
486 yyparse (YYPARSE_PARAM_ARG)
489 /* If reentrant, generate the variables here. */
494 register int yystate;
497 /* Number of tokens to shift before error messages enabled. */
499 /* Lookahead token as an internal (translated) token number. */
502 /* Three stacks and their tools:
503 `yyss': related to states,
504 `yyvs': related to semantic values,
505 `yyls': related to locations.
507 Refer to the stacks thru separate pointers, to allow yyoverflow
508 to reallocate them elsewhere. */
510 /* The state stack. */
511 short yyssa[YYINITDEPTH];
513 register short *yyssp;
515 /* The semantic value stack. */
516 YYSTYPE yyvsa[YYINITDEPTH];
517 YYSTYPE *yyvs = yyvsa;
518 register YYSTYPE *yyvsp;
521 /* The location stack. */
522 YYLTYPE yylsa[YYINITDEPTH];
523 YYLTYPE *yyls = yylsa;
528 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
530 # define YYPOPSTACK (yyvsp--, yyssp--)
533 size_t yystacksize = YYINITDEPTH;
535 /* The variables used to return semantic value and location from the
542 /* When reducing, the number of symbols on the RHS of the reduced
546 YYDPRINTF ((stderr, "Starting parse\n"));
551 yychar = YYEMPTY; /* Cause a token to be read. */
553 /* Initialize stack pointers.
554 Waste one element of value and location stack
555 so that they stay on the same level as the state stack.
556 The wasted elements are never initialized. */
565 /*------------------------------------------------------------.
566 | yynewstate -- Push a new state, which is found in yystate. |
567 `------------------------------------------------------------*/
569 /* In all cases, when you get here, the value and location stacks
570 have just been pushed. so pushing a state here evens the stacks.
577 if (yyssp >= yyss + yystacksize - 1)
579 /* Get the current used size of the three stacks, in elements. */
580 size_t size = yyssp - yyss + 1;
584 /* Give user a chance to reallocate the stack. Use copies of
585 these so that the &'s don't force the real ones into
587 YYSTYPE *yyvs1 = yyvs;
590 /* Each stack pointer address is followed by the size of the
591 data in use in that stack, in bytes. */
593 YYLTYPE *yyls1 = yyls;
594 /* This used to be a conditional around just the two extra args,
595 but that might be undefined if yyoverflow is a macro. */
596 yyoverflow ("parser stack overflow",
597 &yyss1, size * sizeof (*yyssp),
598 &yyvs1, size * sizeof (*yyvsp),
599 &yyls1, size * sizeof (*yylsp),
603 yyoverflow ("parser stack overflow",
604 &yyss1, size * sizeof (*yyssp),
605 &yyvs1, size * sizeof (*yyvsp),
611 #else /* no yyoverflow */
612 /* Extend the stack our own way. */
613 if (yystacksize >= YYMAXDEPTH)
616 if (yystacksize > YYMAXDEPTH)
617 yystacksize = YYMAXDEPTH;
621 char *yyptr = (char *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
624 YYSTACK_RELOCATE (short, yyss);
625 YYSTACK_RELOCATE (YYSTYPE, yyvs);
627 YYSTACK_RELOCATE (YYLTYPE, yyls);
629 # undef YYSTACK_RELOCATE
631 YYSTACK_FREE (yyss1);
633 #endif /* no yyoverflow */
635 yyssp = yyss + size - 1;
636 yyvsp = yyvs + size - 1;
638 yylsp = yyls + size - 1;
641 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
642 (unsigned long int) yystacksize));
644 if (yyssp >= yyss + yystacksize - 1)
648 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
657 /* Do appropriate processing given the current state. */
658 /* Read a lookahead token if we need one and don't already have one. */
661 /* First try to decide what to do without reference to lookahead token. */
663 yyn = yypact[yystate];
667 /* Not known => get a lookahead token if don't already have one. */
669 /* yychar is either YYEMPTY or YYEOF
670 or a valid token in external form. */
672 if (yychar == YYEMPTY)
674 YYDPRINTF ((stderr, "Reading a token: "));
678 /* Convert token to internal form (in yychar1) for indexing tables with. */
680 if (yychar <= 0) /* This means end of input. */
683 yychar = YYEOF; /* Don't call YYLEX any more. */
685 YYDPRINTF ((stderr, "Now at end of input.\n"));
689 yychar1 = YYTRANSLATE (yychar);
692 /* We have to keep this `#if YYDEBUG', since we use variables
693 which are defined only if `YYDEBUG' is set. */
696 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
697 /* Give the individual parser a way to print the precise
698 meaning of a token, for further debugging info. */
700 YYPRINT (stderr, yychar, yylval);
702 fprintf (stderr, ")\n");
708 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
713 /* yyn is what to do for this token type in this state.
714 Negative => reduce, -yyn is rule number.
715 Positive => shift, yyn is new state.
716 New state is final state => don't bother to shift,
718 0, or most negative number => error. */
733 /* Shift the lookahead token. */
734 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
736 /* Discard the token being shifted unless it is eof. */
745 /* Count tokens shifted since error; after three, turn off error
754 /*-----------------------------------------------------------.
755 | yydefault -- do the default action for the current state. |
756 `-----------------------------------------------------------*/
758 yyn = yydefact[yystate];
764 /*-----------------------------.
765 | yyreduce -- Do a reduction. |
766 `-----------------------------*/
768 /* yyn is the number of a rule to reduce with. */
771 /* If YYLEN is nonzero, implement the default value of the action:
774 Otherwise, the following line sets YYVAL to the semantic value of
775 the lookahead token. This behavior is undocumented and Bison
776 users should not rely upon it. Assigning to YYVAL
777 unconditionally makes the parser a bit smaller, and it avoids a
778 GCC warning that YYVAL may be used uninitialized. */
779 yyval = yyvsp[1-yylen];
782 /* Similarly for the default location. Let the user run additional
783 commands if for instance locations are ranges. */
784 yyloc = yylsp[1-yylen];
785 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
789 /* We have to keep this `#if YYDEBUG', since we use variables which
790 are defined only if `YYDEBUG' is set. */
795 fprintf (stderr, "Reducing via rule %d (line %d), ",
798 /* Print the symbols being reduced, and their result. */
799 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
800 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
801 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
808 #line %%line "%%skeleton"
819 short *ssp1 = yyss - 1;
820 fprintf (stderr, "state stack now");
821 while (ssp1 != yyssp)
822 fprintf (stderr, " %d", *++ssp1);
823 fprintf (stderr, "\n");
832 /* Now `shift' the result of the reduction. Determine what state
833 that goes to, based on the state we popped back to and the rule
834 number reduced by. */
838 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
839 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
840 yystate = yytable[yystate];
842 yystate = yydefgoto[yyn - YYNTBASE];
847 /*------------------------------------.
848 | yyerrlab -- here on detecting error |
849 `------------------------------------*/
851 /* If not already recovering from an error, report this error. */
857 yyn = yypact[yystate];
859 if (yyn > YYFLAG && yyn < YYLAST)
866 /* Start X at -YYN if negative to avoid negative indexes in
868 for (x = yyn < 0 ? -yyn : 0;
869 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
870 if (yycheck[x + yyn] == x)
871 size += strlen (yytname[x]) + 15, count++;
872 size += strlen ("parse error, unexpected ") + 1;
873 size += strlen (yytname[YYTRANSLATE (yychar)]);
874 msg = (char *) malloc (size);
877 strcpy (msg, "parse error, unexpected ");
878 strcat (msg, yytname[YYTRANSLATE (yychar)]);
883 for (x = yyn < 0 ? -yyn : 0;
884 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
885 if (yycheck[x + yyn] == x)
887 strcat (msg, count == 0 ? ", expecting " : " or ");
888 strcat (msg, yytname[x]);
896 yyerror ("parse error; also virtual memory exhausted");
899 #endif /* YYERROR_VERBOSE */
900 yyerror ("parse error");
905 /*----------------------------------------------------.
906 | yyerrlab1 -- error raised explicitly by an action. |
907 `----------------------------------------------------*/
909 if (yyerrstatus == 3)
911 /* If just tried and failed to reuse lookahead token after an
912 error, discard it. */
914 /* Return failure if at end of input. */
917 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
918 yychar, yytname[yychar1]));
922 /* Else will try to reuse lookahead token after shifting the error
925 yyerrstatus = 3; /* Each real token shifted decrements this. */
930 /*-------------------------------------------------------------------.
931 | yyerrdefault -- current state does not do anything special for the |
933 `-------------------------------------------------------------------*/
936 /* This is wrong; only states that explicitly want error tokens
937 should shift them. */
939 /* If its default is to accept any token, ok. Otherwise pop it. */
940 yyn = yydefact[yystate];
946 /*---------------------------------------------------------------.
947 | yyerrpop -- pop the current state because it cannot handle the |
949 `---------------------------------------------------------------*/
962 short *ssp1 = yyss - 1;
963 fprintf (stderr, "Error: state stack now");
964 while (ssp1 != yyssp)
965 fprintf (stderr, " %d", *++ssp1);
966 fprintf (stderr, "\n");
974 yyn = yypact[yystate];
979 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
996 YYDPRINTF ((stderr, "Shifting error token, "));
1007 /*-------------------------------------.
1008 | yyacceptlab -- YYACCEPT comes here. |
1009 `-------------------------------------*/
1014 /*-----------------------------------.
1015 | yyabortlab -- YYABORT comes here. |
1016 `-----------------------------------*/
1021 /*---------------------------------------------.
1022 | yyoverflowab -- parser overflow comes here. |
1023 `---------------------------------------------*/
1025 yyerror ("parser stack overflow");
1032 YYSTACK_FREE (yyss);
1037 #line %%input-line "%%filename"