1 /* $Id: btyaccpar.skel,v 1.3 2016/06/06 23:35:55 Tom.Shields Exp $ */
5 /* If the skeleton is changed, the banner should be changed so that */
6 /* the altered version can be easily distinguished from the original. */
8 /* The #defines included with the banner are there because they are */
9 /* useful in subsequent code. The macros #defined in the header or */
10 /* the body either are not useful outside of semantic actions or */
11 /* are conditional. */
14 /* original parser id follows */
15 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
16 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
19 %% insert VERSION here
22 #define yyclearin (yychar = YYEMPTY)
23 #define yyerrok (yyerrflag = 0)
24 #define YYRECOVERING() (yyerrflag != 0)
29 extern int YYPARSE_DECL();
31 extern const YYINT yylhs[];
32 extern const YYINT yylen[];
33 extern const YYINT yydefred[];
34 extern const YYINT yystos[];
35 extern const YYINT yydgoto[];
36 extern const YYINT yysindex[];
37 extern const YYINT yyrindex[];
39 extern const YYINT yycindex[];
41 extern const YYINT yygindex[];
42 extern const YYINT yytable[];
43 extern const YYINT yycheck[];
45 extern const YYINT yyctable[];
48 #if YYDEBUG || defined(yytname)
49 extern const char *const yyname[];
52 extern const char *const yyrule[];
64 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
65 YYLTYPE yyloc; /* position returned by actions */
66 YYLTYPE yylloc; /* position from the lexer */
70 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
71 #ifndef YYLLOC_DEFAULT
72 #define YYLLOC_DEFAULT(loc, rhs, n) \
77 (loc).first_line = ((rhs)[-1]).last_line; \
78 (loc).first_column = ((rhs)[-1]).last_column; \
79 (loc).last_line = ((rhs)[-1]).last_line; \
80 (loc).last_column = ((rhs)[-1]).last_column; \
84 (loc).first_line = ((rhs)[ 0 ]).first_line; \
85 (loc).first_column = ((rhs)[ 0 ]).first_column; \
86 (loc).last_line = ((rhs)[n-1]).last_line; \
87 (loc).last_column = ((rhs)[n-1]).last_column; \
90 #endif /* YYLLOC_DEFAULT */
91 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
94 #ifndef YYLVQUEUEGROWTH
95 #define YYLVQUEUEGROWTH 32
99 /* define the initial stack-sizes */
102 #define YYMAXDEPTH YYSTACKSIZE
105 #define YYSTACKSIZE YYMAXDEPTH
107 #define YYSTACKSIZE 10000
108 #define YYMAXDEPTH 10000
112 #ifndef YYINITSTACKSIZE
113 #define YYINITSTACKSIZE 200
123 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
130 struct YYParseState_s
132 struct YYParseState_s *save; /* Previously saved parser state */
133 YYSTACKDATA yystack; /* saved parser stack */
134 int state; /* saved parser state */
135 int errflag; /* saved error recovery status */
136 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
137 YYINT ctry; /* saved index in yyctable[] for this conflict */
139 typedef struct YYParseState_s YYParseState;
142 /* variables for the parser stack */
143 static YYSTACKDATA yystack;
146 /* Current parser state */
147 static YYParseState *yyps = 0;
149 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
150 static YYParseState *yypath = 0;
152 /* Base of the lexical value queue */
153 static YYSTYPE *yylvals = 0;
155 /* Current position at lexical value queue */
156 static YYSTYPE *yylvp = 0;
158 /* End position of lexical value queue */
159 static YYSTYPE *yylve = 0;
161 /* The last allocated position at the lexical value queue */
162 static YYSTYPE *yylvlim = 0;
164 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
165 /* Base of the lexical position queue */
166 static YYLTYPE *yylpsns = 0;
168 /* Current position at lexical position queue */
169 static YYLTYPE *yylpp = 0;
171 /* End position of lexical position queue */
172 static YYLTYPE *yylpe = 0;
174 /* The last allocated position at the lexical position queue */
175 static YYLTYPE *yylplim = 0;
178 /* Current position at lexical token queue */
179 static short *yylexp = 0;
181 static short *yylexemes = 0;
188 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
189 YYLTYPE yyloc; /* position returned by actions */
190 YYLTYPE yylloc; /* position from the lexer */
193 /* variables for the parser stack */
197 /* Current parser state */
198 static YYParseState *yyps = 0;
200 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
201 static YYParseState *yypath = 0;
203 /* Base of the lexical value queue */
204 static YYSTYPE *yylvals = 0;
206 /* Current position at lexical value queue */
207 static YYSTYPE *yylvp = 0;
209 /* End position of lexical value queue */
210 static YYSTYPE *yylve = 0;
212 /* The last allocated position at the lexical value queue */
213 static YYSTYPE *yylvlim = 0;
215 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
216 /* Base of the lexical position queue */
217 static YYLTYPE *yylpsns = 0;
219 /* Current position at lexical position queue */
220 static YYLTYPE *yylpp = 0;
222 /* End position of lexical position queue */
223 static YYLTYPE *yylpe = 0;
225 /* The last allocated position at the lexical position queue */
226 static YYLTYPE *yylplim = 0;
229 /* Current position at lexical token queue */
230 static short *yylexp = 0;
232 static short *yylexemes = 0;
236 /* For use in generated program */
237 #define yydepth (int)(yystack.s_mark - yystack.s_base)
239 #define yytrial (yyps->save)
243 #include <stdio.h> /* needed for printf */
246 #include <stdlib.h> /* needed for malloc, etc */
247 #include <string.h> /* needed for memset */
249 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
250 static int yygrowstack(YYSTACKDATA *data)
256 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
260 if ((newsize = data->stacksize) == 0)
261 newsize = YYINITSTACKSIZE;
262 else if (newsize >= YYMAXDEPTH)
264 else if ((newsize *= 2) > YYMAXDEPTH)
265 newsize = YYMAXDEPTH;
267 i = (int) (data->s_mark - data->s_base);
268 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
272 data->s_base = newss;
273 data->s_mark = newss + i;
275 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
279 data->l_base = newvs;
280 data->l_mark = newvs + i;
282 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
283 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
287 data->p_base = newps;
288 data->p_mark = newps + i;
291 data->stacksize = newsize;
292 data->s_last = data->s_base + newsize - 1;
296 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
301 #if YYPURE || defined(YY_NO_LEAKS)
302 static void yyfreestack(YYSTACKDATA *data)
306 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
309 memset(data, 0, sizeof(*data));
312 #define yyfreestack(data) /* nothing */
313 #endif /* YYPURE || defined(YY_NO_LEAKS) */
316 static YYParseState *
317 yyNewState(unsigned size)
319 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
320 if (p == NULL) return NULL;
322 p->yystack.stacksize = size;
325 p->yystack.s_base = NULL;
326 p->yystack.l_base = NULL;
327 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
328 p->yystack.p_base = NULL;
332 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
333 if (p->yystack.s_base == NULL) return NULL;
334 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
335 if (p->yystack.l_base == NULL) return NULL;
336 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
337 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
338 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
339 if (p->yystack.p_base == NULL) return NULL;
340 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
347 yyFreeState(YYParseState *p)
349 yyfreestack(&p->yystack);
354 #define YYABORT goto yyabort
355 #define YYREJECT goto yyabort
356 #define YYACCEPT goto yyaccept
357 #define YYERROR goto yyerrlab
359 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
360 #define YYVALID_NESTED do { if (yyps->save && \
361 yyps->save->save == 0) goto yyvalid; } while(0)
368 int yym, yyn, yystate, yyresult;
371 YYParseState *yyerrctx = NULL;
373 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
374 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
379 if ((yys = getenv("YYDEBUG")) != 0)
382 if (yyn >= '0' && yyn <= '9')
386 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
390 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
401 memset(&yystack, 0, sizeof(yystack));
404 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
405 yystack.s_mark = yystack.s_base;
406 yystack.l_mark = yystack.l_base;
407 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
408 yystack.p_mark = yystack.p_base;
414 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
421 /* we're currently re-reading tokens */
423 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
431 /* in trial mode; save scanner results for future parse attempts */
432 if (yylvp == yylvlim)
433 { /* Enlarge lexical value queue */
434 size_t p = (size_t) (yylvp - yylvals);
435 size_t s = (size_t) (yylvlim - yylvals);
437 s += YYLVQUEUEGROWTH;
438 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
439 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
440 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
441 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
443 yylvp = yylve = yylvals + p;
444 yylvlim = yylvals + s;
445 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
446 yylpp = yylpe = yylpsns + p;
447 yylplim = yylpsns + s;
449 yylexp = yylexemes + p;
451 *yylexp = (short) YYLEX;
454 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
461 /* normal operation, no conflict encountered */
467 if (yychar < 0) yychar = YYEOF;
471 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
472 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
473 YYDEBUGSTR, yydepth, yystate, yychar, yys);
474 #ifdef YYSTYPE_TOSTRING
478 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
486 /* Do we have a conflict? */
487 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
488 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
497 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
498 YYDEBUGSTR, yydepth, yystate);
500 /* Switch to the next conflict context */
505 if (save->state != yystate) YYABORT;
512 /* Unresolved conflict - start/continue trial parse */
517 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
519 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
521 fputs("Starting trial parse.\n", stderr);
524 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
525 if (save == NULL) goto yyenomem;
526 save->save = yyps->save;
527 save->state = yystate;
528 save->errflag = yyerrflag;
529 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
530 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
531 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
532 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
533 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
534 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
535 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
538 if (yyctable[ctry] == -1)
541 if (yydebug && yychar >= YYEOF)
542 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
547 if (yyps->save == NULL)
549 /* If this is a first conflict in the stack, start saving lexemes */
552 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
553 if (yylexemes == NULL) goto yyenomem;
554 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
555 if (yylvals == NULL) goto yyenomem;
556 yylvlim = yylvals + YYLVQUEUEGROWTH;
557 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
558 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
559 if (yylpsns == NULL) goto yyenomem;
560 yylplim = yylpsns + YYLVQUEUEGROWTH;
565 yylvp = yylve = yylvals;
566 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
567 yylpp = yylpe = yylpsns;
573 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
576 *yylexp = (short) yychar;
584 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
590 save->lexeme = (int) (yylvp - yylvals);
593 if (yytable[yyn] == ctry)
597 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
598 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
603 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
608 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
610 yystate = yyctable[ctry];
611 *++yystack.s_mark = (YYINT) yystate;
612 *++yystack.l_mark = yylval;
613 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
614 *++yystack.p_mark = yylloc;
617 if (yyerrflag > 0) --yyerrflag;
622 yyn = yyctable[ctry];
625 } /* End of code dealing with conflicts */
627 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
628 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
632 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
633 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
635 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
636 yystate = yytable[yyn];
637 *++yystack.s_mark = yytable[yyn];
638 *++yystack.l_mark = yylval;
639 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
640 *++yystack.p_mark = yylloc;
643 if (yyerrflag > 0) --yyerrflag;
646 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
647 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
652 if (yyerrflag != 0) goto yyinrecovery;
657 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
660 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
661 * before looking for error recovery */
662 yystack.s_mark -= yym;
663 yystate = *yystack.s_mark;
664 yystack.l_mark -= yym;
665 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
666 yystack.p_mark -= yym;
674 YYParseState *save = yyps->save;
677 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
678 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
679 (int)(yylvp - yylvals - yyps->save->lexeme));
681 /* Memorize most forward-looking error state in case it's really an error. */
682 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
684 /* Free old saved error context state */
685 if (yyerrctx) yyFreeState(yyerrctx);
686 /* Create and fill out new saved error context state */
687 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
688 if (yyerrctx == NULL) goto yyenomem;
689 yyerrctx->save = yyps->save;
690 yyerrctx->state = yystate;
691 yyerrctx->errflag = yyerrflag;
692 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
693 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
694 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
695 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
696 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
697 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
698 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
700 yyerrctx->lexeme = (int) (yylvp - yylvals);
702 yylvp = yylvals + save->lexeme;
703 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
704 yylpp = yylpsns + save->lexeme;
706 yylexp = yylexemes + save->lexeme;
708 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
709 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
710 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
711 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
712 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
713 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
714 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
717 yystate = save->state;
718 /* We tried shift, try reduce now */
719 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
720 yyps->save = save->save;
724 /* Nothing left on the stack -- error */
729 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
732 /* Restore state as it was in the most forward-advanced error */
733 yylvp = yylvals + yyerrctx->lexeme;
734 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
735 yylpp = yylpsns + yyerrctx->lexeme;
737 yylexp = yylexemes + yyerrctx->lexeme;
740 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
743 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
744 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
745 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
746 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
747 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
748 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
749 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
751 yystate = yyerrctx->state;
752 yyFreeState(yyerrctx);
757 if (yynewerrflag == 0) goto yyinrecovery;
760 YYERROR_CALL("syntax error");
761 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
762 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
766 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
777 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
778 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
782 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
783 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
785 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
786 yystate = yytable[yyn];
787 *++yystack.s_mark = yytable[yyn];
788 *++yystack.l_mark = yylval;
789 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
790 /* lookahead position is error end position */
791 yyerror_loc_range[1] = yylloc;
792 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
793 *++yystack.p_mark = yyloc;
801 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
802 YYDEBUGSTR, yydepth, *yystack.s_mark);
804 if (yystack.s_mark <= yystack.s_base) goto yyabort;
805 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
806 /* the current TOS position is the error start position */
807 yyerror_loc_range[0] = *yystack.p_mark;
809 #if defined(YYDESTRUCT_CALL)
813 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
814 YYDESTRUCT_CALL("error: discarding state",
815 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
817 YYDESTRUCT_CALL("error: discarding state",
818 yystos[*yystack.s_mark], yystack.l_mark);
819 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
820 #endif /* defined(YYDESTRUCT_CALL) */
823 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
831 if (yychar == YYEOF) goto yyabort;
835 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
836 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
837 YYDEBUGSTR, yydepth, yystate, yychar, yys);
840 #if defined(YYDESTRUCT_CALL)
844 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
845 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
847 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
848 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
849 #endif /* defined(YYDESTRUCT_CALL) */
859 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
860 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
861 #ifdef YYSTYPE_TOSTRING
869 for (i = yym; i > 0; i--)
871 if (i != yym) fputs(", ", stderr);
872 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
873 yystack.l_mark[1-i]), stderr);
882 yyval = yystack.l_mark[1-yym];
884 memset(&yyval, 0, sizeof yyval);
885 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
887 /* Perform position reduction */
888 memset(&yyloc, 0, sizeof(yyloc));
893 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
894 /* just in case YYERROR is invoked within the action, save
895 the start of the rhs as the error start position */
896 yyerror_loc_range[0] = yystack.p_mark[1-yym];
906 yystack.s_mark -= yym;
907 yystate = *yystack.s_mark;
908 yystack.l_mark -= yym;
909 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
910 yystack.p_mark -= yym;
913 if (yystate == 0 && yym == 0)
918 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
919 #ifdef YYSTYPE_TOSTRING
923 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
925 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
929 *++yystack.s_mark = YYFINAL;
930 *++yystack.l_mark = yyval;
931 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
932 *++yystack.p_mark = yyloc;
940 /* we're currently re-reading tokens */
942 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
950 /* in trial mode; save scanner results for future parse attempts */
951 if (yylvp == yylvlim)
952 { /* Enlarge lexical value queue */
953 size_t p = (size_t) (yylvp - yylvals);
954 size_t s = (size_t) (yylvlim - yylvals);
956 s += YYLVQUEUEGROWTH;
957 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
959 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
961 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
962 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
965 yylvp = yylve = yylvals + p;
966 yylvlim = yylvals + s;
967 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
968 yylpp = yylpe = yylpsns + p;
969 yylplim = yylpsns + s;
971 yylexp = yylexemes + p;
973 *yylexp = (short) YYLEX;
976 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
983 /* normal operation, no conflict encountered */
989 if (yychar < 0) yychar = YYEOF;
993 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
994 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
995 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
999 if (yychar == YYEOF) goto yyaccept;
1002 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1003 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1004 yystate = yytable[yyn];
1006 yystate = yydgoto[yym];
1010 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1011 #ifdef YYSTYPE_TOSTRING
1015 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1017 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1020 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1021 *++yystack.s_mark = (YYINT) yystate;
1022 *++yystack.l_mark = yyval;
1023 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1024 *++yystack.p_mark = yyloc;
1029 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1031 if (yypath) YYABORT;
1034 YYParseState *save = yyps->save;
1035 yyps->save = save->save;
1036 save->save = yypath;
1041 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1042 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1046 yyFreeState(yyerrctx);
1049 yylvp = yylvals + yypath->lexeme;
1050 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1051 yylpp = yylpsns + yypath->lexeme;
1053 yylexp = yylexemes + yypath->lexeme;
1055 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1056 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1057 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1058 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1059 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1060 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1061 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1063 yystate = yypath->state;
1068 YYERROR_CALL("yacc stack overflow");
1072 YYERROR_CALL("memory exhausted");
1084 if (yyps->save) goto yyvalid;
1089 #if defined(YYDESTRUCT_CALL)
1090 if (yychar != YYEOF && yychar != YYEMPTY)
1091 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1092 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1094 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1095 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1099 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1102 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1103 YYDESTRUCT_CALL("cleanup: discarding state",
1104 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1106 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1107 YYDESTRUCT_CALL("cleanup: discarding state",
1108 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1109 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1111 #endif /* defined(YYDESTRUCT_CALL) */
1116 yyFreeState(yyerrctx);
1121 YYParseState *save = yyps;
1128 YYParseState *save = yypath;
1129 yypath = save->save;
1134 yyfreestack(&yystack);