2 static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
8 #define YYPATCH 20140101
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
20 /* compatibility with bison */
22 /* compatibility with FreeBSD */
23 # ifdef YYPARSE_PARAM_TYPE
24 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
26 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
29 # define YYPARSE_DECL() yyparse(void)
32 /* Parameters sent to lex. */
34 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
35 # define YYLEX yylex(YYLEX_PARAM)
37 # define YYLEX_DECL() yylex(void)
38 # define YYLEX yylex()
41 /* Parameters sent to yyerror. */
43 #define YYERROR_DECL() yyerror(const char *s)
46 #define YYERROR_CALL(msg) yyerror(msg)
49 extern int YYPARSE_DECL();
52 static const short yylhs[] = { -1,
55 static const short yylen[] = { 2,
58 static const short yydefred[] = { 1,
61 static const short yydgoto[] = { 1,
63 static const short yysindex[] = { 0,
66 static const short yyrindex[] = { 0,
69 static const short yygindex[] = { 0,
72 static const short yytable[] = { 0,
74 static const short yycheck[] = { -1,
81 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? (YYMAXTOKEN + 1) : (a))
83 static const char *yyname[] = {
85 "end-of-file","illegal-symbol",
87 static const char *yyrule[] = {
102 /* define the initial stack-sizes */
105 #define YYMAXDEPTH YYSTACKSIZE
108 #define YYSTACKSIZE YYMAXDEPTH
110 #define YYSTACKSIZE 10000
111 #define YYMAXDEPTH 10000
115 #define YYINITSTACKSIZE 200
125 /* variables for the parser stack */
126 static YYSTACKDATA yystack;
129 #include <stdio.h> /* needed for printf */
132 #include <stdlib.h> /* needed for malloc, etc */
133 #include <string.h> /* needed for memset */
135 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
136 static int yygrowstack(YYSTACKDATA *data)
143 if ((newsize = data->stacksize) == 0)
144 newsize = YYINITSTACKSIZE;
145 else if (newsize >= YYMAXDEPTH)
147 else if ((newsize *= 2) > YYMAXDEPTH)
148 newsize = YYMAXDEPTH;
150 i = (int) (data->s_mark - data->s_base);
151 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
155 data->s_base = newss;
156 data->s_mark = newss + i;
158 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
162 data->l_base = newvs;
163 data->l_mark = newvs + i;
165 data->stacksize = newsize;
166 data->s_last = data->s_base + newsize - 1;
170 #if YYPURE || defined(YY_NO_LEAKS)
171 static void yyfreestack(YYSTACKDATA *data)
175 memset(data, 0, sizeof(*data));
178 #define yyfreestack(data) /* nothing */
181 #define YYABORT goto yyabort
182 #define YYREJECT goto yyabort
183 #define YYACCEPT goto yyaccept
184 #define YYERROR goto yyerrlab
189 int yym, yyn, yystate;
193 if ((yys = getenv("YYDEBUG")) != 0)
196 if (yyn >= '0' && yyn <= '9')
207 memset(&yystack, 0, sizeof(yystack));
210 if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
211 yystack.s_mark = yystack.s_base;
212 yystack.l_mark = yystack.l_base;
217 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
220 if ((yychar = YYLEX) < 0) yychar = 0;
224 yys = yyname[YYTRANSLATE(yychar)];
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;
306 yys = yyname[YYTRANSLATE(yychar)];
307 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
308 YYPREFIX, yystate, yychar, yys);
318 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
319 YYPREFIX, yystate, yyn, yyrule[yyn]);
323 yyval = yystack.l_mark[1-yym];
325 memset(&yyval, 0, sizeof yyval);
329 yystack.s_mark -= yym;
330 yystate = *yystack.s_mark;
331 yystack.l_mark -= yym;
333 if (yystate == 0 && yym == 0)
337 printf("%sdebug: after reduction, shifting from state 0 to\
338 state %d\n", YYPREFIX, YYFINAL);
341 *++yystack.s_mark = YYFINAL;
342 *++yystack.l_mark = yyval;
345 if ((yychar = YYLEX) < 0) yychar = 0;
349 yys = yyname[YYTRANSLATE(yychar)];
350 printf("%sdebug: state %d, reading %d (%s)\n",
351 YYPREFIX, YYFINAL, yychar, yys);
355 if (yychar == 0) goto yyaccept;
358 if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
359 yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
360 yystate = yytable[yyn];
362 yystate = yydgoto[yym];
365 printf("%sdebug: after reduction, shifting from state %d \
366 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
368 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
372 *++yystack.s_mark = (short) yystate;
373 *++yystack.l_mark = yyval;
377 yyerror("yacc stack overflow");
380 yyfreestack(&yystack);
384 yyfreestack(&yystack);