1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent of 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_inherit3_parse
25 #define yylex err_inherit3_lex
29 #define yyerror err_inherit3_error
33 #define yychar err_inherit3_char
37 #define yyval err_inherit3_val
41 #define yylval err_inherit3_lval
45 #define yydebug err_inherit3_debug
49 #define yynerrs err_inherit3_nerrs
53 #define yyerrflag err_inherit3_errflag
54 #endif /* yyerrflag */
57 #define yylhs err_inherit3_lhs
61 #define yylen err_inherit3_len
65 #define yydefred err_inherit3_defred
69 #define yystos err_inherit3_stos
73 #define yydgoto err_inherit3_dgoto
77 #define yysindex err_inherit3_sindex
81 #define yyrindex err_inherit3_rindex
85 #define yygindex err_inherit3_gindex
89 #define yytable err_inherit3_table
93 #define yycheck err_inherit3_check
97 #define yyname err_inherit3_name
101 #define yyrule err_inherit3_rule
107 #define yycindex err_inherit3_cindex
108 #endif /* yycindex */
111 #define yyctable err_inherit3_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "err_inherit3_"
120 #line 2 "err_inherit3.y"
123 typedef enum {cGLOBAL, cLOCAL} class;
124 typedef enum {tREAL, tINTEGER} type;
127 struct symbol { class c; type t; name id; };
128 typedef struct symbol symbol;
130 struct namelist { symbol *s; struct namelist *next; };
131 typedef struct namelist namelist;
133 extern symbol *mksymbol(type t, class c, name id);
136 #define YYLEX_DECL() yylex(void)
137 #define YYERROR_DECL() yyerror(const char *s)
139 #line 39 "err_inherit3.y"
141 #undef YYSTYPE_IS_DECLARED
142 #define YYSTYPE_IS_DECLARED 1
144 #ifndef YYSTYPE_IS_DECLARED
145 #define YYSTYPE_IS_DECLARED 1
153 #endif /* !YYSTYPE_IS_DECLARED */
154 #line 155 "err_inherit3.tab.c"
156 /* compatibility with bison */
158 /* compatibility with FreeBSD */
159 # ifdef YYPARSE_PARAM_TYPE
160 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
162 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
165 # define YYPARSE_DECL() yyparse(void)
168 /* Parameters sent to lex. */
170 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
171 # define YYLEX yylex(YYLEX_PARAM)
173 # define YYLEX_DECL() yylex(void)
174 # define YYLEX yylex()
177 /* Parameters sent to yyerror. */
179 #define YYERROR_DECL() yyerror(const char *s)
182 #define YYERROR_CALL(msg) yyerror(msg)
185 #ifndef YYDESTRUCT_DECL
186 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val)
188 #ifndef YYDESTRUCT_CALL
189 #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val)
192 extern int YYPARSE_DECL();
199 #define YYERRCODE 256
201 static const YYINT err_inherit3_lhs[] = { -1,
202 5, 6, 0, 7, 0, 3, 3, 4, 4, 8,
205 static const YYINT err_inherit3_len[] = { 2,
206 0, 0, 5, 0, 3, 1, 1, 1, 1, 0,
209 static const YYINT err_inherit3_defred[] = { 0,
210 6, 7, 8, 9, 0, 0, 4, 1, 13, 2,
211 5, 2, 0, 0, 12, 3, 0, 14, 0, 11,
213 static const YYINT err_inherit3_stos[] = { 0,
214 257, 258, 259, 260, 263, 266, 267, 267, 270, 268,
215 265, 272, 269, 269, 261, 264, 271, 264, 264, 261,
217 static const YYINT err_inherit3_dgoto[] = { 5,
218 16, 11, 6, 7, 10, 13, 9, 17, 12,
220 static const YYINT err_inherit3_sindex[] = { -257,
221 0, 0, 0, 0, 0, -254, 0, 0, 0, 0,
222 0, 0, -253, -253, 0, 0, -253, 0, -252, 0,
224 static const YYINT err_inherit3_rindex[] = { 0,
225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
229 static const YYINT err_inherit3_cindex[] = { 0,
230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
231 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
234 static const YYINT err_inherit3_gindex[] = { 0,
235 -10, 0, 0, 4, 0, -1, 0, 0, 0,
237 #define YYTABLESIZE 11
238 static const YYINT err_inherit3_table[] = { 1,
239 2, 3, 4, 18, 3, 4, 19, 15, 20, 8,
242 static const YYINT err_inherit3_check[] = { 257,
243 258, 259, 260, 14, 259, 260, 17, 261, 261, 6,
247 static const YYINT err_inherit3_ctable[] = { -1,
248 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
255 #define YYMAXTOKEN 261
256 #define YYUNDFTOKEN 273
257 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
259 static const char *const err_inherit3_name[] = {
261 "$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,
262 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
263 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
264 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
265 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
266 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
267 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER",
268 "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1",
269 "$$2","$$3","$$4","$$5","illegal-symbol",
271 static const char *const err_inherit3_rule[] = {
272 "$accept : declaration",
275 "declaration : class type $$1 $$2 namelist",
277 "declaration : type $$3 locnamelist",
283 "namelist : $$4 namelist NAME",
286 "locnamelist : $$5 $$2 namelist",
298 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
299 YYLTYPE yyloc; /* position returned by actions */
300 YYLTYPE yylloc; /* position from the lexer */
303 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
304 #ifndef YYLLOC_DEFAULT
305 #define YYLLOC_DEFAULT(loc, rhs, n) \
310 (loc).first_line = ((rhs)[-1]).last_line; \
311 (loc).first_column = ((rhs)[-1]).last_column; \
312 (loc).last_line = ((rhs)[-1]).last_line; \
313 (loc).last_column = ((rhs)[-1]).last_column; \
317 (loc).first_line = ((rhs)[ 0 ]).first_line; \
318 (loc).first_column = ((rhs)[ 0 ]).first_column; \
319 (loc).last_line = ((rhs)[n-1]).last_line; \
320 (loc).last_column = ((rhs)[n-1]).last_column; \
323 #endif /* YYLLOC_DEFAULT */
324 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
327 #ifndef YYLVQUEUEGROWTH
328 #define YYLVQUEUEGROWTH 32
330 #endif /* YYBTYACC */
332 /* define the initial stack-sizes */
335 #define YYMAXDEPTH YYSTACKSIZE
338 #define YYSTACKSIZE YYMAXDEPTH
340 #define YYSTACKSIZE 10000
341 #define YYMAXDEPTH 10000
345 #ifndef YYINITSTACKSIZE
346 #define YYINITSTACKSIZE 200
356 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
363 struct YYParseState_s
365 struct YYParseState_s *save; /* Previously saved parser state */
366 YYSTACKDATA yystack; /* saved parser stack */
367 int state; /* saved parser state */
368 int errflag; /* saved error recovery status */
369 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
370 YYINT ctry; /* saved index in yyctable[] for this conflict */
372 typedef struct YYParseState_s YYParseState;
373 #endif /* YYBTYACC */
374 /* variables for the parser stack */
375 static YYSTACKDATA yystack;
378 /* Current parser state */
379 static YYParseState *yyps = 0;
381 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
382 static YYParseState *yypath = 0;
384 /* Base of the lexical value queue */
385 static YYSTYPE *yylvals = 0;
387 /* Current position at lexical value queue */
388 static YYSTYPE *yylvp = 0;
390 /* End position of lexical value queue */
391 static YYSTYPE *yylve = 0;
393 /* The last allocated position at the lexical value queue */
394 static YYSTYPE *yylvlim = 0;
396 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
397 /* Base of the lexical position queue */
398 static YYLTYPE *yylpsns = 0;
400 /* Current position at lexical position queue */
401 static YYLTYPE *yylpp = 0;
403 /* End position of lexical position queue */
404 static YYLTYPE *yylpe = 0;
406 /* The last allocated position at the lexical position queue */
407 static YYLTYPE *yylplim = 0;
410 /* Current position at lexical token queue */
411 static short *yylexp = 0;
413 static short *yylexemes = 0;
414 #endif /* YYBTYACC */
415 #line 78 "err_inherit3.y"
417 extern int YYLEX_DECL();
418 extern void YYERROR_DECL();
419 #line 420 "err_inherit3.tab.c"
421 /* Release memory associated with symbol. */
422 #if ! defined YYDESTRUCT_IS_DECLARED
429 #line 30 "err_inherit3.y"
431 namelist *p = (*val).nlist;
435 free(pp->s); free(pp);
439 #line 440 "err_inherit3.tab.c"
441 #line 30 "err_inherit3.y"
443 namelist *p = (*val).nlist;
447 free(pp->s); free(pp);
451 #line 452 "err_inherit3.tab.c"
453 #line 30 "err_inherit3.y"
455 namelist *p = (*val).nlist;
459 free(pp->s); free(pp);
463 #line 464 "err_inherit3.tab.c"
466 #define YYDESTRUCT_IS_DECLARED 1
469 /* For use in generated program */
470 #define yydepth (int)(yystack.s_mark - yystack.s_base)
472 #define yytrial (yyps->save)
473 #endif /* YYBTYACC */
476 #include <stdio.h> /* needed for printf */
479 #include <stdlib.h> /* needed for malloc, etc */
480 #include <string.h> /* needed for memset */
482 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
483 static int yygrowstack(YYSTACKDATA *data)
489 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
493 if ((newsize = data->stacksize) == 0)
494 newsize = YYINITSTACKSIZE;
495 else if (newsize >= YYMAXDEPTH)
497 else if ((newsize *= 2) > YYMAXDEPTH)
498 newsize = YYMAXDEPTH;
500 i = (int) (data->s_mark - data->s_base);
501 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
505 data->s_base = newss;
506 data->s_mark = newss + i;
508 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
512 data->l_base = newvs;
513 data->l_mark = newvs + i;
515 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
516 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
520 data->p_base = newps;
521 data->p_mark = newps + i;
524 data->stacksize = newsize;
525 data->s_last = data->s_base + newsize - 1;
529 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
534 #if YYPURE || defined(YY_NO_LEAKS)
535 static void yyfreestack(YYSTACKDATA *data)
539 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
542 memset(data, 0, sizeof(*data));
545 #define yyfreestack(data) /* nothing */
546 #endif /* YYPURE || defined(YY_NO_LEAKS) */
549 static YYParseState *
550 yyNewState(unsigned size)
552 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
553 if (p == NULL) return NULL;
555 p->yystack.stacksize = size;
558 p->yystack.s_base = NULL;
559 p->yystack.l_base = NULL;
560 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
561 p->yystack.p_base = NULL;
565 p->yystack.s_base = (short *) malloc(size * sizeof(short));
566 if (p->yystack.s_base == NULL) return NULL;
567 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
568 if (p->yystack.l_base == NULL) return NULL;
569 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
570 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
571 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
572 if (p->yystack.p_base == NULL) return NULL;
573 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
580 yyFreeState(YYParseState *p)
582 yyfreestack(&p->yystack);
585 #endif /* YYBTYACC */
587 #define YYABORT goto yyabort
588 #define YYREJECT goto yyabort
589 #define YYACCEPT goto yyaccept
590 #define YYERROR goto yyerrlab
592 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
593 #define YYVALID_NESTED do { if (yyps->save && \
594 yyps->save->save == 0) goto yyvalid; } while(0)
595 #endif /* YYBTYACC */
600 int yym, yyn, yystate, yyresult;
603 YYParseState *yyerrctx = NULL;
604 #endif /* YYBTYACC */
605 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
606 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
611 if ((yys = getenv("YYDEBUG")) != 0)
614 if (yyn >= '0' && yyn <= '9')
618 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
622 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
624 #endif /* YYBTYACC */
631 memset(&yystack, 0, sizeof(yystack));
634 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
635 yystack.s_mark = yystack.s_base;
636 yystack.l_mark = yystack.l_base;
637 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
638 yystack.p_mark = yystack.p_base;
644 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
651 /* we're currently re-reading tokens */
653 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
661 /* in trial mode; save scanner results for future parse attempts */
662 if (yylvp == yylvlim)
663 { /* Enlarge lexical value queue */
664 size_t p = (size_t) (yylvp - yylvals);
665 size_t s = (size_t) (yylvlim - yylvals);
667 s += YYLVQUEUEGROWTH;
668 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
669 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
670 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
671 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
673 yylvp = yylve = yylvals + p;
674 yylvlim = yylvals + s;
675 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
676 yylpp = yylpe = yylpsns + p;
677 yylplim = yylpsns + s;
679 yylexp = yylexemes + p;
681 *yylexp = (short) YYLEX;
684 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
691 /* normal operation, no conflict encountered */
692 #endif /* YYBTYACC */
696 #endif /* YYBTYACC */
697 if (yychar < 0) yychar = YYEOF;
698 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
702 yys = yyname[YYTRANSLATE(yychar)];
703 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
704 YYDEBUGSTR, yydepth, yystate, yychar, yys);
705 #ifdef YYSTYPE_TOSTRING
708 #endif /* YYBTYACC */
709 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
717 /* Do we have a conflict? */
718 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
719 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
728 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
729 YYDEBUGSTR, yydepth, yystate);
731 /* Switch to the next conflict context */
736 if (save->state != yystate) YYABORT;
743 /* Unresolved conflict - start/continue trial parse */
748 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
750 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
752 fputs("Starting trial parse.\n", stderr);
755 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
756 if (save == NULL) goto yyenomem;
757 save->save = yyps->save;
758 save->state = yystate;
759 save->errflag = yyerrflag;
760 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
761 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
762 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
763 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
764 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
765 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
766 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
769 if (yyctable[ctry] == -1)
772 if (yydebug && yychar >= YYEOF)
773 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
778 if (yyps->save == NULL)
780 /* If this is a first conflict in the stack, start saving lexemes */
783 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
784 if (yylexemes == NULL) goto yyenomem;
785 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
786 if (yylvals == NULL) goto yyenomem;
787 yylvlim = yylvals + YYLVQUEUEGROWTH;
788 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
789 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
790 if (yylpsns == NULL) goto yyenomem;
791 yylplim = yylpsns + YYLVQUEUEGROWTH;
796 yylvp = yylve = yylvals;
797 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
798 yylpp = yylpe = yylpsns;
804 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
807 *yylexp = (short) yychar;
815 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
821 save->lexeme = (int) (yylvp - yylvals);
824 if (yytable[yyn] == ctry)
828 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
829 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
834 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
839 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
841 yystate = yyctable[ctry];
842 *++yystack.s_mark = (short) yystate;
843 *++yystack.l_mark = yylval;
844 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
845 *++yystack.p_mark = yylloc;
848 if (yyerrflag > 0) --yyerrflag;
853 yyn = yyctable[ctry];
856 } /* End of code dealing with conflicts */
857 #endif /* YYBTYACC */
858 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
859 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
863 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
864 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
866 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
867 yystate = yytable[yyn];
868 *++yystack.s_mark = yytable[yyn];
869 *++yystack.l_mark = yylval;
870 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
871 *++yystack.p_mark = yylloc;
874 if (yyerrflag > 0) --yyerrflag;
877 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
878 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
883 if (yyerrflag != 0) goto yyinrecovery;
896 YYParseState *save = yyps->save;
899 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
900 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
901 (int)(yylvp - yylvals - yyps->save->lexeme));
903 /* Memorize most forward-looking error state in case it's really an error. */
904 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
906 /* Free old saved error context state */
907 if (yyerrctx) yyFreeState(yyerrctx);
908 /* Create and fill out new saved error context state */
909 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
910 if (yyerrctx == NULL) goto yyenomem;
911 yyerrctx->save = yyps->save;
912 yyerrctx->state = yystate;
913 yyerrctx->errflag = yyerrflag;
914 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
915 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
916 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
917 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
918 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
919 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
920 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
922 yyerrctx->lexeme = (int) (yylvp - yylvals);
924 yylvp = yylvals + save->lexeme;
925 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
926 yylpp = yylpsns + save->lexeme;
928 yylexp = yylexemes + save->lexeme;
930 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
931 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
932 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
933 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
934 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
935 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
936 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
939 yystate = save->state;
940 /* We tried shift, try reduce now */
941 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
942 yyps->save = save->save;
946 /* Nothing left on the stack -- error */
951 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
954 /* Restore state as it was in the most forward-advanced error */
955 yylvp = yylvals + yyerrctx->lexeme;
956 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
957 yylpp = yylpsns + yyerrctx->lexeme;
959 yylexp = yylexemes + yyerrctx->lexeme;
962 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
965 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
966 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
967 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
968 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
969 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
970 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
971 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
973 yystate = yyerrctx->state;
974 yyFreeState(yyerrctx);
979 if (yynewerrflag == 0) goto yyinrecovery;
980 #endif /* YYBTYACC */
982 YYERROR_CALL("syntax error");
983 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
984 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
999 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1000 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1004 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1005 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1007 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1008 yystate = yytable[yyn];
1009 *++yystack.s_mark = yytable[yyn];
1010 *++yystack.l_mark = yylval;
1011 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1012 /* lookahead position is error end position */
1013 yyerror_loc_range[1] = yylloc;
1014 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1015 *++yystack.p_mark = yyloc;
1023 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1024 YYDEBUGSTR, yydepth, *yystack.s_mark);
1026 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1027 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1028 /* the current TOS position is the error start position */
1029 yyerror_loc_range[0] = *yystack.p_mark;
1031 #if defined(YYDESTRUCT_CALL)
1034 #endif /* YYBTYACC */
1035 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1036 YYDESTRUCT_CALL("error: discarding state",
1037 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1039 YYDESTRUCT_CALL("error: discarding state",
1040 yystos[*yystack.s_mark], yystack.l_mark);
1041 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1042 #endif /* defined(YYDESTRUCT_CALL) */
1045 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1053 if (yychar == YYEOF) goto yyabort;
1057 yys = yyname[YYTRANSLATE(yychar)];
1058 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1059 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1062 #if defined(YYDESTRUCT_CALL)
1065 #endif /* YYBTYACC */
1066 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1067 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1069 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1070 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1071 #endif /* defined(YYDESTRUCT_CALL) */
1081 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1082 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1083 #ifdef YYSTYPE_TOSTRING
1086 #endif /* YYBTYACC */
1091 for (i = yym; i > 0; i--)
1093 if (i != yym) fputs(", ", stderr);
1094 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1095 yystack.l_mark[1-i]), stderr);
1100 fputc('\n', stderr);
1104 yyval = yystack.l_mark[1-yym];
1106 memset(&yyval, 0, sizeof yyval);
1107 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1109 /* Perform position reduction */
1110 memset(&yyloc, 0, sizeof(yyloc));
1113 #endif /* YYBTYACC */
1115 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1116 /* just in case YYERROR is invoked within the action, save
1117 the start of the rhs as the error start position */
1118 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1125 #line 50 "err_inherit3.y"
1126 yyval.cval = yystack.l_mark[-1].cval;
1129 #line 50 "err_inherit3.y"
1130 yyval.tval = yystack.l_mark[-1].tval;
1133 #line 51 "err_inherit3.y"
1134 { yyval.nlist = yystack.l_mark[0].nlist; }
1137 #line 52 "err_inherit3.y"
1138 yyval.tval = yystack.l_mark[0].tval;
1141 #line 53 "err_inherit3.y"
1142 { yyval.nlist = yystack.l_mark[0].nlist; }
1145 #line 56 "err_inherit3.y"
1146 { yyval.cval = cGLOBAL; }
1149 #line 57 "err_inherit3.y"
1150 { yyval.cval = cLOCAL; }
1153 #line 60 "err_inherit3.y"
1154 { yyval.tval = tREAL; }
1157 #line 61 "err_inherit3.y"
1158 { yyval.tval = tINTEGER; }
1161 #line 64 "err_inherit3.y"
1162 yyval.cval = yystack.l_mark[-2];
1165 #line 65 "err_inherit3.y"
1166 { yyval.nlist->s = mksymbol(yystack.l_mark[-5].tval, yystack.l_mark[-5].cval, yystack.l_mark[0].id);
1167 yyval.nlist->next = yystack.l_mark[-1].nlist;
1171 #line 69 "err_inherit3.y"
1172 { yyval.nlist->s = mksymbol(yystack.l_mark[-3], yystack.l_mark[-3], yystack.l_mark[0].id);
1173 yyval.nlist->next = NULL;
1177 #line 74 "err_inherit3.y"
1178 yyval.cval = cLOCAL;
1181 #line 75 "err_inherit3.y"
1182 { yyval.nlist = yystack.l_mark[0].nlist; }
1184 #line 1185 "err_inherit3.tab.c"
1188 yystack.s_mark -= yym;
1189 yystate = *yystack.s_mark;
1190 yystack.l_mark -= yym;
1191 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1192 yystack.p_mark -= yym;
1195 if (yystate == 0 && yym == 0)
1200 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1201 #ifdef YYSTYPE_TOSTRING
1204 #endif /* YYBTYACC */
1205 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1207 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1211 *++yystack.s_mark = YYFINAL;
1212 *++yystack.l_mark = yyval;
1213 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1214 *++yystack.p_mark = yyloc;
1222 /* we're currently re-reading tokens */
1224 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1232 /* in trial mode; save scanner results for future parse attempts */
1233 if (yylvp == yylvlim)
1234 { /* Enlarge lexical value queue */
1235 size_t p = (size_t) (yylvp - yylvals);
1236 size_t s = (size_t) (yylvlim - yylvals);
1238 s += YYLVQUEUEGROWTH;
1239 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1241 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1243 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1244 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1247 yylvp = yylve = yylvals + p;
1248 yylvlim = yylvals + s;
1249 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1250 yylpp = yylpe = yylpsns + p;
1251 yylplim = yylpsns + s;
1253 yylexp = yylexemes + p;
1255 *yylexp = (short) YYLEX;
1258 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1265 /* normal operation, no conflict encountered */
1266 #endif /* YYBTYACC */
1270 #endif /* YYBTYACC */
1271 if (yychar < 0) yychar = YYEOF;
1272 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1276 yys = yyname[YYTRANSLATE(yychar)];
1277 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1278 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1282 if (yychar == YYEOF) goto yyaccept;
1285 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1286 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1287 yystate = yytable[yyn];
1289 yystate = yydgoto[yym];
1293 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1294 #ifdef YYSTYPE_TOSTRING
1297 #endif /* YYBTYACC */
1298 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1300 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1303 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1304 *++yystack.s_mark = (short) yystate;
1305 *++yystack.l_mark = yyval;
1306 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1307 *++yystack.p_mark = yyloc;
1312 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1314 if (yypath) YYABORT;
1317 YYParseState *save = yyps->save;
1318 yyps->save = save->save;
1319 save->save = yypath;
1324 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1325 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1329 yyFreeState(yyerrctx);
1332 yylvp = yylvals + yypath->lexeme;
1333 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1334 yylpp = yylpsns + yypath->lexeme;
1336 yylexp = yylexemes + yypath->lexeme;
1338 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1339 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1340 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1341 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1342 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1343 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1344 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1346 yystate = yypath->state;
1348 #endif /* YYBTYACC */
1351 YYERROR_CALL("yacc stack overflow");
1355 YYERROR_CALL("memory exhausted");
1357 #endif /* YYBTYACC */
1367 if (yyps->save) goto yyvalid;
1368 #endif /* YYBTYACC */
1372 #if defined(YYDESTRUCT_CALL)
1373 if (yychar != YYEOF && yychar != YYEMPTY)
1374 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1375 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1377 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1378 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1382 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1385 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1386 YYDESTRUCT_CALL("cleanup: discarding state",
1387 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1389 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1390 YYDESTRUCT_CALL("cleanup: discarding state",
1391 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1392 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1394 #endif /* defined(YYDESTRUCT_CALL) */
1399 yyFreeState(yyerrctx);
1404 YYParseState *save = yyps;
1411 YYParseState *save = yypath;
1412 yypath = save->save;
1416 #endif /* YYBTYACC */
1417 yyfreestack(&yystack);