1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
8 #define YYCHECK "yyyymmdd"
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
18 #define YYDEBUGSTR YYPREFIX "debug"
21 #define yyparse error_parse
25 #define yylex error_lex
29 #define yyerror error_error
33 #define yychar error_char
37 #define yyval error_val
41 #define yylval error_lval
45 #define yydebug error_debug
49 #define yynerrs error_nerrs
53 #define yyerrflag error_errflag
54 #endif /* yyerrflag */
57 #define yylhs error_lhs
61 #define yylen error_len
65 #define yydefred error_defred
69 #define yystos error_stos
73 #define yydgoto error_dgoto
77 #define yysindex error_sindex
81 #define yyrindex error_rindex
85 #define yygindex error_gindex
89 #define yytable error_table
93 #define yycheck error_check
97 #define yyname error_name
101 #define yyrule error_rule
107 #define yycindex error_cindex
108 #endif /* yycindex */
111 #define yyctable error_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "error_"
120 #line 2 "pure_error.y"
124 #define YYLEX_PARAM &yylval
125 #define YYLEX_DECL() yylex(YYSTYPE *yylval)
126 #define YYERROR_DECL() yyerror(const char *s)
128 static void YYERROR_DECL();
131 #line 132 "pure_error.tab.c"
133 #if ! defined(YYSTYPE) && ! defined(YYSTYPE_IS_DECLARED)
134 /* Default: YYSTYPE is the semantic value type. */
136 # define YYSTYPE_IS_DECLARED 1
139 /* compatibility with bison */
141 /* compatibility with FreeBSD */
142 # ifdef YYPARSE_PARAM_TYPE
143 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
145 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
148 # define YYPARSE_DECL() yyparse(void)
151 /* Parameters sent to lex. */
153 # ifdef YYLEX_PARAM_TYPE
154 # define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
156 # define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
158 # define YYLEX yylex(&yylval, YYLEX_PARAM)
160 # define YYLEX_DECL() yylex(YYSTYPE *yylval)
161 # define YYLEX yylex(&yylval)
164 /* Parameters sent to yyerror. */
166 #define YYERROR_DECL() yyerror(const char *s)
169 #define YYERROR_CALL(msg) yyerror(msg)
172 extern int YYPARSE_DECL();
174 #define YYERRCODE 256
176 static const YYINT error_lhs[] = { -1,
179 static const YYINT error_len[] = { 2,
182 static const YYINT error_defred[] = { 0,
185 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
186 static const YYINT error_stos[] = { 0,
189 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
190 static const YYINT error_dgoto[] = { 2,
192 static const YYINT error_sindex[] = { -256,
195 static const YYINT error_rindex[] = { 0,
199 static const YYINT error_cindex[] = { 0,
203 static const YYINT error_gindex[] = { 0,
205 #define YYTABLESIZE 0
206 static const YYINT error_table[] = { 1,
208 static const YYINT error_check[] = { 256,
211 static const YYINT error_ctable[] = { -1,
218 #define YYMAXTOKEN 256
219 #define YYUNDFTOKEN 259
220 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
222 static const char *const error_name[] = {
224 "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
225 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
226 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
227 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
228 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
229 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
230 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","$accept","S","illegal-symbol",
232 static const char *const error_rule[] = {
243 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
244 #ifndef YYLLOC_DEFAULT
245 #define YYLLOC_DEFAULT(loc, rhs, n) \
250 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
251 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
252 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
253 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
257 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
258 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
259 (loc).last_line = YYRHSLOC(rhs, n).last_line; \
260 (loc).last_column = YYRHSLOC(rhs, n).last_column; \
263 #endif /* YYLLOC_DEFAULT */
264 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
267 #ifndef YYLVQUEUEGROWTH
268 #define YYLVQUEUEGROWTH 32
270 #endif /* YYBTYACC */
272 /* define the initial stack-sizes */
275 #define YYMAXDEPTH YYSTACKSIZE
278 #define YYSTACKSIZE YYMAXDEPTH
280 #define YYSTACKSIZE 10000
281 #define YYMAXDEPTH 10000
285 #ifndef YYINITSTACKSIZE
286 #define YYINITSTACKSIZE 200
296 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
303 struct YYParseState_s
305 struct YYParseState_s *save; /* Previously saved parser state */
306 YYSTACKDATA yystack; /* saved parser stack */
307 int state; /* saved parser state */
308 int errflag; /* saved error recovery status */
309 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
310 YYINT ctry; /* saved index in yyctable[] for this conflict */
312 typedef struct YYParseState_s YYParseState;
313 #endif /* YYBTYACC */
314 #line 17 "pure_error.y"
319 extern int YYLEX_DECL();
325 printf("yyparse() = %d\n", yyparse());
330 yylex(YYSTYPE *value)
332 return value ? 0 : -1;
336 yyerror(const char* s)
340 #line 341 "pure_error.tab.c"
342 /* For use in generated program */
343 #define yydepth (int)(yystack.s_mark - yystack.s_base)
345 #define yytrial (yyps->save)
346 #endif /* YYBTYACC */
349 #include <stdio.h> /* needed for printf */
352 #include <stdlib.h> /* needed for malloc, etc */
353 #include <string.h> /* needed for memset */
355 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
356 static int yygrowstack(YYSTACKDATA *data)
362 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
366 if ((newsize = data->stacksize) == 0)
367 newsize = YYINITSTACKSIZE;
368 else if (newsize >= YYMAXDEPTH)
370 else if ((newsize *= 2) > YYMAXDEPTH)
371 newsize = YYMAXDEPTH;
373 i = (int) (data->s_mark - data->s_base);
374 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
378 data->s_base = newss;
379 data->s_mark = newss + i;
381 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
385 data->l_base = newvs;
386 data->l_mark = newvs + i;
388 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
389 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
393 data->p_base = newps;
394 data->p_mark = newps + i;
397 data->stacksize = newsize;
398 data->s_last = data->s_base + newsize - 1;
402 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
407 #if YYPURE || defined(YY_NO_LEAKS)
408 static void yyfreestack(YYSTACKDATA *data)
412 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
415 memset(data, 0, sizeof(*data));
418 #define yyfreestack(data) /* nothing */
419 #endif /* YYPURE || defined(YY_NO_LEAKS) */
422 static YYParseState *
423 yyNewState(unsigned size)
425 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
426 if (p == NULL) return NULL;
428 p->yystack.stacksize = size;
431 p->yystack.s_base = NULL;
432 p->yystack.l_base = NULL;
433 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
434 p->yystack.p_base = NULL;
438 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
439 if (p->yystack.s_base == NULL) return NULL;
440 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
441 if (p->yystack.l_base == NULL) return NULL;
442 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
443 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
444 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
445 if (p->yystack.p_base == NULL) return NULL;
446 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
453 yyFreeState(YYParseState *p)
455 yyfreestack(&p->yystack);
458 #endif /* YYBTYACC */
460 #define YYABORT goto yyabort
461 #define YYREJECT goto yyabort
462 #define YYACCEPT goto yyaccept
463 #define YYERROR goto yyerrlab
465 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
466 #define YYVALID_NESTED do { if (yyps->save && \
467 yyps->save->save == 0) goto yyvalid; } while(0)
468 #endif /* YYBTYACC */
479 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
480 YYLTYPE yyloc; /* position returned by actions */
481 YYLTYPE yylloc; /* position from the lexer */
484 /* variables for the parser stack */
488 /* Current parser state */
489 static YYParseState *yyps = 0;
491 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
492 static YYParseState *yypath = 0;
494 /* Base of the lexical value queue */
495 static YYSTYPE *yylvals = 0;
497 /* Current position at lexical value queue */
498 static YYSTYPE *yylvp = 0;
500 /* End position of lexical value queue */
501 static YYSTYPE *yylve = 0;
503 /* The last allocated position at the lexical value queue */
504 static YYSTYPE *yylvlim = 0;
506 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
507 /* Base of the lexical position queue */
508 static YYLTYPE *yylpsns = 0;
510 /* Current position at lexical position queue */
511 static YYLTYPE *yylpp = 0;
513 /* End position of lexical position queue */
514 static YYLTYPE *yylpe = 0;
516 /* The last allocated position at the lexical position queue */
517 static YYLTYPE *yylplim = 0;
520 /* Current position at lexical token queue */
521 static YYINT *yylexp = 0;
523 static YYINT *yylexemes = 0;
524 #endif /* YYBTYACC */
525 int yym, yyn, yystate, yyresult;
528 YYParseState *yyerrctx = NULL;
529 #endif /* YYBTYACC */
530 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
531 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
536 if ((yys = getenv("YYDEBUG")) != 0)
539 if (yyn >= '0' && yyn <= '9')
543 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
545 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
546 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
551 memset(&yyval, 0, sizeof(yyval));
552 memset(&yylval, 0, sizeof(yylval));
553 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
554 memset(&yyloc, 0, sizeof(yyloc));
555 memset(&yylloc, 0, sizeof(yylloc));
559 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
561 #endif /* YYBTYACC */
570 memset(&yystack, 0, sizeof(yystack));
573 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
574 yystack.s_mark = yystack.s_base;
575 yystack.l_mark = yystack.l_base;
576 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
577 yystack.p_mark = yystack.p_base;
583 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
590 /* we're currently re-reading tokens */
592 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
600 /* in trial mode; save scanner results for future parse attempts */
601 if (yylvp == yylvlim)
602 { /* Enlarge lexical value queue */
603 size_t p = (size_t) (yylvp - yylvals);
604 size_t s = (size_t) (yylvlim - yylvals);
606 s += YYLVQUEUEGROWTH;
607 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
608 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
609 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
610 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
612 yylvp = yylve = yylvals + p;
613 yylvlim = yylvals + s;
614 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
615 yylpp = yylpe = yylpsns + p;
616 yylplim = yylpsns + s;
618 yylexp = yylexemes + p;
620 *yylexp = (YYINT) YYLEX;
623 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
630 /* normal operation, no conflict encountered */
631 #endif /* YYBTYACC */
635 #endif /* YYBTYACC */
636 if (yychar < 0) yychar = YYEOF;
640 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
641 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
642 YYDEBUGSTR, yydepth, yystate, yychar, yys);
643 #ifdef YYSTYPE_TOSTRING
646 #endif /* YYBTYACC */
647 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
655 /* Do we have a conflict? */
656 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
657 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
666 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
667 YYDEBUGSTR, yydepth, yystate);
669 /* Switch to the next conflict context */
674 if (save->state != yystate) YYABORT;
681 /* Unresolved conflict - start/continue trial parse */
686 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
688 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
690 fputs("Starting trial parse.\n", stderr);
693 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
694 if (save == NULL) goto yyenomem;
695 save->save = yyps->save;
696 save->state = yystate;
697 save->errflag = yyerrflag;
698 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
699 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
700 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
701 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
702 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
703 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
704 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
707 if (yyctable[ctry] == -1)
710 if (yydebug && yychar >= YYEOF)
711 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
716 if (yyps->save == NULL)
718 /* If this is a first conflict in the stack, start saving lexemes */
721 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
722 if (yylexemes == NULL) goto yyenomem;
723 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
724 if (yylvals == NULL) goto yyenomem;
725 yylvlim = yylvals + YYLVQUEUEGROWTH;
726 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
727 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
728 if (yylpsns == NULL) goto yyenomem;
729 yylplim = yylpsns + YYLVQUEUEGROWTH;
734 yylvp = yylve = yylvals;
735 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
736 yylpp = yylpe = yylpsns;
742 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
745 *yylexp = (YYINT) yychar;
753 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
759 save->lexeme = (int) (yylvp - yylvals);
762 if (yytable[yyn] == ctry)
766 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
767 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
772 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
777 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
779 yystate = yyctable[ctry];
780 *++yystack.s_mark = (YYINT) yystate;
781 *++yystack.l_mark = yylval;
782 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
783 *++yystack.p_mark = yylloc;
786 if (yyerrflag > 0) --yyerrflag;
791 yyn = yyctable[ctry];
794 } /* End of code dealing with conflicts */
795 #endif /* YYBTYACC */
796 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
797 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
801 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
802 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
804 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
805 yystate = yytable[yyn];
806 *++yystack.s_mark = yytable[yyn];
807 *++yystack.l_mark = yylval;
808 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
809 *++yystack.p_mark = yylloc;
812 if (yyerrflag > 0) --yyerrflag;
815 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
816 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
821 if (yyerrflag != 0) goto yyinrecovery;
826 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
829 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
830 * before looking for error recovery */
831 yystack.s_mark -= yym;
832 yystate = *yystack.s_mark;
833 yystack.l_mark -= yym;
834 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
835 yystack.p_mark -= yym;
843 YYParseState *save = yyps->save;
846 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
847 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
848 (int)(yylvp - yylvals - yyps->save->lexeme));
850 /* Memorize most forward-looking error state in case it's really an error. */
851 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
853 /* Free old saved error context state */
854 if (yyerrctx) yyFreeState(yyerrctx);
855 /* Create and fill out new saved error context state */
856 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
857 if (yyerrctx == NULL) goto yyenomem;
858 yyerrctx->save = yyps->save;
859 yyerrctx->state = yystate;
860 yyerrctx->errflag = yyerrflag;
861 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
862 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
863 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
864 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
865 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
866 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
867 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
869 yyerrctx->lexeme = (int) (yylvp - yylvals);
871 yylvp = yylvals + save->lexeme;
872 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
873 yylpp = yylpsns + save->lexeme;
875 yylexp = yylexemes + save->lexeme;
877 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
878 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
879 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
880 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
881 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
882 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
883 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
886 yystate = save->state;
887 /* We tried shift, try reduce now */
888 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
889 yyps->save = save->save;
893 /* Nothing left on the stack -- error */
898 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
901 /* Restore state as it was in the most forward-advanced error */
902 yylvp = yylvals + yyerrctx->lexeme;
903 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
904 yylpp = yylpsns + yyerrctx->lexeme;
906 yylexp = yylexemes + yyerrctx->lexeme;
909 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
912 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
913 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
914 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
915 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
916 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
917 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
918 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
920 yystate = yyerrctx->state;
921 yyFreeState(yyerrctx);
926 if (yynewerrflag == 0) goto yyinrecovery;
927 #endif /* YYBTYACC */
929 YYERROR_CALL("syntax error");
930 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
931 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
935 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
946 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
947 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
951 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
952 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
954 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
955 yystate = yytable[yyn];
956 *++yystack.s_mark = yytable[yyn];
957 *++yystack.l_mark = yylval;
958 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
959 /* lookahead position is error end position */
960 yyerror_loc_range[2] = yylloc;
961 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
962 *++yystack.p_mark = yyloc;
970 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
971 YYDEBUGSTR, yydepth, *yystack.s_mark);
973 if (yystack.s_mark <= yystack.s_base) goto yyabort;
974 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
975 /* the current TOS position is the error start position */
976 yyerror_loc_range[1] = *yystack.p_mark;
978 #if defined(YYDESTRUCT_CALL)
981 #endif /* YYBTYACC */
982 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
983 YYDESTRUCT_CALL("error: discarding state",
984 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
986 YYDESTRUCT_CALL("error: discarding state",
987 yystos[*yystack.s_mark], yystack.l_mark);
988 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
989 #endif /* defined(YYDESTRUCT_CALL) */
992 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1000 if (yychar == YYEOF) goto yyabort;
1004 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1005 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1006 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1009 #if defined(YYDESTRUCT_CALL)
1012 #endif /* YYBTYACC */
1013 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1014 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1016 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1017 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1018 #endif /* defined(YYDESTRUCT_CALL) */
1028 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1029 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1030 #ifdef YYSTYPE_TOSTRING
1033 #endif /* YYBTYACC */
1038 for (i = yym; i > 0; i--)
1040 if (i != yym) fputs(", ", stderr);
1041 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1042 yystack.l_mark[1-i]), stderr);
1047 fputc('\n', stderr);
1051 yyval = yystack.l_mark[1-yym];
1053 memset(&yyval, 0, sizeof yyval);
1054 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1056 /* Perform position reduction */
1057 memset(&yyloc, 0, sizeof(yyloc));
1060 #endif /* YYBTYACC */
1062 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1063 /* just in case YYERROR is invoked within the action, save
1064 the start of the rhs as the error start position */
1065 yyerror_loc_range[1] = yystack.p_mark[1-yym];
1074 yystack.s_mark -= yym;
1075 yystate = *yystack.s_mark;
1076 yystack.l_mark -= yym;
1077 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1078 yystack.p_mark -= yym;
1081 if (yystate == 0 && yym == 0)
1086 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1087 #ifdef YYSTYPE_TOSTRING
1090 #endif /* YYBTYACC */
1091 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1093 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1097 *++yystack.s_mark = YYFINAL;
1098 *++yystack.l_mark = yyval;
1099 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1100 *++yystack.p_mark = yyloc;
1108 /* we're currently re-reading tokens */
1110 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1118 /* in trial mode; save scanner results for future parse attempts */
1119 if (yylvp == yylvlim)
1120 { /* Enlarge lexical value queue */
1121 size_t p = (size_t) (yylvp - yylvals);
1122 size_t s = (size_t) (yylvlim - yylvals);
1124 s += YYLVQUEUEGROWTH;
1125 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1127 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1129 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1130 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1133 yylvp = yylve = yylvals + p;
1134 yylvlim = yylvals + s;
1135 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1136 yylpp = yylpe = yylpsns + p;
1137 yylplim = yylpsns + s;
1139 yylexp = yylexemes + p;
1141 *yylexp = (YYINT) YYLEX;
1144 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1151 /* normal operation, no conflict encountered */
1152 #endif /* YYBTYACC */
1156 #endif /* YYBTYACC */
1157 if (yychar < 0) yychar = YYEOF;
1161 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1162 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1163 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1167 if (yychar == YYEOF) goto yyaccept;
1170 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1171 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1172 yystate = yytable[yyn];
1174 yystate = yydgoto[yym];
1178 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1179 #ifdef YYSTYPE_TOSTRING
1182 #endif /* YYBTYACC */
1183 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1185 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1188 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1189 *++yystack.s_mark = (YYINT) yystate;
1190 *++yystack.l_mark = yyval;
1191 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1192 *++yystack.p_mark = yyloc;
1197 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1199 if (yypath) YYABORT;
1202 YYParseState *save = yyps->save;
1203 yyps->save = save->save;
1204 save->save = yypath;
1209 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1210 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1214 yyFreeState(yyerrctx);
1217 yylvp = yylvals + yypath->lexeme;
1218 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1219 yylpp = yylpsns + yypath->lexeme;
1221 yylexp = yylexemes + yypath->lexeme;
1223 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1224 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1225 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1226 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1228 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1229 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1231 yystate = yypath->state;
1233 #endif /* YYBTYACC */
1236 YYERROR_CALL("yacc stack overflow");
1240 YYERROR_CALL("memory exhausted");
1242 #endif /* YYBTYACC */
1252 if (yyps->save) goto yyvalid;
1253 #endif /* YYBTYACC */
1257 #if defined(YYDESTRUCT_CALL)
1258 if (yychar != YYEOF && yychar != YYEMPTY)
1259 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1260 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1262 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1263 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1267 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1270 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1271 YYDESTRUCT_CALL("cleanup: discarding state",
1272 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1274 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1275 YYDESTRUCT_CALL("cleanup: discarding state",
1276 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1277 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1279 #endif /* defined(YYDESTRUCT_CALL) */
1284 yyFreeState(yyerrctx);
1289 YYParseState *save = yyps;
1296 YYParseState *save = yypath;
1297 yypath = save->save;
1301 #endif /* YYBTYACC */
1302 yyfreestack(&yystack);