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 /* Copy the user declarations. */
45 #ifndef YYSTACK_USE_ALLOCA
47 # define YYSTACK_USE_ALLOCA 1
48 # else /* alloca not defined */
50 # define YYSTACK_USE_ALLOCA 1
51 # define alloca __builtin_alloca
52 # else /* not GNU C. */
53 # if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
54 # define YYSTACK_USE_ALLOCA 1
56 # else /* not sparc */
57 /* We think this test detects Watcom and Microsoft C. */
58 /* This used to test MSDOS, but that is a bad idea since that
59 symbol is in the user namespace. */
60 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
62 /* No need for malloc.h, which pollutes the namespace; instead,
63 just don't use alloca. */
66 # else /* not MSDOS, or __TURBOC__ */
68 /* I don't know what this was needed for, but it pollutes the
69 namespace. So I turned it off. rms, 2 May 1997. */
70 /* #include <malloc.h> */
72 # define YYSTACK_USE_ALLOCA 1
73 # else /* not MSDOS, or __TURBOC__, or _AIX */
75 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
76 HPUX 10. Eventually we can turn this on. */
78 # define YYSTACK_USE_ALLOCA 1
79 # define alloca __builtin_alloca
82 # endif /* not _AIX */
83 # endif /* not MSDOS, or __TURBOC__ */
84 # endif /* not sparc */
85 # endif /* not GNU C */
86 # endif /* alloca not defined */
87 #endif /* YYSTACK_USE_ALLOCA not defined */
89 #if YYSTACK_USE_ALLOCA
90 # define YYSTACK_ALLOC alloca
92 # define YYSTACK_ALLOC malloc
95 #define YYBISON 1 /* Identify Bison output. */
96 #define YYPURE %%pure /* Identify pure parsers. */
99 # define YYDEBUG %%debug
103 # define YYSTYPE %%stype
107 typedef struct yyltype
114 # define YYLTYPE %%ltype
117 #ifndef YYERROR_VERBOSE
118 # define YYERROR_VERBOSE %%verbose
124 #define YYFINAL %%final
125 #define YYFLAG %%flag
126 #define YYNTBASE %%ntbase
127 #define YYLAST %%last
129 #define YYNTOKENS %%ntokens
130 #define YYNNTS %%nnts
131 #define YYNRULES %%nrules
132 #define YYNSTATES %%nstates
133 #define YYMAXUTOK %%maxtok
135 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
136 #define YYTRANSLATE(x) ((unsigned)(x) <= %%maxtok ? yytranslate[x] : %%nsym)
138 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
139 static const char yytranslate[] =
145 static const short yyprhs[] =
150 static const short yyrhs[] =
155 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
156 static const short yyrline[] =
162 #if YYDEBUG || YYERROR_VERBOSE
163 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
164 static const char* const yytname[] =
170 /* YYTOKNUM[YYN] -- Index in YYTNAME corresponding to YYLEX. */
171 static const short yytoknum[] =
176 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
177 static const short yyr1[] =
182 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
183 static const short yyr2[] =
188 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
189 doesn't specify something else to do. Zero means the default is an
191 static const short yydefact[] =
196 static const short yydefgoto[] =
201 static const short yypact[] =
206 static const short yypgoto[] =
211 static const short yytable[] =
216 static const short yycheck[] =
221 #define yyerrok (yyerrstatus = 0)
222 #define yyclearin (%%yychar = YYEMPTY)
226 #define YYACCEPT goto yyacceptlab
227 #define YYABORT goto yyabortlab
228 #define YYERROR goto yyerrlab1
230 /* Like YYERROR except do call yyerror. This remains here temporarily
231 to ease the transition to the new meaning of YYERROR, for GCC.
232 Once GCC version 2 has supplanted version 1, this can go. */
234 #define YYFAIL goto yyerrlab
236 #define YYRECOVERING() (!!yyerrstatus)
238 #define YYBACKUP(Token, Value) \
240 if (%%yychar == YYEMPTY && yylen == 1) \
242 %%yychar = (Token); \
243 %%yylval = (Value); \
244 yychar1 = YYTRANSLATE (%%yychar); \
250 %%yyerror ("syntax error: cannot back up"); \
256 #define YYERRCODE 256
258 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
261 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
262 first token. By default, to implement support for ranges, extend
263 its range to the last symbol. */
265 #ifndef YYLLOC_DEFAULT
266 # define YYLLOC_DEFAULT(Current, Rhs, N) \
267 Current.last_line = Rhs[N].last_line; \
268 Current.last_column = Rhs[N].last_column;
271 /* YYLEX -- calling `yylex' with the right arguments. */
276 # define YYLEX %%yylex (&%%yylval, &yylloc, YYLEX_PARAM)
278 # define YYLEX %%yylex (&%%yylval, &yylloc)
280 # else /* !YYLSP_NEEDED */
282 # define YYLEX %%yylex (&%%yylval, YYLEX_PARAM)
284 # define YYLEX %%yylex (&%%yylval)
286 # endif /* !YYLSP_NEEDED */
288 # define YYLEX %%yylex ()
291 /* Enable debugging if requested. */
293 # define YYDPRINTF(Args) \
298 /* Nonzero means print parse trace. [The following comment makes no
299 sense to me. Could someone clarify it? --akim] Since this is
300 uninitialized, it does not stop multiple parsers from coexisting.
304 # define YYDPRINTF(Args)
305 #endif /* !YYDEBUG */
307 /* YYINITDEPTH -- initial size of the parser's stacks. */
309 # define YYINITDEPTH %%initdepth
312 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
313 if the built-in stack extension method is used). */
319 # define YYMAXDEPTH %%maxdepth
324 /* Define __yy_memcpy. Note that the size argument
325 should be passed with type unsigned int, because that is what the non-GCC
326 definitions require. With GCC, __builtin_memcpy takes an arg
327 of type size_t, but it can handle unsigned int. */
329 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
330 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
331 #else /* not GNU C or C++ */
333 /* This is the most reliable way to avoid incompatibilities
334 in available built-in functions on various systems. */
337 __yy_memcpy (to, from, count)
341 # else /* __cplusplus */
342 __yy_memcpy (char *to, const char *from, unsigned int count)
345 register const char *f = from;
346 register char *t = to;
347 register int i = count;
356 #line %%line "%%filename"
358 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
359 into yyparse. The argument should have type void *.
360 It should actually point to an object.
361 Grammar actions can access the variable by casting it
362 to the proper pointer type. */
366 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
367 # define YYPARSE_PARAM_DECL
368 # else /* !__cplusplus */
369 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
370 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
371 # endif /* !__cplusplus */
372 #else /* !YYPARSE_PARAM */
373 # define YYPARSE_PARAM_ARG
374 # define YYPARSE_PARAM_DECL
375 #endif /* !YYPARSE_PARAM */
377 /* Prevent warning if -Wstrict-prototypes. */
379 # ifdef YYPARSE_PARAM
380 int %%yyparse (void *);
382 int %%yyparse (void);
386 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
387 variables are global, or local to YYPARSE. */
389 #define _YY_DECL_VARIABLES \
390 /* The lookahead symbol. */ \
393 /* The semantic value of the lookahead symbol. */ \
396 /* Number of parse errors so far. */ \
400 # define YY_DECL_VARIABLES \
403 /* Location data for the lookahead symbol. */ \
406 # define YY_DECL_VARIABLES \
410 /* If nonreentrant, generate the variables here. */
417 %%yyparse (YYPARSE_PARAM_ARG)
420 /* If reentrant, generate the variables here. */
425 register int yystate;
427 /* Number of tokens to shift before error messages enabled. */
429 /* Lookahead token as an internal (translated) token number. */
432 /* Three stacks and their tools:
433 `yyss': related to states,
434 `yysv': related to semantic values,
435 `yyls': related to locations.
437 Refer to the stacks thru separate pointers, to allow yyoverflow
438 to reallocate them elsewhere. */
440 /* The state stack. */
441 short yyssa[YYINITDEPTH];
443 register short *yyssp;
445 /* The semantic value stack. */
446 YYSTYPE yyvsa[YYINITDEPTH];
447 YYSTYPE *yyvs = yyvsa;
448 register YYSTYPE *yyvsp;
451 /* The location stack. */
452 YYLTYPE yylsa[YYINITDEPTH];
453 YYLTYPE *yyls = yylsa;
458 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
460 # define YYPOPSTACK (yyvsp--, yyssp--)
463 int yystacksize = YYINITDEPTH;
464 int yyfree_stacks = 0;
466 /* The variables used to return semantic value and location from the
473 /* When reducing, the number of symbols on the RHS of the reduced
477 YYDPRINTF ((stderr, "Starting parse\n"));
482 %%yychar = YYEMPTY; /* Cause a token to be read. */
484 /* Initialize stack pointers.
485 Waste one element of value and location stack
486 so that they stay on the same level as the state stack.
487 The wasted elements are never initialized. */
496 /*------------------------------------------------------------.
497 | yynewstate -- Push a new state, which is found in yystate. |
498 `------------------------------------------------------------*/
500 /* In all cases, when you get here, the value and location stacks
501 have just been pushed. so pushing a state here evens the stacks.
508 if (yyssp >= yyss + yystacksize - 1)
510 /* Give user a chance to reallocate the stack. Use copies of
511 these so that the &'s don't force the real ones into memory.
513 YYSTYPE *yyvs1 = yyvs;
516 YYLTYPE *yyls1 = yyls;
519 /* Get the current used size of the three stacks, in elements. */
520 int size = yyssp - yyss + 1;
523 /* Each stack pointer address is followed by the size of the
524 data in use in that stack, in bytes. */
526 /* This used to be a conditional around just the two extra args,
527 but that might be undefined if yyoverflow is a macro. */
528 yyoverflow ("parser stack overflow",
529 &yyss1, size * sizeof (*yyssp),
530 &yyvs1, size * sizeof (*yyvsp),
531 &yyls1, size * sizeof (*yylsp),
534 yyoverflow ("parser stack overflow",
535 &yyss1, size * sizeof (*yyssp),
536 &yyvs1, size * sizeof (*yyvsp),
540 yyss = yyss1; yyvs = yyvs1;
544 #else /* no yyoverflow */
545 /* Extend the stack our own way. */
546 if (yystacksize >= YYMAXDEPTH)
548 %%yyerror ("parser stack overflow");
560 if (yystacksize > YYMAXDEPTH)
561 yystacksize = YYMAXDEPTH;
562 # if !YYSTACK_USE_ALLOCA
565 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
566 __yy_memcpy ((char *)yyss, (char *)yyss1,
567 size * (unsigned int) sizeof (*yyssp));
568 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
569 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
570 size * (unsigned int) sizeof (*yyvsp));
572 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
573 __yy_memcpy ((char *)yyls, (char *)yyls1,
574 size * (unsigned int) sizeof (*yylsp));
576 #endif /* no yyoverflow */
578 yyssp = yyss + size - 1;
579 yyvsp = yyvs + size - 1;
581 yylsp = yyls + size - 1;
584 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
586 if (yyssp >= yyss + yystacksize - 1)
590 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
599 /* Do appropriate processing given the current state. */
600 /* Read a lookahead token if we need one and don't already have one. */
603 /* First try to decide what to do without reference to lookahead token. */
605 yyn = yypact[yystate];
609 /* Not known => get a lookahead token if don't already have one. */
611 /* yychar is either YYEMPTY or YYEOF
612 or a valid token in external form. */
614 if (%%yychar == YYEMPTY)
616 YYDPRINTF ((stderr, "Reading a token: "));
620 /* Convert token to internal form (in yychar1) for indexing tables with */
622 if (%%yychar <= 0) /* This means end of input. */
625 %%yychar = YYEOF; /* Don't call YYLEX any more */
627 YYDPRINTF ((stderr, "Now at end of input.\n"));
631 yychar1 = YYTRANSLATE (%%yychar);
634 /* We have to keep this `#if YYDEBUG', since we use variables
635 which are defined only if `YYDEBUG' is set. */
638 fprintf (stderr, "Next token is %d (%s", %%yychar, yytname[yychar1]);
639 /* Give the individual parser a way to print the precise
640 meaning of a token, for further debugging info. */
642 YYPRINT (stderr, %%yychar, %%yylval);
644 fprintf (stderr, ")\n");
650 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
655 /* yyn is what to do for this token type in this state.
656 Negative => reduce, -yyn is rule number.
657 Positive => shift, yyn is new state.
658 New state is final state => don't bother to shift,
660 0, or most negative number => error. */
675 /* Shift the lookahead token. */
676 YYDPRINTF ((stderr, "Shifting token %d (%s), ", %%yychar, yytname[yychar1]));
678 /* Discard the token being shifted unless it is eof. */
679 if (%%yychar != YYEOF)
687 /* Count tokens shifted since error; after three, turn off error
696 /*-----------------------------------------------------------.
697 | yydefault -- do the default action for the current state. |
698 `-----------------------------------------------------------*/
700 yyn = yydefact[yystate];
706 /*-----------------------------.
707 | yyreduce -- Do a reduction. |
708 `-----------------------------*/
710 /* yyn is the number of a rule to reduce with. */
713 /* If YYLEN is nonzero, implement the default value of the action:
716 Otherwise, the following line sets YYVAL to the semantic value of
717 the lookahead token. This behavior is undocumented and Bison
718 users should not rely upon it. Assigning to YYVAL
719 unconditionally makes the parser a bit smaller, and it avoids a
720 GCC warning that YYVAL may be used uninitialized. */
721 yyval = yyvsp[1-yylen];
724 /* Similarly for the default location. Let the user run additional
725 commands if for instance locations are ranges. */
726 yyloc = yylsp[1-yylen];
727 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
731 /* We have to keep this `#if YYDEBUG', since we use variables which
732 are defined only if `YYDEBUG' is set. */
737 fprintf (stderr, "Reducing via rule %d (line %d), ",
740 /* Print the symbols being reduced, and their result. */
741 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
742 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
743 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
748 %%action /* The action file replaces this line. */
750 #line %%line "%%filename"
761 short *ssp1 = yyss - 1;
762 fprintf (stderr, "state stack now");
763 while (ssp1 != yyssp)
764 fprintf (stderr, " %d", *++ssp1);
765 fprintf (stderr, "\n");
774 /* Now `shift' the result of the reduction. Determine what state
775 that goes to, based on the state we popped back to and the rule
776 number reduced by. */
780 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
781 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
782 yystate = yytable[yystate];
784 yystate = yydefgoto[yyn - YYNTBASE];
789 /*------------------------------------.
790 | yyerrlab -- here on detecting error |
791 `------------------------------------*/
793 /* If not already recovering from an error, report this error. */
799 yyn = yypact[yystate];
801 if (yyn > YYFLAG && yyn < YYLAST)
808 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
809 for (x = (yyn < 0 ? -yyn : 0);
810 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
811 if (yycheck[x + yyn] == x)
812 size += strlen (yytname[x]) + 15, count++;
813 size += strlen ("parse error, unexpected `") + 1;
814 size += strlen (yytname[YYTRANSLATE (%%yychar)]);
815 msg = (char *) malloc (size);
818 strcpy (msg, "parse error, unexpected `");
819 strcat (msg, yytname[YYTRANSLATE (%%yychar)]);
825 for (x = (yyn < 0 ? -yyn : 0);
826 x < (int) (sizeof (yytname) / sizeof (char *)); x++)
827 if (yycheck[x + yyn] == x)
829 strcat (msg, count == 0 ? ", expecting `" : " or `");
830 strcat (msg, yytname[x]);
839 %%yyerror ("parse error; also virtual memory exceeded");
842 #endif /* YYERROR_VERBOSE */
843 %%yyerror ("parse error");
848 /*--------------------------------------------------.
849 | yyerrlab1 -- error raised explicitly by an action |
850 `--------------------------------------------------*/
852 if (yyerrstatus == 3)
854 /* If just tried and failed to reuse lookahead token after an
855 error, discard it. */
857 /* return failure if at end of input */
858 if (%%yychar == YYEOF)
860 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
861 %%yychar, yytname[yychar1]));
865 /* Else will try to reuse lookahead token after shifting the error
868 yyerrstatus = 3; /* Each real token shifted decrements this */
873 /*-------------------------------------------------------------------.
874 | yyerrdefault -- current state does not do anything special for the |
876 `-------------------------------------------------------------------*/
879 /* This is wrong; only states that explicitly want error tokens
880 should shift them. */
882 /* If its default is to accept any token, ok. Otherwise pop it. */
883 yyn = yydefact[yystate];
889 /*---------------------------------------------------------------.
890 | yyerrpop -- pop the current state because it cannot handle the |
892 `---------------------------------------------------------------*/
905 short *ssp1 = yyss - 1;
906 fprintf (stderr, "Error: state stack now");
907 while (ssp1 != yyssp)
908 fprintf (stderr, " %d", *++ssp1);
909 fprintf (stderr, "\n");
917 yyn = yypact[yystate];
922 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
939 YYDPRINTF ((stderr, "Shifting error token, "));
950 /*-------------------------------------.
951 | yyacceptlab -- YYACCEPT comes here. |
952 `-------------------------------------*/
965 /*-----------------------------------.
966 | yyabortlab -- YYABORT comes here. |
967 `-----------------------------------*/