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[] = {
242 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
243 #ifndef YYLLOC_DEFAULT
244 #define YYLLOC_DEFAULT(loc, rhs, n) \
249 (loc).first_line = ((rhs)[-1]).last_line; \
250 (loc).first_column = ((rhs)[-1]).last_column; \
251 (loc).last_line = ((rhs)[-1]).last_line; \
252 (loc).last_column = ((rhs)[-1]).last_column; \
256 (loc).first_line = ((rhs)[ 0 ]).first_line; \
257 (loc).first_column = ((rhs)[ 0 ]).first_column; \
258 (loc).last_line = ((rhs)[n-1]).last_line; \
259 (loc).last_column = ((rhs)[n-1]).last_column; \
262 #endif /* YYLLOC_DEFAULT */
263 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
266 #ifndef YYLVQUEUEGROWTH
267 #define YYLVQUEUEGROWTH 32
269 #endif /* YYBTYACC */
271 /* define the initial stack-sizes */
274 #define YYMAXDEPTH YYSTACKSIZE
277 #define YYSTACKSIZE YYMAXDEPTH
279 #define YYSTACKSIZE 10000
280 #define YYMAXDEPTH 10000
284 #ifndef YYINITSTACKSIZE
285 #define YYINITSTACKSIZE 200
295 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
302 struct YYParseState_s
304 struct YYParseState_s *save; /* Previously saved parser state */
305 YYSTACKDATA yystack; /* saved parser stack */
306 int state; /* saved parser state */
307 int errflag; /* saved error recovery status */
308 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
309 YYINT ctry; /* saved index in yyctable[] for this conflict */
311 typedef struct YYParseState_s YYParseState;
312 #endif /* YYBTYACC */
313 #line 17 "pure_error.y"
318 extern int YYLEX_DECL();
324 printf("yyparse() = %d\n", yyparse());
329 yylex(YYSTYPE *value)
331 return value ? 0 : -1;
335 yyerror(const char* s)
339 #line 340 "pure_error.tab.c"
341 /* For use in generated program */
342 #define yydepth (int)(yystack.s_mark - yystack.s_base)
344 #define yytrial (yyps->save)
345 #endif /* YYBTYACC */
348 #include <stdio.h> /* needed for printf */
351 #include <stdlib.h> /* needed for malloc, etc */
352 #include <string.h> /* needed for memset */
354 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
355 static int yygrowstack(YYSTACKDATA *data)
361 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
365 if ((newsize = data->stacksize) == 0)
366 newsize = YYINITSTACKSIZE;
367 else if (newsize >= YYMAXDEPTH)
369 else if ((newsize *= 2) > YYMAXDEPTH)
370 newsize = YYMAXDEPTH;
372 i = (int) (data->s_mark - data->s_base);
373 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
377 data->s_base = newss;
378 data->s_mark = newss + i;
380 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
384 data->l_base = newvs;
385 data->l_mark = newvs + i;
387 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
388 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
392 data->p_base = newps;
393 data->p_mark = newps + i;
396 data->stacksize = newsize;
397 data->s_last = data->s_base + newsize - 1;
401 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
406 #if YYPURE || defined(YY_NO_LEAKS)
407 static void yyfreestack(YYSTACKDATA *data)
411 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
414 memset(data, 0, sizeof(*data));
417 #define yyfreestack(data) /* nothing */
418 #endif /* YYPURE || defined(YY_NO_LEAKS) */
421 static YYParseState *
422 yyNewState(unsigned size)
424 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
425 if (p == NULL) return NULL;
427 p->yystack.stacksize = size;
430 p->yystack.s_base = NULL;
431 p->yystack.l_base = NULL;
432 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
433 p->yystack.p_base = NULL;
437 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
438 if (p->yystack.s_base == NULL) return NULL;
439 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
440 if (p->yystack.l_base == NULL) return NULL;
441 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
442 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
443 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
444 if (p->yystack.p_base == NULL) return NULL;
445 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
452 yyFreeState(YYParseState *p)
454 yyfreestack(&p->yystack);
457 #endif /* YYBTYACC */
459 #define YYABORT goto yyabort
460 #define YYREJECT goto yyabort
461 #define YYACCEPT goto yyaccept
462 #define YYERROR goto yyerrlab
464 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
465 #define YYVALID_NESTED do { if (yyps->save && \
466 yyps->save->save == 0) goto yyvalid; } while(0)
467 #endif /* YYBTYACC */
476 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
477 YYLTYPE yyloc; /* position returned by actions */
478 YYLTYPE yylloc; /* position from the lexer */
481 /* variables for the parser stack */
485 /* Current parser state */
486 static YYParseState *yyps = 0;
488 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
489 static YYParseState *yypath = 0;
491 /* Base of the lexical value queue */
492 static YYSTYPE *yylvals = 0;
494 /* Current position at lexical value queue */
495 static YYSTYPE *yylvp = 0;
497 /* End position of lexical value queue */
498 static YYSTYPE *yylve = 0;
500 /* The last allocated position at the lexical value queue */
501 static YYSTYPE *yylvlim = 0;
503 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
504 /* Base of the lexical position queue */
505 static YYLTYPE *yylpsns = 0;
507 /* Current position at lexical position queue */
508 static YYLTYPE *yylpp = 0;
510 /* End position of lexical position queue */
511 static YYLTYPE *yylpe = 0;
513 /* The last allocated position at the lexical position queue */
514 static YYLTYPE *yylplim = 0;
517 /* Current position at lexical token queue */
518 static YYINT *yylexp = 0;
520 static YYINT *yylexemes = 0;
521 #endif /* YYBTYACC */
522 int yym, yyn, yystate, yyresult;
525 YYParseState *yyerrctx = NULL;
526 #endif /* YYBTYACC */
527 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
528 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
533 if ((yys = getenv("YYDEBUG")) != 0)
536 if (yyn >= '0' && yyn <= '9')
540 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
542 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
543 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
548 memset(&yyval, 0, sizeof(yyval));
549 memset(&yylval, 0, sizeof(yylval));
550 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
551 memset(&yyloc, 0, sizeof(yyloc));
552 memset(&yylloc, 0, sizeof(yylloc));
556 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
558 #endif /* YYBTYACC */
567 memset(&yystack, 0, sizeof(yystack));
570 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
571 yystack.s_mark = yystack.s_base;
572 yystack.l_mark = yystack.l_base;
573 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
574 yystack.p_mark = yystack.p_base;
580 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
587 /* we're currently re-reading tokens */
589 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
597 /* in trial mode; save scanner results for future parse attempts */
598 if (yylvp == yylvlim)
599 { /* Enlarge lexical value queue */
600 size_t p = (size_t) (yylvp - yylvals);
601 size_t s = (size_t) (yylvlim - yylvals);
603 s += YYLVQUEUEGROWTH;
604 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
605 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
606 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
607 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
609 yylvp = yylve = yylvals + p;
610 yylvlim = yylvals + s;
611 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
612 yylpp = yylpe = yylpsns + p;
613 yylplim = yylpsns + s;
615 yylexp = yylexemes + p;
617 *yylexp = (YYINT) YYLEX;
620 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
627 /* normal operation, no conflict encountered */
628 #endif /* YYBTYACC */
632 #endif /* YYBTYACC */
633 if (yychar < 0) yychar = YYEOF;
637 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
638 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
639 YYDEBUGSTR, yydepth, yystate, yychar, yys);
640 #ifdef YYSTYPE_TOSTRING
643 #endif /* YYBTYACC */
644 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
652 /* Do we have a conflict? */
653 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
654 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
663 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
664 YYDEBUGSTR, yydepth, yystate);
666 /* Switch to the next conflict context */
671 if (save->state != yystate) YYABORT;
678 /* Unresolved conflict - start/continue trial parse */
683 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
685 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
687 fputs("Starting trial parse.\n", stderr);
690 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
691 if (save == NULL) goto yyenomem;
692 save->save = yyps->save;
693 save->state = yystate;
694 save->errflag = yyerrflag;
695 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
696 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
697 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
698 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
699 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
700 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
701 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
704 if (yyctable[ctry] == -1)
707 if (yydebug && yychar >= YYEOF)
708 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
713 if (yyps->save == NULL)
715 /* If this is a first conflict in the stack, start saving lexemes */
718 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
719 if (yylexemes == NULL) goto yyenomem;
720 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
721 if (yylvals == NULL) goto yyenomem;
722 yylvlim = yylvals + YYLVQUEUEGROWTH;
723 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
724 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
725 if (yylpsns == NULL) goto yyenomem;
726 yylplim = yylpsns + YYLVQUEUEGROWTH;
731 yylvp = yylve = yylvals;
732 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
733 yylpp = yylpe = yylpsns;
739 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
742 *yylexp = (YYINT) yychar;
750 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
756 save->lexeme = (int) (yylvp - yylvals);
759 if (yytable[yyn] == ctry)
763 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
764 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
769 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
774 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
776 yystate = yyctable[ctry];
777 *++yystack.s_mark = (YYINT) yystate;
778 *++yystack.l_mark = yylval;
779 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
780 *++yystack.p_mark = yylloc;
783 if (yyerrflag > 0) --yyerrflag;
788 yyn = yyctable[ctry];
791 } /* End of code dealing with conflicts */
792 #endif /* YYBTYACC */
793 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
794 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
798 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
799 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
801 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
802 yystate = yytable[yyn];
803 *++yystack.s_mark = yytable[yyn];
804 *++yystack.l_mark = yylval;
805 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
806 *++yystack.p_mark = yylloc;
809 if (yyerrflag > 0) --yyerrflag;
812 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
813 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
818 if (yyerrflag != 0) goto yyinrecovery;
823 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
826 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
827 * before looking for error recovery */
828 yystack.s_mark -= yym;
829 yystate = *yystack.s_mark;
830 yystack.l_mark -= yym;
831 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
832 yystack.p_mark -= yym;
840 YYParseState *save = yyps->save;
843 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
844 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
845 (int)(yylvp - yylvals - yyps->save->lexeme));
847 /* Memorize most forward-looking error state in case it's really an error. */
848 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
850 /* Free old saved error context state */
851 if (yyerrctx) yyFreeState(yyerrctx);
852 /* Create and fill out new saved error context state */
853 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
854 if (yyerrctx == NULL) goto yyenomem;
855 yyerrctx->save = yyps->save;
856 yyerrctx->state = yystate;
857 yyerrctx->errflag = yyerrflag;
858 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
859 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
860 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
861 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
862 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
863 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
864 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
866 yyerrctx->lexeme = (int) (yylvp - yylvals);
868 yylvp = yylvals + save->lexeme;
869 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
870 yylpp = yylpsns + save->lexeme;
872 yylexp = yylexemes + save->lexeme;
874 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
875 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
876 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
877 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
878 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
879 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
880 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
883 yystate = save->state;
884 /* We tried shift, try reduce now */
885 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
886 yyps->save = save->save;
890 /* Nothing left on the stack -- error */
895 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
898 /* Restore state as it was in the most forward-advanced error */
899 yylvp = yylvals + yyerrctx->lexeme;
900 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
901 yylpp = yylpsns + yyerrctx->lexeme;
903 yylexp = yylexemes + yyerrctx->lexeme;
906 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
909 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
910 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
911 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
912 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
913 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
914 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
915 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
917 yystate = yyerrctx->state;
918 yyFreeState(yyerrctx);
923 if (yynewerrflag == 0) goto yyinrecovery;
924 #endif /* YYBTYACC */
926 YYERROR_CALL("syntax error");
927 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
928 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
932 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
943 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
944 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
948 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
949 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
951 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
952 yystate = yytable[yyn];
953 *++yystack.s_mark = yytable[yyn];
954 *++yystack.l_mark = yylval;
955 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
956 /* lookahead position is error end position */
957 yyerror_loc_range[1] = yylloc;
958 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
959 *++yystack.p_mark = yyloc;
967 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
968 YYDEBUGSTR, yydepth, *yystack.s_mark);
970 if (yystack.s_mark <= yystack.s_base) goto yyabort;
971 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
972 /* the current TOS position is the error start position */
973 yyerror_loc_range[0] = *yystack.p_mark;
975 #if defined(YYDESTRUCT_CALL)
978 #endif /* YYBTYACC */
979 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
980 YYDESTRUCT_CALL("error: discarding state",
981 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
983 YYDESTRUCT_CALL("error: discarding state",
984 yystos[*yystack.s_mark], yystack.l_mark);
985 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
986 #endif /* defined(YYDESTRUCT_CALL) */
989 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
997 if (yychar == YYEOF) goto yyabort;
1001 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1002 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1003 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1006 #if defined(YYDESTRUCT_CALL)
1009 #endif /* YYBTYACC */
1010 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1011 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1013 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1014 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1015 #endif /* defined(YYDESTRUCT_CALL) */
1025 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1026 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1027 #ifdef YYSTYPE_TOSTRING
1030 #endif /* YYBTYACC */
1035 for (i = yym; i > 0; i--)
1037 if (i != yym) fputs(", ", stderr);
1038 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1039 yystack.l_mark[1-i]), stderr);
1044 fputc('\n', stderr);
1048 yyval = yystack.l_mark[1-yym];
1050 memset(&yyval, 0, sizeof yyval);
1051 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1053 /* Perform position reduction */
1054 memset(&yyloc, 0, sizeof(yyloc));
1057 #endif /* YYBTYACC */
1059 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1060 /* just in case YYERROR is invoked within the action, save
1061 the start of the rhs as the error start position */
1062 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1071 yystack.s_mark -= yym;
1072 yystate = *yystack.s_mark;
1073 yystack.l_mark -= yym;
1074 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1075 yystack.p_mark -= yym;
1078 if (yystate == 0 && yym == 0)
1083 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1084 #ifdef YYSTYPE_TOSTRING
1087 #endif /* YYBTYACC */
1088 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1090 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1094 *++yystack.s_mark = YYFINAL;
1095 *++yystack.l_mark = yyval;
1096 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1097 *++yystack.p_mark = yyloc;
1105 /* we're currently re-reading tokens */
1107 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1115 /* in trial mode; save scanner results for future parse attempts */
1116 if (yylvp == yylvlim)
1117 { /* Enlarge lexical value queue */
1118 size_t p = (size_t) (yylvp - yylvals);
1119 size_t s = (size_t) (yylvlim - yylvals);
1121 s += YYLVQUEUEGROWTH;
1122 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1124 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1126 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1127 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1130 yylvp = yylve = yylvals + p;
1131 yylvlim = yylvals + s;
1132 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1133 yylpp = yylpe = yylpsns + p;
1134 yylplim = yylpsns + s;
1136 yylexp = yylexemes + p;
1138 *yylexp = (YYINT) YYLEX;
1141 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1148 /* normal operation, no conflict encountered */
1149 #endif /* YYBTYACC */
1153 #endif /* YYBTYACC */
1154 if (yychar < 0) yychar = YYEOF;
1158 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1159 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1160 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1164 if (yychar == YYEOF) goto yyaccept;
1167 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1168 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1169 yystate = yytable[yyn];
1171 yystate = yydgoto[yym];
1175 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1176 #ifdef YYSTYPE_TOSTRING
1179 #endif /* YYBTYACC */
1180 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1182 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1185 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1186 *++yystack.s_mark = (YYINT) yystate;
1187 *++yystack.l_mark = yyval;
1188 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1189 *++yystack.p_mark = yyloc;
1194 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1196 if (yypath) YYABORT;
1199 YYParseState *save = yyps->save;
1200 yyps->save = save->save;
1201 save->save = yypath;
1206 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1207 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1211 yyFreeState(yyerrctx);
1214 yylvp = yylvals + yypath->lexeme;
1215 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1216 yylpp = yylpsns + yypath->lexeme;
1218 yylexp = yylexemes + yypath->lexeme;
1220 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1221 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1222 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1223 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1224 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1225 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1226 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1228 yystate = yypath->state;
1230 #endif /* YYBTYACC */
1233 YYERROR_CALL("yacc stack overflow");
1237 YYERROR_CALL("memory exhausted");
1239 #endif /* YYBTYACC */
1249 if (yyps->save) goto yyvalid;
1250 #endif /* YYBTYACC */
1254 #if defined(YYDESTRUCT_CALL)
1255 if (yychar != YYEOF && yychar != YYEMPTY)
1256 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1257 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1259 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1260 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1264 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1267 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1268 YYDESTRUCT_CALL("cleanup: discarding state",
1269 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1271 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1272 YYDESTRUCT_CALL("cleanup: discarding state",
1273 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1274 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1276 #endif /* defined(YYDESTRUCT_CALL) */
1281 yyFreeState(yyerrctx);
1286 YYParseState *save = yyps;
1293 YYParseState *save = yypath;
1294 yypath = save->save;
1298 #endif /* YYBTYACC */
1299 yyfreestack(&yystack);