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)
17 #line 2 "code_error.y"
21 static void yyerror(const char *);
24 #line 25 "code_error.code.c"
30 /* compatibility with bison */
32 /* compatibility with FreeBSD */
33 # ifdef YYPARSE_PARAM_TYPE
34 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
36 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
39 # define YYPARSE_DECL() yyparse(void)
42 /* Parameters sent to lex. */
44 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
45 # define YYLEX yylex(YYLEX_PARAM)
47 # define YYLEX_DECL() yylex(void)
48 # define YYLEX yylex()
51 /* Parameters sent to yyerror. */
53 #define YYERROR_DECL() yyerror(const char *s)
56 #define YYERROR_CALL(msg) yyerror(msg)
59 extern int YYPARSE_DECL();
70 #define yyparse error_parse
74 #define yylex error_lex
78 #define yyerror error_error
82 #define yychar error_char
86 #define yyval error_val
90 #define yylval error_lval
94 #define yydebug error_debug
98 #define yynerrs error_nerrs
102 #define yyerrflag error_errflag
103 #endif /* yyerrflag */
106 #define yylhs error_lhs
110 #define yylen error_len
114 #define yydefred error_defred
115 #endif /* yydefred */
118 #define yydgoto error_dgoto
122 #define yysindex error_sindex
123 #endif /* yysindex */
126 #define yyrindex error_rindex
127 #endif /* yyrindex */
130 #define yygindex error_gindex
131 #endif /* yygindex */
134 #define yytable error_table
138 #define yycheck error_check
142 #define yyname error_name
146 #define yyrule error_rule
148 #define YYPREFIX "error_"
150 extern int YYPARSE_DECL();
151 extern short yylhs[];
152 extern short yylen[];
153 extern short yydefred[];
154 extern short yydgoto[];
155 extern short yysindex[];
156 extern short yyrindex[];
157 extern short yygindex[];
158 extern short yytable[];
159 extern short yycheck[];
162 extern char *yyname[];
163 extern char *yyrule[];
174 /* define the initial stack-sizes */
177 #define YYMAXDEPTH YYSTACKSIZE
180 #define YYSTACKSIZE YYMAXDEPTH
182 #define YYSTACKSIZE 500
183 #define YYMAXDEPTH 500
187 #define YYINITSTACKSIZE 500
197 /* variables for the parser stack */
198 static YYSTACKDATA yystack;
199 #line 12 "code_error.y"
204 extern int YYLEX_DECL();
210 printf("yyparse() = %d\n", yyparse());
221 yyerror(const char* s)
225 #line 226 "code_error.code.c"
228 #include <stdio.h> /* needed for printf */
231 #include <stdlib.h> /* needed for malloc, etc */
232 #include <string.h> /* needed for memset */
234 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
235 static int yygrowstack(YYSTACKDATA *data)
242 if ((newsize = data->stacksize) == 0)
243 newsize = YYINITSTACKSIZE;
244 else if (newsize >= YYMAXDEPTH)
246 else if ((newsize *= 2) > YYMAXDEPTH)
247 newsize = YYMAXDEPTH;
249 i = (int) (data->s_mark - data->s_base);
250 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
254 data->s_base = newss;
255 data->s_mark = newss + i;
257 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
261 data->l_base = newvs;
262 data->l_mark = newvs + i;
264 data->stacksize = newsize;
265 data->s_last = data->s_base + newsize - 1;
269 #if YYPURE || defined(YY_NO_LEAKS)
270 static void yyfreestack(YYSTACKDATA *data)
274 memset(data, 0, sizeof(*data));
277 #define yyfreestack(data) /* nothing */
280 #define YYABORT goto yyabort
281 #define YYREJECT goto yyabort
282 #define YYACCEPT goto yyaccept
283 #define YYERROR goto yyerrlab
288 int yym, yyn, yystate;
292 if ((yys = getenv("YYDEBUG")) != 0)
295 if (yyn >= '0' && yyn <= '9')
306 memset(&yystack, 0, sizeof(yystack));
309 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
310 yystack.s_mark = yystack.s_base;
311 yystack.l_mark = yystack.l_base;
316 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
319 if ((yychar = YYLEX) < 0) yychar = 0;
324 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
325 if (!yys) yys = "illegal-symbol";
326 printf("%sdebug: state %d, reading %d (%s)\n",
327 YYPREFIX, yystate, yychar, yys);
331 if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
332 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
336 printf("%sdebug: state %d, shifting to state %d\n",
337 YYPREFIX, yystate, yytable[yyn]);
339 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
343 yystate = yytable[yyn];
344 *++yystack.s_mark = yytable[yyn];
345 *++yystack.l_mark = yylval;
347 if (yyerrflag > 0) --yyerrflag;
350 if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
351 yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
356 if (yyerrflag) goto yyinrecovery;
358 yyerror("syntax error");
371 if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
372 yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
376 printf("%sdebug: state %d, error recovery shifting\
377 to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
379 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
383 yystate = yytable[yyn];
384 *++yystack.s_mark = yytable[yyn];
385 *++yystack.l_mark = yylval;
392 printf("%sdebug: error recovery discarding state %d\n",
393 YYPREFIX, *yystack.s_mark);
395 if (yystack.s_mark <= yystack.s_base) goto yyabort;
403 if (yychar == 0) goto yyabort;
408 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
409 if (!yys) yys = "illegal-symbol";
410 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
411 YYPREFIX, yystate, yychar, yys);
421 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
422 YYPREFIX, yystate, yyn, yyrule[yyn]);
426 yyval = yystack.l_mark[1-yym];
428 memset(&yyval, 0, sizeof yyval);
432 yystack.s_mark -= yym;
433 yystate = *yystack.s_mark;
434 yystack.l_mark -= yym;
436 if (yystate == 0 && yym == 0)
440 printf("%sdebug: after reduction, shifting from state 0 to\
441 state %d\n", YYPREFIX, YYFINAL);
444 *++yystack.s_mark = YYFINAL;
445 *++yystack.l_mark = yyval;
448 if ((yychar = YYLEX) < 0) yychar = 0;
453 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
454 if (!yys) yys = "illegal-symbol";
455 printf("%sdebug: state %d, reading %d (%s)\n",
456 YYPREFIX, YYFINAL, yychar, yys);
460 if (yychar == 0) goto yyaccept;
463 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
464 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
465 yystate = yytable[yyn];
467 yystate = yydgoto[yym];
470 printf("%sdebug: after reduction, shifting from state %d \
471 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
473 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
477 *++yystack.s_mark = (short) yystate;
478 *++yystack.l_mark = yyval;
482 yyerror("yacc stack overflow");
485 yyfreestack(&yystack);
489 yyfreestack(&yystack);