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",
302 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
303 YYLTYPE yyloc; /* position returned by actions */
304 YYLTYPE yylloc; /* position from the lexer */
307 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
308 #ifndef YYLLOC_DEFAULT
309 #define YYLLOC_DEFAULT(loc, rhs, n) \
314 (loc).first_line = YYRHSLOC(rhs, 0).last_line; \
315 (loc).first_column = YYRHSLOC(rhs, 0).last_column; \
316 (loc).last_line = YYRHSLOC(rhs, 0).last_line; \
317 (loc).last_column = YYRHSLOC(rhs, 0).last_column; \
321 (loc).first_line = YYRHSLOC(rhs, 1).first_line; \
322 (loc).first_column = YYRHSLOC(rhs, 1).first_column; \
323 (loc).last_line = YYRHSLOC(rhs, n).last_line; \
324 (loc).last_column = YYRHSLOC(rhs, n).last_column; \
327 #endif /* YYLLOC_DEFAULT */
328 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
331 #ifndef YYLVQUEUEGROWTH
332 #define YYLVQUEUEGROWTH 32
334 #endif /* YYBTYACC */
336 /* define the initial stack-sizes */
339 #define YYMAXDEPTH YYSTACKSIZE
342 #define YYSTACKSIZE YYMAXDEPTH
344 #define YYSTACKSIZE 10000
345 #define YYMAXDEPTH 10000
349 #ifndef YYINITSTACKSIZE
350 #define YYINITSTACKSIZE 200
360 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
367 struct YYParseState_s
369 struct YYParseState_s *save; /* Previously saved parser state */
370 YYSTACKDATA yystack; /* saved parser stack */
371 int state; /* saved parser state */
372 int errflag; /* saved error recovery status */
373 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
374 YYINT ctry; /* saved index in yyctable[] for this conflict */
376 typedef struct YYParseState_s YYParseState;
377 #endif /* YYBTYACC */
378 /* variables for the parser stack */
379 static YYSTACKDATA yystack;
382 /* Current parser state */
383 static YYParseState *yyps = 0;
385 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
386 static YYParseState *yypath = 0;
388 /* Base of the lexical value queue */
389 static YYSTYPE *yylvals = 0;
391 /* Current position at lexical value queue */
392 static YYSTYPE *yylvp = 0;
394 /* End position of lexical value queue */
395 static YYSTYPE *yylve = 0;
397 /* The last allocated position at the lexical value queue */
398 static YYSTYPE *yylvlim = 0;
400 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
401 /* Base of the lexical position queue */
402 static YYLTYPE *yylpsns = 0;
404 /* Current position at lexical position queue */
405 static YYLTYPE *yylpp = 0;
407 /* End position of lexical position queue */
408 static YYLTYPE *yylpe = 0;
410 /* The last allocated position at the lexical position queue */
411 static YYLTYPE *yylplim = 0;
414 /* Current position at lexical token queue */
415 static YYINT *yylexp = 0;
417 static YYINT *yylexemes = 0;
418 #endif /* YYBTYACC */
419 #line 78 "inherit2.y"
421 extern int YYLEX_DECL();
422 extern void YYERROR_DECL();
423 #line 424 "inherit2.tab.c"
425 /* Release memory associated with symbol. */
426 #if ! defined YYDESTRUCT_IS_DECLARED
433 #line 30 "inherit2.y"
435 namelist *p = (*val).nlist;
439 free(pp->s); free(pp);
443 #line 444 "inherit2.tab.c"
445 #line 30 "inherit2.y"
447 namelist *p = (*val).nlist;
451 free(pp->s); free(pp);
455 #line 456 "inherit2.tab.c"
457 #line 30 "inherit2.y"
459 namelist *p = (*val).nlist;
463 free(pp->s); free(pp);
467 #line 468 "inherit2.tab.c"
470 #define YYDESTRUCT_IS_DECLARED 1
473 /* For use in generated program */
474 #define yydepth (int)(yystack.s_mark - yystack.s_base)
476 #define yytrial (yyps->save)
477 #endif /* YYBTYACC */
480 #include <stdio.h> /* needed for printf */
483 #include <stdlib.h> /* needed for malloc, etc */
484 #include <string.h> /* needed for memset */
486 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
487 static int yygrowstack(YYSTACKDATA *data)
493 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
497 if ((newsize = data->stacksize) == 0)
498 newsize = YYINITSTACKSIZE;
499 else if (newsize >= YYMAXDEPTH)
501 else if ((newsize *= 2) > YYMAXDEPTH)
502 newsize = YYMAXDEPTH;
504 i = (int) (data->s_mark - data->s_base);
505 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
509 data->s_base = newss;
510 data->s_mark = newss + i;
512 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
516 data->l_base = newvs;
517 data->l_mark = newvs + i;
519 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
520 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
524 data->p_base = newps;
525 data->p_mark = newps + i;
528 data->stacksize = newsize;
529 data->s_last = data->s_base + newsize - 1;
533 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
538 #if YYPURE || defined(YY_NO_LEAKS)
539 static void yyfreestack(YYSTACKDATA *data)
543 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
546 memset(data, 0, sizeof(*data));
549 #define yyfreestack(data) /* nothing */
550 #endif /* YYPURE || defined(YY_NO_LEAKS) */
553 static YYParseState *
554 yyNewState(unsigned size)
556 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
557 if (p == NULL) return NULL;
559 p->yystack.stacksize = size;
562 p->yystack.s_base = NULL;
563 p->yystack.l_base = NULL;
564 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
565 p->yystack.p_base = NULL;
569 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
570 if (p->yystack.s_base == NULL) return NULL;
571 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
572 if (p->yystack.l_base == NULL) return NULL;
573 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
574 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
575 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
576 if (p->yystack.p_base == NULL) return NULL;
577 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
584 yyFreeState(YYParseState *p)
586 yyfreestack(&p->yystack);
589 #endif /* YYBTYACC */
591 #define YYABORT goto yyabort
592 #define YYREJECT goto yyabort
593 #define YYACCEPT goto yyaccept
594 #define YYERROR goto yyerrlab
596 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
597 #define YYVALID_NESTED do { if (yyps->save && \
598 yyps->save->save == 0) goto yyvalid; } while(0)
599 #endif /* YYBTYACC */
604 int yym, yyn, yystate, yyresult;
607 YYParseState *yyerrctx = NULL;
608 #endif /* YYBTYACC */
609 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
610 YYLTYPE yyerror_loc_range[3]; /* position of error start/end (0 unused) */
615 if ((yys = getenv("YYDEBUG")) != 0)
618 if (yyn >= '0' && yyn <= '9')
622 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
624 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
625 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
629 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
631 #endif /* YYBTYACC */
640 memset(&yystack, 0, sizeof(yystack));
643 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
644 yystack.s_mark = yystack.s_base;
645 yystack.l_mark = yystack.l_base;
646 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
647 yystack.p_mark = yystack.p_base;
653 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
660 /* we're currently re-reading tokens */
662 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
670 /* in trial mode; save scanner results for future parse attempts */
671 if (yylvp == yylvlim)
672 { /* Enlarge lexical value queue */
673 size_t p = (size_t) (yylvp - yylvals);
674 size_t s = (size_t) (yylvlim - yylvals);
676 s += YYLVQUEUEGROWTH;
677 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
678 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
679 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
680 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
682 yylvp = yylve = yylvals + p;
683 yylvlim = yylvals + s;
684 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
685 yylpp = yylpe = yylpsns + p;
686 yylplim = yylpsns + s;
688 yylexp = yylexemes + p;
690 *yylexp = (YYINT) YYLEX;
693 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
700 /* normal operation, no conflict encountered */
701 #endif /* YYBTYACC */
705 #endif /* YYBTYACC */
706 if (yychar < 0) yychar = YYEOF;
710 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
711 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
712 YYDEBUGSTR, yydepth, yystate, yychar, yys);
713 #ifdef YYSTYPE_TOSTRING
716 #endif /* YYBTYACC */
717 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
725 /* Do we have a conflict? */
726 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
727 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
736 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
737 YYDEBUGSTR, yydepth, yystate);
739 /* Switch to the next conflict context */
744 if (save->state != yystate) YYABORT;
751 /* Unresolved conflict - start/continue trial parse */
756 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
758 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
760 fputs("Starting trial parse.\n", stderr);
763 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
764 if (save == NULL) goto yyenomem;
765 save->save = yyps->save;
766 save->state = yystate;
767 save->errflag = yyerrflag;
768 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
769 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
770 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
771 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
772 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
773 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
774 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
777 if (yyctable[ctry] == -1)
780 if (yydebug && yychar >= YYEOF)
781 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
786 if (yyps->save == NULL)
788 /* If this is a first conflict in the stack, start saving lexemes */
791 yylexemes = (YYINT *) malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
792 if (yylexemes == NULL) goto yyenomem;
793 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
794 if (yylvals == NULL) goto yyenomem;
795 yylvlim = yylvals + YYLVQUEUEGROWTH;
796 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
797 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
798 if (yylpsns == NULL) goto yyenomem;
799 yylplim = yylpsns + YYLVQUEUEGROWTH;
804 yylvp = yylve = yylvals;
805 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
806 yylpp = yylpe = yylpsns;
812 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
815 *yylexp = (YYINT) yychar;
823 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
829 save->lexeme = (int) (yylvp - yylvals);
832 if (yytable[yyn] == ctry)
836 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
837 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
842 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
847 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
849 yystate = yyctable[ctry];
850 *++yystack.s_mark = (YYINT) yystate;
851 *++yystack.l_mark = yylval;
852 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
853 *++yystack.p_mark = yylloc;
856 if (yyerrflag > 0) --yyerrflag;
861 yyn = yyctable[ctry];
864 } /* End of code dealing with conflicts */
865 #endif /* YYBTYACC */
866 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
867 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
871 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
872 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
874 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
875 yystate = yytable[yyn];
876 *++yystack.s_mark = yytable[yyn];
877 *++yystack.l_mark = yylval;
878 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
879 *++yystack.p_mark = yylloc;
882 if (yyerrflag > 0) --yyerrflag;
885 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
886 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
891 if (yyerrflag != 0) goto yyinrecovery;
896 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
899 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
900 * before looking for error recovery */
901 yystack.s_mark -= yym;
902 yystate = *yystack.s_mark;
903 yystack.l_mark -= yym;
904 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
905 yystack.p_mark -= yym;
913 YYParseState *save = yyps->save;
916 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
917 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
918 (int)(yylvp - yylvals - yyps->save->lexeme));
920 /* Memorize most forward-looking error state in case it's really an error. */
921 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
923 /* Free old saved error context state */
924 if (yyerrctx) yyFreeState(yyerrctx);
925 /* Create and fill out new saved error context state */
926 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
927 if (yyerrctx == NULL) goto yyenomem;
928 yyerrctx->save = yyps->save;
929 yyerrctx->state = yystate;
930 yyerrctx->errflag = yyerrflag;
931 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
932 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
933 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
934 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
935 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
936 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
937 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
939 yyerrctx->lexeme = (int) (yylvp - yylvals);
941 yylvp = yylvals + save->lexeme;
942 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
943 yylpp = yylpsns + save->lexeme;
945 yylexp = yylexemes + save->lexeme;
947 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
948 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
949 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
950 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
951 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
952 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
953 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
956 yystate = save->state;
957 /* We tried shift, try reduce now */
958 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
959 yyps->save = save->save;
963 /* Nothing left on the stack -- error */
968 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
971 /* Restore state as it was in the most forward-advanced error */
972 yylvp = yylvals + yyerrctx->lexeme;
973 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
974 yylpp = yylpsns + yyerrctx->lexeme;
976 yylexp = yylexemes + yyerrctx->lexeme;
979 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
982 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
983 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
984 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
985 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
986 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
987 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
988 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
990 yystate = yyerrctx->state;
991 yyFreeState(yyerrctx);
996 if (yynewerrflag == 0) goto yyinrecovery;
997 #endif /* YYBTYACC */
999 YYERROR_CALL("syntax error");
1000 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1001 yyerror_loc_range[1] = yylloc; /* lookahead position is error start position */
1005 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1016 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1017 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1021 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1022 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1024 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1025 yystate = yytable[yyn];
1026 *++yystack.s_mark = yytable[yyn];
1027 *++yystack.l_mark = yylval;
1028 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1029 /* lookahead position is error end position */
1030 yyerror_loc_range[2] = yylloc;
1031 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1032 *++yystack.p_mark = yyloc;
1040 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1041 YYDEBUGSTR, yydepth, *yystack.s_mark);
1043 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1044 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1045 /* the current TOS position is the error start position */
1046 yyerror_loc_range[1] = *yystack.p_mark;
1048 #if defined(YYDESTRUCT_CALL)
1051 #endif /* YYBTYACC */
1052 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1053 YYDESTRUCT_CALL("error: discarding state",
1054 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1056 YYDESTRUCT_CALL("error: discarding state",
1057 yystos[*yystack.s_mark], yystack.l_mark);
1058 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1059 #endif /* defined(YYDESTRUCT_CALL) */
1062 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1070 if (yychar == YYEOF) goto yyabort;
1074 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1075 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1076 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1079 #if defined(YYDESTRUCT_CALL)
1082 #endif /* YYBTYACC */
1083 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1084 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1086 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1087 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1088 #endif /* defined(YYDESTRUCT_CALL) */
1098 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1099 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1100 #ifdef YYSTYPE_TOSTRING
1103 #endif /* YYBTYACC */
1108 for (i = yym; i > 0; i--)
1110 if (i != yym) fputs(", ", stderr);
1111 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1112 yystack.l_mark[1-i]), stderr);
1117 fputc('\n', stderr);
1121 yyval = yystack.l_mark[1-yym];
1123 memset(&yyval, 0, sizeof yyval);
1124 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1126 /* Perform position reduction */
1127 memset(&yyloc, 0, sizeof(yyloc));
1130 #endif /* YYBTYACC */
1132 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[-yym], yym);
1133 /* just in case YYERROR is invoked within the action, save
1134 the start of the rhs as the error start position */
1135 yyerror_loc_range[1] = yystack.p_mark[1-yym];
1142 #line 50 "inherit2.y"
1143 yyval.cval = yystack.l_mark[-1].cval;
1146 #line 50 "inherit2.y"
1147 yyval.tval = yystack.l_mark[-1].tval;
1150 #line 51 "inherit2.y"
1151 { yyval.nlist = yystack.l_mark[0].nlist; }
1154 #line 53 "inherit2.y"
1155 { yyval.nlist = yystack.l_mark[0].nlist; }
1158 #line 56 "inherit2.y"
1159 { yyval.cval = cGLOBAL; }
1162 #line 57 "inherit2.y"
1163 { yyval.cval = cLOCAL; }
1166 #line 60 "inherit2.y"
1167 { yyval.tval = tREAL; }
1170 #line 61 "inherit2.y"
1171 { yyval.tval = tINTEGER; }
1174 #line 65 "inherit2.y"
1175 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id);
1176 yyval.nlist->next = yystack.l_mark[-1].nlist;
1180 #line 69 "inherit2.y"
1181 { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id);
1182 yyval.nlist->next = NULL;
1186 #line 74 "inherit2.y"
1187 yyval.cval = cLOCAL;
1190 #line 75 "inherit2.y"
1191 { yyval.nlist = yystack.l_mark[0].nlist; }
1193 #line 1194 "inherit2.tab.c"
1197 yystack.s_mark -= yym;
1198 yystate = *yystack.s_mark;
1199 yystack.l_mark -= yym;
1200 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1201 yystack.p_mark -= yym;
1204 if (yystate == 0 && yym == 0)
1209 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1210 #ifdef YYSTYPE_TOSTRING
1213 #endif /* YYBTYACC */
1214 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1216 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1220 *++yystack.s_mark = YYFINAL;
1221 *++yystack.l_mark = yyval;
1222 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1223 *++yystack.p_mark = yyloc;
1231 /* we're currently re-reading tokens */
1233 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1241 /* in trial mode; save scanner results for future parse attempts */
1242 if (yylvp == yylvlim)
1243 { /* Enlarge lexical value queue */
1244 size_t p = (size_t) (yylvp - yylvals);
1245 size_t s = (size_t) (yylvlim - yylvals);
1247 s += YYLVQUEUEGROWTH;
1248 if ((yylexemes = (YYINT *)realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1250 if ((yylvals = (YYSTYPE *)realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1252 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1253 if ((yylpsns = (YYLTYPE *)realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1256 yylvp = yylve = yylvals + p;
1257 yylvlim = yylvals + s;
1258 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1259 yylpp = yylpe = yylpsns + p;
1260 yylplim = yylpsns + s;
1262 yylexp = yylexemes + p;
1264 *yylexp = (YYINT) YYLEX;
1267 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1274 /* normal operation, no conflict encountered */
1275 #endif /* YYBTYACC */
1279 #endif /* YYBTYACC */
1280 if (yychar < 0) yychar = YYEOF;
1284 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1285 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1286 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1290 if (yychar == YYEOF) goto yyaccept;
1293 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1294 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1295 yystate = yytable[yyn];
1297 yystate = yydgoto[yym];
1301 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1302 #ifdef YYSTYPE_TOSTRING
1305 #endif /* YYBTYACC */
1306 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1308 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1311 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1312 *++yystack.s_mark = (YYINT) yystate;
1313 *++yystack.l_mark = yyval;
1314 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1315 *++yystack.p_mark = yyloc;
1320 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1322 if (yypath) YYABORT;
1325 YYParseState *save = yyps->save;
1326 yyps->save = save->save;
1327 save->save = yypath;
1332 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1333 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1337 yyFreeState(yyerrctx);
1340 yylvp = yylvals + yypath->lexeme;
1341 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1342 yylpp = yylpsns + yypath->lexeme;
1344 yylexp = yylexemes + yypath->lexeme;
1346 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1347 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1348 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1349 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1350 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1351 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1352 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1354 yystate = yypath->state;
1356 #endif /* YYBTYACC */
1359 YYERROR_CALL("yacc stack overflow");
1363 YYERROR_CALL("memory exhausted");
1365 #endif /* YYBTYACC */
1375 if (yyps->save) goto yyvalid;
1376 #endif /* YYBTYACC */
1380 #if defined(YYDESTRUCT_CALL)
1381 if (yychar != YYEOF && yychar != YYEMPTY)
1382 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1383 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1385 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1386 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1390 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1393 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1394 YYDESTRUCT_CALL("cleanup: discarding state",
1395 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1397 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1398 YYDESTRUCT_CALL("cleanup: discarding state",
1399 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1400 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1402 #endif /* defined(YYDESTRUCT_CALL) */
1407 yyFreeState(yyerrctx);
1412 YYParseState *save = yyps;
1419 YYParseState *save = yypath;
1420 yypath = save->save;
1424 #endif /* YYBTYACC */
1425 yyfreestack(&yystack);