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 err_syntax10_parse
25 #define yylex err_syntax10_lex
29 #define yyerror err_syntax10_error
33 #define yychar err_syntax10_char
37 #define yyval err_syntax10_val
41 #define yylval err_syntax10_lval
45 #define yydebug err_syntax10_debug
49 #define yynerrs err_syntax10_nerrs
53 #define yyerrflag err_syntax10_errflag
54 #endif /* yyerrflag */
57 #define yylhs err_syntax10_lhs
61 #define yylen err_syntax10_len
65 #define yydefred err_syntax10_defred
69 #define yystos err_syntax10_stos
73 #define yydgoto err_syntax10_dgoto
77 #define yysindex err_syntax10_sindex
81 #define yyrindex err_syntax10_rindex
85 #define yygindex err_syntax10_gindex
89 #define yytable err_syntax10_table
93 #define yycheck err_syntax10_check
97 #define yyname err_syntax10_name
101 #define yyrule err_syntax10_rule
107 #define yycindex err_syntax10_cindex
108 #endif /* yycindex */
111 #define yyctable err_syntax10_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "err_syntax10_"
120 #line 2 "err_syntax10.y"
122 static void yyerror(const char *);
123 #line 124 "err_syntax10.tab.c"
125 /* compatibility with bison */
127 /* compatibility with FreeBSD */
128 # ifdef YYPARSE_PARAM_TYPE
129 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
131 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
134 # define YYPARSE_DECL() yyparse(void)
137 /* Parameters sent to lex. */
139 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
140 # define YYLEX yylex(YYLEX_PARAM)
142 # define YYLEX_DECL() yylex(void)
143 # define YYLEX yylex()
146 /* Parameters sent to yyerror. */
148 #define YYERROR_DECL() yyerror(const char *s)
151 #define YYERROR_CALL(msg) yyerror(msg)
154 extern int YYPARSE_DECL();
156 #define YYERRCODE 256
158 static const YYINT err_syntax10_lhs[] = { -1,
161 static const YYINT err_syntax10_len[] = { 2,
164 static const YYINT err_syntax10_defred[] = { 0,
167 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
168 static const YYINT err_syntax10_stos[] = { 0,
171 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
172 static const YYINT err_syntax10_dgoto[] = { 2,
174 static const YYINT err_syntax10_sindex[] = { -256,
177 static const YYINT err_syntax10_rindex[] = { 0,
181 static const YYINT err_syntax10_cindex[] = { 0,
185 static const YYINT err_syntax10_gindex[] = { 0,
187 #define YYTABLESIZE 0
188 static const YYINT err_syntax10_table[] = { 1,
190 static const YYINT err_syntax10_check[] = { 256,
193 static const YYINT err_syntax10_ctable[] = { -1,
200 #define YYMAXTOKEN 256
201 #define YYUNDFTOKEN 259
202 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
204 static const char *const err_syntax10_name[] = {
206 "$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,
207 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,
208 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,
209 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,
210 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,
211 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,
212 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,"error","$accept","S",
215 static const char *const err_syntax10_rule[] = {
229 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
230 YYLTYPE yyloc; /* position returned by actions */
231 YYLTYPE yylloc; /* position from the lexer */
234 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
235 #ifndef YYLLOC_DEFAULT
236 #define YYLLOC_DEFAULT(loc, rhs, n) \
241 (loc).first_line = ((rhs)[-1]).last_line; \
242 (loc).first_column = ((rhs)[-1]).last_column; \
243 (loc).last_line = ((rhs)[-1]).last_line; \
244 (loc).last_column = ((rhs)[-1]).last_column; \
248 (loc).first_line = ((rhs)[ 0 ]).first_line; \
249 (loc).first_column = ((rhs)[ 0 ]).first_column; \
250 (loc).last_line = ((rhs)[n-1]).last_line; \
251 (loc).last_column = ((rhs)[n-1]).last_column; \
254 #endif /* YYLLOC_DEFAULT */
255 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
258 #ifndef YYLVQUEUEGROWTH
259 #define YYLVQUEUEGROWTH 32
261 #endif /* YYBTYACC */
263 /* define the initial stack-sizes */
266 #define YYMAXDEPTH YYSTACKSIZE
269 #define YYSTACKSIZE YYMAXDEPTH
271 #define YYSTACKSIZE 10000
272 #define YYMAXDEPTH 10000
276 #ifndef YYINITSTACKSIZE
277 #define YYINITSTACKSIZE 200
287 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
294 struct YYParseState_s
296 struct YYParseState_s *save; /* Previously saved parser state */
297 YYSTACKDATA yystack; /* saved parser stack */
298 int state; /* saved parser state */
299 int errflag; /* saved error recovery status */
300 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
301 YYINT ctry; /* saved index in yyctable[] for this conflict */
303 typedef struct YYParseState_s YYParseState;
304 #endif /* YYBTYACC */
305 /* variables for the parser stack */
306 static YYSTACKDATA yystack;
309 /* Current parser state */
310 static YYParseState *yyps = 0;
312 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
313 static YYParseState *yypath = 0;
315 /* Base of the lexical value queue */
316 static YYSTYPE *yylvals = 0;
318 /* Current position at lexical value queue */
319 static YYSTYPE *yylvp = 0;
321 /* End position of lexical value queue */
322 static YYSTYPE *yylve = 0;
324 /* The last allocated position at the lexical value queue */
325 static YYSTYPE *yylvlim = 0;
327 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
328 /* Base of the lexical position queue */
329 static YYLTYPE *yylpsns = 0;
331 /* Current position at lexical position queue */
332 static YYLTYPE *yylpp = 0;
334 /* End position of lexical position queue */
335 static YYLTYPE *yylpe = 0;
337 /* The last allocated position at the lexical position queue */
338 static YYLTYPE *yylplim = 0;
341 /* Current position at lexical token queue */
342 static YYINT *yylexp = 0;
344 static YYINT *yylexemes = 0;
345 #endif /* YYBTYACC */
346 #line 12 "err_syntax10.y"
353 printf("yyparse() = %d\n", yyparse());
364 yyerror(const char* s)
368 #line 369 "err_syntax10.tab.c"
370 /* For use in generated program */
371 #define yydepth (int)(yystack.s_mark - yystack.s_base)
373 #define yytrial (yyps->save)
374 #endif /* YYBTYACC */
377 #include <stdio.h> /* needed for printf */
380 #include <stdlib.h> /* needed for malloc, etc */
381 #include <string.h> /* needed for memset */
383 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
384 static int yygrowstack(YYSTACKDATA *data)
390 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
394 if ((newsize = data->stacksize) == 0)
395 newsize = YYINITSTACKSIZE;
396 else if (newsize >= YYMAXDEPTH)
398 else if ((newsize *= 2) > YYMAXDEPTH)
399 newsize = YYMAXDEPTH;
401 i = (int) (data->s_mark - data->s_base);
402 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
406 data->s_base = newss;
407 data->s_mark = newss + i;
409 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
413 data->l_base = newvs;
414 data->l_mark = newvs + i;
416 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
417 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
421 data->p_base = newps;
422 data->p_mark = newps + i;
425 data->stacksize = newsize;
426 data->s_last = data->s_base + newsize - 1;
430 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
435 #if YYPURE || defined(YY_NO_LEAKS)
436 static void yyfreestack(YYSTACKDATA *data)
440 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
443 memset(data, 0, sizeof(*data));
446 #define yyfreestack(data) /* nothing */
447 #endif /* YYPURE || defined(YY_NO_LEAKS) */
450 static YYParseState *
451 yyNewState(unsigned size)
453 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
454 if (p == NULL) return NULL;
456 p->yystack.stacksize = size;
459 p->yystack.s_base = NULL;
460 p->yystack.l_base = NULL;
461 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
462 p->yystack.p_base = NULL;
466 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
467 if (p->yystack.s_base == NULL) return NULL;
468 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
469 if (p->yystack.l_base == NULL) return NULL;
470 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
471 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
472 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
473 if (p->yystack.p_base == NULL) return NULL;
474 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
481 yyFreeState(YYParseState *p)
483 yyfreestack(&p->yystack);
486 #endif /* YYBTYACC */
488 #define YYABORT goto yyabort
489 #define YYREJECT goto yyabort
490 #define YYACCEPT goto yyaccept
491 #define YYERROR goto yyerrlab
493 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
494 #define YYVALID_NESTED do { if (yyps->save && \
495 yyps->save->save == 0) goto yyvalid; } while(0)
496 #endif /* YYBTYACC */
501 int yym, yyn, yystate, yyresult;
504 YYParseState *yyerrctx = NULL;
505 #endif /* YYBTYACC */
506 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
507 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
512 if ((yys = getenv("YYDEBUG")) != 0)
515 if (yyn >= '0' && yyn <= '9')
519 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
523 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
525 #endif /* YYBTYACC */
534 memset(&yystack, 0, sizeof(yystack));
537 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
538 yystack.s_mark = yystack.s_base;
539 yystack.l_mark = yystack.l_base;
540 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
541 yystack.p_mark = yystack.p_base;
547 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
554 /* we're currently re-reading tokens */
556 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
564 /* in trial mode; save scanner results for future parse attempts */
565 if (yylvp == yylvlim)
566 { /* Enlarge lexical value queue */
567 size_t p = (size_t) (yylvp - yylvals);
568 size_t s = (size_t) (yylvlim - yylvals);
570 s += YYLVQUEUEGROWTH;
571 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
572 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
573 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
574 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
576 yylvp = yylve = yylvals + p;
577 yylvlim = yylvals + s;
578 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
579 yylpp = yylpe = yylpsns + p;
580 yylplim = yylpsns + s;
582 yylexp = yylexemes + p;
584 *yylexp = (YYINT) YYLEX;
587 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
594 /* normal operation, no conflict encountered */
595 #endif /* YYBTYACC */
599 #endif /* YYBTYACC */
600 if (yychar < 0) yychar = YYEOF;
604 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
605 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
606 YYDEBUGSTR, yydepth, yystate, yychar, yys);
607 #ifdef YYSTYPE_TOSTRING
610 #endif /* YYBTYACC */
611 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
619 /* Do we have a conflict? */
620 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
621 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
630 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
631 YYDEBUGSTR, yydepth, yystate);
633 /* Switch to the next conflict context */
638 if (save->state != yystate) YYABORT;
645 /* Unresolved conflict - start/continue trial parse */
650 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
652 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
654 fputs("Starting trial parse.\n", stderr);
657 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
658 if (save == NULL) goto yyenomem;
659 save->save = yyps->save;
660 save->state = yystate;
661 save->errflag = yyerrflag;
662 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
663 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
664 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
665 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
666 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
667 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
668 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
671 if (yyctable[ctry] == -1)
674 if (yydebug && yychar >= YYEOF)
675 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
680 if (yyps->save == NULL)
682 /* If this is a first conflict in the stack, start saving lexemes */
685 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
686 if (yylexemes == NULL) goto yyenomem;
687 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
688 if (yylvals == NULL) goto yyenomem;
689 yylvlim = yylvals + YYLVQUEUEGROWTH;
690 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
691 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
692 if (yylpsns == NULL) goto yyenomem;
693 yylplim = yylpsns + YYLVQUEUEGROWTH;
698 yylvp = yylve = yylvals;
699 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
700 yylpp = yylpe = yylpsns;
706 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
709 *yylexp = (YYINT) yychar;
717 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
723 save->lexeme = (int) (yylvp - yylvals);
726 if (yytable[yyn] == ctry)
730 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
731 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
736 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
741 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
743 yystate = yyctable[ctry];
744 *++yystack.s_mark = (YYINT) yystate;
745 *++yystack.l_mark = yylval;
746 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
747 *++yystack.p_mark = yylloc;
750 if (yyerrflag > 0) --yyerrflag;
755 yyn = yyctable[ctry];
758 } /* End of code dealing with conflicts */
759 #endif /* YYBTYACC */
760 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
761 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
765 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
766 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
768 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
769 yystate = yytable[yyn];
770 *++yystack.s_mark = yytable[yyn];
771 *++yystack.l_mark = yylval;
772 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
773 *++yystack.p_mark = yylloc;
776 if (yyerrflag > 0) --yyerrflag;
779 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
780 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
785 if (yyerrflag != 0) goto yyinrecovery;
790 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
793 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
794 * before looking for error recovery */
795 yystack.s_mark -= yym;
796 yystate = *yystack.s_mark;
797 yystack.l_mark -= yym;
798 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
799 yystack.p_mark -= yym;
807 YYParseState *save = yyps->save;
810 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
811 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
812 (int)(yylvp - yylvals - yyps->save->lexeme));
814 /* Memorize most forward-looking error state in case it's really an error. */
815 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
817 /* Free old saved error context state */
818 if (yyerrctx) yyFreeState(yyerrctx);
819 /* Create and fill out new saved error context state */
820 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
821 if (yyerrctx == NULL) goto yyenomem;
822 yyerrctx->save = yyps->save;
823 yyerrctx->state = yystate;
824 yyerrctx->errflag = yyerrflag;
825 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
826 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
827 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
828 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
829 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
830 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
831 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
833 yyerrctx->lexeme = (int) (yylvp - yylvals);
835 yylvp = yylvals + save->lexeme;
836 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
837 yylpp = yylpsns + save->lexeme;
839 yylexp = yylexemes + save->lexeme;
841 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
842 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
843 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
844 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
845 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
846 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
847 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
850 yystate = save->state;
851 /* We tried shift, try reduce now */
852 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
853 yyps->save = save->save;
857 /* Nothing left on the stack -- error */
862 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
865 /* Restore state as it was in the most forward-advanced error */
866 yylvp = yylvals + yyerrctx->lexeme;
867 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
868 yylpp = yylpsns + yyerrctx->lexeme;
870 yylexp = yylexemes + yyerrctx->lexeme;
873 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
876 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
877 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
878 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
879 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
880 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
881 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
882 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
884 yystate = yyerrctx->state;
885 yyFreeState(yyerrctx);
890 if (yynewerrflag == 0) goto yyinrecovery;
891 #endif /* YYBTYACC */
893 YYERROR_CALL("syntax error");
894 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
895 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
899 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
910 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
911 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
915 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
916 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
918 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
919 yystate = yytable[yyn];
920 *++yystack.s_mark = yytable[yyn];
921 *++yystack.l_mark = yylval;
922 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
923 /* lookahead position is error end position */
924 yyerror_loc_range[1] = yylloc;
925 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
926 *++yystack.p_mark = yyloc;
934 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
935 YYDEBUGSTR, yydepth, *yystack.s_mark);
937 if (yystack.s_mark <= yystack.s_base) goto yyabort;
938 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
939 /* the current TOS position is the error start position */
940 yyerror_loc_range[0] = *yystack.p_mark;
942 #if defined(YYDESTRUCT_CALL)
945 #endif /* YYBTYACC */
946 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
947 YYDESTRUCT_CALL("error: discarding state",
948 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
950 YYDESTRUCT_CALL("error: discarding state",
951 yystos[*yystack.s_mark], yystack.l_mark);
952 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
953 #endif /* defined(YYDESTRUCT_CALL) */
956 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
964 if (yychar == YYEOF) goto yyabort;
968 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
969 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
970 YYDEBUGSTR, yydepth, yystate, yychar, yys);
973 #if defined(YYDESTRUCT_CALL)
976 #endif /* YYBTYACC */
977 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
978 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
980 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
981 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
982 #endif /* defined(YYDESTRUCT_CALL) */
992 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
993 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
994 #ifdef YYSTYPE_TOSTRING
997 #endif /* YYBTYACC */
1002 for (i = yym; i > 0; i--)
1004 if (i != yym) fputs(", ", stderr);
1005 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1006 yystack.l_mark[1-i]), stderr);
1011 fputc('\n', stderr);
1015 yyval = yystack.l_mark[1-yym];
1017 memset(&yyval, 0, sizeof yyval);
1018 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1020 /* Perform position reduction */
1021 memset(&yyloc, 0, sizeof(yyloc));
1024 #endif /* YYBTYACC */
1026 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1027 /* just in case YYERROR is invoked within the action, save
1028 the start of the rhs as the error start position */
1029 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1038 yystack.s_mark -= yym;
1039 yystate = *yystack.s_mark;
1040 yystack.l_mark -= yym;
1041 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1042 yystack.p_mark -= yym;
1045 if (yystate == 0 && yym == 0)
1050 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1051 #ifdef YYSTYPE_TOSTRING
1054 #endif /* YYBTYACC */
1055 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1057 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1061 *++yystack.s_mark = YYFINAL;
1062 *++yystack.l_mark = yyval;
1063 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1064 *++yystack.p_mark = yyloc;
1072 /* we're currently re-reading tokens */
1074 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1082 /* in trial mode; save scanner results for future parse attempts */
1083 if (yylvp == yylvlim)
1084 { /* Enlarge lexical value queue */
1085 size_t p = (size_t) (yylvp - yylvals);
1086 size_t s = (size_t) (yylvlim - yylvals);
1088 s += YYLVQUEUEGROWTH;
1089 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1091 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1093 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1094 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1097 yylvp = yylve = yylvals + p;
1098 yylvlim = yylvals + s;
1099 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1100 yylpp = yylpe = yylpsns + p;
1101 yylplim = yylpsns + s;
1103 yylexp = yylexemes + p;
1105 *yylexp = (YYINT) YYLEX;
1108 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1115 /* normal operation, no conflict encountered */
1116 #endif /* YYBTYACC */
1120 #endif /* YYBTYACC */
1121 if (yychar < 0) yychar = YYEOF;
1125 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1126 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1127 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1131 if (yychar == YYEOF) goto yyaccept;
1134 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1135 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1136 yystate = yytable[yyn];
1138 yystate = yydgoto[yym];
1142 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1143 #ifdef YYSTYPE_TOSTRING
1146 #endif /* YYBTYACC */
1147 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1149 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1152 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1153 *++yystack.s_mark = (YYINT) yystate;
1154 *++yystack.l_mark = yyval;
1155 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1156 *++yystack.p_mark = yyloc;
1161 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1163 if (yypath) YYABORT;
1166 YYParseState *save = yyps->save;
1167 yyps->save = save->save;
1168 save->save = yypath;
1173 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1174 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1178 yyFreeState(yyerrctx);
1181 yylvp = yylvals + yypath->lexeme;
1182 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1183 yylpp = yylpsns + yypath->lexeme;
1185 yylexp = yylexemes + yypath->lexeme;
1187 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1188 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1189 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1190 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1191 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1192 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1193 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1195 yystate = yypath->state;
1197 #endif /* YYBTYACC */
1200 YYERROR_CALL("yacc stack overflow");
1204 YYERROR_CALL("memory exhausted");
1206 #endif /* YYBTYACC */
1216 if (yyps->save) goto yyvalid;
1217 #endif /* YYBTYACC */
1221 #if defined(YYDESTRUCT_CALL)
1222 if (yychar != YYEOF && yychar != YYEMPTY)
1223 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1224 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1226 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1227 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1231 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1234 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1235 YYDESTRUCT_CALL("cleanup: discarding state",
1236 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1238 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1239 YYDESTRUCT_CALL("cleanup: discarding state",
1240 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1241 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1243 #endif /* defined(YYDESTRUCT_CALL) */
1248 yyFreeState(yyerrctx);
1253 YYParseState *save = yyps;
1260 YYParseState *save = yypath;
1261 yypath = save->save;
1265 #endif /* YYBTYACC */
1266 yyfreestack(&yystack);