1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
3 /* Skeleton output parser for bison,
4 Copyright 1984, 1989, 1990, 2000 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* This is the parser code that is written into each bison parser when
27 the %semantic_parser declaration is not specified in the grammar.
28 It was written by Richard Stallman by simplifying the hairy parser
29 used when %semantic_parser is specified. */
31 #ifndef YYSTACK_USE_ALLOCA
33 # define YYSTACK_USE_ALLOCA
34 # else /* alloca not defined */
36 # define YYSTACK_USE_ALLOCA
37 # define alloca __builtin_alloca
38 # else /* not GNU C. */
39 # if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
40 # define YYSTACK_USE_ALLOCA
42 # else /* not sparc */
43 /* We think this test detects Watcom and Microsoft C. */
44 /* This used to test MSDOS, but that is a bad idea since that
45 symbol is in the user namespace. */
46 # if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
48 /* No need for malloc.h, which pollutes the namespace; instead,
49 just don't use alloca. */
52 # else /* not MSDOS, or __TURBOC__ */
54 /* I don't know what this was needed for, but it pollutes the
55 namespace. So I turned it off. rms, 2 May 1997. */
56 /* #include <malloc.h> */
58 # define YYSTACK_USE_ALLOCA
59 # else /* not MSDOS, or __TURBOC__, or _AIX */
61 /* haible@ilog.fr says this works for HPUX 9.05 and up, and on
62 HPUX 10. Eventually we can turn this on. */
64 # define YYSTACK_USE_ALLOCA
65 # define alloca __builtin_alloca
68 # endif /* not _AIX */
69 # endif /* not MSDOS, or __TURBOC__ */
70 # endif /* not sparc */
71 # endif /* not GNU C */
72 # endif /* alloca not defined */
73 #endif /* YYSTACK_USE_ALLOCA not defined */
75 #ifdef YYSTACK_USE_ALLOCA
76 # define YYSTACK_ALLOC alloca
78 # define YYSTACK_ALLOC malloc
81 #define yyerrok (yyerrstatus = 0)
82 #define yyclearin (yychar = YYEMPTY)
85 #define YYACCEPT goto yyacceptlab
86 #define YYABORT goto yyabortlab
87 #define YYERROR goto yyerrlab1
88 /* Like YYERROR except do call yyerror. This remains here temporarily
89 to ease the transition to the new meaning of YYERROR, for GCC.
90 Once GCC version 2 has supplanted version 1, this can go. */
91 #define YYFAIL goto yyerrlab
92 #define YYRECOVERING() (!!yyerrstatus)
93 #define YYBACKUP(Token, Value) \
95 if (yychar == YYEMPTY && yylen == 1) \
99 yychar1 = YYTRANSLATE (yychar); \
105 yyerror ("syntax error: cannot back up"); \
111 #define YYERRCODE 256
114 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
117 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
118 first token. By default, to implement support for ranges, extend
119 its range to the last symbol. */
121 #ifndef YYLLOC_DEFAULT
122 # define YYLLOC_DEFAULT(Current, Last) \
123 Current.last_line = Last.last_line; \
124 Current.last_column = Last.last_column;
128 /* YYLEX -- calling `yylex' with the right arguments. */
133 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
135 # define YYLEX yylex (&yylval, &yylloc)
137 # else /* !YYLSP_NEEDED */
139 # define YYLEX yylex (&yylval, YYLEX_PARAM)
141 # define YYLEX yylex (&yylval)
143 # endif /* !YYLSP_NEEDED */
145 # define YYLEX yylex ()
149 /* Enable debugging if requested. */
151 # define YYDPRINTF(Args) \
156 /* Nonzero means print parse trace. [The following comment makes no
157 sense to me. Could someone clarify it? --akim] Since this is
158 uninitialized, it does not stop multiple parsers from coexisting.
162 # define YYDPRINTF(Args)
163 #endif /* !YYDEBUG */
165 /* YYINITDEPTH -- initial size of the parser's stacks. */
167 # define YYINITDEPTH 200
170 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
171 if the built-in stack extension method is used). */
177 # define YYMAXDEPTH 10000
180 /* Define __yy_memcpy. Note that the size argument
181 should be passed with type unsigned int, because that is what the non-GCC
182 definitions require. With GCC, __builtin_memcpy takes an arg
183 of type size_t, but it can handle unsigned int. */
185 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
186 # define __yy_memcpy(To, From, Count) __builtin_memcpy (To, From, Count)
187 #else /* not GNU C or C++ */
190 /* This is the most reliable way to avoid incompatibilities
191 in available built-in functions on various systems. */
193 __yy_memcpy (to, from, count)
198 register char *f = from;
199 register char *t = to;
200 register int i = count;
206 # else /* __cplusplus */
208 /* This is the most reliable way to avoid incompatibilities
209 in available built-in functions on various systems. */
211 __yy_memcpy (char *to, char *from, unsigned int count)
213 register char *t = to;
214 register char *f = from;
215 register int i = count;
226 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
227 into yyparse. The argument should have type void *.
228 It should actually point to an object.
229 Grammar actions can access the variable by casting it
230 to the proper pointer type. */
234 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
235 # define YYPARSE_PARAM_DECL
236 # else /* !__cplusplus */
237 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
238 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
239 # endif /* !__cplusplus */
240 #else /* !YYPARSE_PARAM */
241 # define YYPARSE_PARAM_ARG
242 # define YYPARSE_PARAM_DECL
243 #endif /* !YYPARSE_PARAM */
245 /* Prevent warning if -Wstrict-prototypes. */
247 # ifdef YYPARSE_PARAM
248 int yyparse (void *);
254 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
255 variables are global, or local to YYPARSE. */
257 #define _YY_DECL_VARIABLES \
258 /* The lookahead symbol. */ \
261 /* The semantic value of the lookahead symbol. */ \
264 /* Number of parse errors so far. */ \
268 # define YY_DECL_VARIABLES \
271 /* Location data for the lookahead symbol. */ \
274 # define YY_DECL_VARIABLES \
279 /* If nonreentrant, generate the variables here. */
286 yyparse (YYPARSE_PARAM_ARG)
289 /* If reentrant, generate the variables here. */
294 register int yystate;
296 /* Number of tokens to shift before error messages enabled. */
298 /* Lookahead token as an internal (translated) token number. */
301 /* Three stacks and their tools:
302 `yyss': related to states,
303 `yysv': related to semantic values,
304 `yyls': related to locations.
306 Refer to the stacks thru separate pointers, to allow yyoverflow
307 to reallocate them elsewhere. */
309 /* The state stack. */
310 short yyssa[YYINITDEPTH];
312 register short *yyssp;
314 /* The semantic value stack. */
315 YYSTYPE yyvsa[YYINITDEPTH];
316 YYSTYPE *yyvs = yyvsa;
317 register YYSTYPE *yyvsp;
320 /* The location stack. */
321 YYLTYPE yylsa[YYINITDEPTH];
322 YYLTYPE *yyls = yylsa;
327 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
329 # define YYPOPSTACK (yyvsp--, yyssp--)
332 int yystacksize = YYINITDEPTH;
333 int yyfree_stacks = 0;
336 /* The variables used to return semantic value and location from the
343 /* When reducing, the number of symbols on the RHS of the reduced
347 YYDPRINTF ((stderr, "Starting parse\n"));
352 yychar = YYEMPTY; /* Cause a token to be read. */
354 /* Initialize stack pointers.
355 Waste one element of value and location stack
356 so that they stay on the same level as the state stack.
357 The wasted elements are never initialized. */
366 /*------------------------------------------------------------.
367 | yynewstate -- Push a new state, which is found in yystate. |
368 `------------------------------------------------------------*/
370 /* In all cases, when you get here, the value and location stacks
371 have just been pushed. so pushing a state here evens the stacks.
375 if (yyssp >= yyss + yystacksize - 1)
377 /* Give user a chance to reallocate the stack. Use copies of
378 these so that the &'s don't force the real ones into memory.
380 YYSTYPE *yyvs1 = yyvs;
383 YYLTYPE *yyls1 = yyls;
386 /* Get the current used size of the three stacks, in elements. */
387 int size = yyssp - yyss + 1;
390 /* Each stack pointer address is followed by the size of the
391 data in use in that stack, in bytes. */
393 /* This used to be a conditional around just the two extra args,
394 but that might be undefined if yyoverflow is a macro. */
395 yyoverflow ("parser stack overflow",
396 &yyss1, size * sizeof (*yyssp),
397 &yyvs1, size * sizeof (*yyvsp),
398 &yyls1, size * sizeof (*yylsp),
401 yyoverflow ("parser stack overflow",
402 &yyss1, size * sizeof (*yyssp),
403 &yyvs1, size * sizeof (*yyvsp),
407 yyss = yyss1; yyvs = yyvs1;
411 #else /* no yyoverflow */
412 /* Extend the stack our own way. */
413 if (yystacksize >= YYMAXDEPTH)
415 yyerror ("parser stack overflow");
427 if (yystacksize > YYMAXDEPTH)
428 yystacksize = YYMAXDEPTH;
429 # ifndef YYSTACK_USE_ALLOCA
432 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
433 __yy_memcpy ((char *)yyss, (char *)yyss1,
434 size * (unsigned int) sizeof (*yyssp));
435 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
436 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
437 size * (unsigned int) sizeof (*yyvsp));
439 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
440 __yy_memcpy ((char *)yyls, (char *)yyls1,
441 size * (unsigned int) sizeof (*yylsp));
443 #endif /* no yyoverflow */
445 yyssp = yyss + size - 1;
446 yyvsp = yyvs + size - 1;
448 yylsp = yyls + size - 1;
451 YYDPRINTF ((stderr, "Stack size increased to %d\n", yystacksize));
453 if (yyssp >= yyss + yystacksize - 1)
457 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
467 /* Do appropriate processing given the current state. */
468 /* Read a lookahead token if we need one and don't already have one. */
471 /* First try to decide what to do without reference to lookahead token. */
473 yyn = yypact[yystate];
477 /* Not known => get a lookahead token if don't already have one. */
479 /* yychar is either YYEMPTY or YYEOF
480 or a valid token in external form. */
482 if (yychar == YYEMPTY)
484 YYDPRINTF ((stderr, "Reading a token: "));
488 /* Convert token to internal form (in yychar1) for indexing tables with */
490 if (yychar <= 0) /* This means end of input. */
493 yychar = YYEOF; /* Don't call YYLEX any more */
495 YYDPRINTF ((stderr, "Now at end of input.\n"));
499 yychar1 = YYTRANSLATE (yychar);
502 /* We have to keep this `#if YYDEBUG', since we use variables
503 which are defined only if `YYDEBUG' is set. */
506 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
507 /* Give the individual parser a way to print the precise
508 meaning of a token, for further debugging info. */
510 YYPRINT (stderr, yychar, yylval);
512 fprintf (stderr, ")\n");
518 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
523 /* yyn is what to do for this token type in this state.
524 Negative => reduce, -yyn is rule number.
525 Positive => shift, yyn is new state.
526 New state is final state => don't bother to shift,
528 0, or most negative number => error. */
543 /* Shift the lookahead token. */
544 YYDPRINTF ((stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]));
546 /* Discard the token being shifted unless it is eof. */
555 /* Count tokens shifted since error; after three, turn off error
564 /*-----------------------------------------------------------.
565 | yydefault -- do the default action for the current state. |
566 `-----------------------------------------------------------*/
568 yyn = yydefact[yystate];
574 /*-----------------------------.
575 | yyreduce -- Do a reduction. |
576 `-----------------------------*/
578 /* yyn is the number of a rule to reduce with. */
581 /* If YYLEN is nonzero, implement the default value of the action:
584 Otherwise, the following line sets YYVAL to the semantic value of
585 the lookahead token. This behavior is undocumented and Bison
586 users should not rely upon it. Assigning to YYVAL
587 unconditionally makes the parser a bit smaller, and it avoids a
588 GCC warning that YYVAL may be used uninitialized. */
589 yyval = yyvsp[1-yylen];
592 /* Similarly for the default location. Let the user run additional
593 commands if for instance locations are ranges. */
594 yyloc = yylsp[1-yylen];
595 YYLLOC_DEFAULT (yyloc, yylsp[0]);
599 /* We have to keep this `#if YYDEBUG', since we use variables which
600 are defined only if `YYDEBUG' is set. */
605 fprintf (stderr, "Reducing via rule %d (line %d), ",
608 /* Print the symbols being reduced, and their result. */
609 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
610 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
611 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
614 %% actions /* The action file replaces this line. */
626 short *ssp1 = yyss - 1;
627 fprintf (stderr, "state stack now");
628 while (ssp1 != yyssp)
629 fprintf (stderr, " %d", *++ssp1);
630 fprintf (stderr, "\n");
639 /* Now `shift' the result of the reduction. Determine what state
640 that goes to, based on the state we popped back to and the rule
641 number reduced by. */
645 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
646 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
647 yystate = yytable[yystate];
649 yystate = yydefgoto[yyn - YYNTBASE];
654 /*------------------------------------.
655 | yyerrlab -- here on detecting error |
656 `------------------------------------*/
658 /* If not already recovering from an error, report this error. */
663 #ifdef YYERROR_VERBOSE
664 yyn = yypact[yystate];
666 if (yyn > YYFLAG && yyn < YYLAST)
673 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
674 for (x = (yyn < 0 ? -yyn : 0);
675 x < (sizeof (yytname) / sizeof (char *)); x++)
676 if (yycheck[x + yyn] == x)
677 size += strlen (yytname[x]) + 15, count++;
678 size += strlen ("parse error, unexpected `") + 1;
679 size += strlen (yytname[YYTRANSLATE (yychar)]);
680 msg = (char *) malloc (size);
683 strcpy (msg, "parse error, unexpected `");
684 strcat (msg, yytname[YYTRANSLATE (yychar)]);
690 for (x = (yyn < 0 ? -yyn : 0);
691 x < (sizeof (yytname) / sizeof (char *)); x++)
692 if (yycheck[x + yyn] == x)
694 strcat (msg, count == 0 ? ", expecting `" : " or `");
695 strcat (msg, yytname[x]);
704 yyerror ("parse error; also virtual memory exceeded");
707 #endif /* YYERROR_VERBOSE */
708 yyerror ("parse error");
713 /*--------------------------------------------------.
714 | yyerrlab1 -- error raised explicitly by an action |
715 `--------------------------------------------------*/
717 if (yyerrstatus == 3)
719 /* If just tried and failed to reuse lookahead token after an
720 error, discard it. */
722 /* return failure if at end of input */
725 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
726 yychar, yytname[yychar1]));
730 /* Else will try to reuse lookahead token after shifting the error
733 yyerrstatus = 3; /* Each real token shifted decrements this */
738 /*-------------------------------------------------------------------.
739 | yyerrdefault -- current state does not do anything special for the |
741 `-------------------------------------------------------------------*/
744 /* This is wrong; only states that explicitly want error tokens
745 should shift them. */
747 /* If its default is to accept any token, ok. Otherwise pop it. */
748 yyn = yydefact[yystate];
754 /*---------------------------------------------------------------.
755 | yyerrpop -- pop the current state because it cannot handle the |
757 `---------------------------------------------------------------*/
770 short *ssp1 = yyss - 1;
771 fprintf (stderr, "Error: state stack now");
772 while (ssp1 != yyssp)
773 fprintf (stderr, " %d", *++ssp1);
774 fprintf (stderr, "\n");
782 yyn = yypact[yystate];
787 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
804 YYDPRINTF ((stderr, "Shifting error token, "));
815 /*-------------------------------------.
816 | yyacceptlab -- YYACCEPT comes here. |
817 `-------------------------------------*/
830 /*-----------------------------------.
831 | yyabortlab -- YYABORT comes here. |
832 `-----------------------------------*/