1 /* Id: yaccpar.skel,v 1.5 2014/04/07 21:51:00 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[];
42 extern char *yyname[];
43 extern char *yyrule[];
57 /* define the initial stack-sizes */
60 #define YYMAXDEPTH YYSTACKSIZE
63 #define YYSTACKSIZE YYMAXDEPTH
65 #define YYSTACKSIZE 10000
66 #define YYMAXDEPTH 10000
70 #define YYINITSTACKSIZE 200
81 /* variables for the parser stack */
82 static YYSTACKDATA yystack;
89 /* variables for the parser stack */
94 #include <stdio.h> /* needed for printf */
97 #include <stdlib.h> /* needed for malloc, etc */
98 #include <string.h> /* needed for memset */
100 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
101 static int yygrowstack(YYSTACKDATA *data)
108 if ((newsize = data->stacksize) == 0)
109 newsize = YYINITSTACKSIZE;
110 else if (newsize >= YYMAXDEPTH)
112 else if ((newsize *= 2) > YYMAXDEPTH)
113 newsize = YYMAXDEPTH;
115 i = (int) (data->s_mark - data->s_base);
116 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
120 data->s_base = newss;
121 data->s_mark = newss + i;
123 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
127 data->l_base = newvs;
128 data->l_mark = newvs + i;
130 data->stacksize = newsize;
131 data->s_last = data->s_base + newsize - 1;
135 #if YYPURE || defined(YY_NO_LEAKS)
136 static void yyfreestack(YYSTACKDATA *data)
140 memset(data, 0, sizeof(*data));
143 #define yyfreestack(data) /* nothing */
146 #define YYABORT goto yyabort
147 #define YYREJECT goto yyabort
148 #define YYACCEPT goto yyaccept
149 #define YYERROR goto yyerrlab
155 int yym, yyn, yystate;
159 if ((yys = getenv("YYDEBUG")) != 0)
162 if (yyn >= '0' && yyn <= '9')
173 memset(&yystack, 0, sizeof(yystack));
176 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
177 yystack.s_mark = yystack.s_base;
178 yystack.l_mark = yystack.l_base;
183 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
186 if ((yychar = YYLEX) < 0) yychar = YYEOF;
190 yys = yyname[YYTRANSLATE(yychar)];
191 printf("%sdebug: state %d, reading %d (%s)\n",
192 YYPREFIX, yystate, yychar, yys);
196 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
197 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
201 printf("%sdebug: state %d, shifting to state %d\n",
202 YYPREFIX, yystate, yytable[yyn]);
204 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
208 yystate = yytable[yyn];
209 *++yystack.s_mark = yytable[yyn];
210 *++yystack.l_mark = yylval;
212 if (yyerrflag > 0) --yyerrflag;
215 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
216 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
221 if (yyerrflag) goto yyinrecovery;
223 YYERROR_CALL("syntax error");
236 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
237 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
241 printf("%sdebug: state %d, error recovery shifting\
242 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
244 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
248 yystate = yytable[yyn];
249 *++yystack.s_mark = yytable[yyn];
250 *++yystack.l_mark = yylval;
257 printf("%sdebug: error recovery discarding state %d\n",
258 YYPREFIX, *yystack.s_mark);
260 if (yystack.s_mark <= yystack.s_base) goto yyabort;
268 if (yychar == YYEOF) goto yyabort;
272 yys = yyname[YYTRANSLATE(yychar)];
273 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
274 YYPREFIX, yystate, yychar, yys);
284 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
285 YYPREFIX, yystate, yyn, yyrule[yyn]);
289 yyval = yystack.l_mark[1-yym];
291 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;
312 if ((yychar = YYLEX) < 0) yychar = YYEOF;
316 yys = yyname[YYTRANSLATE(yychar)];
317 printf("%sdebug: state %d, reading %d (%s)\n",
318 YYPREFIX, YYFINAL, yychar, yys);
322 if (yychar == YYEOF) goto yyaccept;
325 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
326 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
327 yystate = yytable[yyn];
329 yystate = yydgoto[yym];
332 printf("%sdebug: after reduction, shifting from state %d \
333 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
335 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
339 *++yystack.s_mark = (YYINT) yystate;
340 *++yystack.l_mark = yyval;
344 YYERROR_CALL("yacc stack overflow");
347 yyfreestack(&yystack);
351 yyfreestack(&yystack);