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)
18 #line 2 "code_error.y"
22 static void yyerror(const char *);
25 #line 25 "/dev/stdout"
31 /* compatibility with bison */
33 /* compatibility with FreeBSD */
34 # ifdef YYPARSE_PARAM_TYPE
35 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
37 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
40 # define YYPARSE_DECL() yyparse(void)
43 /* Parameters sent to lex. */
45 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
46 # define YYLEX yylex(YYLEX_PARAM)
48 # define YYLEX_DECL() yylex(void)
49 # define YYLEX yylex()
52 /* Parameters sent to yyerror. */
54 #define YYERROR_DECL() yyerror(const char *s)
57 #define YYERROR_CALL(msg) yyerror(msg)
60 extern int YYPARSE_DECL();
63 static const short yylhs[] = { -1,
66 static const short yylen[] = { 2,
69 static const short yydefred[] = { 0,
72 static const short yydgoto[] = { 2,
74 static const short yysindex[] = { -256,
77 static const short yyrindex[] = { 0,
80 static const short yygindex[] = { 0,
83 static const short yytable[] = { 1,
85 static const short yycheck[] = { 256,
93 static const char *yyname[] = {
97 static const char *yyrule[] = {
112 /* define the initial stack-sizes */
115 #define YYMAXDEPTH YYSTACKSIZE
118 #define YYSTACKSIZE YYMAXDEPTH
120 #define YYSTACKSIZE 500
121 #define YYMAXDEPTH 500
125 #define YYINITSTACKSIZE 500
135 /* variables for the parser stack */
136 static YYSTACKDATA yystack;
137 #line 12 "code_error.y"
142 extern int YYLEX_DECL();
148 printf("yyparse() = %d\n", yyparse());
159 yyerror(const char* s)
163 #line 163 "/dev/stdout"
166 #include <stdio.h> /* needed for printf */
169 #include <stdlib.h> /* needed for malloc, etc */
170 #include <string.h> /* needed for memset */
172 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
173 static int yygrowstack(YYSTACKDATA *data)
180 if ((newsize = data->stacksize) == 0)
181 newsize = YYINITSTACKSIZE;
182 else if (newsize >= YYMAXDEPTH)
184 else if ((newsize *= 2) > YYMAXDEPTH)
185 newsize = YYMAXDEPTH;
187 i = data->s_mark - data->s_base;
188 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
192 data->s_base = newss;
193 data->s_mark = newss + i;
195 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
199 data->l_base = newvs;
200 data->l_mark = newvs + i;
202 data->stacksize = newsize;
203 data->s_last = data->s_base + newsize - 1;
207 #if YYPURE || defined(YY_NO_LEAKS)
208 static void yyfreestack(YYSTACKDATA *data)
212 memset(data, 0, sizeof(*data));
215 #define yyfreestack(data) /* nothing */
218 #define YYABORT goto yyabort
219 #define YYREJECT goto yyabort
220 #define YYACCEPT goto yyaccept
221 #define YYERROR goto yyerrlab
226 int yym, yyn, yystate;
230 if ((yys = getenv("YYDEBUG")) != 0)
233 if (yyn >= '0' && yyn <= '9')
244 memset(&yystack, 0, sizeof(yystack));
247 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
248 yystack.s_mark = yystack.s_base;
249 yystack.l_mark = yystack.l_base;
254 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
257 if ((yychar = YYLEX) < 0) yychar = 0;
262 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
263 if (!yys) yys = "illegal-symbol";
264 printf("%sdebug: state %d, reading %d (%s)\n",
265 YYPREFIX, yystate, yychar, yys);
269 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
270 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
274 printf("%sdebug: state %d, shifting to state %d\n",
275 YYPREFIX, yystate, yytable[yyn]);
277 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
281 yystate = yytable[yyn];
282 *++yystack.s_mark = yytable[yyn];
283 *++yystack.l_mark = yylval;
285 if (yyerrflag > 0) --yyerrflag;
288 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
289 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
294 if (yyerrflag) goto yyinrecovery;
296 yyerror("syntax error");
309 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
310 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
314 printf("%sdebug: state %d, error recovery shifting\
315 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
317 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
321 yystate = yytable[yyn];
322 *++yystack.s_mark = yytable[yyn];
323 *++yystack.l_mark = yylval;
330 printf("%sdebug: error recovery discarding state %d\n",
331 YYPREFIX, *yystack.s_mark);
333 if (yystack.s_mark <= yystack.s_base) goto yyabort;
341 if (yychar == 0) goto yyabort;
346 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
347 if (!yys) yys = "illegal-symbol";
348 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
349 YYPREFIX, yystate, yychar, yys);
359 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
360 YYPREFIX, yystate, yyn, yyrule[yyn]);
364 yyval = yystack.l_mark[1-yym];
366 memset(&yyval, 0, sizeof yyval);
370 yystack.s_mark -= yym;
371 yystate = *yystack.s_mark;
372 yystack.l_mark -= yym;
374 if (yystate == 0 && yym == 0)
378 printf("%sdebug: after reduction, shifting from state 0 to\
379 state %d\n", YYPREFIX, YYFINAL);
382 *++yystack.s_mark = YYFINAL;
383 *++yystack.l_mark = yyval;
386 if ((yychar = YYLEX) < 0) yychar = 0;
391 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
392 if (!yys) yys = "illegal-symbol";
393 printf("%sdebug: state %d, reading %d (%s)\n",
394 YYPREFIX, YYFINAL, yychar, yys);
398 if (yychar == 0) goto yyaccept;
401 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
402 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
403 yystate = yytable[yyn];
405 yystate = yydgoto[yym];
408 printf("%sdebug: after reduction, shifting from state %d \
409 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
411 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
415 *++yystack.s_mark = (short) yystate;
416 *++yystack.l_mark = yyval;
420 yyerror("yacc stack overflow");
423 yyfreestack(&yystack);
427 yyfreestack(&yystack);