1 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
3 /* Skeleton output parser for bison,
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* As a special exception, when this file is copied by Bison into a
24 Bison output file, you may use that output file without restriction.
25 This special exception was added by the Free Software Foundation
26 in version 1.24 of Bison. */
28 /* This is the parser code that is written into each bison parser when
29 the %semantic_parser declaration is not specified in the grammar.
30 It was written by Richard Stallman by simplifying the hairy parser
31 used when %semantic_parser is specified. */
33 /* All symbols defined below should begin with yy or YY, to avoid
34 infringing on user name space. This should be done even for local
35 variables, as they might otherwise be expanded by user macros.
36 There are some unavoidable exceptions within include files to
37 define necessary library symbols; they are noted "INFRINGES ON
38 USER NAME SPACE" below. */
40 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
42 /* The parser invokes alloca or malloc; define the necessary symbols. */
44 # if YYSTACK_USE_ALLOCA
45 # define YYSTACK_ALLOC alloca
47 # ifndef YYSTACK_USE_ALLOCA
48 # if defined (alloca) || defined (_ALLOCA_H)
49 # define YYSTACK_ALLOC alloca
52 # define YYSTACK_ALLOC __builtin_alloca
59 /* Pacify GCC's `empty if-body' warning. */
60 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
62 # if defined (__STDC__) || defined (__cplusplus)
63 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
64 # define YYSIZE_T size_t
66 # define YYSTACK_ALLOC malloc
67 # define YYSTACK_FREE free
69 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
72 #if (! defined (yyoverflow) \
73 && (! defined (__cplusplus) \
74 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
76 /* A type that is properly aligned for any stack member. */
86 /* The size of the maximum gap between one aligned stack and the next. */
87 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
89 /* The size of an array large to enough to hold all stacks, each with
92 # define YYSTACK_BYTES(N) \
93 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
94 + 2 * YYSTACK_GAP_MAX)
96 # define YYSTACK_BYTES(N) \
97 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
101 /* Copy COUNT objects from FROM to TO. The source and destination do
105 # define YYCOPY(To, From, Count) \
106 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
108 # define YYCOPY(To, From, Count) \
111 register YYSIZE_T yyi; \
112 for (yyi = 0; yyi < (Count); yyi++) \
113 (To)[yyi] = (From)[yyi]; \
119 /* Relocate STACK from its old location to the new one. The
120 local variables YYSIZE and YYSTACKSIZE give the old and new number of
121 elements in the stack, and YYPTR gives the new location of the
122 stack. Advance YYPTR to a properly aligned location for the next
124 # define YYSTACK_RELOCATE(Stack) \
127 YYSIZE_T yynewbytes; \
128 YYCOPY (&yyptr->Stack, Stack, yysize); \
129 Stack = &yyptr->Stack; \
130 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
131 yyptr += yynewbytes / sizeof (*yyptr); \
138 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
139 # define YYSIZE_T __SIZE_TYPE__
141 #if ! defined (YYSIZE_T) && defined (size_t)
142 # define YYSIZE_T size_t
144 #if ! defined (YYSIZE_T)
145 # if defined (__STDC__) || defined (__cplusplus)
146 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
147 # define YYSIZE_T size_t
150 #if ! defined (YYSIZE_T)
151 # define YYSIZE_T unsigned int
154 #define yyerrok (yyerrstatus = 0)
155 #define yyclearin (yychar = YYEMPTY)
158 #define YYACCEPT goto yyacceptlab
159 #define YYABORT goto yyabortlab
160 #define YYERROR goto yyerrlab1
161 /* Like YYERROR except do call yyerror. This remains here temporarily
162 to ease the transition to the new meaning of YYERROR, for GCC.
163 Once GCC version 2 has supplanted version 1, this can go. */
164 #define YYFAIL goto yyerrlab
165 #define YYRECOVERING() (!!yyerrstatus)
166 #define YYBACKUP(Token, Value) \
168 if (yychar == YYEMPTY && yylen == 1) \
172 yychar1 = YYTRANSLATE (yychar); \
178 yyerror ("syntax error: cannot back up"); \
184 #define YYERRCODE 256
187 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
190 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
191 first token. By default, to implement support for ranges, extend
192 its range to the last symbol. */
194 #ifndef YYLLOC_DEFAULT
195 # define YYLLOC_DEFAULT(Current, Rhs, N) \
196 Current.last_line = Rhs[N].last_line; \
197 Current.last_column = Rhs[N].last_column;
201 /* YYLEX -- calling `yylex' with the right arguments. */
206 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
208 # define YYLEX yylex (&yylval, &yylloc)
210 # else /* !YYLSP_NEEDED */
212 # define YYLEX yylex (&yylval, YYLEX_PARAM)
214 # define YYLEX yylex (&yylval)
216 # endif /* !YYLSP_NEEDED */
218 # define YYLEX yylex ()
222 /* Enable debugging if requested. */
226 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
227 # define YYFPRINTF fprintf
230 # define YYDPRINTF(Args) \
235 /* Nonzero means print parse trace. It is left uninitialized so that
236 multiple parsers can coexist. */
239 # define YYDPRINTF(Args)
240 #endif /* !YYDEBUG */
242 /* YYINITDEPTH -- initial size of the parser's stacks. */
244 # define YYINITDEPTH 200
247 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
248 if the built-in stack extension method is used).
250 Do not make this value too large; the results are undefined if
251 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
252 evaluated with infinite-precision integer arithmetic. */
259 # define YYMAXDEPTH 10000
262 #ifdef YYERROR_VERBOSE
265 # if defined (__GLIBC__) && defined (_STRING_H)
266 # define yystrlen strlen
268 /* Return the length of YYSTR. */
270 # if defined (__STDC__) || defined (__cplusplus)
271 yystrlen (const char *yystr)
277 register const char *yys = yystr;
279 while (*yys++ != '\0')
282 return yys - yystr - 1;
288 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
289 # define yystpcpy stpcpy
291 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
294 # if defined (__STDC__) || defined (__cplusplus)
295 yystpcpy (char *yydest, const char *yysrc)
297 yystpcpy (yydest, yysrc)
302 register char *yyd = yydest;
303 register const char *yys = yysrc;
305 while ((*yyd++ = *yys++) != '\0')
316 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
317 into yyparse. The argument should have type void *.
318 It should actually point to an object.
319 Grammar actions can access the variable by casting it
320 to the proper pointer type. */
323 # if defined (__STDC__) || defined (__cplusplus)
324 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
325 # define YYPARSE_PARAM_DECL
327 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
328 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
330 #else /* !YYPARSE_PARAM */
331 # define YYPARSE_PARAM_ARG
332 # define YYPARSE_PARAM_DECL
333 #endif /* !YYPARSE_PARAM */
335 /* Prevent warning if -Wstrict-prototypes. */
337 # ifdef YYPARSE_PARAM
338 int yyparse (void *);
344 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
345 variables are global, or local to YYPARSE. */
347 #define YY_DECL_NON_LSP_VARIABLES \
348 /* The lookahead symbol. */ \
351 /* The semantic value of the lookahead symbol. */ \
354 /* Number of parse errors so far. */ \
358 # define YY_DECL_VARIABLES \
359 YY_DECL_NON_LSP_VARIABLES \
361 /* Location data for the lookahead symbol. */ \
364 # define YY_DECL_VARIABLES \
365 YY_DECL_NON_LSP_VARIABLES
369 /* If nonreentrant, generate the variables here. */
376 yyparse (YYPARSE_PARAM_ARG)
379 /* If reentrant, generate the variables here. */
384 register int yystate;
387 /* Number of tokens to shift before error messages enabled. */
389 /* Lookahead token as an internal (translated) token number. */
392 /* Three stacks and their tools:
393 `yyss': related to states,
394 `yyvs': related to semantic values,
395 `yyls': related to locations.
397 Refer to the stacks thru separate pointers, to allow yyoverflow
398 to reallocate them elsewhere. */
400 /* The state stack. */
401 short yyssa[YYINITDEPTH];
403 register short *yyssp;
405 /* The semantic value stack. */
406 YYSTYPE yyvsa[YYINITDEPTH];
407 YYSTYPE *yyvs = yyvsa;
408 register YYSTYPE *yyvsp;
411 /* The location stack. */
412 YYLTYPE yylsa[YYINITDEPTH];
413 YYLTYPE *yyls = yylsa;
418 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
420 # define YYPOPSTACK (yyvsp--, yyssp--)
423 YYSIZE_T yystacksize = YYINITDEPTH;
426 /* The variables used to return semantic value and location from the
433 /* When reducing, the number of symbols on the RHS of the reduced
437 YYDPRINTF ((stderr, "Starting parse\n"));
442 yychar = YYEMPTY; /* Cause a token to be read. */
444 /* Initialize stack pointers.
445 Waste one element of value and location stack
446 so that they stay on the same level as the state stack.
447 The wasted elements are never initialized. */
456 /*------------------------------------------------------------.
457 | yynewstate -- Push a new state, which is found in yystate. |
458 `------------------------------------------------------------*/
460 /* In all cases, when you get here, the value and location stacks
461 have just been pushed. so pushing a state here evens the stacks.
468 if (yyssp >= yyss + yystacksize - 1)
470 /* Get the current used size of the three stacks, in elements. */
471 YYSIZE_T yysize = yyssp - yyss + 1;
475 /* Give user a chance to reallocate the stack. Use copies of
476 these so that the &'s don't force the real ones into
478 YYSTYPE *yyvs1 = yyvs;
481 /* Each stack pointer address is followed by the size of the
482 data in use in that stack, in bytes. */
484 YYLTYPE *yyls1 = yyls;
485 /* This used to be a conditional around just the two extra args,
486 but that might be undefined if yyoverflow is a macro. */
487 yyoverflow ("parser stack overflow",
488 &yyss1, yysize * sizeof (*yyssp),
489 &yyvs1, yysize * sizeof (*yyvsp),
490 &yyls1, yysize * sizeof (*yylsp),
494 yyoverflow ("parser stack overflow",
495 &yyss1, yysize * sizeof (*yyssp),
496 &yyvs1, yysize * sizeof (*yyvsp),
502 #else /* no yyoverflow */
503 # ifndef YYSTACK_RELOCATE
506 /* Extend the stack our own way. */
507 if (yystacksize >= YYMAXDEPTH)
510 if (yystacksize > YYMAXDEPTH)
511 yystacksize = YYMAXDEPTH;
515 union yyalloc *yyptr =
516 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
519 YYSTACK_RELOCATE (yyss);
520 YYSTACK_RELOCATE (yyvs);
522 YYSTACK_RELOCATE (yyls);
524 # undef YYSTACK_RELOCATE
526 YYSTACK_FREE (yyss1);
529 #endif /* no yyoverflow */
531 yyssp = yyss + yysize - 1;
532 yyvsp = yyvs + yysize - 1;
534 yylsp = yyls + yysize - 1;
537 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
538 (unsigned long int) yystacksize));
540 if (yyssp >= yyss + yystacksize - 1)
544 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
554 /* Do appropriate processing given the current state. */
555 /* Read a lookahead token if we need one and don't already have one. */
558 /* First try to decide what to do without reference to lookahead token. */
560 yyn = yypact[yystate];
564 /* Not known => get a lookahead token if don't already have one. */
566 /* yychar is either YYEMPTY or YYEOF
567 or a valid token in external form. */
569 if (yychar == YYEMPTY)
571 YYDPRINTF ((stderr, "Reading a token: "));
575 /* Convert token to internal form (in yychar1) for indexing tables with */
577 if (yychar <= 0) /* This means end of input. */
580 yychar = YYEOF; /* Don't call YYLEX any more */
582 YYDPRINTF ((stderr, "Now at end of input.\n"));
586 yychar1 = YYTRANSLATE (yychar);
589 /* We have to keep this `#if YYDEBUG', since we use variables
590 which are defined only if `YYDEBUG' is set. */
593 YYFPRINTF (stderr, "Next token is %d (%s",
594 yychar, yytname[yychar1]);
595 /* Give the individual parser a way to print the precise
596 meaning of a token, for further debugging info. */
598 YYPRINT (stderr, yychar, yylval);
600 YYFPRINTF (stderr, ")\n");
606 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
611 /* yyn is what to do for this token type in this state.
612 Negative => reduce, -yyn is rule number.
613 Positive => shift, yyn is new state.
614 New state is final state => don't bother to shift,
616 0, or most negative number => error. */
631 /* Shift the lookahead token. */
632 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
633 yychar, yytname[yychar1]));
635 /* Discard the token being shifted unless it is eof. */
644 /* Count tokens shifted since error; after three, turn off error
653 /*-----------------------------------------------------------.
654 | yydefault -- do the default action for the current state. |
655 `-----------------------------------------------------------*/
657 yyn = yydefact[yystate];
663 /*-----------------------------.
664 | yyreduce -- Do a reduction. |
665 `-----------------------------*/
667 /* yyn is the number of a rule to reduce with. */
670 /* If YYLEN is nonzero, implement the default value of the action:
673 Otherwise, the following line sets YYVAL to the semantic value of
674 the lookahead token. This behavior is undocumented and Bison
675 users should not rely upon it. Assigning to YYVAL
676 unconditionally makes the parser a bit smaller, and it avoids a
677 GCC warning that YYVAL may be used uninitialized. */
678 yyval = yyvsp[1-yylen];
681 /* Similarly for the default location. Let the user run additional
682 commands if for instance locations are ranges. */
683 yyloc = yylsp[1-yylen];
684 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
688 /* We have to keep this `#if YYDEBUG', since we use variables which
689 are defined only if `YYDEBUG' is set. */
694 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
697 /* Print the symbols being reduced, and their result. */
698 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
699 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
700 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
703 %% actions /* The action file replaces this line. */
715 short *yyssp1 = yyss - 1;
716 YYFPRINTF (stderr, "state stack now");
717 while (yyssp1 != yyssp)
718 YYFPRINTF (stderr, " %d", *++yyssp1);
719 YYFPRINTF (stderr, "\n");
728 /* Now `shift' the result of the reduction. Determine what state
729 that goes to, based on the state we popped back to and the rule
730 number reduced by. */
734 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
735 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
736 yystate = yytable[yystate];
738 yystate = yydefgoto[yyn - YYNTBASE];
743 /*------------------------------------.
744 | yyerrlab -- here on detecting error |
745 `------------------------------------*/
747 /* If not already recovering from an error, report this error. */
752 #ifdef YYERROR_VERBOSE
753 yyn = yypact[yystate];
755 if (yyn > YYFLAG && yyn < YYLAST)
762 /* Start YYX at -YYN if negative to avoid negative indexes in
764 for (yyx = yyn < 0 ? -yyn : 0;
765 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
766 if (yycheck[yyx + yyn] == yyx)
767 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
768 yysize += yystrlen ("parse error, unexpected ") + 1;
769 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
770 yymsg = (char *) YYSTACK_ALLOC (yysize);
773 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
774 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
779 for (yyx = yyn < 0 ? -yyn : 0;
780 yyx < (int) (sizeof (yytname) / sizeof (char *));
782 if (yycheck[yyx + yyn] == yyx)
784 const char *yyq = ! yycount ? ", expecting " : " or ";
785 yyp = yystpcpy (yyp, yyq);
786 yyp = yystpcpy (yyp, yytname[yyx]);
791 YYSTACK_FREE (yymsg);
794 yyerror ("parse error; also virtual memory exhausted");
797 #endif /* defined (YYERROR_VERBOSE) */
798 yyerror ("parse error");
803 /*--------------------------------------------------.
804 | yyerrlab1 -- error raised explicitly by an action |
805 `--------------------------------------------------*/
807 if (yyerrstatus == 3)
809 /* If just tried and failed to reuse lookahead token after an
810 error, discard it. */
812 /* return failure if at end of input */
815 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
816 yychar, yytname[yychar1]));
820 /* Else will try to reuse lookahead token after shifting the error
823 yyerrstatus = 3; /* Each real token shifted decrements this */
828 /*-------------------------------------------------------------------.
829 | yyerrdefault -- current state does not do anything special for the |
831 `-------------------------------------------------------------------*/
834 /* This is wrong; only states that explicitly want error tokens
835 should shift them. */
837 /* If its default is to accept any token, ok. Otherwise pop it. */
838 yyn = yydefact[yystate];
844 /*---------------------------------------------------------------.
845 | yyerrpop -- pop the current state because it cannot handle the |
847 `---------------------------------------------------------------*/
860 short *yyssp1 = yyss - 1;
861 YYFPRINTF (stderr, "Error: state stack now");
862 while (yyssp1 != yyssp)
863 YYFPRINTF (stderr, " %d", *++yyssp1);
864 YYFPRINTF (stderr, "\n");
872 yyn = yypact[yystate];
877 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
894 YYDPRINTF ((stderr, "Shifting error token, "));
905 /*-------------------------------------.
906 | yyacceptlab -- YYACCEPT comes here. |
907 `-------------------------------------*/
912 /*-----------------------------------.
913 | yyabortlab -- YYABORT comes here. |
914 `-----------------------------------*/
919 /*---------------------------------------------.
920 | yyoverflowab -- parser overflow comes here. |
921 `---------------------------------------------*/
923 yyerror ("parser stack overflow");