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)
139 #line 39 "err_inherit3.y"
141 #undef YYSTYPE_IS_DECLARED
142 #define YYSTYPE_IS_DECLARED 1
144 #ifndef YYSTYPE_IS_DECLARED
145 #define YYSTYPE_IS_DECLARED 1
153 #endif /* !YYSTYPE_IS_DECLARED */
154 #line 155 "err_inherit3.tab.c"
156 /* compatibility with bison */
158 /* compatibility with FreeBSD */
159 # ifdef YYPARSE_PARAM_TYPE
160 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
162 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
165 # define YYPARSE_DECL() yyparse(void)
168 /* Parameters sent to lex. */
170 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
171 # define YYLEX yylex(YYLEX_PARAM)
173 # define YYLEX_DECL() yylex(void)
174 # define YYLEX yylex()
177 /* Parameters sent to yyerror. */
179 #define YYERROR_DECL() yyerror(const char *s)
182 #define YYERROR_CALL(msg) yyerror(msg)
185 #ifndef YYDESTRUCT_DECL
186 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val)
188 #ifndef YYDESTRUCT_CALL
189 #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val)
192 extern int YYPARSE_DECL();
199 #define YYERRCODE 256
201 static const YYINT err_inherit3_lhs[] = { -1,
202 5, 6, 0, 7, 0, 3, 3, 4, 4, 8,
205 static const YYINT err_inherit3_len[] = { 2,
206 0, 0, 5, 0, 3, 1, 1, 1, 1, 0,
209 static const YYINT err_inherit3_defred[] = { 0,
210 6, 7, 8, 9, 0, 0, 4, 1, 13, 2,
211 5, 2, 0, 0, 12, 3, 0, 14, 0, 11,
213 static const YYINT err_inherit3_stos[] = { 0,
214 257, 258, 259, 260, 263, 266, 267, 267, 270, 268,
215 265, 272, 269, 269, 261, 264, 271, 264, 264, 261,
217 static const YYINT err_inherit3_dgoto[] = { 5,
218 16, 11, 6, 7, 10, 13, 9, 17, 12,
220 static const YYINT err_inherit3_sindex[] = { -257,
221 0, 0, 0, 0, 0, -254, 0, 0, 0, 0,
222 0, 0, -253, -253, 0, 0, -253, 0, -252, 0,
224 static const YYINT err_inherit3_rindex[] = { 0,
225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
226 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
229 static const YYINT err_inherit3_cindex[] = { 0,
230 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
231 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
234 static const YYINT err_inherit3_gindex[] = { 0,
235 -10, 0, 0, 4, 0, -1, 0, 0, 0,
237 #define YYTABLESIZE 11
238 static const YYINT err_inherit3_table[] = { 1,
239 2, 3, 4, 18, 3, 4, 19, 15, 20, 8,
242 static const YYINT err_inherit3_check[] = { 257,
243 258, 259, 260, 14, 259, 260, 17, 261, 261, 6,
250 #define YYMAXTOKEN 261
251 #define YYUNDFTOKEN 273
252 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
254 static const char *const err_inherit3_name[] = {
256 "$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,
257 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
258 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
259 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
260 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
261 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
262 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER",
263 "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1",
264 "$$2","$$3","$$4","$$5","illegal-symbol",
266 static const char *const err_inherit3_rule[] = {
267 "$accept : declaration",
270 "declaration : class type $$1 $$2 namelist",
272 "declaration : type $$3 locnamelist",
278 "namelist : $$4 namelist NAME",
281 "locnamelist : $$5 $$2 namelist",
293 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
294 YYLTYPE yyloc; /* position returned by actions */
295 YYLTYPE yylloc; /* position from the lexer */
298 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
299 #ifndef YYLLOC_DEFAULT
300 #define YYLLOC_DEFAULT(loc, rhs, n) \
305 (loc).first_line = ((rhs)[-1]).last_line; \
306 (loc).first_column = ((rhs)[-1]).last_column; \
307 (loc).last_line = ((rhs)[-1]).last_line; \
308 (loc).last_column = ((rhs)[-1]).last_column; \
312 (loc).first_line = ((rhs)[ 0 ]).first_line; \
313 (loc).first_column = ((rhs)[ 0 ]).first_column; \
314 (loc).last_line = ((rhs)[n-1]).last_line; \
315 (loc).last_column = ((rhs)[n-1]).last_column; \
318 #endif /* YYLLOC_DEFAULT */
319 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
322 #ifndef YYLVQUEUEGROWTH
323 #define YYLVQUEUEGROWTH 32
325 #endif /* YYBTYACC */
327 /* define the initial stack-sizes */
330 #define YYMAXDEPTH YYSTACKSIZE
333 #define YYSTACKSIZE YYMAXDEPTH
335 #define YYSTACKSIZE 10000
336 #define YYMAXDEPTH 10000
340 #ifndef YYINITSTACKSIZE
341 #define YYINITSTACKSIZE 200
351 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
358 struct YYParseState_s
360 struct YYParseState_s *save; /* Previously saved parser state */
361 YYSTACKDATA yystack; /* saved parser stack */
362 int state; /* saved parser state */
363 int errflag; /* saved error recovery status */
364 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
365 YYINT ctry; /* saved index in yyctable[] for this conflict */
367 typedef struct YYParseState_s YYParseState;
368 #endif /* YYBTYACC */
369 /* variables for the parser stack */
370 static YYSTACKDATA yystack;
373 /* Current parser state */
374 static YYParseState *yyps = 0;
376 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
377 static YYParseState *yypath = 0;
379 /* Base of the lexical value queue */
380 static YYSTYPE *yylvals = 0;
382 /* Current position at lexical value queue */
383 static YYSTYPE *yylvp = 0;
385 /* End position of lexical value queue */
386 static YYSTYPE *yylve = 0;
388 /* The last allocated position at the lexical value queue */
389 static YYSTYPE *yylvlim = 0;
391 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
392 /* Base of the lexical position queue */
393 static YYLTYPE *yylpsns = 0;
395 /* Current position at lexical position queue */
396 static YYLTYPE *yylpp = 0;
398 /* End position of lexical position queue */
399 static YYLTYPE *yylpe = 0;
401 /* The last allocated position at the lexical position queue */
402 static YYLTYPE *yylplim = 0;
405 /* Current position at lexical token queue */
406 static short *yylexp = 0;
408 static short *yylexemes = 0;
409 #endif /* YYBTYACC */
410 #line 78 "err_inherit3.y"
412 extern int YYLEX_DECL();
413 extern void YYERROR_DECL();
414 #line 415 "err_inherit3.tab.c"
416 /* Release memory associated with symbol. */
417 #if ! defined YYDESTRUCT_IS_DECLARED
424 #line 30 "err_inherit3.y"
426 namelist *p = (*val).nlist;
430 free(pp->s); free(pp);
434 #line 435 "err_inherit3.tab.c"
436 #line 30 "err_inherit3.y"
438 namelist *p = (*val).nlist;
442 free(pp->s); free(pp);
446 #line 447 "err_inherit3.tab.c"
448 #line 30 "err_inherit3.y"
450 namelist *p = (*val).nlist;
454 free(pp->s); free(pp);
458 #line 459 "err_inherit3.tab.c"
461 #define YYDESTRUCT_IS_DECLARED 1
464 /* For use in generated program */
465 #define yydepth (int)(yystack.s_mark - yystack.s_base)
467 #define yytrial (yyps->save)
468 #endif /* YYBTYACC */
471 #include <stdio.h> /* needed for printf */
474 #include <stdlib.h> /* needed for malloc, etc */
475 #include <string.h> /* needed for memset */
477 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
478 static int yygrowstack(YYSTACKDATA *data)
484 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
488 if ((newsize = data->stacksize) == 0)
489 newsize = YYINITSTACKSIZE;
490 else if (newsize >= YYMAXDEPTH)
492 else if ((newsize *= 2) > YYMAXDEPTH)
493 newsize = YYMAXDEPTH;
495 i = (int) (data->s_mark - data->s_base);
496 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
500 data->s_base = newss;
501 data->s_mark = newss + i;
503 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
507 data->l_base = newvs;
508 data->l_mark = newvs + i;
510 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
511 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
515 data->p_base = newps;
516 data->p_mark = newps + i;
519 data->stacksize = newsize;
520 data->s_last = data->s_base + newsize - 1;
524 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
529 #if YYPURE || defined(YY_NO_LEAKS)
530 static void yyfreestack(YYSTACKDATA *data)
534 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
537 memset(data, 0, sizeof(*data));
540 #define yyfreestack(data) /* nothing */
541 #endif /* YYPURE || defined(YY_NO_LEAKS) */
544 static YYParseState *
545 yyNewState(unsigned size)
547 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
548 if (p == NULL) return NULL;
550 p->yystack.stacksize = size;
553 p->yystack.s_base = NULL;
554 p->yystack.l_base = NULL;
555 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
556 p->yystack.p_base = NULL;
560 p->yystack.s_base = (short *) malloc(size * sizeof(short));
561 if (p->yystack.s_base == NULL) return NULL;
562 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
563 if (p->yystack.l_base == NULL) return NULL;
564 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
565 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
566 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
567 if (p->yystack.p_base == NULL) return NULL;
568 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
575 yyFreeState(YYParseState *p)
577 yyfreestack(&p->yystack);
580 #endif /* YYBTYACC */
582 #define YYABORT goto yyabort
583 #define YYREJECT goto yyabort
584 #define YYACCEPT goto yyaccept
585 #define YYERROR goto yyerrlab
587 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
588 #define YYVALID_NESTED do { if (yyps->save && \
589 yyps->save->save == 0) goto yyvalid; } while(0)
590 #endif /* YYBTYACC */
595 int yym, yyn, yystate, yyresult;
598 YYParseState *yyerrctx = NULL;
599 #endif /* YYBTYACC */
600 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
601 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
606 if ((yys = getenv("YYDEBUG")) != 0)
609 if (yyn >= '0' && yyn <= '9')
613 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
617 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
619 #endif /* YYBTYACC */
626 memset(&yystack, 0, sizeof(yystack));
629 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
630 yystack.s_mark = yystack.s_base;
631 yystack.l_mark = yystack.l_base;
632 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
633 yystack.p_mark = yystack.p_base;
639 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
646 /* we're currently re-reading tokens */
648 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
656 /* in trial mode; save scanner results for future parse attempts */
657 if (yylvp == yylvlim)
658 { /* Enlarge lexical value queue */
659 int p = yylvp - yylvals;
660 int s = yylvlim - yylvals;
662 s += YYLVQUEUEGROWTH;
663 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
664 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
665 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
666 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
668 yylvp = yylve = yylvals + p;
669 yylvlim = yylvals + s;
670 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
671 yylpp = yylpe = yylpsns + p;
672 yylplim = yylpsns + s;
674 yylexp = yylexemes + p;
676 *yylexp = (short) YYLEX;
679 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
686 /* normal operation, no conflict encountered */
687 #endif /* YYBTYACC */
691 #endif /* YYBTYACC */
692 if (yychar < 0) yychar = YYEOF;
693 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
697 yys = yyname[YYTRANSLATE(yychar)];
698 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
699 YYDEBUGSTR, yydepth, yystate, yychar, yys);
700 #ifdef YYSTYPE_TOSTRING
703 #endif /* YYBTYACC */
704 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
712 /* Do we have a conflict? */
713 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
714 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
723 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
724 YYDEBUGSTR, yydepth, yystate);
726 /* Switch to the next conflict context */
731 if (save->state != yystate) YYABORT;
738 /* Unresolved conflict - start/continue trial parse */
743 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
745 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
747 fputs("Starting trial parse.\n", stderr);
750 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
751 if (save == NULL) goto yyenomem;
752 save->save = yyps->save;
753 save->state = yystate;
754 save->errflag = yyerrflag;
755 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
756 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
757 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
758 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
759 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
760 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
761 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
764 if (yyctable[ctry] == -1)
767 if (yydebug && yychar >= YYEOF)
768 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
773 if (yyps->save == NULL)
775 /* If this is a first conflict in the stack, start saving lexemes */
778 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
779 if (yylexemes == NULL) goto yyenomem;
780 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
781 if (yylvals == NULL) goto yyenomem;
782 yylvlim = yylvals + YYLVQUEUEGROWTH;
783 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
784 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
785 if (yylpsns == NULL) goto yyenomem;
786 yylplim = yylpsns + YYLVQUEUEGROWTH;
791 yylvp = yylve = yylvals;
792 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
793 yylpp = yylpe = yylpsns;
799 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
802 *yylexp = (short) yychar;
810 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
816 save->lexeme = yylvp - yylvals;
819 if (yytable[yyn] == ctry)
823 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
824 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
829 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
834 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
836 yystate = yyctable[ctry];
837 *++yystack.s_mark = (short) yystate;
838 *++yystack.l_mark = yylval;
839 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
840 *++yystack.p_mark = yylloc;
843 if (yyerrflag > 0) --yyerrflag;
848 yyn = yyctable[ctry];
851 } /* End of code dealing with conflicts */
852 #endif /* YYBTYACC */
853 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
854 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
858 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
859 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
861 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
862 yystate = yytable[yyn];
863 *++yystack.s_mark = yytable[yyn];
864 *++yystack.l_mark = yylval;
865 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
866 *++yystack.p_mark = yylloc;
869 if (yyerrflag > 0) --yyerrflag;
872 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
873 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
878 if (yyerrflag != 0) goto yyinrecovery;
891 YYParseState *save = yyps->save;
894 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
895 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
896 (int)(yylvp - yylvals - yyps->save->lexeme));
898 /* Memorize most forward-looking error state in case it's really an error. */
899 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
901 /* Free old saved error context state */
902 if (yyerrctx) yyFreeState(yyerrctx);
903 /* Create and fill out new saved error context state */
904 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
905 if (yyerrctx == NULL) goto yyenomem;
906 yyerrctx->save = yyps->save;
907 yyerrctx->state = yystate;
908 yyerrctx->errflag = yyerrflag;
909 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
910 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
911 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
912 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
913 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
914 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
915 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
917 yyerrctx->lexeme = yylvp - yylvals;
919 yylvp = yylvals + save->lexeme;
920 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
921 yylpp = yylpsns + save->lexeme;
923 yylexp = yylexemes + save->lexeme;
925 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
926 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
927 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
928 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
929 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
930 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
931 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
934 yystate = save->state;
935 /* We tried shift, try reduce now */
936 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
937 yyps->save = save->save;
941 /* Nothing left on the stack -- error */
946 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
949 /* Restore state as it was in the most forward-advanced error */
950 yylvp = yylvals + yyerrctx->lexeme;
951 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
952 yylpp = yylpsns + yyerrctx->lexeme;
954 yylexp = yylexemes + yyerrctx->lexeme;
957 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
960 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
961 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
962 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
963 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
964 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
965 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
966 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
968 yystate = yyerrctx->state;
969 yyFreeState(yyerrctx);
974 if (yynewerrflag == 0) goto yyinrecovery;
975 #endif /* YYBTYACC */
977 YYERROR_CALL("syntax error");
978 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
979 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
994 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
995 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
999 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1000 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1002 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1003 yystate = yytable[yyn];
1004 *++yystack.s_mark = yytable[yyn];
1005 *++yystack.l_mark = yylval;
1006 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1007 /* lookahead position is error end position */
1008 yyerror_loc_range[1] = yylloc;
1009 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1010 *++yystack.p_mark = yyloc;
1018 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1019 YYDEBUGSTR, yydepth, *yystack.s_mark);
1021 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1022 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1023 /* the current TOS position is the error start position */
1024 yyerror_loc_range[0] = *yystack.p_mark;
1026 #if defined(YYDESTRUCT_CALL)
1029 #endif /* YYBTYACC */
1030 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1031 YYDESTRUCT_CALL("error: discarding state",
1032 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1034 YYDESTRUCT_CALL("error: discarding state",
1035 yystos[*yystack.s_mark], yystack.l_mark);
1036 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1037 #endif /* defined(YYDESTRUCT_CALL) */
1040 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1048 if (yychar == YYEOF) goto yyabort;
1052 yys = yyname[YYTRANSLATE(yychar)];
1053 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1054 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1057 #if defined(YYDESTRUCT_CALL)
1060 #endif /* YYBTYACC */
1061 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1062 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1064 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1065 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1066 #endif /* defined(YYDESTRUCT_CALL) */
1076 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1077 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1078 #ifdef YYSTYPE_TOSTRING
1081 #endif /* YYBTYACC */
1086 for (i = yym; i > 0; i--)
1088 if (i != yym) fputs(", ", stderr);
1089 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1090 yystack.l_mark[1-i]), stderr);
1095 fputc('\n', stderr);
1099 yyval = yystack.l_mark[1-yym];
1101 memset(&yyval, 0, sizeof yyval);
1102 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1104 /* Perform position reduction */
1105 memset(&yyloc, 0, sizeof(yyloc));
1108 #endif /* YYBTYACC */
1110 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1111 /* just in case YYERROR is invoked within the action, save
1112 the start of the rhs as the error start position */
1113 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1120 #line 50 "err_inherit3.y"
1121 yyval.cval = yystack.l_mark[-1].cval;
1124 #line 50 "err_inherit3.y"
1125 yyval.tval = yystack.l_mark[-1].tval;
1128 #line 51 "err_inherit3.y"
1129 { yyval.nlist = yystack.l_mark[0].nlist; }
1132 #line 52 "err_inherit3.y"
1133 yyval.tval = yystack.l_mark[0].tval;
1136 #line 53 "err_inherit3.y"
1137 { yyval.nlist = yystack.l_mark[0].nlist; }
1140 #line 56 "err_inherit3.y"
1141 { yyval.cval = cGLOBAL; }
1144 #line 57 "err_inherit3.y"
1145 { yyval.cval = cLOCAL; }
1148 #line 60 "err_inherit3.y"
1149 { yyval.tval = tREAL; }
1152 #line 61 "err_inherit3.y"
1153 { yyval.tval = tINTEGER; }
1156 #line 64 "err_inherit3.y"
1157 yyval.cval = yystack.l_mark[-2];
1160 #line 65 "err_inherit3.y"
1161 { yyval.nlist->s = mksymbol(yystack.l_mark[-5].tval, yystack.l_mark[-5].cval, yystack.l_mark[0].id);
1162 yyval.nlist->next = yystack.l_mark[-1].nlist;
1166 #line 69 "err_inherit3.y"
1167 { yyval.nlist->s = mksymbol(yystack.l_mark[-3], yystack.l_mark[-3], yystack.l_mark[0].id);
1168 yyval.nlist->next = NULL;
1172 #line 74 "err_inherit3.y"
1173 yyval.cval = cLOCAL;
1176 #line 75 "err_inherit3.y"
1177 { yyval.nlist = yystack.l_mark[0].nlist; }
1179 #line 1180 "err_inherit3.tab.c"
1183 yystack.s_mark -= yym;
1184 yystate = *yystack.s_mark;
1185 yystack.l_mark -= yym;
1186 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1187 yystack.p_mark -= yym;
1190 if (yystate == 0 && yym == 0)
1195 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1196 #ifdef YYSTYPE_TOSTRING
1199 #endif /* YYBTYACC */
1200 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1202 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1206 *++yystack.s_mark = YYFINAL;
1207 *++yystack.l_mark = yyval;
1208 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1209 *++yystack.p_mark = yyloc;
1217 /* we're currently re-reading tokens */
1219 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1227 /* in trial mode; save scanner results for future parse attempts */
1228 if (yylvp == yylvlim)
1229 { /* Enlarge lexical value queue */
1230 int p = yylvp - yylvals;
1231 int s = yylvlim - yylvals;
1233 s += YYLVQUEUEGROWTH;
1234 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1236 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1238 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1239 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1242 yylvp = yylve = yylvals + p;
1243 yylvlim = yylvals + s;
1244 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1245 yylpp = yylpe = yylpsns + p;
1246 yylplim = yylpsns + s;
1248 yylexp = yylexemes + p;
1250 *yylexp = (short) YYLEX;
1253 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1260 /* normal operation, no conflict encountered */
1261 #endif /* YYBTYACC */
1265 #endif /* YYBTYACC */
1266 if (yychar < 0) yychar = YYEOF;
1267 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1271 yys = yyname[YYTRANSLATE(yychar)];
1272 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1273 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1277 if (yychar == YYEOF) goto yyaccept;
1280 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1281 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1282 yystate = yytable[yyn];
1284 yystate = yydgoto[yym];
1288 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1289 #ifdef YYSTYPE_TOSTRING
1292 #endif /* YYBTYACC */
1293 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1295 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1298 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1299 *++yystack.s_mark = (short) yystate;
1300 *++yystack.l_mark = yyval;
1301 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1302 *++yystack.p_mark = yyloc;
1307 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1309 if (yypath) YYABORT;
1312 YYParseState *save = yyps->save;
1313 yyps->save = save->save;
1314 save->save = yypath;
1319 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1320 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1324 yyFreeState(yyerrctx);
1327 yylvp = yylvals + yypath->lexeme;
1328 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1329 yylpp = yylpsns + yypath->lexeme;
1331 yylexp = yylexemes + yypath->lexeme;
1333 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1334 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1335 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1336 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1337 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1338 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1339 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1341 yystate = yypath->state;
1343 #endif /* YYBTYACC */
1346 YYERROR_CALL("yacc stack overflow");
1350 YYERROR_CALL("memory exhausted");
1352 #endif /* YYBTYACC */
1362 if (yyps->save) goto yyvalid;
1363 #endif /* YYBTYACC */
1367 #if defined(YYDESTRUCT_CALL)
1368 if (yychar != YYEOF && yychar != YYEMPTY)
1369 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1370 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1372 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1373 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1377 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1380 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1381 YYDESTRUCT_CALL("cleanup: discarding state",
1382 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1384 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1385 YYDESTRUCT_CALL("cleanup: discarding state",
1386 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1387 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1389 #endif /* defined(YYDESTRUCT_CALL) */
1394 yyFreeState(yyerrctx);
1399 YYParseState *save = yyps;
1406 YYParseState *save = yypath;
1407 yypath = save->save;
1411 #endif /* YYBTYACC */
1412 yyfreestack(&yystack);