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 inherit2_parse
25 #define yylex inherit2_lex
29 #define yyerror inherit2_error
33 #define yychar inherit2_char
37 #define yyval inherit2_val
41 #define yylval inherit2_lval
45 #define yydebug inherit2_debug
49 #define yynerrs inherit2_nerrs
53 #define yyerrflag inherit2_errflag
54 #endif /* yyerrflag */
57 #define yylhs inherit2_lhs
61 #define yylen inherit2_len
65 #define yydefred inherit2_defred
69 #define yystos inherit2_stos
73 #define yydgoto inherit2_dgoto
77 #define yysindex inherit2_sindex
81 #define yyrindex inherit2_rindex
85 #define yygindex inherit2_gindex
89 #define yytable inherit2_table
93 #define yycheck inherit2_check
97 #define yyname inherit2_name
101 #define yyrule inherit2_rule
107 #define yycindex inherit2_cindex
108 #endif /* yycindex */
111 #define yyctable inherit2_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "inherit2_"
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)
140 #undef YYSTYPE_IS_DECLARED
141 #define YYSTYPE_IS_DECLARED 1
143 #ifndef YYSTYPE_IS_DECLARED
144 #define YYSTYPE_IS_DECLARED 1
145 #line 39 "inherit2.y"
153 #endif /* !YYSTYPE_IS_DECLARED */
154 #line 155 "inherit2.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 inherit2_lhs[] = { -1,
202 5, 6, 0, 0, 3, 3, 4, 4, 1, 1,
205 static const YYINT inherit2_len[] = { 2,
206 0, 0, 5, 2, 1, 1, 1, 1, 2, 1,
209 static const YYINT inherit2_defred[] = { 0,
210 5, 6, 7, 8, 0, 0, 11, 1, 4, 2,
211 2, 0, 0, 10, 0, 0, 9,
213 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
214 static const YYINT inherit2_stos[] = { 0,
215 257, 258, 259, 260, 263, 266, 267, 267, 265, 270,
216 268, 269, 269, 261, 264, 264, 261,
218 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
219 static const YYINT inherit2_dgoto[] = { 5,
220 15, 9, 6, 7, 11, 12, 10,
222 static const YYINT inherit2_sindex[] = { -257,
223 0, 0, 0, 0, 0, -255, 0, 0, 0, 0,
224 0, -254, -254, 0, -253, -253, 0,
226 static const YYINT inherit2_rindex[] = { 0,
227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
231 static const YYINT inherit2_cindex[] = { 0,
232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
236 static const YYINT inherit2_gindex[] = { 0,
237 -3, 0, 0, 5, 0, 1, 0,
239 #define YYTABLESIZE 12
240 static const YYINT inherit2_table[] = { 1,
241 2, 3, 4, 3, 4, 12, 14, 17, 3, 16,
244 static const YYINT inherit2_check[] = { 257,
245 258, 259, 260, 259, 260, 0, 261, 261, 0, 13,
249 static const YYINT inherit2_ctable[] = { -1,
250 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
258 #define YYMAXTOKEN 261
259 #define YYUNDFTOKEN 271
260 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
262 static const char *const inherit2_name[] = {
264 "$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,
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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
268 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
269 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
270 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER",
271 "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1",
272 "$$2","$$3","illegal-symbol",
274 static const char *const inherit2_rule[] = {
275 "$accept : declaration",
278 "declaration : class type $$1 $$2 namelist",
279 "declaration : type locnamelist",
284 "namelist : namelist NAME",
287 "locnamelist : $$3 $$2 namelist",
299 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
300 YYLTYPE yyloc; /* position returned by actions */
301 YYLTYPE yylloc; /* position from the lexer */
304 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
305 #ifndef YYLLOC_DEFAULT
306 #define YYLLOC_DEFAULT(loc, rhs, n) \
311 (loc).first_line = ((rhs)[-1]).last_line; \
312 (loc).first_column = ((rhs)[-1]).last_column; \
313 (loc).last_line = ((rhs)[-1]).last_line; \
314 (loc).last_column = ((rhs)[-1]).last_column; \
318 (loc).first_line = ((rhs)[ 0 ]).first_line; \
319 (loc).first_column = ((rhs)[ 0 ]).first_column; \
320 (loc).last_line = ((rhs)[n-1]).last_line; \
321 (loc).last_column = ((rhs)[n-1]).last_column; \
324 #endif /* YYLLOC_DEFAULT */
325 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
328 #ifndef YYLVQUEUEGROWTH
329 #define YYLVQUEUEGROWTH 32
331 #endif /* YYBTYACC */
333 /* define the initial stack-sizes */
336 #define YYMAXDEPTH YYSTACKSIZE
339 #define YYSTACKSIZE YYMAXDEPTH
341 #define YYSTACKSIZE 10000
342 #define YYMAXDEPTH 10000
346 #ifndef YYINITSTACKSIZE
347 #define YYINITSTACKSIZE 200
357 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
364 struct YYParseState_s
366 struct YYParseState_s *save; /* Previously saved parser state */
367 YYSTACKDATA yystack; /* saved parser stack */
368 int state; /* saved parser state */
369 int errflag; /* saved error recovery status */
370 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
371 YYINT ctry; /* saved index in yyctable[] for this conflict */
373 typedef struct YYParseState_s YYParseState;
374 #endif /* YYBTYACC */
375 /* variables for the parser stack */
376 static YYSTACKDATA yystack;
379 /* Current parser state */
380 static YYParseState *yyps = 0;
382 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
383 static YYParseState *yypath = 0;
385 /* Base of the lexical value queue */
386 static YYSTYPE *yylvals = 0;
388 /* Current position at lexical value queue */
389 static YYSTYPE *yylvp = 0;
391 /* End position of lexical value queue */
392 static YYSTYPE *yylve = 0;
394 /* The last allocated position at the lexical value queue */
395 static YYSTYPE *yylvlim = 0;
397 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
398 /* Base of the lexical position queue */
399 static YYLTYPE *yylpsns = 0;
401 /* Current position at lexical position queue */
402 static YYLTYPE *yylpp = 0;
404 /* End position of lexical position queue */
405 static YYLTYPE *yylpe = 0;
407 /* The last allocated position at the lexical position queue */
408 static YYLTYPE *yylplim = 0;
411 /* Current position at lexical token queue */
412 static YYINT *yylexp = 0;
414 static YYINT *yylexemes = 0;
415 #endif /* YYBTYACC */
416 #line 78 "inherit2.y"
418 extern int YYLEX_DECL();
419 extern void YYERROR_DECL();
420 #line 421 "inherit2.tab.c"
422 /* Release memory associated with symbol. */
423 #if ! defined YYDESTRUCT_IS_DECLARED
430 #line 30 "inherit2.y"
432 namelist *p = (*val).nlist;
436 free(pp->s); free(pp);
440 #line 441 "inherit2.tab.c"
442 #line 30 "inherit2.y"
444 namelist *p = (*val).nlist;
448 free(pp->s); free(pp);
452 #line 453 "inherit2.tab.c"
454 #line 30 "inherit2.y"
456 namelist *p = (*val).nlist;
460 free(pp->s); free(pp);
464 #line 465 "inherit2.tab.c"
467 #define YYDESTRUCT_IS_DECLARED 1
470 /* For use in generated program */
471 #define yydepth (int)(yystack.s_mark - yystack.s_base)
473 #define yytrial (yyps->save)
474 #endif /* YYBTYACC */
477 #include <stdio.h> /* needed for printf */
480 #include <stdlib.h> /* needed for malloc, etc */
481 #include <string.h> /* needed for memset */
483 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
484 static int yygrowstack(YYSTACKDATA *data)
490 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
494 if ((newsize = data->stacksize) == 0)
495 newsize = YYINITSTACKSIZE;
496 else if (newsize >= YYMAXDEPTH)
498 else if ((newsize *= 2) > YYMAXDEPTH)
499 newsize = YYMAXDEPTH;
501 i = (int) (data->s_mark - data->s_base);
502 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
506 data->s_base = newss;
507 data->s_mark = newss + i;
509 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
513 data->l_base = newvs;
514 data->l_mark = newvs + i;
516 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
517 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
521 data->p_base = newps;
522 data->p_mark = newps + i;
525 data->stacksize = newsize;
526 data->s_last = data->s_base + newsize - 1;
530 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
535 #if YYPURE || defined(YY_NO_LEAKS)
536 static void yyfreestack(YYSTACKDATA *data)
540 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
543 memset(data, 0, sizeof(*data));
546 #define yyfreestack(data) /* nothing */
547 #endif /* YYPURE || defined(YY_NO_LEAKS) */
550 static YYParseState *
551 yyNewState(unsigned size)
553 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
554 if (p == NULL) return NULL;
556 p->yystack.stacksize = size;
559 p->yystack.s_base = NULL;
560 p->yystack.l_base = NULL;
561 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
562 p->yystack.p_base = NULL;
566 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
567 if (p->yystack.s_base == NULL) return NULL;
568 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
569 if (p->yystack.l_base == NULL) return NULL;
570 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
571 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
572 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
573 if (p->yystack.p_base == NULL) return NULL;
574 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
581 yyFreeState(YYParseState *p)
583 yyfreestack(&p->yystack);
586 #endif /* YYBTYACC */
588 #define YYABORT goto yyabort
589 #define YYREJECT goto yyabort
590 #define YYACCEPT goto yyaccept
591 #define YYERROR goto yyerrlab
593 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
594 #define YYVALID_NESTED do { if (yyps->save && \
595 yyps->save->save == 0) goto yyvalid; } while(0)
596 #endif /* YYBTYACC */
601 int yym, yyn, yystate, yyresult;
604 YYParseState *yyerrctx = NULL;
605 #endif /* YYBTYACC */
606 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
607 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
612 if ((yys = getenv("YYDEBUG")) != 0)
615 if (yyn >= '0' && yyn <= '9')
619 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
621 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
622 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
626 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
628 #endif /* YYBTYACC */
637 memset(&yystack, 0, sizeof(yystack));
640 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
641 yystack.s_mark = yystack.s_base;
642 yystack.l_mark = yystack.l_base;
643 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
644 yystack.p_mark = yystack.p_base;
650 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
657 /* we're currently re-reading tokens */
659 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
667 /* in trial mode; save scanner results for future parse attempts */
668 if (yylvp == yylvlim)
669 { /* Enlarge lexical value queue */
670 size_t p = (size_t) (yylvp - yylvals);
671 size_t s = (size_t) (yylvlim - yylvals);
673 s += YYLVQUEUEGROWTH;
674 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
675 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
676 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
677 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
679 yylvp = yylve = yylvals + p;
680 yylvlim = yylvals + s;
681 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
682 yylpp = yylpe = yylpsns + p;
683 yylplim = yylpsns + s;
685 yylexp = yylexemes + p;
687 *yylexp = (YYINT) YYLEX;
690 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
697 /* normal operation, no conflict encountered */
698 #endif /* YYBTYACC */
702 #endif /* YYBTYACC */
703 if (yychar < 0) yychar = YYEOF;
707 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
708 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
709 YYDEBUGSTR, yydepth, yystate, yychar, yys);
710 #ifdef YYSTYPE_TOSTRING
713 #endif /* YYBTYACC */
714 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
722 /* Do we have a conflict? */
723 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
724 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
733 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
734 YYDEBUGSTR, yydepth, yystate);
736 /* Switch to the next conflict context */
741 if (save->state != yystate) YYABORT;
748 /* Unresolved conflict - start/continue trial parse */
753 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
755 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
757 fputs("Starting trial parse.\n", stderr);
760 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
761 if (save == NULL) goto yyenomem;
762 save->save = yyps->save;
763 save->state = yystate;
764 save->errflag = yyerrflag;
765 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
766 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
767 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
768 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
769 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
770 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
771 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
774 if (yyctable[ctry] == -1)
777 if (yydebug && yychar >= YYEOF)
778 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
783 if (yyps->save == NULL)
785 /* If this is a first conflict in the stack, start saving lexemes */
788 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
789 if (yylexemes == NULL) goto yyenomem;
790 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
791 if (yylvals == NULL) goto yyenomem;
792 yylvlim = yylvals + YYLVQUEUEGROWTH;
793 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
794 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
795 if (yylpsns == NULL) goto yyenomem;
796 yylplim = yylpsns + YYLVQUEUEGROWTH;
801 yylvp = yylve = yylvals;
802 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
803 yylpp = yylpe = yylpsns;
809 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
812 *yylexp = (YYINT) yychar;
820 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
826 save->lexeme = (int) (yylvp - yylvals);
829 if (yytable[yyn] == ctry)
833 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
834 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
839 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
844 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
846 yystate = yyctable[ctry];
847 *++yystack.s_mark = (YYINT) yystate;
848 *++yystack.l_mark = yylval;
849 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
850 *++yystack.p_mark = yylloc;
853 if (yyerrflag > 0) --yyerrflag;
858 yyn = yyctable[ctry];
861 } /* End of code dealing with conflicts */
862 #endif /* YYBTYACC */
863 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
864 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
868 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
869 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
871 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
872 yystate = yytable[yyn];
873 *++yystack.s_mark = yytable[yyn];
874 *++yystack.l_mark = yylval;
875 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
876 *++yystack.p_mark = yylloc;
879 if (yyerrflag > 0) --yyerrflag;
882 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
883 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
888 if (yyerrflag != 0) goto yyinrecovery;
893 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
896 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
897 * before looking for error recovery */
898 yystack.s_mark -= yym;
899 yystate = *yystack.s_mark;
900 yystack.l_mark -= yym;
901 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
902 yystack.p_mark -= yym;
910 YYParseState *save = yyps->save;
913 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
914 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
915 (int)(yylvp - yylvals - yyps->save->lexeme));
917 /* Memorize most forward-looking error state in case it's really an error. */
918 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
920 /* Free old saved error context state */
921 if (yyerrctx) yyFreeState(yyerrctx);
922 /* Create and fill out new saved error context state */
923 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
924 if (yyerrctx == NULL) goto yyenomem;
925 yyerrctx->save = yyps->save;
926 yyerrctx->state = yystate;
927 yyerrctx->errflag = yyerrflag;
928 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
929 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
930 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
931 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
932 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
933 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
934 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
936 yyerrctx->lexeme = (int) (yylvp - yylvals);
938 yylvp = yylvals + save->lexeme;
939 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
940 yylpp = yylpsns + save->lexeme;
942 yylexp = yylexemes + save->lexeme;
944 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
945 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
946 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
947 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
948 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
949 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
950 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
953 yystate = save->state;
954 /* We tried shift, try reduce now */
955 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
956 yyps->save = save->save;
960 /* Nothing left on the stack -- error */
965 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
968 /* Restore state as it was in the most forward-advanced error */
969 yylvp = yylvals + yyerrctx->lexeme;
970 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
971 yylpp = yylpsns + yyerrctx->lexeme;
973 yylexp = yylexemes + yyerrctx->lexeme;
976 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
979 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
980 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
981 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
982 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
983 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
984 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
985 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
987 yystate = yyerrctx->state;
988 yyFreeState(yyerrctx);
993 if (yynewerrflag == 0) goto yyinrecovery;
994 #endif /* YYBTYACC */
996 YYERROR_CALL("syntax error");
997 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
998 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1002 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1013 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1014 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1018 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1019 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1021 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1022 yystate = yytable[yyn];
1023 *++yystack.s_mark = yytable[yyn];
1024 *++yystack.l_mark = yylval;
1025 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1026 /* lookahead position is error end position */
1027 yyerror_loc_range[1] = yylloc;
1028 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1029 *++yystack.p_mark = yyloc;
1037 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1038 YYDEBUGSTR, yydepth, *yystack.s_mark);
1040 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1041 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1042 /* the current TOS position is the error start position */
1043 yyerror_loc_range[0] = *yystack.p_mark;
1045 #if defined(YYDESTRUCT_CALL)
1048 #endif /* YYBTYACC */
1049 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1050 YYDESTRUCT_CALL("error: discarding state",
1051 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1053 YYDESTRUCT_CALL("error: discarding state",
1054 yystos[*yystack.s_mark], yystack.l_mark);
1055 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1056 #endif /* defined(YYDESTRUCT_CALL) */
1059 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1067 if (yychar == YYEOF) goto yyabort;
1071 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1072 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1073 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1076 #if defined(YYDESTRUCT_CALL)
1079 #endif /* YYBTYACC */
1080 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1081 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1083 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1084 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1085 #endif /* defined(YYDESTRUCT_CALL) */
1095 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1096 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1097 #ifdef YYSTYPE_TOSTRING
1100 #endif /* YYBTYACC */
1105 for (i = yym; i > 0; i--)
1107 if (i != yym) fputs(", ", stderr);
1108 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1109 yystack.l_mark[1-i]), stderr);
1114 fputc('\n', stderr);
1118 yyval = yystack.l_mark[1-yym];
1120 memset(&yyval, 0, sizeof yyval);
1121 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1123 /* Perform position reduction */
1124 memset(&yyloc, 0, sizeof(yyloc));
1127 #endif /* YYBTYACC */
1129 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1130 /* just in case YYERROR is invoked within the action, save
1131 the start of the rhs as the error start position */
1132 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1139 #line 50 "inherit2.y"
1140 yyval.cval = yystack.l_mark[-1].cval;
1143 #line 50 "inherit2.y"
1144 yyval.tval = yystack.l_mark[-1].tval;
1147 #line 51 "inherit2.y"
1148 { yyval.nlist = yystack.l_mark[0].nlist; }
1151 #line 53 "inherit2.y"
1152 { yyval.nlist = yystack.l_mark[0].nlist; }
1155 #line 56 "inherit2.y"
1156 { yyval.cval = cGLOBAL; }
1159 #line 57 "inherit2.y"
1160 { yyval.cval = cLOCAL; }
1163 #line 60 "inherit2.y"
1164 { yyval.tval = tREAL; }
1167 #line 61 "inherit2.y"
1168 { yyval.tval = tINTEGER; }
1171 #line 65 "inherit2.y"
1172 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id);
1173 yyval.nlist->next = yystack.l_mark[-1].nlist;
1177 #line 69 "inherit2.y"
1178 { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id);
1179 yyval.nlist->next = NULL;
1183 #line 74 "inherit2.y"
1184 yyval.cval = cLOCAL;
1187 #line 75 "inherit2.y"
1188 { yyval.nlist = yystack.l_mark[0].nlist; }
1190 #line 1191 "inherit2.tab.c"
1194 yystack.s_mark -= yym;
1195 yystate = *yystack.s_mark;
1196 yystack.l_mark -= yym;
1197 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1198 yystack.p_mark -= yym;
1201 if (yystate == 0 && yym == 0)
1206 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1207 #ifdef YYSTYPE_TOSTRING
1210 #endif /* YYBTYACC */
1211 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1213 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1217 *++yystack.s_mark = YYFINAL;
1218 *++yystack.l_mark = yyval;
1219 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1220 *++yystack.p_mark = yyloc;
1228 /* we're currently re-reading tokens */
1230 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1238 /* in trial mode; save scanner results for future parse attempts */
1239 if (yylvp == yylvlim)
1240 { /* Enlarge lexical value queue */
1241 size_t p = (size_t) (yylvp - yylvals);
1242 size_t s = (size_t) (yylvlim - yylvals);
1244 s += YYLVQUEUEGROWTH;
1245 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1247 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1249 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1250 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1253 yylvp = yylve = yylvals + p;
1254 yylvlim = yylvals + s;
1255 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1256 yylpp = yylpe = yylpsns + p;
1257 yylplim = yylpsns + s;
1259 yylexp = yylexemes + p;
1261 *yylexp = (YYINT) YYLEX;
1264 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1271 /* normal operation, no conflict encountered */
1272 #endif /* YYBTYACC */
1276 #endif /* YYBTYACC */
1277 if (yychar < 0) yychar = YYEOF;
1281 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1282 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1283 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1287 if (yychar == YYEOF) goto yyaccept;
1290 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1291 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1292 yystate = yytable[yyn];
1294 yystate = yydgoto[yym];
1298 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1299 #ifdef YYSTYPE_TOSTRING
1302 #endif /* YYBTYACC */
1303 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1305 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1308 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1309 *++yystack.s_mark = (YYINT) yystate;
1310 *++yystack.l_mark = yyval;
1311 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1312 *++yystack.p_mark = yyloc;
1317 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1319 if (yypath) YYABORT;
1322 YYParseState *save = yyps->save;
1323 yyps->save = save->save;
1324 save->save = yypath;
1329 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1330 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1334 yyFreeState(yyerrctx);
1337 yylvp = yylvals + yypath->lexeme;
1338 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1339 yylpp = yylpsns + yypath->lexeme;
1341 yylexp = yylexemes + yypath->lexeme;
1343 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1344 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1345 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1346 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1347 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1348 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1349 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1351 yystate = yypath->state;
1353 #endif /* YYBTYACC */
1356 YYERROR_CALL("yacc stack overflow");
1360 YYERROR_CALL("memory exhausted");
1362 #endif /* YYBTYACC */
1372 if (yyps->save) goto yyvalid;
1373 #endif /* YYBTYACC */
1377 #if defined(YYDESTRUCT_CALL)
1378 if (yychar != YYEOF && yychar != YYEMPTY)
1379 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1380 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1382 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1383 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1387 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1390 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1391 YYDESTRUCT_CALL("cleanup: discarding state",
1392 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1394 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1395 YYDESTRUCT_CALL("cleanup: discarding state",
1396 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1397 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1399 #endif /* defined(YYDESTRUCT_CALL) */
1404 yyFreeState(yyerrctx);
1409 YYParseState *save = yyps;
1416 YYParseState *save = yypath;
1417 yypath = save->save;
1421 #endif /* YYBTYACC */
1422 yyfreestack(&yystack);