1 /* $NetBSD: yaccpar.c,v 1.2 2015/01/04 01:34:20 christos Exp $ */
3 /* This file generated automatically using
4 * @Id: skel2c,v 1.3 2014/04/06 19:48:04 tom Exp @
7 /* @Id: yaccpar.skel,v 1.5 2014/04/07 21:51:00 tom Exp @ */
11 /* If the skeleton is changed, the banner should be changed so that */
12 /* the altered version can be easily distinguished from the original. */
14 /* The #defines included with the banner are there because they are */
15 /* useful in subsequent code. The macros #defined in the header or */
16 /* the body either are not useful outside of semantic actions or */
17 /* are conditional. */
19 const char *const banner
[] =
21 "/* original parser id follows */",
22 "/* yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\" */",
23 "/* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */",
26 CONCAT1("#define YYMAJOR ", YYMAJOR
),
27 CONCAT1("#define YYMINOR ", YYMINOR
),
29 CONCAT1("#define YYPATCH ", YYPATCH
),
32 "#define YYEMPTY (-1)",
33 "#define yyclearin (yychar = YYEMPTY)",
34 "#define yyerrok (yyerrflag = 0)",
35 "#define YYRECOVERING() (yyerrflag != 0)",
36 "#define YYENOMEM (-2)",
41 const char *const xdecls
[] =
44 "extern int YYPARSE_DECL();",
48 const char *const tables
[] =
50 "extern YYINT yylhs[];",
51 "extern YYINT yylen[];",
52 "extern YYINT yydefred[];",
53 "extern YYINT yydgoto[];",
54 "extern YYINT yysindex[];",
55 "extern YYINT yyrindex[];",
56 "extern YYINT yygindex[];",
57 "extern YYINT yytable[];",
58 "extern YYINT yycheck[];",
61 "extern char *yyname[];",
62 "extern char *yyrule[];",
67 const char *const global_vars
[] =
75 const char *const impure_vars
[] =
85 const char *const hdr_defs
[] =
88 "/* define the initial stack-sizes */",
91 "#define YYMAXDEPTH YYSTACKSIZE",
94 "#define YYSTACKSIZE YYMAXDEPTH",
96 "#define YYSTACKSIZE 10000",
97 "#define YYMAXDEPTH 10000",
101 "#define YYINITSTACKSIZE 200",
104 " unsigned stacksize;",
114 const char *const hdr_vars
[] =
116 "/* variables for the parser stack */",
117 "static YYSTACKDATA yystack;",
121 const char *const body_vars
[] =
128 " /* variables for the parser stack */",
129 " YYSTACKDATA yystack;",
133 const char *const body_1
[] =
137 "#include <stdio.h> /* needed for printf */",
140 "#include <stdlib.h> /* needed for malloc, etc */",
141 "#include <string.h> /* needed for memset */",
143 "/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
144 "static int yygrowstack(YYSTACKDATA *data)",
147 " unsigned newsize;",
151 " if ((newsize = data->stacksize) == 0)",
152 " newsize = YYINITSTACKSIZE;",
153 " else if (newsize >= YYMAXDEPTH)",
155 " else if ((newsize *= 2) > YYMAXDEPTH)",
156 " newsize = YYMAXDEPTH;",
158 " i = (int) (data->s_mark - data->s_base);",
159 " newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));",
163 " data->s_base = newss;",
164 " data->s_mark = newss + i;",
166 " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
170 " data->l_base = newvs;",
171 " data->l_mark = newvs + i;",
173 " data->stacksize = newsize;",
174 " data->s_last = data->s_base + newsize - 1;",
178 "#if YYPURE || defined(YY_NO_LEAKS)",
179 "static void yyfreestack(YYSTACKDATA *data)",
181 " free(data->s_base);",
182 " free(data->l_base);",
183 " memset(data, 0, sizeof(*data));",
186 "#define yyfreestack(data) /* nothing */",
189 "#define YYABORT goto yyabort",
190 "#define YYREJECT goto yyabort",
191 "#define YYACCEPT goto yyaccept",
192 "#define YYERROR goto yyerrlab",
200 const char *const body_2
[] =
202 " int yym, yyn, yystate;",
206 " if ((yys = getenv(\"YYDEBUG\")) != 0)",
209 " if (yyn >= '0' && yyn <= '9')",
210 " yydebug = yyn - '0';",
217 const char *const body_3
[] =
221 " yychar = YYEMPTY;",
225 " memset(&yystack, 0, sizeof(yystack));",
228 " if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;",
229 " yystack.s_mark = yystack.s_base;",
230 " yystack.l_mark = yystack.l_base;",
232 " *yystack.s_mark = 0;",
235 " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;",
238 " if ((yychar = YYLEX) < 0) yychar = YYEOF;",
242 " yys = yyname[YYTRANSLATE(yychar)];",
243 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
244 " YYPREFIX, yystate, yychar, yys);",
248 " if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&",
249 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
253 " printf(\"%sdebug: state %d, shifting to state %d\\n\",",
254 " YYPREFIX, yystate, yytable[yyn]);",
256 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
260 " yystate = yytable[yyn];",
261 " *++yystack.s_mark = yytable[yyn];",
262 " *++yystack.l_mark = yylval;",
263 " yychar = YYEMPTY;",
264 " if (yyerrflag > 0) --yyerrflag;",
267 " if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&",
268 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
270 " yyn = yytable[yyn];",
273 " if (yyerrflag) goto yyinrecovery;",
275 " YYERROR_CALL(\"syntax error\");",
283 " if (yyerrflag < 3)",
288 " if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&",
289 " yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)",
293 " printf(\"%sdebug: state %d, error recovery shifting\\",
294 " to state %d\\n\", YYPREFIX, *yystack.s_mark, yytable[yyn]);",
296 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
300 " yystate = yytable[yyn];",
301 " *++yystack.s_mark = yytable[yyn];",
302 " *++yystack.l_mark = yylval;",
309 " printf(\"%sdebug: error recovery discarding state %d\\n\",",
310 " YYPREFIX, *yystack.s_mark);",
312 " if (yystack.s_mark <= yystack.s_base) goto yyabort;",
313 " --yystack.s_mark;",
314 " --yystack.l_mark;",
320 " if (yychar == YYEOF) goto yyabort;",
324 " yys = yyname[YYTRANSLATE(yychar)];",
325 " printf(\"%sdebug: state %d, error recovery discards token %d (%s)\\n\",",
326 " YYPREFIX, yystate, yychar, yys);",
329 " yychar = YYEMPTY;",
336 " printf(\"%sdebug: state %d, reducing by rule %d (%s)\\n\",",
337 " YYPREFIX, yystate, yyn, yyrule[yyn]);",
339 " yym = yylen[yyn];",
341 " yyval = yystack.l_mark[1-yym];",
343 " memset(&yyval, 0, sizeof yyval);",
349 const char *const trailer
[] =
352 " yystack.s_mark -= yym;",
353 " yystate = *yystack.s_mark;",
354 " yystack.l_mark -= yym;",
355 " yym = yylhs[yyn];",
356 " if (yystate == 0 && yym == 0)",
360 " printf(\"%sdebug: after reduction, shifting from state 0 to\\",
361 " state %d\\n\", YYPREFIX, YYFINAL);",
363 " yystate = YYFINAL;",
364 " *++yystack.s_mark = YYFINAL;",
365 " *++yystack.l_mark = yyval;",
368 " if ((yychar = YYLEX) < 0) yychar = YYEOF;",
372 " yys = yyname[YYTRANSLATE(yychar)];",
373 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
374 " YYPREFIX, YYFINAL, yychar, yys);",
378 " if (yychar == YYEOF) goto yyaccept;",
381 " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&",
382 " yyn <= YYTABLESIZE && yycheck[yyn] == yystate)",
383 " yystate = yytable[yyn];",
385 " yystate = yydgoto[yym];",
388 " printf(\"%sdebug: after reduction, shifting from state %d \\",
389 "to state %d\\n\", YYPREFIX, *yystack.s_mark, yystate);",
391 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
395 " *++yystack.s_mark = (YYINT) yystate;",
396 " *++yystack.l_mark = yyval;",
400 " YYERROR_CALL(\"yacc stack overflow\");",
403 " yyfreestack(&yystack);",
407 " yyfreestack(&yystack);",
414 write_section(FILE * fp
, const char *const section
[])
419 for (i
= 0; (s
= section
[i
]) != 0; ++i
)
423 fprintf(fp
, "%s\n", s
);