1 /* This file generated automatically using
2 * @Id: skel2c,v 1.4 2016/06/07 00:26:09 tom Exp @
5 /* @Id: btyaccpar.skel,v 1.10 2018/05/25 01:03:46 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 const YYINT yylhs[];",
49 "extern const YYINT yylen[];",
50 "extern const YYINT yydefred[];",
51 "extern const YYINT yystos[];",
52 "extern const YYINT yydgoto[];",
53 "extern const YYINT yysindex[];",
54 "extern const YYINT yyrindex[];",
57 "extern const YYINT yycindex[];",
58 "#endif /* YYBTYACC */",
59 #endif /* defined(YYBTYACC) */
60 "extern const YYINT yygindex[];",
61 "extern const YYINT yytable[];",
62 "extern const YYINT yycheck[];",
65 "extern const YYINT yyctable[];",
66 "#endif /* YYBTYACC */",
67 #endif /* defined(YYBTYACC) */
69 "#if YYDEBUG || defined(yytname)",
70 "extern const char *const yyname[];",
73 "extern const char *const yyrule[];",
78 const char *const global_vars[] =
87 const char *const impure_vars[] =
96 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
97 "YYLTYPE yyloc; /* position returned by actions */",
98 "YYLTYPE yylloc; /* position from the lexer */",
103 const char *const hdr_defs[] =
106 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
107 "#ifndef YYLLOC_DEFAULT",
108 "#define YYLLOC_DEFAULT(loc, rhs, n) \\",
113 " (loc).first_line = YYRHSLOC(rhs, 0).last_line; \\",
114 " (loc).first_column = YYRHSLOC(rhs, 0).last_column; \\",
115 " (loc).last_line = YYRHSLOC(rhs, 0).last_line; \\",
116 " (loc).last_column = YYRHSLOC(rhs, 0).last_column; \\",
120 " (loc).first_line = YYRHSLOC(rhs, 1).first_line; \\",
121 " (loc).first_column = YYRHSLOC(rhs, 1).first_column; \\",
122 " (loc).last_line = YYRHSLOC(rhs, n).last_line; \\",
123 " (loc).last_column = YYRHSLOC(rhs, n).last_column; \\",
126 "#endif /* YYLLOC_DEFAULT */",
127 "#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */",
128 #if defined(YYBTYACC)
131 "#ifndef YYLVQUEUEGROWTH",
132 "#define YYLVQUEUEGROWTH 32",
134 "#endif /* YYBTYACC */",
135 #endif /* defined(YYBTYACC) */
137 "/* define the initial stack-sizes */",
138 "#ifdef YYSTACKSIZE",
140 "#define YYMAXDEPTH YYSTACKSIZE",
143 "#define YYSTACKSIZE YYMAXDEPTH",
145 "#define YYSTACKSIZE 10000",
146 "#define YYMAXDEPTH 10000",
150 "#ifndef YYINITSTACKSIZE",
151 "#define YYINITSTACKSIZE 200",
155 " unsigned stacksize;",
161 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
166 #if defined(YYBTYACC)
169 "struct YYParseState_s",
171 " struct YYParseState_s *save; /* Previously saved parser state */",
172 " YYSTACKDATA yystack; /* saved parser stack */",
173 " int state; /* saved parser state */",
174 " int errflag; /* saved error recovery status */",
175 " int lexeme; /* saved index of the conflict lexeme in the lexical queue */",
176 " YYINT ctry; /* saved index in yyctable[] for this conflict */",
178 "typedef struct YYParseState_s YYParseState;",
179 "#endif /* YYBTYACC */",
180 #endif /* defined(YYBTYACC) */
184 const char *const hdr_vars[] =
186 "/* variables for the parser stack */",
187 "static YYSTACKDATA yystack;",
188 #if defined(YYBTYACC)
191 "/* Current parser state */",
192 "static YYParseState *yyps = 0;",
194 "/* yypath != NULL: do the full parse, starting at *yypath parser state. */",
195 "static YYParseState *yypath = 0;",
197 "/* Base of the lexical value queue */",
198 "static YYSTYPE *yylvals = 0;",
200 "/* Current position at lexical value queue */",
201 "static YYSTYPE *yylvp = 0;",
203 "/* End position of lexical value queue */",
204 "static YYSTYPE *yylve = 0;",
206 "/* The last allocated position at the lexical value queue */",
207 "static YYSTYPE *yylvlim = 0;",
209 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
210 "/* Base of the lexical position queue */",
211 "static YYLTYPE *yylpsns = 0;",
213 "/* Current position at lexical position queue */",
214 "static YYLTYPE *yylpp = 0;",
216 "/* End position of lexical position queue */",
217 "static YYLTYPE *yylpe = 0;",
219 "/* The last allocated position at the lexical position queue */",
220 "static YYLTYPE *yylplim = 0;",
223 "/* Current position at lexical token queue */",
224 "static YYINT *yylexp = 0;",
226 "static YYINT *yylexemes = 0;",
227 "#endif /* YYBTYACC */",
228 #endif /* defined(YYBTYACC) */
232 const char *const body_vars[] =
240 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
241 " YYLTYPE yyloc; /* position returned by actions */",
242 " YYLTYPE yylloc; /* position from the lexer */",
245 " /* variables for the parser stack */",
246 " YYSTACKDATA yystack;",
247 #if defined(YYBTYACC)
250 " /* Current parser state */",
251 " static YYParseState *yyps = 0;",
253 " /* yypath != NULL: do the full parse, starting at *yypath parser state. */",
254 " static YYParseState *yypath = 0;",
256 " /* Base of the lexical value queue */",
257 " static YYSTYPE *yylvals = 0;",
259 " /* Current position at lexical value queue */",
260 " static YYSTYPE *yylvp = 0;",
262 " /* End position of lexical value queue */",
263 " static YYSTYPE *yylve = 0;",
265 " /* The last allocated position at the lexical value queue */",
266 " static YYSTYPE *yylvlim = 0;",
268 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
269 " /* Base of the lexical position queue */",
270 " static YYLTYPE *yylpsns = 0;",
272 " /* Current position at lexical position queue */",
273 " static YYLTYPE *yylpp = 0;",
275 " /* End position of lexical position queue */",
276 " static YYLTYPE *yylpe = 0;",
278 " /* The last allocated position at the lexical position queue */",
279 " static YYLTYPE *yylplim = 0;",
282 " /* Current position at lexical token queue */",
283 " static YYINT *yylexp = 0;",
285 " static YYINT *yylexemes = 0;",
286 "#endif /* YYBTYACC */",
287 #endif /* defined(YYBTYACC) */
291 const char *const body_1[] =
294 "/* For use in generated program */",
295 "#define yydepth (int)(yystack.s_mark - yystack.s_base)",
296 #if defined(YYBTYACC)
298 "#define yytrial (yyps->save)",
299 "#endif /* YYBTYACC */",
300 #endif /* defined(YYBTYACC) */
303 "#include <stdio.h> /* needed for printf */",
306 "#include <stdlib.h> /* needed for malloc, etc */",
307 "#include <string.h> /* needed for memset */",
309 "/* allocate initial stack or double stack size, up to YYMAXDEPTH */",
310 "static int yygrowstack(YYSTACKDATA *data)",
313 " unsigned newsize;",
316 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
320 " if ((newsize = data->stacksize) == 0)",
321 " newsize = YYINITSTACKSIZE;",
322 " else if (newsize >= YYMAXDEPTH)",
324 " else if ((newsize *= 2) > YYMAXDEPTH)",
325 " newsize = YYMAXDEPTH;",
327 " i = (int) (data->s_mark - data->s_base);",
328 " newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));",
332 " data->s_base = newss;",
333 " data->s_mark = newss + i;",
335 " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
339 " data->l_base = newvs;",
340 " data->l_mark = newvs + i;",
342 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
343 " newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));",
347 " data->p_base = newps;",
348 " data->p_mark = newps + i;",
351 " data->stacksize = newsize;",
352 " data->s_last = data->s_base + newsize - 1;",
356 " fprintf(stderr, \"%sdebug: stack size increased to %d\\n\", YYPREFIX, newsize);",
361 "#if YYPURE || defined(YY_NO_LEAKS)",
362 "static void yyfreestack(YYSTACKDATA *data)",
364 " free(data->s_base);",
365 " free(data->l_base);",
366 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
367 " free(data->p_base);",
369 " memset(data, 0, sizeof(*data));",
372 "#define yyfreestack(data) /* nothing */",
373 "#endif /* YYPURE || defined(YY_NO_LEAKS) */",
374 #if defined(YYBTYACC)
377 "static YYParseState *",
378 "yyNewState(unsigned size)",
380 " YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));",
381 " if (p == NULL) return NULL;",
383 " p->yystack.stacksize = size;",
386 " p->yystack.s_base = NULL;",
387 " p->yystack.l_base = NULL;",
388 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
389 " p->yystack.p_base = NULL;",
393 " p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));",
394 " if (p->yystack.s_base == NULL) return NULL;",
395 " p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));",
396 " if (p->yystack.l_base == NULL) return NULL;",
397 " memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));",
398 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
399 " p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));",
400 " if (p->yystack.p_base == NULL) return NULL;",
401 " memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));",
408 "yyFreeState(YYParseState *p)",
410 " yyfreestack(&p->yystack);",
413 "#endif /* YYBTYACC */",
414 #endif /* defined(YYBTYACC) */
416 "#define YYABORT goto yyabort",
417 "#define YYREJECT goto yyabort",
418 "#define YYACCEPT goto yyaccept",
419 "#define YYERROR goto yyerrlab",
420 #if defined(YYBTYACC)
422 "#define YYVALID do { if (yyps->save) goto yyvalid; } while(0)",
423 "#define YYVALID_NESTED do { if (yyps->save && \\",
424 " yyps->save->save == 0) goto yyvalid; } while(0)",
425 "#endif /* YYBTYACC */",
426 #endif /* defined(YYBTYACC) */
434 const char *const body_2[] =
436 " int yym, yyn, yystate, yyresult;",
437 #if defined(YYBTYACC)
439 " int yynewerrflag;",
440 " YYParseState *yyerrctx = NULL;",
441 "#endif /* YYBTYACC */",
442 #endif /* defined(YYBTYACC) */
443 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
444 " YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */",
449 " if ((yys = getenv(\"YYDEBUG\")) != 0)",
452 " if (yyn >= '0' && yyn <= '9')",
453 " yydebug = yyn - '0';",
456 " fprintf(stderr, \"%sdebug[<# of symbols on state stack>]\\n\", YYPREFIX);",
458 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
459 " memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));",
465 const char *const init_vars[] =
469 " memset(&yyval, 0, sizeof(yyval));",
470 " memset(&yylval, 0, sizeof(yylval));",
471 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
472 " memset(&yyloc, 0, sizeof(yyloc));",
473 " memset(&yylloc, 0, sizeof(yylloc));",
479 const char *const body_3[] =
481 #if defined(YYBTYACC)
483 " yyps = yyNewState(0); if (yyps == 0) goto yyenomem;",
485 "#endif /* YYBTYACC */",
486 #endif /* defined(YYBTYACC) */
491 " yychar = YYEMPTY;",
495 " memset(&yystack, 0, sizeof(yystack));",
498 " if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;",
499 " yystack.s_mark = yystack.s_base;",
500 " yystack.l_mark = yystack.l_base;",
501 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
502 " yystack.p_mark = yystack.p_base;",
505 " *yystack.s_mark = 0;",
508 " if ((yyn = yydefred[yystate]) != 0) goto yyreduce;",
511 #if defined(YYBTYACC)
514 " if (yylvp < yylve)",
516 " /* we're currently re-reading tokens */",
517 " yylval = *yylvp++;",
518 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
519 " yylloc = *yylpp++;",
521 " yychar = *yylexp++;",
526 " /* in trial mode; save scanner results for future parse attempts */",
527 " if (yylvp == yylvlim)",
528 " { /* Enlarge lexical value queue */",
529 " size_t p = (size_t) (yylvp - yylvals);",
530 " size_t s = (size_t) (yylvlim - yylvals);",
532 " s += YYLVQUEUEGROWTH;",
533 " if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;",
534 " if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;",
535 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
536 " if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;",
538 " yylvp = yylve = yylvals + p;",
539 " yylvlim = yylvals + s;",
540 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
541 " yylpp = yylpe = yylpsns + p;",
542 " yylplim = yylpsns + s;",
544 " yylexp = yylexemes + p;",
546 " *yylexp = (YYINT) YYLEX;",
547 " *yylvp++ = yylval;",
549 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
550 " *yylpp++ = yylloc;",
553 " yychar = *yylexp++;",
556 " /* normal operation, no conflict encountered */",
557 "#endif /* YYBTYACC */",
558 #endif /* defined(YYBTYACC) */
560 #if defined(YYBTYACC)
563 "#endif /* YYBTYACC */",
564 #endif /* defined(YYBTYACC) */
565 " if (yychar < 0) yychar = YYEOF;",
569 " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];",
570 " fprintf(stderr, \"%s[%d]: state %d, reading token %d (%s)\",",
571 " YYDEBUGSTR, yydepth, yystate, yychar, yys);",
572 "#ifdef YYSTYPE_TOSTRING",
573 #if defined(YYBTYACC)
576 "#endif /* YYBTYACC */",
577 #endif /* defined(YYBTYACC) */
578 " fprintf(stderr, \" <%s>\", YYSTYPE_TOSTRING(yychar, yylval));",
580 " fputc('\\n', stderr);",
584 #if defined(YYBTYACC)
587 " /* Do we have a conflict? */",
588 " if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&",
589 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)",
595 " YYParseState *save;",
598 " fprintf(stderr, \"%s[%d]: CONFLICT in state %d: following successful trial parse\\n\",",
599 " YYDEBUGSTR, yydepth, yystate);",
601 " /* Switch to the next conflict context */",
603 " yypath = save->save;",
604 " save->save = NULL;",
605 " ctry = save->ctry;",
606 " if (save->state != yystate) YYABORT;",
607 " yyFreeState(save);",
613 " /* Unresolved conflict - start/continue trial parse */",
614 " YYParseState *save;",
618 " fprintf(stderr, \"%s[%d]: CONFLICT in state %d. \", YYDEBUGSTR, yydepth, yystate);",
620 " fputs(\"ALREADY in conflict, continuing trial parse.\\n\", stderr);",
622 " fputs(\"Starting trial parse.\\n\", stderr);",
625 " save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));",
626 " if (save == NULL) goto yyenomem;",
627 " save->save = yyps->save;",
628 " save->state = yystate;",
629 " save->errflag = yyerrflag;",
630 " save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);",
631 " memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));",
632 " save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);",
633 " memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));",
634 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
635 " save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);",
636 " memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));",
638 " ctry = yytable[yyn];",
639 " if (yyctable[ctry] == -1)",
642 " if (yydebug && yychar >= YYEOF)",
643 " fprintf(stderr, \"%s[%d]: backtracking 1 token\\n\", YYDEBUGSTR, yydepth);",
647 " save->ctry = ctry;",
648 " if (yyps->save == NULL)",
650 " /* If this is a first conflict in the stack, start saving lexemes */",
653 " yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));",
654 " if (yylexemes == NULL) goto yyenomem;",
655 " yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));",
656 " if (yylvals == NULL) goto yyenomem;",
657 " yylvlim = yylvals + YYLVQUEUEGROWTH;",
658 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
659 " yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));",
660 " if (yylpsns == NULL) goto yyenomem;",
661 " yylplim = yylpsns + YYLVQUEUEGROWTH;",
664 " if (yylvp == yylve)",
666 " yylvp = yylve = yylvals;",
667 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
668 " yylpp = yylpe = yylpsns;",
670 " yylexp = yylexemes;",
671 " if (yychar >= YYEOF)",
673 " *yylve++ = yylval;",
674 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
675 " *yylpe++ = yylloc;",
677 " *yylexp = (YYINT) yychar;",
678 " yychar = YYEMPTY;",
682 " if (yychar >= YYEOF)",
685 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
689 " yychar = YYEMPTY;",
691 " save->lexeme = (int) (yylvp - yylvals);",
692 " yyps->save = save;",
694 " if (yytable[yyn] == ctry)",
698 " fprintf(stderr, \"%s[%d]: state %d, shifting to state %d\\n\",",
699 " YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);",
704 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
709 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)",
711 " yystate = yyctable[ctry];",
712 " *++yystack.s_mark = (YYINT) yystate;",
713 " *++yystack.l_mark = yylval;",
714 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
715 " *++yystack.p_mark = yylloc;",
717 " yychar = YYEMPTY;",
718 " if (yyerrflag > 0) --yyerrflag;",
723 " yyn = yyctable[ctry];",
726 " } /* End of code dealing with conflicts */",
727 "#endif /* YYBTYACC */",
728 #endif /* defined(YYBTYACC) */
729 " if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&",
730 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)",
734 " fprintf(stderr, \"%s[%d]: state %d, shifting to state %d\\n\",",
735 " YYDEBUGSTR, yydepth, yystate, yytable[yyn]);",
737 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;",
738 " yystate = yytable[yyn];",
739 " *++yystack.s_mark = yytable[yyn];",
740 " *++yystack.l_mark = yylval;",
741 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
742 " *++yystack.p_mark = yylloc;",
744 " yychar = YYEMPTY;",
745 " if (yyerrflag > 0) --yyerrflag;",
748 " if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&",
749 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)",
751 " yyn = yytable[yyn];",
754 " if (yyerrflag != 0) goto yyinrecovery;",
755 #if defined(YYBTYACC)
758 " yynewerrflag = 1;",
759 " goto yyerrhandler;",
760 " goto yyerrlab; /* redundant goto avoids 'unused label' warning */",
763 " /* explicit YYERROR from an action -- pop the rhs of the rule reduced",
764 " * before looking for error recovery */",
765 " yystack.s_mark -= yym;",
766 " yystate = *yystack.s_mark;",
767 " yystack.l_mark -= yym;",
768 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
769 " yystack.p_mark -= yym;",
772 " yynewerrflag = 0;",
774 " while (yyps->save)",
777 " YYParseState *save = yyps->save;",
780 " fprintf(stderr, \"%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\\n\",",
781 " YYDEBUGSTR, yydepth, yystate, yyps->save->state,",
782 " (int)(yylvp - yylvals - yyps->save->lexeme));",
784 " /* Memorize most forward-looking error state in case it's really an error. */",
785 " if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)",
787 " /* Free old saved error context state */",
788 " if (yyerrctx) yyFreeState(yyerrctx);",
789 " /* Create and fill out new saved error context state */",
790 " yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));",
791 " if (yyerrctx == NULL) goto yyenomem;",
792 " yyerrctx->save = yyps->save;",
793 " yyerrctx->state = yystate;",
794 " yyerrctx->errflag = yyerrflag;",
795 " yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);",
796 " memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));",
797 " yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);",
798 " memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));",
799 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
800 " yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);",
801 " memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));",
803 " yyerrctx->lexeme = (int) (yylvp - yylvals);",
805 " yylvp = yylvals + save->lexeme;",
806 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
807 " yylpp = yylpsns + save->lexeme;",
809 " yylexp = yylexemes + save->lexeme;",
810 " yychar = YYEMPTY;",
811 " yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);",
812 " memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));",
813 " yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);",
814 " memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));",
815 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
816 " yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);",
817 " memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));",
819 " ctry = ++save->ctry;",
820 " yystate = save->state;",
821 " /* We tried shift, try reduce now */",
822 " if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;",
823 " yyps->save = save->save;",
824 " save->save = NULL;",
825 " yyFreeState(save);",
827 " /* Nothing left on the stack -- error */",
832 " fprintf(stderr, \"%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\\n\",",
833 " YYPREFIX, yydepth);",
835 " /* Restore state as it was in the most forward-advanced error */",
836 " yylvp = yylvals + yyerrctx->lexeme;",
837 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
838 " yylpp = yylpsns + yyerrctx->lexeme;",
840 " yylexp = yylexemes + yyerrctx->lexeme;",
841 " yychar = yylexp[-1];",
842 " yylval = yylvp[-1];",
843 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
844 " yylloc = yylpp[-1];",
846 " yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);",
847 " memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));",
848 " yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);",
849 " memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));",
850 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
851 " yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);",
852 " memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));",
854 " yystate = yyerrctx->state;",
855 " yyFreeState(yyerrctx);",
858 " yynewerrflag = 1;",
860 " if (yynewerrflag == 0) goto yyinrecovery;",
861 "#endif /* YYBTYACC */",
862 #endif /* defined(YYBTYACC) */
864 " YYERROR_CALL(\"syntax error\");",
865 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
866 " yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */",
870 " goto yyerrlab; /* redundant goto avoids 'unused label' warning */",
876 " if (yyerrflag < 3)",
881 " if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&",
882 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)",
886 " fprintf(stderr, \"%s[%d]: state %d, error recovery shifting to state %d\\n\",",
887 " YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);",
889 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;",
890 " yystate = yytable[yyn];",
891 " *++yystack.s_mark = yytable[yyn];",
892 " *++yystack.l_mark = yylval;",
893 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
894 " /* lookahead position is error end position */",
895 " yyerror_loc_range[2] = yylloc;",
896 " YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */",
897 " *++yystack.p_mark = yyloc;",
905 " fprintf(stderr, \"%s[%d]: error recovery discarding state %d\\n\",",
906 " YYDEBUGSTR, yydepth, *yystack.s_mark);",
908 " if (yystack.s_mark <= yystack.s_base) goto yyabort;",
909 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
910 " /* the current TOS position is the error start position */",
911 " yyerror_loc_range[1] = *yystack.p_mark;",
913 "#if defined(YYDESTRUCT_CALL)",
914 #if defined(YYBTYACC)
917 "#endif /* YYBTYACC */",
918 #endif /* defined(YYBTYACC) */
919 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
920 " YYDESTRUCT_CALL(\"error: discarding state\",",
921 " yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);",
923 " YYDESTRUCT_CALL(\"error: discarding state\",",
924 " yystos[*yystack.s_mark], yystack.l_mark);",
925 "#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */",
926 "#endif /* defined(YYDESTRUCT_CALL) */",
927 " --yystack.s_mark;",
928 " --yystack.l_mark;",
929 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
930 " --yystack.p_mark;",
937 " if (yychar == YYEOF) goto yyabort;",
941 " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];",
942 " fprintf(stderr, \"%s[%d]: state %d, error recovery discarding token %d (%s)\\n\",",
943 " YYDEBUGSTR, yydepth, yystate, yychar, yys);",
946 "#if defined(YYDESTRUCT_CALL)",
947 #if defined(YYBTYACC)
950 "#endif /* YYBTYACC */",
951 #endif /* defined(YYBTYACC) */
952 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
953 " YYDESTRUCT_CALL(\"error: discarding token\", yychar, &yylval, &yylloc);",
955 " YYDESTRUCT_CALL(\"error: discarding token\", yychar, &yylval);",
956 "#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */",
957 "#endif /* defined(YYDESTRUCT_CALL) */",
958 " yychar = YYEMPTY;",
963 " yym = yylen[yyn];",
967 " fprintf(stderr, \"%s[%d]: state %d, reducing by rule %d (%s)\",",
968 " YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);",
969 "#ifdef YYSTYPE_TOSTRING",
970 #if defined(YYBTYACC)
973 "#endif /* YYBTYACC */",
974 #endif /* defined(YYBTYACC) */
978 " fputc('<', stderr);",
979 " for (i = yym; i > 0; i--)",
981 " if (i != yym) fputs(\", \", stderr);",
982 " fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],",
983 " yystack.l_mark[1-i]), stderr);",
985 " fputc('>', stderr);",
988 " fputc('\\n', stderr);",
992 " yyval = yystack.l_mark[1-yym];",
994 " memset(&yyval, 0, sizeof yyval);",
995 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
997 " /* Perform position reduction */",
998 " memset(&yyloc, 0, sizeof(yyloc));",
999 #if defined(YYBTYACC)
1002 "#endif /* YYBTYACC */",
1003 #endif /* defined(YYBTYACC) */
1005 " YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);",
1006 " /* just in case YYERROR is invoked within the action, save",
1007 " the start of the rhs as the error start position */",
1008 " yyerror_loc_range[1] = yystack.p_mark[1-yym];",
1017 const char *const trailer[] =
1022 " yystack.s_mark -= yym;",
1023 " yystate = *yystack.s_mark;",
1024 " yystack.l_mark -= yym;",
1025 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1026 " yystack.p_mark -= yym;",
1028 " yym = yylhs[yyn];",
1029 " if (yystate == 0 && yym == 0)",
1034 " fprintf(stderr, \"%s[%d]: after reduction, \", YYDEBUGSTR, yydepth);",
1035 "#ifdef YYSTYPE_TOSTRING",
1036 #if defined(YYBTYACC)
1039 "#endif /* YYBTYACC */",
1040 #endif /* defined(YYBTYACC) */
1041 " fprintf(stderr, \"result is <%s>, \", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));",
1043 " fprintf(stderr, \"shifting from state 0 to final state %d\\n\", YYFINAL);",
1046 " yystate = YYFINAL;",
1047 " *++yystack.s_mark = YYFINAL;",
1048 " *++yystack.l_mark = yyval;",
1049 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1050 " *++yystack.p_mark = yyloc;",
1054 #if defined(YYBTYACC)
1057 " if (yylvp < yylve)",
1059 " /* we're currently re-reading tokens */",
1060 " yylval = *yylvp++;",
1061 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1062 " yylloc = *yylpp++;",
1064 " yychar = *yylexp++;",
1069 " /* in trial mode; save scanner results for future parse attempts */",
1070 " if (yylvp == yylvlim)",
1071 " { /* Enlarge lexical value queue */",
1072 " size_t p = (size_t) (yylvp - yylvals);",
1073 " size_t s = (size_t) (yylvlim - yylvals);",
1075 " s += YYLVQUEUEGROWTH;",
1076 " if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)",
1078 " if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)",
1080 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1081 " if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)",
1084 " yylvp = yylve = yylvals + p;",
1085 " yylvlim = yylvals + s;",
1086 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1087 " yylpp = yylpe = yylpsns + p;",
1088 " yylplim = yylpsns + s;",
1090 " yylexp = yylexemes + p;",
1092 " *yylexp = (YYINT) YYLEX;",
1093 " *yylvp++ = yylval;",
1095 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1096 " *yylpp++ = yylloc;",
1099 " yychar = *yylexp++;",
1102 " /* normal operation, no conflict encountered */",
1103 "#endif /* YYBTYACC */",
1104 #endif /* defined(YYBTYACC) */
1106 #if defined(YYBTYACC)
1109 "#endif /* YYBTYACC */",
1110 #endif /* defined(YYBTYACC) */
1111 " if (yychar < 0) yychar = YYEOF;",
1115 " if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];",
1116 " fprintf(stderr, \"%s[%d]: state %d, reading token %d (%s)\\n\",",
1117 " YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);",
1121 " if (yychar == YYEOF) goto yyaccept;",
1124 " if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&",
1125 " yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)",
1126 " yystate = yytable[yyn];",
1128 " yystate = yydgoto[yym];",
1132 " fprintf(stderr, \"%s[%d]: after reduction, \", YYDEBUGSTR, yydepth);",
1133 "#ifdef YYSTYPE_TOSTRING",
1134 #if defined(YYBTYACC)
1137 "#endif /* YYBTYACC */",
1138 #endif /* defined(YYBTYACC) */
1139 " fprintf(stderr, \"result is <%s>, \", YYSTYPE_TOSTRING(yystos[yystate], yyval));",
1141 " fprintf(stderr, \"shifting from state %d to state %d\\n\", *yystack.s_mark, yystate);",
1144 " if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;",
1145 " *++yystack.s_mark = (YYINT) yystate;",
1146 " *++yystack.l_mark = yyval;",
1147 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1148 " *++yystack.p_mark = yyloc;",
1151 #if defined(YYBTYACC)
1154 " /* Reduction declares that this path is valid. Set yypath and do a full parse */",
1156 " if (yypath) YYABORT;",
1157 " while (yyps->save)",
1159 " YYParseState *save = yyps->save;",
1160 " yyps->save = save->save;",
1161 " save->save = yypath;",
1166 " fprintf(stderr, \"%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\\n\",",
1167 " YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));",
1171 " yyFreeState(yyerrctx);",
1172 " yyerrctx = NULL;",
1174 " yylvp = yylvals + yypath->lexeme;",
1175 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1176 " yylpp = yylpsns + yypath->lexeme;",
1178 " yylexp = yylexemes + yypath->lexeme;",
1179 " yychar = YYEMPTY;",
1180 " yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);",
1181 " memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));",
1182 " yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);",
1183 " memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));",
1184 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1185 " yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);",
1186 " memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));",
1188 " yystate = yypath->state;",
1190 "#endif /* YYBTYACC */",
1191 #endif /* defined(YYBTYACC) */
1194 " YYERROR_CALL(\"yacc stack overflow\");",
1195 #if defined(YYBTYACC)
1197 " goto yyabort_nomem;",
1199 " YYERROR_CALL(\"memory exhausted\");",
1201 "#endif /* YYBTYACC */",
1202 #endif /* defined(YYBTYACC) */
1211 #if defined(YYBTYACC)
1213 " if (yyps->save) goto yyvalid;",
1214 "#endif /* YYBTYACC */",
1215 #endif /* defined(YYBTYACC) */
1219 "#if defined(YYDESTRUCT_CALL)",
1220 " if (yychar != YYEOF && yychar != YYEMPTY)",
1221 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1222 " YYDESTRUCT_CALL(\"cleanup: discarding token\", yychar, &yylval, &yylloc);",
1224 " YYDESTRUCT_CALL(\"cleanup: discarding token\", yychar, &yylval);",
1225 "#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */",
1229 "#if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)",
1232 " for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)",
1233 " YYDESTRUCT_CALL(\"cleanup: discarding state\",",
1234 " yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);",
1236 " for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)",
1237 " YYDESTRUCT_CALL(\"cleanup: discarding state\",",
1238 " yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);",
1239 "#endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */",
1241 "#endif /* defined(YYDESTRUCT_CALL) */",
1243 #if defined(YYBTYACC)
1247 " yyFreeState(yyerrctx);",
1248 " yyerrctx = NULL;",
1252 " YYParseState *save = yyps;",
1253 " yyps = save->save;",
1254 " save->save = NULL;",
1255 " yyFreeState(save);",
1259 " YYParseState *save = yypath;",
1260 " yypath = save->save;",
1261 " save->save = NULL;",
1262 " yyFreeState(save);",
1264 "#endif /* YYBTYACC */",
1265 #endif /* defined(YYBTYACC) */
1266 " yyfreestack(&yystack);",
1267 " return (yyresult);",
1273 write_section(FILE * fp, const char *const section[])
1278 for (i = 0; (s = section[i]) != 0; ++i)
1280 if (fp == code_file)
1282 fprintf(fp, "%s\n", s);