1 /* This file generated automatically using
2 * @Id: skel2c,v 1.3 2014/04/06 19:48:04 tom Exp @
5 /* @Id: yaccpar.skel,v 1.5 2014/04/07 21:51:00 tom Exp @ */
9 /* If the skeleton is changed, the banner should be changed so that */
10 /* the altered version can be easily distinguished from the original. */
12 /* The #defines included with the banner are there because they are */
13 /* useful in subsequent code. The macros #defined in the header or */
14 /* the body either are not useful outside of semantic actions or */
15 /* are conditional. */
17 const char *const banner
[] =
19 "/* original parser id follows */",
20 "/* yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\" */",
21 "/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */",
24 CONCAT1("#define YYMAJOR ", YYMAJOR
),
25 CONCAT1("#define YYMINOR ", YYMINOR
),
27 CONCAT1("#define YYPATCH ", YYPATCH
),
30 "#define YYEMPTY (-1)",
31 "#define yyclearin (yychar = YYEMPTY)",
32 "#define yyerrok (yyerrflag = 0)",
33 "#define YYRECOVERING() (yyerrflag != 0)",
34 "#define YYENOMEM (-2)",
39 const char *const xdecls
[] =
42 "extern int YYPARSE_DECL();",
46 const char *const tables
[] =
48 "extern YYINT yylhs[];",
49 "extern YYINT yylen[];",
50 "extern YYINT yydefred[];",
51 "extern YYINT yydgoto[];",
52 "extern YYINT yysindex[];",
53 "extern YYINT yyrindex[];",
54 "extern YYINT yygindex[];",
55 "extern YYINT yytable[];",
56 "extern YYINT yycheck[];",
59 "extern char *yyname[];",
60 "extern char *yyrule[];",
65 const char *const global_vars
[] =
73 const char *const impure_vars
[] =
83 const char *const hdr_defs
[] =
86 "/* define the initial stack-sizes */",
89 "#define YYMAXDEPTH YYSTACKSIZE",
92 "#define YYSTACKSIZE YYMAXDEPTH",
94 "#define YYSTACKSIZE 10000",
95 "#define YYMAXDEPTH 10000",
99 "#define YYINITSTACKSIZE 200",
102 " unsigned stacksize;",
112 const char *const hdr_vars
[] =
114 "/* variables for the parser stack */",
115 "static YYSTACKDATA yystack;",
119 const char *const body_vars
[] =
126 " /* variables for the parser stack */",
127 " YYSTACKDATA yystack;",
131 const char *const body_1
[] =
135 "#include <stdio.h> /* needed for printf */",
138 "#include <stdlib.h> /* needed for malloc, etc */",
139 "#include <string.h> /* needed for memset */",
141 "/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
142 "static int yygrowstack(YYSTACKDATA *data)",
145 " unsigned newsize;",
149 " if ((newsize = data->stacksize) == 0)",
150 " newsize = YYINITSTACKSIZE;",
151 " else if (newsize >= YYMAXDEPTH)",
153 " else if ((newsize *= 2) > YYMAXDEPTH)",
154 " newsize = YYMAXDEPTH;",
156 " i = (int) (data->s_mark - data->s_base);",
157 " newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));",
161 " data->s_base = newss;",
162 " data->s_mark = newss + i;",
164 " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
168 " data->l_base = newvs;",
169 " data->l_mark = newvs + i;",
171 " data->stacksize = newsize;",
172 " data->s_last = data->s_base + newsize - 1;",
176 "#if YYPURE || defined(YY_NO_LEAKS)",
177 "static void yyfreestack(YYSTACKDATA *data)",
179 " free(data->s_base);",
180 " free(data->l_base);",
181 " memset(data, 0, sizeof(*data));",
184 "#define yyfreestack(data) /* nothing */",
187 "#define YYABORT goto yyabort",
188 "#define YYREJECT goto yyabort",
189 "#define YYACCEPT goto yyaccept",
190 "#define YYERROR goto yyerrlab",
198 const char *const body_2
[] =
200 " int yym, yyn, yystate;",
204 " if ((yys = getenv(\"YYDEBUG\")) != 0)",
207 " if (yyn >= '0' && yyn <= '9')",
208 " yydebug = yyn - '0';",
214 " yychar = YYEMPTY;",
218 " memset(&yystack, 0, sizeof(yystack));",
221 " if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;",
222 " yystack.s_mark = yystack.s_base;",
223 " yystack.l_mark = yystack.l_base;",
225 " *yystack.s_mark = 0;",
228 " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;",
231 " if ((yychar = YYLEX) < 0) yychar = YYEOF;",
235 " yys = yyname[YYTRANSLATE(yychar)];",
236 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
237 " YYPREFIX, yystate, yychar, yys);",
241 " if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&",
242 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
246 " printf(\"%sdebug: state %d, shifting to state %d\\n\",",
247 " YYPREFIX, yystate, yytable[yyn]);",
249 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
253 " yystate = yytable[yyn];",
254 " *++yystack.s_mark = yytable[yyn];",
255 " *++yystack.l_mark = yylval;",
256 " yychar = YYEMPTY;",
257 " if (yyerrflag > 0) --yyerrflag;",
260 " if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&",
261 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
263 " yyn = yytable[yyn];",
266 " if (yyerrflag) goto yyinrecovery;",
268 " YYERROR_CALL(\"syntax error\");",
276 " if (yyerrflag < 3)",
281 " if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&",
282 " yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)",
286 " printf(\"%sdebug: state %d, error recovery shifting\\",
287 " to state %d\\n\", YYPREFIX, *yystack.s_mark, yytable[yyn]);",
289 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
293 " yystate = yytable[yyn];",
294 " *++yystack.s_mark = yytable[yyn];",
295 " *++yystack.l_mark = yylval;",
302 " printf(\"%sdebug: error recovery discarding state %d\\n\",",
303 " YYPREFIX, *yystack.s_mark);",
305 " if (yystack.s_mark <= yystack.s_base) goto yyabort;",
306 " --yystack.s_mark;",
307 " --yystack.l_mark;",
313 " if (yychar == YYEOF) goto yyabort;",
317 " yys = yyname[YYTRANSLATE(yychar)];",
318 " printf(\"%sdebug: state %d, error recovery discards token %d (%s)\\n\",",
319 " YYPREFIX, yystate, yychar, yys);",
322 " yychar = YYEMPTY;",
329 " printf(\"%sdebug: state %d, reducing by rule %d (%s)\\n\",",
330 " YYPREFIX, yystate, yyn, yyrule[yyn]);",
332 " yym = yylen[yyn];",
334 " yyval = yystack.l_mark[1-yym];",
336 " memset(&yyval, 0, sizeof yyval);",
342 const char *const trailer
[] =
345 " yystack.s_mark -= yym;",
346 " yystate = *yystack.s_mark;",
347 " yystack.l_mark -= yym;",
348 " yym = yylhs[yyn];",
349 " if (yystate == 0 && yym == 0)",
353 " printf(\"%sdebug: after reduction, shifting from state 0 to\\",
354 " state %d\\n\", YYPREFIX, YYFINAL);",
356 " yystate = YYFINAL;",
357 " *++yystack.s_mark = YYFINAL;",
358 " *++yystack.l_mark = yyval;",
361 " if ((yychar = YYLEX) < 0) yychar = YYEOF;",
365 " yys = yyname[YYTRANSLATE(yychar)];",
366 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
367 " YYPREFIX, YYFINAL, yychar, yys);",
371 " if (yychar == YYEOF) goto yyaccept;",
374 " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&",
375 " yyn <= YYTABLESIZE && yycheck[yyn] == yystate)",
376 " yystate = yytable[yyn];",
378 " yystate = yydgoto[yym];",
381 " printf(\"%sdebug: after reduction, shifting from state %d \\",
382 "to state %d\\n\", YYPREFIX, *yystack.s_mark, yystate);",
384 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
388 " *++yystack.s_mark = (YYINT) yystate;",
389 " *++yystack.l_mark = yyval;",
393 " YYERROR_CALL(\"yacc stack overflow\");",
396 " yyfreestack(&yystack);",
400 " yyfreestack(&yystack);",
407 write_section(FILE * fp
, const char *const section
[])
412 for (i
= 0; (s
= section
[i
]) != 0; ++i
)
416 fprintf(fp
, "%s\n", s
);