1 /* original parser id follows */
2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */
3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */
8 #define YYCHECK "yyyymmdd"
11 #define yyclearin (yychar = YYEMPTY)
12 #define yyerrok (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
18 #define YYDEBUGSTR YYPREFIX "debug"
21 #define yyparse err_inherit3_parse
25 #define yylex err_inherit3_lex
29 #define yyerror err_inherit3_error
33 #define yychar err_inherit3_char
37 #define yyval err_inherit3_val
41 #define yylval err_inherit3_lval
45 #define yydebug err_inherit3_debug
49 #define yynerrs err_inherit3_nerrs
53 #define yyerrflag err_inherit3_errflag
54 #endif /* yyerrflag */
57 #define yylhs err_inherit3_lhs
61 #define yylen err_inherit3_len
65 #define yydefred err_inherit3_defred
69 #define yystos err_inherit3_stos
73 #define yydgoto err_inherit3_dgoto
77 #define yysindex err_inherit3_sindex
81 #define yyrindex err_inherit3_rindex
85 #define yygindex err_inherit3_gindex
89 #define yytable err_inherit3_table
93 #define yycheck err_inherit3_check
97 #define yyname err_inherit3_name
101 #define yyrule err_inherit3_rule
107 #define yycindex err_inherit3_cindex
108 #endif /* yycindex */
111 #define yyctable err_inherit3_ctable
112 #endif /* yyctable */
114 #endif /* YYBTYACC */
116 #define YYPREFIX "err_inherit3_"
120 #line 2 "err_inherit3.y"
123 typedef enum {cGLOBAL, cLOCAL} class;
124 typedef enum {tREAL, tINTEGER} type;
127 struct symbol { class c; type t; name id; };
128 typedef struct symbol symbol;
130 struct namelist { symbol *s; struct namelist *next; };
131 typedef struct namelist namelist;
133 extern symbol *mksymbol(type t, class c, name id);
136 #define YYLEX_DECL() yylex(void)
137 #define YYERROR_DECL() yyerror(const char *s)
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 "err_inherit3.y"
153 #endif /* !YYSTYPE_IS_DECLARED */
154 #line 155 "err_inherit3.tab.c"
156 /* compatibility with bison */
158 /* compatibility with FreeBSD */
159 # ifdef YYPARSE_PARAM_TYPE
160 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
162 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
165 # define YYPARSE_DECL() yyparse(void)
168 /* Parameters sent to lex. */
170 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
171 # define YYLEX yylex(YYLEX_PARAM)
173 # define YYLEX_DECL() yylex(void)
174 # define YYLEX yylex()
177 /* Parameters sent to yyerror. */
179 #define YYERROR_DECL() yyerror(const char *s)
182 #define YYERROR_CALL(msg) yyerror(msg)
185 #ifndef YYDESTRUCT_DECL
186 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val)
188 #ifndef YYDESTRUCT_CALL
189 #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val)
192 extern int YYPARSE_DECL();
199 #define YYERRCODE 256
201 static const YYINT err_inherit3_lhs[] = { -1,
202 5, 6, 0, 0, 3, 3, 4, 4, 7, 1,
205 static const YYINT err_inherit3_len[] = { 2,
206 0, 0, 5, 2, 1, 1, 1, 1, 0, 3,
209 static const YYINT err_inherit3_defred[] = { 0,
210 5, 6, 7, 8, 0, 0, 12, 1, 4, 2,
211 2, 0, 0, 11, 13, 0, 3, 0, 10,
213 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)
214 static const YYINT err_inherit3_stos[] = { 0,
215 257, 258, 259, 260, 263, 266, 267, 267, 265, 271,
216 268, 269, 269, 261, 264, 270, 264, 264, 261,
218 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */
219 static const YYINT err_inherit3_dgoto[] = { 5,
220 15, 9, 6, 7, 11, 12, 16, 10,
222 static const YYINT err_inherit3_sindex[] = { -257,
223 0, 0, 0, 0, 0, -254, 0, 0, 0, 0,
224 0, -253, -253, 0, 0, -253, 0, -252, 0,
226 static const YYINT err_inherit3_rindex[] = { 0,
227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
228 0, 0, 0, 0, 0, 0, 0, 0, 0,
231 static const YYINT err_inherit3_cindex[] = { 0,
232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
233 0, 0, 0, 0, 0, 0, 0, 0, 0,
236 static const YYINT err_inherit3_gindex[] = { 0,
237 -9, 0, 0, 4, 0, 1, 0, 0,
239 #define YYTABLESIZE 12
240 static const YYINT err_inherit3_table[] = { 1,
241 2, 3, 4, 17, 3, 4, 18, 14, 19, 8,
244 static const YYINT err_inherit3_check[] = { 257,
245 258, 259, 260, 13, 259, 260, 16, 261, 261, 6,
249 static const YYINT err_inherit3_ctable[] = { -1,
250 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
258 #define YYMAXTOKEN 261
259 #define YYUNDFTOKEN 272
260 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
262 static const char *const err_inherit3_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","$$4","illegal-symbol",
274 static const char *const err_inherit3_rule[] = {
275 "$accept : declaration",
278 "declaration : class type $$1 $$2 namelist",
279 "declaration : type locnamelist",
285 "namelist : $$3 namelist NAME",
288 "locnamelist : $$4 $$2 namelist",
300 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
301 YYLTYPE yyloc; /* position returned by actions */
302 YYLTYPE yylloc; /* position from the lexer */
305 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
306 #ifndef YYLLOC_DEFAULT
307 #define YYLLOC_DEFAULT(loc, rhs, n) \
312 (loc).first_line = ((rhs)[-1]).last_line; \
313 (loc).first_column = ((rhs)[-1]).last_column; \
314 (loc).last_line = ((rhs)[-1]).last_line; \
315 (loc).last_column = ((rhs)[-1]).last_column; \
319 (loc).first_line = ((rhs)[ 0 ]).first_line; \
320 (loc).first_column = ((rhs)[ 0 ]).first_column; \
321 (loc).last_line = ((rhs)[n-1]).last_line; \
322 (loc).last_column = ((rhs)[n-1]).last_column; \
325 #endif /* YYLLOC_DEFAULT */
326 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
329 #ifndef YYLVQUEUEGROWTH
330 #define YYLVQUEUEGROWTH 32
332 #endif /* YYBTYACC */
334 /* define the initial stack-sizes */
337 #define YYMAXDEPTH YYSTACKSIZE
340 #define YYSTACKSIZE YYMAXDEPTH
342 #define YYSTACKSIZE 10000
343 #define YYMAXDEPTH 10000
347 #ifndef YYINITSTACKSIZE
348 #define YYINITSTACKSIZE 200
358 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
365 struct YYParseState_s
367 struct YYParseState_s *save; /* Previously saved parser state */
368 YYSTACKDATA yystack; /* saved parser stack */
369 int state; /* saved parser state */
370 int errflag; /* saved error recovery status */
371 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
372 YYINT ctry; /* saved index in yyctable[] for this conflict */
374 typedef struct YYParseState_s YYParseState;
375 #endif /* YYBTYACC */
376 /* variables for the parser stack */
377 static YYSTACKDATA yystack;
380 /* Current parser state */
381 static YYParseState *yyps = 0;
383 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
384 static YYParseState *yypath = 0;
386 /* Base of the lexical value queue */
387 static YYSTYPE *yylvals = 0;
389 /* Current position at lexical value queue */
390 static YYSTYPE *yylvp = 0;
392 /* End position of lexical value queue */
393 static YYSTYPE *yylve = 0;
395 /* The last allocated position at the lexical value queue */
396 static YYSTYPE *yylvlim = 0;
398 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
399 /* Base of the lexical position queue */
400 static YYLTYPE *yylpsns = 0;
402 /* Current position at lexical position queue */
403 static YYLTYPE *yylpp = 0;
405 /* End position of lexical position queue */
406 static YYLTYPE *yylpe = 0;
408 /* The last allocated position at the lexical position queue */
409 static YYLTYPE *yylplim = 0;
412 /* Current position at lexical token queue */
413 static YYINT *yylexp = 0;
415 static YYINT *yylexemes = 0;
416 #endif /* YYBTYACC */
417 #line 78 "err_inherit3.y"
419 extern int YYLEX_DECL();
420 extern void YYERROR_DECL();
421 #line 422 "err_inherit3.tab.c"
423 /* Release memory associated with symbol. */
424 #if ! defined YYDESTRUCT_IS_DECLARED
431 #line 30 "err_inherit3.y"
433 namelist *p = (*val).nlist;
437 free(pp->s); free(pp);
441 #line 442 "err_inherit3.tab.c"
443 #line 30 "err_inherit3.y"
445 namelist *p = (*val).nlist;
449 free(pp->s); free(pp);
453 #line 454 "err_inherit3.tab.c"
455 #line 30 "err_inherit3.y"
457 namelist *p = (*val).nlist;
461 free(pp->s); free(pp);
465 #line 466 "err_inherit3.tab.c"
468 #define YYDESTRUCT_IS_DECLARED 1
471 /* For use in generated program */
472 #define yydepth (int)(yystack.s_mark - yystack.s_base)
474 #define yytrial (yyps->save)
475 #endif /* YYBTYACC */
478 #include <stdio.h> /* needed for printf */
481 #include <stdlib.h> /* needed for malloc, etc */
482 #include <string.h> /* needed for memset */
484 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
485 static int yygrowstack(YYSTACKDATA *data)
491 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
495 if ((newsize = data->stacksize) == 0)
496 newsize = YYINITSTACKSIZE;
497 else if (newsize >= YYMAXDEPTH)
499 else if ((newsize *= 2) > YYMAXDEPTH)
500 newsize = YYMAXDEPTH;
502 i = (int) (data->s_mark - data->s_base);
503 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss));
507 data->s_base = newss;
508 data->s_mark = newss + i;
510 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
514 data->l_base = newvs;
515 data->l_mark = newvs + i;
517 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
518 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
522 data->p_base = newps;
523 data->p_mark = newps + i;
526 data->stacksize = newsize;
527 data->s_last = data->s_base + newsize - 1;
531 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
536 #if YYPURE || defined(YY_NO_LEAKS)
537 static void yyfreestack(YYSTACKDATA *data)
541 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
544 memset(data, 0, sizeof(*data));
547 #define yyfreestack(data) /* nothing */
548 #endif /* YYPURE || defined(YY_NO_LEAKS) */
551 static YYParseState *
552 yyNewState(unsigned size)
554 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
555 if (p == NULL) return NULL;
557 p->yystack.stacksize = size;
560 p->yystack.s_base = NULL;
561 p->yystack.l_base = NULL;
562 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
563 p->yystack.p_base = NULL;
567 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT));
568 if (p->yystack.s_base == NULL) return NULL;
569 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
570 if (p->yystack.l_base == NULL) return NULL;
571 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
572 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
573 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
574 if (p->yystack.p_base == NULL) return NULL;
575 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
582 yyFreeState(YYParseState *p)
584 yyfreestack(&p->yystack);
587 #endif /* YYBTYACC */
589 #define YYABORT goto yyabort
590 #define YYREJECT goto yyabort
591 #define YYACCEPT goto yyaccept
592 #define YYERROR goto yyerrlab
594 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
595 #define YYVALID_NESTED do { if (yyps->save && \
596 yyps->save->save == 0) goto yyvalid; } while(0)
597 #endif /* YYBTYACC */
602 int yym, yyn, yystate, yyresult;
605 YYParseState *yyerrctx = NULL;
606 #endif /* YYBTYACC */
607 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
608 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
613 if ((yys = getenv("YYDEBUG")) != 0)
616 if (yyn >= '0' && yyn <= '9')
620 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
624 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
626 #endif /* YYBTYACC */
635 memset(&yystack, 0, sizeof(yystack));
638 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
639 yystack.s_mark = yystack.s_base;
640 yystack.l_mark = yystack.l_base;
641 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
642 yystack.p_mark = yystack.p_base;
648 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
655 /* we're currently re-reading tokens */
657 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
665 /* in trial mode; save scanner results for future parse attempts */
666 if (yylvp == yylvlim)
667 { /* Enlarge lexical value queue */
668 size_t p = (size_t) (yylvp - yylvals);
669 size_t s = (size_t) (yylvlim - yylvals);
671 s += YYLVQUEUEGROWTH;
672 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
673 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
674 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
675 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
677 yylvp = yylve = yylvals + p;
678 yylvlim = yylvals + s;
679 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
680 yylpp = yylpe = yylpsns + p;
681 yylplim = yylpsns + s;
683 yylexp = yylexemes + p;
685 *yylexp = (YYINT) YYLEX;
688 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
695 /* normal operation, no conflict encountered */
696 #endif /* YYBTYACC */
700 #endif /* YYBTYACC */
701 if (yychar < 0) yychar = YYEOF;
705 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
706 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
707 YYDEBUGSTR, yydepth, yystate, yychar, yys);
708 #ifdef YYSTYPE_TOSTRING
711 #endif /* YYBTYACC */
712 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
720 /* Do we have a conflict? */
721 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
722 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
731 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
732 YYDEBUGSTR, yydepth, yystate);
734 /* Switch to the next conflict context */
739 if (save->state != yystate) YYABORT;
746 /* Unresolved conflict - start/continue trial parse */
751 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
753 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
755 fputs("Starting trial parse.\n", stderr);
758 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
759 if (save == NULL) goto yyenomem;
760 save->save = yyps->save;
761 save->state = yystate;
762 save->errflag = yyerrflag;
763 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
764 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
765 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
766 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
767 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
768 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
769 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
772 if (yyctable[ctry] == -1)
775 if (yydebug && yychar >= YYEOF)
776 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
781 if (yyps->save == NULL)
783 /* If this is a first conflict in the stack, start saving lexemes */
786 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
787 if (yylexemes == NULL) goto yyenomem;
788 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
789 if (yylvals == NULL) goto yyenomem;
790 yylvlim = yylvals + YYLVQUEUEGROWTH;
791 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
792 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
793 if (yylpsns == NULL) goto yyenomem;
794 yylplim = yylpsns + YYLVQUEUEGROWTH;
799 yylvp = yylve = yylvals;
800 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
801 yylpp = yylpe = yylpsns;
807 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
810 *yylexp = (YYINT) yychar;
818 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
824 save->lexeme = (int) (yylvp - yylvals);
827 if (yytable[yyn] == ctry)
831 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
832 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
837 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
842 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
844 yystate = yyctable[ctry];
845 *++yystack.s_mark = (YYINT) yystate;
846 *++yystack.l_mark = yylval;
847 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
848 *++yystack.p_mark = yylloc;
851 if (yyerrflag > 0) --yyerrflag;
856 yyn = yyctable[ctry];
859 } /* End of code dealing with conflicts */
860 #endif /* YYBTYACC */
861 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
862 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
866 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
867 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
869 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
870 yystate = yytable[yyn];
871 *++yystack.s_mark = yytable[yyn];
872 *++yystack.l_mark = yylval;
873 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
874 *++yystack.p_mark = yylloc;
877 if (yyerrflag > 0) --yyerrflag;
880 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
881 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
886 if (yyerrflag != 0) goto yyinrecovery;
891 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
894 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
895 * before looking for error recovery */
896 yystack.s_mark -= yym;
897 yystate = *yystack.s_mark;
898 yystack.l_mark -= yym;
899 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
900 yystack.p_mark -= yym;
908 YYParseState *save = yyps->save;
911 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
912 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
913 (int)(yylvp - yylvals - yyps->save->lexeme));
915 /* Memorize most forward-looking error state in case it's really an error. */
916 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
918 /* Free old saved error context state */
919 if (yyerrctx) yyFreeState(yyerrctx);
920 /* Create and fill out new saved error context state */
921 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
922 if (yyerrctx == NULL) goto yyenomem;
923 yyerrctx->save = yyps->save;
924 yyerrctx->state = yystate;
925 yyerrctx->errflag = yyerrflag;
926 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
927 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
928 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
929 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
930 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
931 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
932 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
934 yyerrctx->lexeme = (int) (yylvp - yylvals);
936 yylvp = yylvals + save->lexeme;
937 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
938 yylpp = yylpsns + save->lexeme;
940 yylexp = yylexemes + save->lexeme;
942 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
943 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
944 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
945 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
946 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
947 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
948 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
951 yystate = save->state;
952 /* We tried shift, try reduce now */
953 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
954 yyps->save = save->save;
958 /* Nothing left on the stack -- error */
963 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
966 /* Restore state as it was in the most forward-advanced error */
967 yylvp = yylvals + yyerrctx->lexeme;
968 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
969 yylpp = yylpsns + yyerrctx->lexeme;
971 yylexp = yylexemes + yyerrctx->lexeme;
974 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
977 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
978 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
979 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
980 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
981 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
982 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
983 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
985 yystate = yyerrctx->state;
986 yyFreeState(yyerrctx);
991 if (yynewerrflag == 0) goto yyinrecovery;
992 #endif /* YYBTYACC */
994 YYERROR_CALL("syntax error");
995 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
996 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1000 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1011 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1012 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1016 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1017 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1019 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1020 yystate = yytable[yyn];
1021 *++yystack.s_mark = yytable[yyn];
1022 *++yystack.l_mark = yylval;
1023 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1024 /* lookahead position is error end position */
1025 yyerror_loc_range[1] = yylloc;
1026 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1027 *++yystack.p_mark = yyloc;
1035 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1036 YYDEBUGSTR, yydepth, *yystack.s_mark);
1038 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1039 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1040 /* the current TOS position is the error start position */
1041 yyerror_loc_range[0] = *yystack.p_mark;
1043 #if defined(YYDESTRUCT_CALL)
1046 #endif /* YYBTYACC */
1047 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1048 YYDESTRUCT_CALL("error: discarding state",
1049 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1051 YYDESTRUCT_CALL("error: discarding state",
1052 yystos[*yystack.s_mark], yystack.l_mark);
1053 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1054 #endif /* defined(YYDESTRUCT_CALL) */
1057 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1065 if (yychar == YYEOF) goto yyabort;
1069 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1070 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1071 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1074 #if defined(YYDESTRUCT_CALL)
1077 #endif /* YYBTYACC */
1078 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1079 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1081 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1082 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1083 #endif /* defined(YYDESTRUCT_CALL) */
1093 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1094 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1095 #ifdef YYSTYPE_TOSTRING
1098 #endif /* YYBTYACC */
1103 for (i = yym; i > 0; i--)
1105 if (i != yym) fputs(", ", stderr);
1106 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1107 yystack.l_mark[1-i]), stderr);
1112 fputc('\n', stderr);
1116 yyval = yystack.l_mark[1-yym];
1118 memset(&yyval, 0, sizeof yyval);
1119 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1121 /* Perform position reduction */
1122 memset(&yyloc, 0, sizeof(yyloc));
1125 #endif /* YYBTYACC */
1127 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1128 /* just in case YYERROR is invoked within the action, save
1129 the start of the rhs as the error start position */
1130 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1137 #line 50 "err_inherit3.y"
1138 yyval.cval = yystack.l_mark[-1].cval;
1141 #line 50 "err_inherit3.y"
1142 yyval.tval = yystack.l_mark[-1].tval;
1145 #line 51 "err_inherit3.y"
1146 { yyval.nlist = yystack.l_mark[0].nlist; }
1149 #line 53 "err_inherit3.y"
1150 { yyval.nlist = yystack.l_mark[0].nlist; }
1153 #line 56 "err_inherit3.y"
1154 { yyval.cval = cGLOBAL; }
1157 #line 57 "err_inherit3.y"
1158 { yyval.cval = cLOCAL; }
1161 #line 60 "err_inherit3.y"
1162 { yyval.tval = tREAL; }
1165 #line 61 "err_inherit3.y"
1166 { yyval.tval = tINTEGER; }
1169 #line 64 "err_inherit3.y"
1170 yyval.cval = yystack.l_mark[-2];
1173 #line 65 "err_inherit3.y"
1174 { yyval.nlist->s = mksymbol(yystack.l_mark[-5].tval, yystack.l_mark[-5].cval, yystack.l_mark[0].id);
1175 yyval.nlist->next = yystack.l_mark[-1].nlist;
1179 #line 69 "err_inherit3.y"
1180 { yyval.nlist->s = mksymbol(yystack.l_mark[-3], yystack.l_mark[-3], yystack.l_mark[0].id);
1181 yyval.nlist->next = NULL;
1185 #line 74 "err_inherit3.y"
1186 yyval.cval = cLOCAL;
1189 #line 75 "err_inherit3.y"
1190 { yyval.nlist = yystack.l_mark[0].nlist; }
1192 #line 1193 "err_inherit3.tab.c"
1196 yystack.s_mark -= yym;
1197 yystate = *yystack.s_mark;
1198 yystack.l_mark -= yym;
1199 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1200 yystack.p_mark -= yym;
1203 if (yystate == 0 && yym == 0)
1208 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1209 #ifdef YYSTYPE_TOSTRING
1212 #endif /* YYBTYACC */
1213 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1215 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1219 *++yystack.s_mark = YYFINAL;
1220 *++yystack.l_mark = yyval;
1221 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1222 *++yystack.p_mark = yyloc;
1230 /* we're currently re-reading tokens */
1232 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1240 /* in trial mode; save scanner results for future parse attempts */
1241 if (yylvp == yylvlim)
1242 { /* Enlarge lexical value queue */
1243 size_t p = (size_t) (yylvp - yylvals);
1244 size_t s = (size_t) (yylvlim - yylvals);
1246 s += YYLVQUEUEGROWTH;
1247 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1249 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1251 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1252 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1255 yylvp = yylve = yylvals + p;
1256 yylvlim = yylvals + s;
1257 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1258 yylpp = yylpe = yylpsns + p;
1259 yylplim = yylpsns + s;
1261 yylexp = yylexemes + p;
1263 *yylexp = (YYINT) YYLEX;
1266 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1273 /* normal operation, no conflict encountered */
1274 #endif /* YYBTYACC */
1278 #endif /* YYBTYACC */
1279 if (yychar < 0) yychar = YYEOF;
1283 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1284 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1285 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1289 if (yychar == YYEOF) goto yyaccept;
1292 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1293 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1294 yystate = yytable[yyn];
1296 yystate = yydgoto[yym];
1300 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1301 #ifdef YYSTYPE_TOSTRING
1304 #endif /* YYBTYACC */
1305 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1307 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1310 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1311 *++yystack.s_mark = (YYINT) yystate;
1312 *++yystack.l_mark = yyval;
1313 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1314 *++yystack.p_mark = yyloc;
1319 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1321 if (yypath) YYABORT;
1324 YYParseState *save = yyps->save;
1325 yyps->save = save->save;
1326 save->save = yypath;
1331 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1332 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1336 yyFreeState(yyerrctx);
1339 yylvp = yylvals + yypath->lexeme;
1340 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1341 yylpp = yylpsns + yypath->lexeme;
1343 yylexp = yylexemes + yypath->lexeme;
1345 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1346 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1347 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1348 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1349 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1350 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1351 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1353 yystate = yypath->state;
1355 #endif /* YYBTYACC */
1358 YYERROR_CALL("yacc stack overflow");
1362 YYERROR_CALL("memory exhausted");
1364 #endif /* YYBTYACC */
1374 if (yyps->save) goto yyvalid;
1375 #endif /* YYBTYACC */
1379 #if defined(YYDESTRUCT_CALL)
1380 if (yychar != YYEOF && yychar != YYEMPTY)
1381 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1382 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1384 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1385 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1389 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1392 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1393 YYDESTRUCT_CALL("cleanup: discarding state",
1394 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1396 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1397 YYDESTRUCT_CALL("cleanup: discarding state",
1398 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1399 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1401 #endif /* defined(YYDESTRUCT_CALL) */
1406 yyFreeState(yyerrctx);
1411 YYParseState *save = yyps;
1418 YYParseState *save = yypath;
1419 yypath = save->save;
1423 #endif /* YYBTYACC */
1424 yyfreestack(&yystack);