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)
20 static void yyerror(const char *);
21 #line 21 "/dev/stdout"
27 /* compatibility with bison */
29 /* compatibility with FreeBSD */
30 # ifdef YYPARSE_PARAM_TYPE
31 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
33 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
36 # define YYPARSE_DECL() yyparse(void)
39 /* Parameters sent to lex. */
41 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
42 # define YYLEX yylex(YYLEX_PARAM)
44 # define YYLEX_DECL() yylex(void)
45 # define YYLEX yylex()
48 /* Parameters sent to yyerror. */
50 #define YYERROR_DECL() yyerror(const char *s)
53 #define YYERROR_CALL(msg) yyerror(msg)
56 extern int YYPARSE_DECL();
59 static const short yylhs[] = { -1,
62 static const short yylen[] = { 2,
65 static const short yydefred[] = { 0,
68 static const short yydgoto[] = { 2,
70 static const short yysindex[] = { -256,
73 static const short yyrindex[] = { 0,
76 static const short yygindex[] = { 0,
79 static const short yytable[] = { 1,
81 static const short yycheck[] = { 256,
89 static const char *yyname[] = {
93 static const char *yyrule[] = {
108 /* define the initial stack-sizes */
111 #define YYMAXDEPTH YYSTACKSIZE
114 #define YYSTACKSIZE YYMAXDEPTH
116 #define YYSTACKSIZE 500
117 #define YYMAXDEPTH 500
121 #define YYINITSTACKSIZE 500
131 /* variables for the parser stack */
132 static YYSTACKDATA yystack;
140 printf("yyparse() = %d\n", yyparse());
151 yyerror(const char* s)
155 #line 155 "/dev/stdout"
158 #include <stdio.h> /* needed for printf */
161 #include <stdlib.h> /* needed for malloc, etc */
162 #include <string.h> /* needed for memset */
164 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
165 static int yygrowstack(YYSTACKDATA *data)
172 if ((newsize = data->stacksize) == 0)
173 newsize = YYINITSTACKSIZE;
174 else if (newsize >= YYMAXDEPTH)
176 else if ((newsize *= 2) > YYMAXDEPTH)
177 newsize = YYMAXDEPTH;
179 i = data->s_mark - data->s_base;
180 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
184 data->s_base = newss;
185 data->s_mark = newss + i;
187 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
191 data->l_base = newvs;
192 data->l_mark = newvs + i;
194 data->stacksize = newsize;
195 data->s_last = data->s_base + newsize - 1;
199 #if YYPURE || defined(YY_NO_LEAKS)
200 static void yyfreestack(YYSTACKDATA *data)
204 memset(data, 0, sizeof(*data));
207 #define yyfreestack(data) /* nothing */
210 #define YYABORT goto yyabort
211 #define YYREJECT goto yyabort
212 #define YYACCEPT goto yyaccept
213 #define YYERROR goto yyerrlab
218 int yym, yyn, yystate;
222 if ((yys = getenv("YYDEBUG")) != 0)
225 if (yyn >= '0' && yyn <= '9')
236 memset(&yystack, 0, sizeof(yystack));
239 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
240 yystack.s_mark = yystack.s_base;
241 yystack.l_mark = yystack.l_base;
246 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
249 if ((yychar = YYLEX) < 0) yychar = 0;
254 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
255 if (!yys) yys = "illegal-symbol";
256 printf("%sdebug: state %d, reading %d (%s)\n",
257 YYPREFIX, yystate, yychar, yys);
261 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
262 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
266 printf("%sdebug: state %d, shifting to state %d\n",
267 YYPREFIX, yystate, yytable[yyn]);
269 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
273 yystate = yytable[yyn];
274 *++yystack.s_mark = yytable[yyn];
275 *++yystack.l_mark = yylval;
277 if (yyerrflag > 0) --yyerrflag;
280 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
281 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
286 if (yyerrflag) goto yyinrecovery;
288 yyerror("syntax error");
301 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
302 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
306 printf("%sdebug: state %d, error recovery shifting\
307 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
309 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
313 yystate = yytable[yyn];
314 *++yystack.s_mark = yytable[yyn];
315 *++yystack.l_mark = yylval;
322 printf("%sdebug: error recovery discarding state %d\n",
323 YYPREFIX, *yystack.s_mark);
325 if (yystack.s_mark <= yystack.s_base) goto yyabort;
333 if (yychar == 0) goto yyabort;
338 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
339 if (!yys) yys = "illegal-symbol";
340 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
341 YYPREFIX, yystate, yychar, yys);
351 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
352 YYPREFIX, yystate, yyn, yyrule[yyn]);
356 yyval = yystack.l_mark[1-yym];
358 memset(&yyval, 0, sizeof yyval);
362 yystack.s_mark -= yym;
363 yystate = *yystack.s_mark;
364 yystack.l_mark -= yym;
366 if (yystate == 0 && yym == 0)
370 printf("%sdebug: after reduction, shifting from state 0 to\
371 state %d\n", YYPREFIX, YYFINAL);
374 *++yystack.s_mark = YYFINAL;
375 *++yystack.l_mark = yyval;
378 if ((yychar = YYLEX) < 0) yychar = 0;
383 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
384 if (!yys) yys = "illegal-symbol";
385 printf("%sdebug: state %d, reading %d (%s)\n",
386 YYPREFIX, YYFINAL, yychar, yys);
390 if (yychar == 0) goto yyaccept;
393 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
394 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
395 yystate = yytable[yyn];
397 yystate = yydgoto[yym];
400 printf("%sdebug: after reduction, shifting from state %d \
401 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
403 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
407 *++yystack.s_mark = (short) yystate;
408 *++yystack.l_mark = yyval;
412 yyerror("yacc stack overflow");
415 yyfreestack(&yystack);
419 yyfreestack(&yystack);