1 /* $Id: yaccpar.skel,v 1.8 2016/12/02 21:44:42 tom Exp $ */
5 /* If the skeleton is changed, the banner should be changed so that */
6 /* the altered version can be easily distinguished from the original. */
8 /* The #defines included with the banner are there because they are */
9 /* useful in subsequent code. The macros #defined in the header or */
10 /* the body either are not useful outside of semantic actions or */
11 /* are conditional. */
14 /* original parser id follows */
15 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
16 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
19 %% insert VERSION here
22 #define yyclearin (yychar = YYEMPTY)
23 #define yyerrok (yyerrflag = 0)
24 #define YYRECOVERING() (yyerrflag != 0)
29 extern int YYPARSE_DECL();
33 extern YYINT yydefred[];
34 extern YYINT yydgoto[];
35 extern YYINT yysindex[];
36 extern YYINT yyrindex[];
37 extern YYINT yygindex[];
38 extern YYINT yytable[];
39 extern YYINT yycheck[];
41 #if YYDEBUG || defined(yytname)
42 extern char *yyname[];
45 extern char *yyrule[];
59 /* define the initial stack-sizes */
62 #define YYMAXDEPTH YYSTACKSIZE
65 #define YYSTACKSIZE YYMAXDEPTH
67 #define YYSTACKSIZE 10000
68 #define YYMAXDEPTH 10000
72 #define YYINITSTACKSIZE 200
83 /* variables for the parser stack */
84 static YYSTACKDATA yystack;
91 /* variables for the parser stack */
96 #include <stdio.h> /* needed for printf */
99 #include <stdlib.h> /* needed for malloc, etc */
100 #include <string.h> /* needed for memset */
102 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
103 static int yygrowstack(YYSTACKDATA *data)
110 if ((newsize = data->stacksize) == 0)
111 newsize = YYINITSTACKSIZE;
112 else if (newsize >= YYMAXDEPTH)
114 else if ((newsize *= 2) > YYMAXDEPTH)
115 newsize = YYMAXDEPTH;
117 i = (int) (data->s_mark - data->s_base);
118 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
122 data->s_base = newss;
123 data->s_mark = newss + i;
125 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
129 data->l_base = newvs;
130 data->l_mark = newvs + i;
132 data->stacksize = newsize;
133 data->s_last = data->s_base + newsize - 1;
137 #if YYPURE || defined(YY_NO_LEAKS)
138 static void yyfreestack(YYSTACKDATA *data)
142 memset(data, 0, sizeof(*data));
145 #define yyfreestack(data) /* nothing */
148 #define YYABORT goto yyabort
149 #define YYREJECT goto yyabort
150 #define YYACCEPT goto yyaccept
151 #define YYERROR goto yyerrlab
157 int yym, yyn, yystate;
161 if ((yys = getenv("YYDEBUG")) != 0)
164 if (yyn >= '0' && yyn <= '9')
178 memset(&yystack, 0, sizeof(yystack));
181 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
182 yystack.s_mark = yystack.s_base;
183 yystack.l_mark = yystack.l_base;
188 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
192 if (yychar < 0) yychar = YYEOF;
196 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
197 printf("%sdebug: state %d, reading %d (%s)\n",
198 YYPREFIX, yystate, yychar, yys);
202 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
203 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
207 printf("%sdebug: state %d, shifting to state %d\n",
208 YYPREFIX, yystate, yytable[yyn]);
210 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
211 yystate = yytable[yyn];
212 *++yystack.s_mark = yytable[yyn];
213 *++yystack.l_mark = yylval;
215 if (yyerrflag > 0) --yyerrflag;
218 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
219 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
224 if (yyerrflag != 0) goto yyinrecovery;
226 YYERROR_CALL("syntax error");
228 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
238 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
239 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
243 printf("%sdebug: state %d, error recovery shifting\
244 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
246 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
247 yystate = yytable[yyn];
248 *++yystack.s_mark = yytable[yyn];
249 *++yystack.l_mark = yylval;
256 printf("%sdebug: error recovery discarding state %d\n",
257 YYPREFIX, *yystack.s_mark);
259 if (yystack.s_mark <= yystack.s_base) goto yyabort;
267 if (yychar == YYEOF) goto yyabort;
271 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
272 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
273 YYPREFIX, yystate, yychar, yys);
283 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
284 YYPREFIX, yystate, yyn, yyrule[yyn]);
288 yyval = yystack.l_mark[1-yym];
290 memset(&yyval, 0, sizeof yyval);
296 yystack.s_mark -= yym;
297 yystate = *yystack.s_mark;
298 yystack.l_mark -= yym;
300 if (yystate == 0 && yym == 0)
304 printf("%sdebug: after reduction, shifting from state 0 to\
305 state %d\n", YYPREFIX, YYFINAL);
308 *++yystack.s_mark = YYFINAL;
309 *++yystack.l_mark = yyval;
313 if (yychar < 0) yychar = YYEOF;
317 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
318 printf("%sdebug: state %d, reading %d (%s)\n",
319 YYPREFIX, YYFINAL, yychar, yys);
323 if (yychar == YYEOF) goto yyaccept;
326 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
327 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
328 yystate = yytable[yyn];
330 yystate = yydgoto[yym];
333 printf("%sdebug: after reduction, shifting from state %d \
334 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
336 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
337 *++yystack.s_mark = (YYINT) yystate;
338 *++yystack.l_mark = yyval;
342 YYERROR_CALL("yacc stack overflow");
345 yyfreestack(&yystack);
349 yyfreestack(&yystack);