2 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
10 #define yyclearin (yychar = YYEMPTY)
11 #define yyerrok (yyerrflag = 0)
12 #define YYRECOVERING() (yyerrflag != 0)
19 /* compatibility with bison */
21 /* compatibility with FreeBSD */
22 # ifdef YYPARSE_PARAM_TYPE
23 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
25 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
28 # define YYPARSE_DECL() yyparse(void)
31 /* Parameters sent to lex. */
33 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
34 # define YYLEX yylex(YYLEX_PARAM)
36 # define YYLEX_DECL() yylex(void)
37 # define YYLEX yylex()
40 /* Parameters sent to yyerror. */
42 #define YYERROR_DECL() yyerror(const char *s)
45 #define YYERROR_CALL(msg) yyerror(msg)
48 extern int YYPARSE_DECL();
51 static const short yylhs[] = { -1,
54 static const short yylen[] = { 2,
57 static const short yydefred[] = { 1,
60 static const short yydgoto[] = { 1,
62 static const short yysindex[] = { 0,
65 static const short yyrindex[] = { 0,
68 static const short yygindex[] = { 0,
71 static const short yytable[] = { 0,
73 static const short yycheck[] = { -1,
81 static const char *yyname[] = {
85 static const char *yyrule[] = {
100 /* define the initial stack-sizes */
103 #define YYMAXDEPTH YYSTACKSIZE
106 #define YYSTACKSIZE YYMAXDEPTH
108 #define YYSTACKSIZE 500
109 #define YYMAXDEPTH 500
113 #define YYINITSTACKSIZE 500
123 /* variables for the parser stack */
124 static YYSTACKDATA yystack;
127 #include <stdio.h> /* needed for printf */
130 #include <stdlib.h> /* needed for malloc, etc */
131 #include <string.h> /* needed for memset */
133 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
134 static int yygrowstack(YYSTACKDATA *data)
141 if ((newsize = data->stacksize) == 0)
142 newsize = YYINITSTACKSIZE;
143 else if (newsize >= YYMAXDEPTH)
145 else if ((newsize *= 2) > YYMAXDEPTH)
146 newsize = YYMAXDEPTH;
148 i = data->s_mark - data->s_base;
149 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
153 data->s_base = newss;
154 data->s_mark = newss + i;
156 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
160 data->l_base = newvs;
161 data->l_mark = newvs + i;
163 data->stacksize = newsize;
164 data->s_last = data->s_base + newsize - 1;
168 #if YYPURE || defined(YY_NO_LEAKS)
169 static void yyfreestack(YYSTACKDATA *data)
173 memset(data, 0, sizeof(*data));
176 #define yyfreestack(data) /* nothing */
179 #define YYABORT goto yyabort
180 #define YYREJECT goto yyabort
181 #define YYACCEPT goto yyaccept
182 #define YYERROR goto yyerrlab
187 int yym, yyn, yystate;
191 if ((yys = getenv("YYDEBUG")) != 0)
194 if (yyn >= '0' && yyn <= '9')
205 memset(&yystack, 0, sizeof(yystack));
208 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
209 yystack.s_mark = yystack.s_base;
210 yystack.l_mark = yystack.l_base;
215 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
218 if ((yychar = YYLEX) < 0) yychar = 0;
223 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
224 if (!yys) yys = "illegal-symbol";
225 printf("%sdebug: state %d, reading %d (%s)\n",
226 YYPREFIX, yystate, yychar, yys);
230 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
231 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
235 printf("%sdebug: state %d, shifting to state %d\n",
236 YYPREFIX, yystate, yytable[yyn]);
238 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
242 yystate = yytable[yyn];
243 *++yystack.s_mark = yytable[yyn];
244 *++yystack.l_mark = yylval;
246 if (yyerrflag > 0) --yyerrflag;
249 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
250 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
255 if (yyerrflag) goto yyinrecovery;
257 yyerror("syntax error");
270 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
271 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
275 printf("%sdebug: state %d, error recovery shifting\
276 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
278 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
282 yystate = yytable[yyn];
283 *++yystack.s_mark = yytable[yyn];
284 *++yystack.l_mark = yylval;
291 printf("%sdebug: error recovery discarding state %d\n",
292 YYPREFIX, *yystack.s_mark);
294 if (yystack.s_mark <= yystack.s_base) goto yyabort;
302 if (yychar == 0) goto yyabort;
307 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
308 if (!yys) yys = "illegal-symbol";
309 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
310 YYPREFIX, yystate, yychar, yys);
320 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
321 YYPREFIX, yystate, yyn, yyrule[yyn]);
325 yyval = yystack.l_mark[1-yym];
327 memset(&yyval, 0, sizeof yyval);
331 yystack.s_mark -= yym;
332 yystate = *yystack.s_mark;
333 yystack.l_mark -= yym;
335 if (yystate == 0 && yym == 0)
339 printf("%sdebug: after reduction, shifting from state 0 to\
340 state %d\n", YYPREFIX, YYFINAL);
343 *++yystack.s_mark = YYFINAL;
344 *++yystack.l_mark = yyval;
347 if ((yychar = YYLEX) < 0) yychar = 0;
352 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
353 if (!yys) yys = "illegal-symbol";
354 printf("%sdebug: state %d, reading %d (%s)\n",
355 YYPREFIX, YYFINAL, yychar, yys);
359 if (yychar == 0) goto yyaccept;
362 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
363 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
364 yystate = yytable[yyn];
366 yystate = yydgoto[yym];
369 printf("%sdebug: after reduction, shifting from state %d \
370 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
372 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
376 *++yystack.s_mark = (short) yystate;
377 *++yystack.l_mark = yyval;
381 yyerror("yacc stack overflow");
384 yyfreestack(&yystack);
388 yyfreestack(&yystack);