Remove building with NOCRYPTO option
[minix3.git] / external / bsd / byacc / dist / yaccpar.c
blob164679053615ddebace174d33c674b9a865b2dd1
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 @
5 */
7 /* @Id: yaccpar.skel,v 1.5 2014/04/07 21:51:00 tom Exp @ */
9 #include "defs.h"
11 /* If the skeleton is changed, the banner should be changed so that */
12 /* the altered version can be easily distinguished from the original. */
13 /* */
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) */",
24 "",
25 "#define YYBYACC 1",
26 CONCAT1("#define YYMAJOR ", YYMAJOR),
27 CONCAT1("#define YYMINOR ", YYMINOR),
28 #ifdef YYPATCH
29 CONCAT1("#define YYPATCH ", YYPATCH),
30 #endif
31 "",
32 "#define YYEMPTY (-1)",
33 "#define yyclearin (yychar = YYEMPTY)",
34 "#define yyerrok (yyerrflag = 0)",
35 "#define YYRECOVERING() (yyerrflag != 0)",
36 "#define YYENOMEM (-2)",
37 "#define YYEOF 0",
41 const char *const xdecls[] =
43 "",
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[];",
59 "",
60 "#if YYDEBUG",
61 "extern char *yyname[];",
62 "extern char *yyrule[];",
63 "#endif",
67 const char *const global_vars[] =
69 "",
70 "int yydebug;",
71 "int yynerrs;",
75 const char *const impure_vars[] =
77 "",
78 "int yyerrflag;",
79 "int yychar;",
80 "YYSTYPE yyval;",
81 "YYSTYPE yylval;",
85 const char *const hdr_defs[] =
87 "",
88 "/* define the initial stack-sizes */",
89 "#ifdef YYSTACKSIZE",
90 "#undef YYMAXDEPTH",
91 "#define YYMAXDEPTH YYSTACKSIZE",
92 "#else",
93 "#ifdef YYMAXDEPTH",
94 "#define YYSTACKSIZE YYMAXDEPTH",
95 "#else",
96 "#define YYSTACKSIZE 10000",
97 "#define YYMAXDEPTH 10000",
98 "#endif",
99 "#endif",
101 "#define YYINITSTACKSIZE 200",
103 "typedef struct {",
104 " unsigned stacksize;",
105 " YYINT *s_base;",
106 " YYINT *s_mark;",
107 " YYINT *s_last;",
108 " YYSTYPE *l_base;",
109 " YYSTYPE *l_mark;",
110 "} YYSTACKDATA;",
114 const char *const hdr_vars[] =
116 "/* variables for the parser stack */",
117 "static YYSTACKDATA yystack;",
121 const char *const body_vars[] =
123 " int yyerrflag;",
124 " int yychar;",
125 " YYSTYPE yyval;",
126 " YYSTYPE yylval;",
128 " /* variables for the parser stack */",
129 " YYSTACKDATA yystack;",
133 const char *const body_1[] =
136 "#if YYDEBUG",
137 "#include <stdio.h> /* needed for printf */",
138 "#endif",
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)",
145 "{",
146 " int i;",
147 " unsigned newsize;",
148 " YYINT *newss;",
149 " YYSTYPE *newvs;",
151 " if ((newsize = data->stacksize) == 0)",
152 " newsize = YYINITSTACKSIZE;",
153 " else if (newsize >= YYMAXDEPTH)",
154 " return YYENOMEM;",
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));",
160 " if (newss == 0)",
161 " return YYENOMEM;",
163 " data->s_base = newss;",
164 " data->s_mark = newss + i;",
166 " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
167 " if (newvs == 0)",
168 " return YYENOMEM;",
170 " data->l_base = newvs;",
171 " data->l_mark = newvs + i;",
173 " data->stacksize = newsize;",
174 " data->s_last = data->s_base + newsize - 1;",
175 " return 0;",
176 "}",
178 "#if YYPURE || defined(YY_NO_LEAKS)",
179 "static void yyfreestack(YYSTACKDATA *data)",
180 "{",
181 " free(data->s_base);",
182 " free(data->l_base);",
183 " memset(data, 0, sizeof(*data));",
184 "}",
185 "#else",
186 "#define yyfreestack(data) /* nothing */",
187 "#endif",
189 "#define YYABORT goto yyabort",
190 "#define YYREJECT goto yyabort",
191 "#define YYACCEPT goto yyaccept",
192 "#define YYERROR goto yyerrlab",
194 "int",
195 "YYPARSE_DECL()",
196 "{",
200 const char *const body_2[] =
202 " int yym, yyn, yystate;",
203 "#if YYDEBUG",
204 " const char *yys;",
206 " if ((yys = getenv(\"YYDEBUG\")) != 0)",
207 " {",
208 " yyn = *yys;",
209 " if (yyn >= '0' && yyn <= '9')",
210 " yydebug = yyn - '0';",
211 " }",
212 "#endif",
217 const char *const body_3[] =
219 " yynerrs = 0;",
220 " yyerrflag = 0;",
221 " yychar = YYEMPTY;",
222 " yystate = 0;",
224 "#if YYPURE",
225 " memset(&yystack, 0, sizeof(yystack));",
226 "#endif",
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;",
231 " yystate = 0;",
232 " *yystack.s_mark = 0;",
234 "yyloop:",
235 " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;",
236 " if (yychar < 0)",
237 " {",
238 " if ((yychar = YYLEX) < 0) yychar = YYEOF;",
239 "#if YYDEBUG",
240 " if (yydebug)",
241 " {",
242 " yys = yyname[YYTRANSLATE(yychar)];",
243 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
244 " YYPREFIX, yystate, yychar, yys);",
245 " }",
246 "#endif",
247 " }",
248 " if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&",
249 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
250 " {",
251 "#if YYDEBUG",
252 " if (yydebug)",
253 " printf(\"%sdebug: state %d, shifting to state %d\\n\",",
254 " YYPREFIX, yystate, yytable[yyn]);",
255 "#endif",
256 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
257 " {",
258 " goto yyoverflow;",
259 " }",
260 " yystate = yytable[yyn];",
261 " *++yystack.s_mark = yytable[yyn];",
262 " *++yystack.l_mark = yylval;",
263 " yychar = YYEMPTY;",
264 " if (yyerrflag > 0) --yyerrflag;",
265 " goto yyloop;",
266 " }",
267 " if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&",
268 " yyn <= YYTABLESIZE && yycheck[yyn] == yychar)",
269 " {",
270 " yyn = yytable[yyn];",
271 " goto yyreduce;",
272 " }",
273 " if (yyerrflag) goto yyinrecovery;",
275 " YYERROR_CALL(\"syntax error\");",
277 " goto yyerrlab;",
279 "yyerrlab:",
280 " ++yynerrs;",
282 "yyinrecovery:",
283 " if (yyerrflag < 3)",
284 " {",
285 " yyerrflag = 3;",
286 " for (;;)",
287 " {",
288 " if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&",
289 " yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)",
290 " {",
291 "#if YYDEBUG",
292 " if (yydebug)",
293 " printf(\"%sdebug: state %d, error recovery shifting\\",
294 " to state %d\\n\", YYPREFIX, *yystack.s_mark, yytable[yyn]);",
295 "#endif",
296 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
297 " {",
298 " goto yyoverflow;",
299 " }",
300 " yystate = yytable[yyn];",
301 " *++yystack.s_mark = yytable[yyn];",
302 " *++yystack.l_mark = yylval;",
303 " goto yyloop;",
304 " }",
305 " else",
306 " {",
307 "#if YYDEBUG",
308 " if (yydebug)",
309 " printf(\"%sdebug: error recovery discarding state %d\\n\",",
310 " YYPREFIX, *yystack.s_mark);",
311 "#endif",
312 " if (yystack.s_mark <= yystack.s_base) goto yyabort;",
313 " --yystack.s_mark;",
314 " --yystack.l_mark;",
315 " }",
316 " }",
317 " }",
318 " else",
319 " {",
320 " if (yychar == YYEOF) goto yyabort;",
321 "#if YYDEBUG",
322 " if (yydebug)",
323 " {",
324 " yys = yyname[YYTRANSLATE(yychar)];",
325 " printf(\"%sdebug: state %d, error recovery discards token %d (%s)\\n\",",
326 " YYPREFIX, yystate, yychar, yys);",
327 " }",
328 "#endif",
329 " yychar = YYEMPTY;",
330 " goto yyloop;",
331 " }",
333 "yyreduce:",
334 "#if YYDEBUG",
335 " if (yydebug)",
336 " printf(\"%sdebug: state %d, reducing by rule %d (%s)\\n\",",
337 " YYPREFIX, yystate, yyn, yyrule[yyn]);",
338 "#endif",
339 " yym = yylen[yyn];",
340 " if (yym)",
341 " yyval = yystack.l_mark[1-yym];",
342 " else",
343 " memset(&yyval, 0, sizeof yyval);",
344 " switch (yyn)",
345 " {",
349 const char *const trailer[] =
351 " }",
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)",
357 " {",
358 "#if YYDEBUG",
359 " if (yydebug)",
360 " printf(\"%sdebug: after reduction, shifting from state 0 to\\",
361 " state %d\\n\", YYPREFIX, YYFINAL);",
362 "#endif",
363 " yystate = YYFINAL;",
364 " *++yystack.s_mark = YYFINAL;",
365 " *++yystack.l_mark = yyval;",
366 " if (yychar < 0)",
367 " {",
368 " if ((yychar = YYLEX) < 0) yychar = YYEOF;",
369 "#if YYDEBUG",
370 " if (yydebug)",
371 " {",
372 " yys = yyname[YYTRANSLATE(yychar)];",
373 " printf(\"%sdebug: state %d, reading %d (%s)\\n\",",
374 " YYPREFIX, YYFINAL, yychar, yys);",
375 " }",
376 "#endif",
377 " }",
378 " if (yychar == YYEOF) goto yyaccept;",
379 " goto yyloop;",
380 " }",
381 " if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&",
382 " yyn <= YYTABLESIZE && yycheck[yyn] == yystate)",
383 " yystate = yytable[yyn];",
384 " else",
385 " yystate = yydgoto[yym];",
386 "#if YYDEBUG",
387 " if (yydebug)",
388 " printf(\"%sdebug: after reduction, shifting from state %d \\",
389 "to state %d\\n\", YYPREFIX, *yystack.s_mark, yystate);",
390 "#endif",
391 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
392 " {",
393 " goto yyoverflow;",
394 " }",
395 " *++yystack.s_mark = (YYINT) yystate;",
396 " *++yystack.l_mark = yyval;",
397 " goto yyloop;",
399 "yyoverflow:",
400 " YYERROR_CALL(\"yacc stack overflow\");",
402 "yyabort:",
403 " yyfreestack(&yystack);",
404 " return (1);",
406 "yyaccept:",
407 " yyfreestack(&yystack);",
408 " return (0);",
409 "}",
413 void
414 write_section(FILE * fp, const char *const section[])
416 int i;
417 const char *s;
419 for (i = 0; (s = section[i]) != 0; ++i)
421 if (fp == code_file)
422 ++outline;
423 fprintf(fp, "%s\n", s);