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_inherit4_parse
25 #define yylex err_inherit4_lex
29 #define yyerror err_inherit4_error
33 #define yychar err_inherit4_char
37 #define yyval err_inherit4_val
41 #define yylval err_inherit4_lval
45 #define yydebug err_inherit4_debug
49 #define yynerrs err_inherit4_nerrs
53 #define yyerrflag err_inherit4_errflag
54 #endif /* yyerrflag */
57 #define yylhs err_inherit4_lhs
61 #define yylen err_inherit4_len
65 #define yydefred err_inherit4_defred
69 #define yystos err_inherit4_stos
73 #define yydgoto err_inherit4_dgoto
77 #define yysindex err_inherit4_sindex
81 #define yyrindex err_inherit4_rindex
85 #define yygindex err_inherit4_gindex
89 #define yytable err_inherit4_table
93 #define yycheck err_inherit4_check
97 #define yyname err_inherit4_name
101 #define yyrule err_inherit4_rule
105 #define yyloc err_inherit4_loc
109 #define yylloc err_inherit4_lloc
115 #define yycindex err_inherit4_cindex
116 #endif /* yycindex */
119 #define yyctable err_inherit4_ctable
120 #endif /* yyctable */
122 #endif /* YYBTYACC */
124 #define YYPREFIX "err_inherit4_"
128 #line 3 "err_inherit4.y"
131 typedef enum {cGLOBAL, cLOCAL} class;
132 typedef enum {tREAL, tINTEGER} type;
135 struct symbol { class c; type t; name id; };
136 typedef struct symbol symbol;
138 struct namelist { symbol *s; struct namelist *next; };
139 typedef struct namelist namelist;
141 extern symbol *mksymbol(type t, class c, name id);
144 #define YYLEX_DECL() yylex(void)
145 #define YYERROR_DECL() yyerror(const char *s)
147 #line 41 "err_inherit4.y"
149 #undef YYSTYPE_IS_DECLARED
150 #define YYSTYPE_IS_DECLARED 1
152 #ifndef YYSTYPE_IS_DECLARED
153 #define YYSTYPE_IS_DECLARED 1
161 #endif /* !YYSTYPE_IS_DECLARED */
162 #line 163 "err_inherit4.tab.c"
164 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
165 /* Default: YYLTYPE is the text position type. */
166 typedef struct YYLTYPE
173 #define YYLTYPE_IS_DECLARED 1
176 /* compatibility with bison */
178 /* compatibility with FreeBSD */
179 # ifdef YYPARSE_PARAM_TYPE
180 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
182 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
185 # define YYPARSE_DECL() yyparse(void)
188 /* Parameters sent to lex. */
190 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
191 # define YYLEX yylex(YYLEX_PARAM)
193 # define YYLEX_DECL() yylex(void)
194 # define YYLEX yylex()
197 /* Parameters sent to yyerror. */
199 #define YYERROR_DECL() yyerror(YYLTYPE loc, const char *s)
202 #define YYERROR_CALL(msg) yyerror(yylloc, msg)
205 #ifndef YYDESTRUCT_DECL
206 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val, YYLTYPE *loc)
208 #ifndef YYDESTRUCT_CALL
209 #define YYDESTRUCT_CALL(msg, psymb, val, loc) yydestruct(msg, psymb, val, loc)
212 extern int YYPARSE_DECL();
219 #define YYERRCODE 256
221 static const YYINT err_inherit4_lhs[] = { -1,
222 5, 6, 0, 7, 0, 3, 3, 4, 4, 1,
225 static const YYINT err_inherit4_len[] = { 2,
226 0, 0, 5, 0, 3, 1, 1, 1, 1, 2,
229 static const YYINT err_inherit4_defred[] = { 0,
230 6, 7, 8, 9, 0, 0, 4, 1, 0, 2,
233 static const YYINT err_inherit4_stos[] = { 0,
234 257, 258, 259, 260, 263, 266, 267, 267, 270, 268,
235 261, 264, 265, 269, 261, 264,
237 static const YYINT err_inherit4_dgoto[] = { 5,
238 12, 13, 6, 7, 10, 14, 9,
240 static const YYINT err_inherit4_sindex[] = { -257,
241 0, 0, 0, 0, 0, -255, 0, 0, -254, 0,
242 0, -253, 0, -254, 0, -253,
244 static const YYINT err_inherit4_rindex[] = { 0,
245 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
249 static const YYINT err_inherit4_cindex[] = { 0,
250 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
254 static const YYINT err_inherit4_gindex[] = { 0,
255 -4, 0, 0, 5, 0, 0, 0,
257 #define YYTABLESIZE 11
258 static const YYINT err_inherit4_table[] = { 1,
259 2, 3, 4, 3, 4, 12, 11, 15, 3, 16,
262 static const YYINT err_inherit4_check[] = { 257,
263 258, 259, 260, 259, 260, 0, 261, 261, 0, 14,
270 #define YYMAXTOKEN 261
271 #define YYUNDFTOKEN 271
272 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a))
274 static const char *const err_inherit4_name[] = {
276 "$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,
277 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
278 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
279 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
280 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
281 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
282 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER",
283 "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1",
284 "$$2","$$3","illegal-symbol",
286 static const char *const err_inherit4_rule[] = {
287 "$accept : declaration",
290 "declaration : class type $$1 $$2 namelist",
292 "declaration : type $$3 locnamelist",
297 "namelist : namelist NAME",
299 "locnamelist : namelist",
311 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
312 YYLTYPE yyloc; /* position returned by actions */
313 YYLTYPE yylloc; /* position from the lexer */
316 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
317 #ifndef YYLLOC_DEFAULT
318 #define YYLLOC_DEFAULT(loc, rhs, n) \
323 (loc).first_line = ((rhs)[-1]).last_line; \
324 (loc).first_column = ((rhs)[-1]).last_column; \
325 (loc).last_line = ((rhs)[-1]).last_line; \
326 (loc).last_column = ((rhs)[-1]).last_column; \
330 (loc).first_line = ((rhs)[ 0 ]).first_line; \
331 (loc).first_column = ((rhs)[ 0 ]).first_column; \
332 (loc).last_line = ((rhs)[n-1]).last_line; \
333 (loc).last_column = ((rhs)[n-1]).last_column; \
336 #endif /* YYLLOC_DEFAULT */
337 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
340 #ifndef YYLVQUEUEGROWTH
341 #define YYLVQUEUEGROWTH 32
343 #endif /* YYBTYACC */
345 /* define the initial stack-sizes */
348 #define YYMAXDEPTH YYSTACKSIZE
351 #define YYSTACKSIZE YYMAXDEPTH
353 #define YYSTACKSIZE 10000
354 #define YYMAXDEPTH 10000
358 #ifndef YYINITSTACKSIZE
359 #define YYINITSTACKSIZE 200
369 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
376 struct YYParseState_s
378 struct YYParseState_s *save; /* Previously saved parser state */
379 YYSTACKDATA yystack; /* saved parser stack */
380 int state; /* saved parser state */
381 int errflag; /* saved error recovery status */
382 int lexeme; /* saved index of the conflict lexeme in the lexical queue */
383 YYINT ctry; /* saved index in yyctable[] for this conflict */
385 typedef struct YYParseState_s YYParseState;
386 #endif /* YYBTYACC */
387 /* variables for the parser stack */
388 static YYSTACKDATA yystack;
391 /* Current parser state */
392 static YYParseState *yyps = 0;
394 /* yypath != NULL: do the full parse, starting at *yypath parser state. */
395 static YYParseState *yypath = 0;
397 /* Base of the lexical value queue */
398 static YYSTYPE *yylvals = 0;
400 /* Current position at lexical value queue */
401 static YYSTYPE *yylvp = 0;
403 /* End position of lexical value queue */
404 static YYSTYPE *yylve = 0;
406 /* The last allocated position at the lexical value queue */
407 static YYSTYPE *yylvlim = 0;
409 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
410 /* Base of the lexical position queue */
411 static YYLTYPE *yylpsns = 0;
413 /* Current position at lexical position queue */
414 static YYLTYPE *yylpp = 0;
416 /* End position of lexical position queue */
417 static YYLTYPE *yylpe = 0;
419 /* The last allocated position at the lexical position queue */
420 static YYLTYPE *yylplim = 0;
423 /* Current position at lexical token queue */
424 static short *yylexp = 0;
426 static short *yylexemes = 0;
427 #endif /* YYBTYACC */
428 #line 80 "err_inherit4.y"
430 extern int YYLEX_DECL();
431 extern void YYERROR_DECL();
432 #line 433 "err_inherit4.tab.c"
434 /* Release memory associated with symbol. */
435 #if ! defined YYDESTRUCT_IS_DECLARED
442 #line 28 "err_inherit4.y"
445 #line 446 "err_inherit4.tab.c"
447 #line 28 "err_inherit4.y"
450 #line 451 "err_inherit4.tab.c"
452 #line 28 "err_inherit4.y"
455 #line 456 "err_inherit4.tab.c"
458 #define YYDESTRUCT_IS_DECLARED 1
461 /* For use in generated program */
462 #define yydepth (int)(yystack.s_mark - yystack.s_base)
464 #define yytrial (yyps->save)
465 #endif /* YYBTYACC */
468 #include <stdio.h> /* needed for printf */
471 #include <stdlib.h> /* needed for malloc, etc */
472 #include <string.h> /* needed for memset */
474 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
475 static int yygrowstack(YYSTACKDATA *data)
481 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
485 if ((newsize = data->stacksize) == 0)
486 newsize = YYINITSTACKSIZE;
487 else if (newsize >= YYMAXDEPTH)
489 else if ((newsize *= 2) > YYMAXDEPTH)
490 newsize = YYMAXDEPTH;
492 i = (int) (data->s_mark - data->s_base);
493 newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
497 data->s_base = newss;
498 data->s_mark = newss + i;
500 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
504 data->l_base = newvs;
505 data->l_mark = newvs + i;
507 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
508 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps));
512 data->p_base = newps;
513 data->p_mark = newps + i;
516 data->stacksize = newsize;
517 data->s_last = data->s_base + newsize - 1;
521 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize);
526 #if YYPURE || defined(YY_NO_LEAKS)
527 static void yyfreestack(YYSTACKDATA *data)
531 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
534 memset(data, 0, sizeof(*data));
537 #define yyfreestack(data) /* nothing */
538 #endif /* YYPURE || defined(YY_NO_LEAKS) */
541 static YYParseState *
542 yyNewState(unsigned size)
544 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState));
545 if (p == NULL) return NULL;
547 p->yystack.stacksize = size;
550 p->yystack.s_base = NULL;
551 p->yystack.l_base = NULL;
552 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
553 p->yystack.p_base = NULL;
557 p->yystack.s_base = (short *) malloc(size * sizeof(short));
558 if (p->yystack.s_base == NULL) return NULL;
559 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE));
560 if (p->yystack.l_base == NULL) return NULL;
561 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE));
562 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
563 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE));
564 if (p->yystack.p_base == NULL) return NULL;
565 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE));
572 yyFreeState(YYParseState *p)
574 yyfreestack(&p->yystack);
577 #endif /* YYBTYACC */
579 #define YYABORT goto yyabort
580 #define YYREJECT goto yyabort
581 #define YYACCEPT goto yyaccept
582 #define YYERROR goto yyerrlab
584 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0)
585 #define YYVALID_NESTED do { if (yyps->save && \
586 yyps->save->save == 0) goto yyvalid; } while(0)
587 #endif /* YYBTYACC */
592 int yym, yyn, yystate, yyresult;
595 YYParseState *yyerrctx = NULL;
596 #endif /* YYBTYACC */
597 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
598 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */
603 if ((yys = getenv("YYDEBUG")) != 0)
606 if (yyn >= '0' && yyn <= '9')
610 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX);
614 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
616 #endif /* YYBTYACC */
623 memset(&yystack, 0, sizeof(yystack));
626 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
627 yystack.s_mark = yystack.s_base;
628 yystack.l_mark = yystack.l_base;
629 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
630 yystack.p_mark = yystack.p_base;
636 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
643 /* we're currently re-reading tokens */
645 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
653 /* in trial mode; save scanner results for future parse attempts */
654 if (yylvp == yylvlim)
655 { /* Enlarge lexical value queue */
656 int p = yylvp - yylvals;
657 int s = yylvlim - yylvals;
659 s += YYLVQUEUEGROWTH;
660 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL) goto yyenomem;
661 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
662 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
663 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
665 yylvp = yylve = yylvals + p;
666 yylvlim = yylvals + s;
667 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
668 yylpp = yylpe = yylpsns + p;
669 yylplim = yylpsns + s;
671 yylexp = yylexemes + p;
673 *yylexp = (short) YYLEX;
676 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
683 /* normal operation, no conflict encountered */
684 #endif /* YYBTYACC */
688 #endif /* YYBTYACC */
689 if (yychar < 0) yychar = YYEOF;
690 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
694 yys = yyname[YYTRANSLATE(yychar)];
695 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
696 YYDEBUGSTR, yydepth, yystate, yychar, yys);
697 #ifdef YYSTYPE_TOSTRING
700 #endif /* YYBTYACC */
701 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
709 /* Do we have a conflict? */
710 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
711 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
720 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
721 YYDEBUGSTR, yydepth, yystate);
723 /* Switch to the next conflict context */
728 if (save->state != yystate) YYABORT;
735 /* Unresolved conflict - start/continue trial parse */
740 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
742 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
744 fputs("Starting trial parse.\n", stderr);
747 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
748 if (save == NULL) goto yyenomem;
749 save->save = yyps->save;
750 save->state = yystate;
751 save->errflag = yyerrflag;
752 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
753 memcpy (save->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
754 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
755 memcpy (save->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
756 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
757 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
758 memcpy (save->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
761 if (yyctable[ctry] == -1)
764 if (yydebug && yychar >= YYEOF)
765 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
770 if (yyps->save == NULL)
772 /* If this is a first conflict in the stack, start saving lexemes */
775 yylexemes = (short *) malloc((YYLVQUEUEGROWTH) * sizeof(short));
776 if (yylexemes == NULL) goto yyenomem;
777 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
778 if (yylvals == NULL) goto yyenomem;
779 yylvlim = yylvals + YYLVQUEUEGROWTH;
780 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
781 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
782 if (yylpsns == NULL) goto yyenomem;
783 yylplim = yylpsns + YYLVQUEUEGROWTH;
788 yylvp = yylve = yylvals;
789 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
790 yylpp = yylpe = yylpsns;
796 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
799 *yylexp = (short) yychar;
807 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
813 save->lexeme = yylvp - yylvals;
816 if (yytable[yyn] == ctry)
820 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
821 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
826 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
831 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
833 yystate = yyctable[ctry];
834 *++yystack.s_mark = (short) yystate;
835 *++yystack.l_mark = yylval;
836 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
837 *++yystack.p_mark = yylloc;
840 if (yyerrflag > 0) --yyerrflag;
845 yyn = yyctable[ctry];
848 } /* End of code dealing with conflicts */
849 #endif /* YYBTYACC */
850 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
851 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
855 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
856 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
858 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
859 yystate = yytable[yyn];
860 *++yystack.s_mark = yytable[yyn];
861 *++yystack.l_mark = yylval;
862 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
863 *++yystack.p_mark = yylloc;
866 if (yyerrflag > 0) --yyerrflag;
869 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
870 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
875 if (yyerrflag != 0) goto yyinrecovery;
888 YYParseState *save = yyps->save;
891 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
892 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
893 (int)(yylvp - yylvals - yyps->save->lexeme));
895 /* Memorize most forward-looking error state in case it's really an error. */
896 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
898 /* Free old saved error context state */
899 if (yyerrctx) yyFreeState(yyerrctx);
900 /* Create and fill out new saved error context state */
901 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
902 if (yyerrctx == NULL) goto yyenomem;
903 yyerrctx->save = yyps->save;
904 yyerrctx->state = yystate;
905 yyerrctx->errflag = yyerrflag;
906 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
907 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
908 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
909 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
910 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
911 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
912 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
914 yyerrctx->lexeme = yylvp - yylvals;
916 yylvp = yylvals + save->lexeme;
917 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
918 yylpp = yylpsns + save->lexeme;
920 yylexp = yylexemes + save->lexeme;
922 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
923 memcpy (yystack.s_base, save->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
924 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
925 memcpy (yystack.l_base, save->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
926 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
927 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
928 memcpy (yystack.p_base, save->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
931 yystate = save->state;
932 /* We tried shift, try reduce now */
933 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
934 yyps->save = save->save;
938 /* Nothing left on the stack -- error */
943 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
946 /* Restore state as it was in the most forward-advanced error */
947 yylvp = yylvals + yyerrctx->lexeme;
948 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
949 yylpp = yylpsns + yyerrctx->lexeme;
951 yylexp = yylexemes + yyerrctx->lexeme;
954 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
957 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
958 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
959 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
960 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
961 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
962 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
963 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
965 yystate = yyerrctx->state;
966 yyFreeState(yyerrctx);
971 if (yynewerrflag == 0) goto yyinrecovery;
972 #endif /* YYBTYACC */
974 YYERROR_CALL("syntax error");
975 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
976 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
991 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
992 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
996 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
997 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
999 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1000 yystate = yytable[yyn];
1001 *++yystack.s_mark = yytable[yyn];
1002 *++yystack.l_mark = yylval;
1003 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1004 /* lookahead position is error end position */
1005 yyerror_loc_range[1] = yylloc;
1006 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1007 *++yystack.p_mark = yyloc;
1015 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1016 YYDEBUGSTR, yydepth, *yystack.s_mark);
1018 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1019 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1020 /* the current TOS position is the error start position */
1021 yyerror_loc_range[0] = *yystack.p_mark;
1023 #if defined(YYDESTRUCT_CALL)
1026 #endif /* YYBTYACC */
1027 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1028 YYDESTRUCT_CALL("error: discarding state",
1029 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1031 YYDESTRUCT_CALL("error: discarding state",
1032 yystos[*yystack.s_mark], yystack.l_mark);
1033 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1034 #endif /* defined(YYDESTRUCT_CALL) */
1037 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1045 if (yychar == YYEOF) goto yyabort;
1049 yys = yyname[YYTRANSLATE(yychar)];
1050 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1051 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1054 #if defined(YYDESTRUCT_CALL)
1057 #endif /* YYBTYACC */
1058 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1059 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1061 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1062 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1063 #endif /* defined(YYDESTRUCT_CALL) */
1073 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1074 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1075 #ifdef YYSTYPE_TOSTRING
1078 #endif /* YYBTYACC */
1083 for (i = yym; i > 0; i--)
1085 if (i != yym) fputs(", ", stderr);
1086 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1087 yystack.l_mark[1-i]), stderr);
1092 fputc('\n', stderr);
1096 yyval = yystack.l_mark[1-yym];
1098 memset(&yyval, 0, sizeof yyval);
1099 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1101 /* Perform position reduction */
1102 memset(&yyloc, 0, sizeof(yyloc));
1105 #endif /* YYBTYACC */
1107 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1108 /* just in case YYERROR is invoked within the action, save
1109 the start of the rhs as the error start position */
1110 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1117 #line 52 "err_inherit4.y"
1118 yyval.cval = yystack.l_mark[-1].cval;
1121 #line 52 "err_inherit4.y"
1122 yyval.tval = yystack.l_mark[-1].tval;
1125 #line 53 "err_inherit4.y"
1126 { yyval.nlist = yystack.l_mark[0].nlist; }
1129 #line 54 "err_inherit4.y"
1130 yyval.tval = yystack.l_mark[0].tval;
1133 #line 55 "err_inherit4.y"
1134 { yyval.nlist = yystack.l_mark[0].nlist; }
1137 #line 58 "err_inherit4.y"
1138 { yyval.cval = cGLOBAL; }
1141 #line 59 "err_inherit4.y"
1142 { yyval.cval = cLOCAL; }
1145 #line 62 "err_inherit4.y"
1146 { yyval.tval = tREAL; }
1149 #line 63 "err_inherit4.y"
1150 { yyval.tval = tINTEGER; }
1153 #line 67 "err_inherit4.y"
1154 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id);
1155 yyval.nlist->next = yystack.l_mark[-1].nlist;
1159 #line 71 "err_inherit4.y"
1160 { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id);
1161 yyval.nlist->next = NULL;
1165 #line 77 "err_inherit4.y"
1166 { yyval.nlist = yystack.l_mark[0].nlist; yyloc = yystack.p_mark[1]; }
1168 #line 1169 "err_inherit4.tab.c"
1172 yystack.s_mark -= yym;
1173 yystate = *yystack.s_mark;
1174 yystack.l_mark -= yym;
1175 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1176 yystack.p_mark -= yym;
1179 if (yystate == 0 && yym == 0)
1184 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1185 #ifdef YYSTYPE_TOSTRING
1188 #endif /* YYBTYACC */
1189 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1191 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1195 *++yystack.s_mark = YYFINAL;
1196 *++yystack.l_mark = yyval;
1197 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1198 *++yystack.p_mark = yyloc;
1206 /* we're currently re-reading tokens */
1208 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1216 /* in trial mode; save scanner results for future parse attempts */
1217 if (yylvp == yylvlim)
1218 { /* Enlarge lexical value queue */
1219 int p = yylvp - yylvals;
1220 int s = yylvlim - yylvals;
1222 s += YYLVQUEUEGROWTH;
1223 if ((yylexemes = (short *) realloc(yylexemes, s * sizeof(short))) == NULL)
1225 if ((yylvals = (YYSTYPE *) realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1228 if ((yylpsns = (YYLTYPE *) realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1231 yylvp = yylve = yylvals + p;
1232 yylvlim = yylvals + s;
1233 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1234 yylpp = yylpe = yylpsns + p;
1235 yylplim = yylpsns + s;
1237 yylexp = yylexemes + p;
1239 *yylexp = (short) YYLEX;
1242 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1249 /* normal operation, no conflict encountered */
1250 #endif /* YYBTYACC */
1254 #endif /* YYBTYACC */
1255 if (yychar < 0) yychar = YYEOF;
1256 /* if ((yychar = YYLEX) < 0) yychar = YYEOF; */
1260 yys = yyname[YYTRANSLATE(yychar)];
1261 fprintf(stderr, "%s[%d]: state %d, reading %d (%s)\n",
1262 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1266 if (yychar == YYEOF) goto yyaccept;
1269 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1270 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1271 yystate = yytable[yyn];
1273 yystate = yydgoto[yym];
1277 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1278 #ifdef YYSTYPE_TOSTRING
1281 #endif /* YYBTYACC */
1282 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1284 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1287 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1288 *++yystack.s_mark = (short) yystate;
1289 *++yystack.l_mark = yyval;
1290 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1291 *++yystack.p_mark = yyloc;
1296 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1298 if (yypath) YYABORT;
1301 YYParseState *save = yyps->save;
1302 yyps->save = save->save;
1303 save->save = yypath;
1308 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1309 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1313 yyFreeState(yyerrctx);
1316 yylvp = yylvals + yypath->lexeme;
1317 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1318 yylpp = yylpsns + yypath->lexeme;
1320 yylexp = yylexemes + yypath->lexeme;
1322 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1323 memcpy (yystack.s_base, yypath->yystack.s_base, (yystack.s_mark - yystack.s_base + 1) * sizeof(short));
1324 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1325 memcpy (yystack.l_base, yypath->yystack.l_base, (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1326 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1327 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1328 memcpy (yystack.p_base, yypath->yystack.p_base, (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1330 yystate = yypath->state;
1332 #endif /* YYBTYACC */
1335 YYERROR_CALL("yacc stack overflow");
1339 YYERROR_CALL("memory exhausted");
1341 #endif /* YYBTYACC */
1351 if (yyps->save) goto yyvalid;
1352 #endif /* YYBTYACC */
1356 #if defined(YYDESTRUCT_CALL)
1357 if (yychar != YYEOF && yychar != YYEMPTY)
1358 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1359 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1361 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1362 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1366 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1369 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1370 YYDESTRUCT_CALL("cleanup: discarding state",
1371 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1373 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1374 YYDESTRUCT_CALL("cleanup: discarding state",
1375 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1376 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1378 #endif /* defined(YYDESTRUCT_CALL) */
1383 yyFreeState(yyerrctx);
1388 YYParseState *save = yyps;
1395 YYParseState *save = yypath;
1396 yypath = save->save;
1400 #endif /* YYBTYACC */
1401 yyfreestack(&yystack);