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);
623 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
625 #endif /* YYBTYACC */
634 memset(&yystack, 0, sizeof(yystack));
637 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
638 yystack.s_mark = yystack.s_base;
639 yystack.l_mark = yystack.l_base;
640 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
641 yystack.p_mark = yystack.p_base;
647 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
654 /* we're currently re-reading tokens */
656 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
664 /* in trial mode; save scanner results for future parse attempts */
665 if (yylvp == yylvlim)
666 { /* Enlarge lexical value queue */
667 size_t p = (size_t) (yylvp - yylvals);
668 size_t s = (size_t) (yylvlim - yylvals);
670 s += YYLVQUEUEGROWTH;
671 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
672 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
673 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
674 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
676 yylvp = yylve = yylvals + p;
677 yylvlim = yylvals + s;
678 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
679 yylpp = yylpe = yylpsns + p;
680 yylplim = yylpsns + s;
682 yylexp = yylexemes + p;
684 *yylexp = (YYINT) YYLEX;
687 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
694 /* normal operation, no conflict encountered */
695 #endif /* YYBTYACC */
699 #endif /* YYBTYACC */
700 if (yychar < 0) yychar = YYEOF;
704 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
705 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
706 YYDEBUGSTR, yydepth, yystate, yychar, yys);
707 #ifdef YYSTYPE_TOSTRING
710 #endif /* YYBTYACC */
711 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
719 /* Do we have a conflict? */
720 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
721 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
730 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
731 YYDEBUGSTR, yydepth, yystate);
733 /* Switch to the next conflict context */
738 if (save->state != yystate) YYABORT;
745 /* Unresolved conflict - start/continue trial parse */
750 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
752 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
754 fputs("Starting trial parse.\n", stderr);
757 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
758 if (save == NULL) goto yyenomem;
759 save->save = yyps->save;
760 save->state = yystate;
761 save->errflag = yyerrflag;
762 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
763 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
764 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
765 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
766 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
767 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
768 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
771 if (yyctable[ctry] == -1)
774 if (yydebug && yychar >= YYEOF)
775 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
780 if (yyps->save == NULL)
782 /* If this is a first conflict in the stack, start saving lexemes */
785 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
786 if (yylexemes == NULL) goto yyenomem;
787 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
788 if (yylvals == NULL) goto yyenomem;
789 yylvlim = yylvals + YYLVQUEUEGROWTH;
790 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
791 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
792 if (yylpsns == NULL) goto yyenomem;
793 yylplim = yylpsns + YYLVQUEUEGROWTH;
798 yylvp = yylve = yylvals;
799 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
800 yylpp = yylpe = yylpsns;
806 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
809 *yylexp = (YYINT) yychar;
817 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
823 save->lexeme = (int) (yylvp - yylvals);
826 if (yytable[yyn] == ctry)
830 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
831 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
836 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
841 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
843 yystate = yyctable[ctry];
844 *++yystack.s_mark = (YYINT) yystate;
845 *++yystack.l_mark = yylval;
846 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
847 *++yystack.p_mark = yylloc;
850 if (yyerrflag > 0) --yyerrflag;
855 yyn = yyctable[ctry];
858 } /* End of code dealing with conflicts */
859 #endif /* YYBTYACC */
860 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
861 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
865 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
866 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
868 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
869 yystate = yytable[yyn];
870 *++yystack.s_mark = yytable[yyn];
871 *++yystack.l_mark = yylval;
872 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
873 *++yystack.p_mark = yylloc;
876 if (yyerrflag > 0) --yyerrflag;
879 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
880 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
885 if (yyerrflag != 0) goto yyinrecovery;
890 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
893 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
894 * before looking for error recovery */
895 yystack.s_mark -= yym;
896 yystate = *yystack.s_mark;
897 yystack.l_mark -= yym;
898 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
899 yystack.p_mark -= yym;
907 YYParseState *save = yyps->save;
910 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
911 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
912 (int)(yylvp - yylvals - yyps->save->lexeme));
914 /* Memorize most forward-looking error state in case it's really an error. */
915 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
917 /* Free old saved error context state */
918 if (yyerrctx) yyFreeState(yyerrctx);
919 /* Create and fill out new saved error context state */
920 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
921 if (yyerrctx == NULL) goto yyenomem;
922 yyerrctx->save = yyps->save;
923 yyerrctx->state = yystate;
924 yyerrctx->errflag = yyerrflag;
925 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
926 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
927 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
928 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
929 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
930 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
931 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
933 yyerrctx->lexeme = (int) (yylvp - yylvals);
935 yylvp = yylvals + save->lexeme;
936 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
937 yylpp = yylpsns + save->lexeme;
939 yylexp = yylexemes + save->lexeme;
941 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
942 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
943 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
944 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
946 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
947 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
950 yystate = save->state;
951 /* We tried shift, try reduce now */
952 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
953 yyps->save = save->save;
957 /* Nothing left on the stack -- error */
962 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
965 /* Restore state as it was in the most forward-advanced error */
966 yylvp = yylvals + yyerrctx->lexeme;
967 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
968 yylpp = yylpsns + yyerrctx->lexeme;
970 yylexp = yylexemes + yyerrctx->lexeme;
973 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
976 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
977 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
978 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
979 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
980 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
981 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
982 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
984 yystate = yyerrctx->state;
985 yyFreeState(yyerrctx);
990 if (yynewerrflag == 0) goto yyinrecovery;
991 #endif /* YYBTYACC */
993 YYERROR_CALL("syntax error");
994 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
995 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
999 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1010 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1011 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1015 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1016 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1018 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1019 yystate = yytable[yyn];
1020 *++yystack.s_mark = yytable[yyn];
1021 *++yystack.l_mark = yylval;
1022 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1023 /* lookahead position is error end position */
1024 yyerror_loc_range[1] = yylloc;
1025 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1026 *++yystack.p_mark = yyloc;
1034 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1035 YYDEBUGSTR, yydepth, *yystack.s_mark);
1037 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1038 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1039 /* the current TOS position is the error start position */
1040 yyerror_loc_range[0] = *yystack.p_mark;
1042 #if defined(YYDESTRUCT_CALL)
1045 #endif /* YYBTYACC */
1046 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1047 YYDESTRUCT_CALL("error: discarding state",
1048 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1050 YYDESTRUCT_CALL("error: discarding state",
1051 yystos[*yystack.s_mark], yystack.l_mark);
1052 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1053 #endif /* defined(YYDESTRUCT_CALL) */
1056 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1064 if (yychar == YYEOF) goto yyabort;
1068 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1069 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1070 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1073 #if defined(YYDESTRUCT_CALL)
1076 #endif /* YYBTYACC */
1077 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1078 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1080 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1081 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1082 #endif /* defined(YYDESTRUCT_CALL) */
1092 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1093 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1094 #ifdef YYSTYPE_TOSTRING
1097 #endif /* YYBTYACC */
1102 for (i = yym; i > 0; i--)
1104 if (i != yym) fputs(", ", stderr);
1105 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1106 yystack.l_mark[1-i]), stderr);
1111 fputc('\n', stderr);
1115 yyval = yystack.l_mark[1-yym];
1117 memset(&yyval, 0, sizeof yyval);
1118 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1120 /* Perform position reduction */
1121 memset(&yyloc, 0, sizeof(yyloc));
1124 #endif /* YYBTYACC */
1126 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1127 /* just in case YYERROR is invoked within the action, save
1128 the start of the rhs as the error start position */
1129 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1136 #line 50 "inherit2.y"
1137 yyval.cval = yystack.l_mark[-1].cval;
1140 #line 50 "inherit2.y"
1141 yyval.tval = yystack.l_mark[-1].tval;
1144 #line 51 "inherit2.y"
1145 { yyval.nlist = yystack.l_mark[0].nlist; }
1148 #line 53 "inherit2.y"
1149 { yyval.nlist = yystack.l_mark[0].nlist; }
1152 #line 56 "inherit2.y"
1153 { yyval.cval = cGLOBAL; }
1156 #line 57 "inherit2.y"
1157 { yyval.cval = cLOCAL; }
1160 #line 60 "inherit2.y"
1161 { yyval.tval = tREAL; }
1164 #line 61 "inherit2.y"
1165 { yyval.tval = tINTEGER; }
1168 #line 65 "inherit2.y"
1169 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id);
1170 yyval.nlist->next = yystack.l_mark[-1].nlist;
1174 #line 69 "inherit2.y"
1175 { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id);
1176 yyval.nlist->next = NULL;
1180 #line 74 "inherit2.y"
1181 yyval.cval = cLOCAL;
1184 #line 75 "inherit2.y"
1185 { yyval.nlist = yystack.l_mark[0].nlist; }
1187 #line 1188 "inherit2.tab.c"
1191 yystack.s_mark -= yym;
1192 yystate = *yystack.s_mark;
1193 yystack.l_mark -= yym;
1194 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1195 yystack.p_mark -= yym;
1198 if (yystate == 0 && yym == 0)
1203 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1204 #ifdef YYSTYPE_TOSTRING
1207 #endif /* YYBTYACC */
1208 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1210 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1214 *++yystack.s_mark = YYFINAL;
1215 *++yystack.l_mark = yyval;
1216 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1217 *++yystack.p_mark = yyloc;
1225 /* we're currently re-reading tokens */
1227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1235 /* in trial mode; save scanner results for future parse attempts */
1236 if (yylvp == yylvlim)
1237 { /* Enlarge lexical value queue */
1238 size_t p = (size_t) (yylvp - yylvals);
1239 size_t s = (size_t) (yylvlim - yylvals);
1241 s += YYLVQUEUEGROWTH;
1242 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1244 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1246 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1247 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1250 yylvp = yylve = yylvals + p;
1251 yylvlim = yylvals + s;
1252 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1253 yylpp = yylpe = yylpsns + p;
1254 yylplim = yylpsns + s;
1256 yylexp = yylexemes + p;
1258 *yylexp = (YYINT) YYLEX;
1261 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1268 /* normal operation, no conflict encountered */
1269 #endif /* YYBTYACC */
1273 #endif /* YYBTYACC */
1274 if (yychar < 0) yychar = YYEOF;
1278 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1279 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1280 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1284 if (yychar == YYEOF) goto yyaccept;
1287 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1288 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1289 yystate = yytable[yyn];
1291 yystate = yydgoto[yym];
1295 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1296 #ifdef YYSTYPE_TOSTRING
1299 #endif /* YYBTYACC */
1300 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1302 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1305 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1306 *++yystack.s_mark = (YYINT) yystate;
1307 *++yystack.l_mark = yyval;
1308 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1309 *++yystack.p_mark = yyloc;
1314 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1316 if (yypath) YYABORT;
1319 YYParseState *save = yyps->save;
1320 yyps->save = save->save;
1321 save->save = yypath;
1326 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1327 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1331 yyFreeState(yyerrctx);
1334 yylvp = yylvals + yypath->lexeme;
1335 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1336 yylpp = yylpsns + yypath->lexeme;
1338 yylexp = yylexemes + yypath->lexeme;
1340 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1341 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1342 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1343 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1344 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1345 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1346 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1348 yystate = yypath->state;
1350 #endif /* YYBTYACC */
1353 YYERROR_CALL("yacc stack overflow");
1357 YYERROR_CALL("memory exhausted");
1359 #endif /* YYBTYACC */
1369 if (yyps->save) goto yyvalid;
1370 #endif /* YYBTYACC */
1374 #if defined(YYDESTRUCT_CALL)
1375 if (yychar != YYEOF && yychar != YYEMPTY)
1376 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1377 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1379 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1380 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1384 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1387 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1388 YYDESTRUCT_CALL("cleanup: discarding state",
1389 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1391 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1392 YYDESTRUCT_CALL("cleanup: discarding state",
1393 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1394 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1396 #endif /* defined(YYDESTRUCT_CALL) */
1401 yyFreeState(yyerrctx);
1406 YYParseState *save = yyps;
1413 YYParseState *save = yypath;
1414 yypath = save->save;
1418 #endif /* YYBTYACC */
1419 yyfreestack(&yystack);