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);
622 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
623 memset(yyerror_loc_range, 0, sizeof(yyerror_loc_range));
627 yyps = yyNewState(0); if (yyps == 0) goto yyenomem;
629 #endif /* YYBTYACC */
638 memset(&yystack, 0, sizeof(yystack));
641 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
642 yystack.s_mark = yystack.s_base;
643 yystack.l_mark = yystack.l_base;
644 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
645 yystack.p_mark = yystack.p_base;
651 if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
658 /* we're currently re-reading tokens */
660 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
668 /* in trial mode; save scanner results for future parse attempts */
669 if (yylvp == yylvlim)
670 { /* Enlarge lexical value queue */
671 size_t p = (size_t) (yylvp - yylvals);
672 size_t s = (size_t) (yylvlim - yylvals);
674 s += YYLVQUEUEGROWTH;
675 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem;
676 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem;
677 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
678 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem;
680 yylvp = yylve = yylvals + p;
681 yylvlim = yylvals + s;
682 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
683 yylpp = yylpe = yylpsns + p;
684 yylplim = yylpsns + s;
686 yylexp = yylexemes + p;
688 *yylexp = (YYINT) YYLEX;
691 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
698 /* normal operation, no conflict encountered */
699 #endif /* YYBTYACC */
703 #endif /* YYBTYACC */
704 if (yychar < 0) yychar = YYEOF;
708 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
709 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)",
710 YYDEBUGSTR, yydepth, yystate, yychar, yys);
711 #ifdef YYSTYPE_TOSTRING
714 #endif /* YYBTYACC */
715 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval));
723 /* Do we have a conflict? */
724 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
725 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
734 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n",
735 YYDEBUGSTR, yydepth, yystate);
737 /* Switch to the next conflict context */
742 if (save->state != yystate) YYABORT;
749 /* Unresolved conflict - start/continue trial parse */
754 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate);
756 fputs("ALREADY in conflict, continuing trial parse.\n", stderr);
758 fputs("Starting trial parse.\n", stderr);
761 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
762 if (save == NULL) goto yyenomem;
763 save->save = yyps->save;
764 save->state = yystate;
765 save->errflag = yyerrflag;
766 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base);
767 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
768 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base);
769 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
770 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
771 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base);
772 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
775 if (yyctable[ctry] == -1)
778 if (yydebug && yychar >= YYEOF)
779 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth);
784 if (yyps->save == NULL)
786 /* If this is a first conflict in the stack, start saving lexemes */
789 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT));
790 if (yylexemes == NULL) goto yyenomem;
791 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE));
792 if (yylvals == NULL) goto yyenomem;
793 yylvlim = yylvals + YYLVQUEUEGROWTH;
794 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
795 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE));
796 if (yylpsns == NULL) goto yyenomem;
797 yylplim = yylpsns + YYLVQUEUEGROWTH;
802 yylvp = yylve = yylvals;
803 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
804 yylpp = yylpe = yylpsns;
810 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
813 *yylexp = (YYINT) yychar;
821 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
827 save->lexeme = (int) (yylvp - yylvals);
830 if (yytable[yyn] == ctry)
834 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
835 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]);
840 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
845 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM)
847 yystate = yyctable[ctry];
848 *++yystack.s_mark = (YYINT) yystate;
849 *++yystack.l_mark = yylval;
850 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
851 *++yystack.p_mark = yylloc;
854 if (yyerrflag > 0) --yyerrflag;
859 yyn = yyctable[ctry];
862 } /* End of code dealing with conflicts */
863 #endif /* YYBTYACC */
864 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
865 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
869 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n",
870 YYDEBUGSTR, yydepth, yystate, yytable[yyn]);
872 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
873 yystate = yytable[yyn];
874 *++yystack.s_mark = yytable[yyn];
875 *++yystack.l_mark = yylval;
876 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
877 *++yystack.p_mark = yylloc;
880 if (yyerrflag > 0) --yyerrflag;
883 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 &&
884 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar)
889 if (yyerrflag != 0) goto yyinrecovery;
894 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
897 /* explicit YYERROR from an action -- pop the rhs of the rule reduced
898 * before looking for error recovery */
899 yystack.s_mark -= yym;
900 yystate = *yystack.s_mark;
901 yystack.l_mark -= yym;
902 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
903 yystack.p_mark -= yym;
911 YYParseState *save = yyps->save;
914 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n",
915 YYDEBUGSTR, yydepth, yystate, yyps->save->state,
916 (int)(yylvp - yylvals - yyps->save->lexeme));
918 /* Memorize most forward-looking error state in case it's really an error. */
919 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals)
921 /* Free old saved error context state */
922 if (yyerrctx) yyFreeState(yyerrctx);
923 /* Create and fill out new saved error context state */
924 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1));
925 if (yyerrctx == NULL) goto yyenomem;
926 yyerrctx->save = yyps->save;
927 yyerrctx->state = yystate;
928 yyerrctx->errflag = yyerrflag;
929 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base);
930 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
931 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base);
932 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
933 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
934 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base);
935 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
937 yyerrctx->lexeme = (int) (yylvp - yylvals);
939 yylvp = yylvals + save->lexeme;
940 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
941 yylpp = yylpsns + save->lexeme;
943 yylexp = yylexemes + save->lexeme;
945 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base);
946 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
947 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base);
948 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
949 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
950 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base);
951 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
954 yystate = save->state;
955 /* We tried shift, try reduce now */
956 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce;
957 yyps->save = save->save;
961 /* Nothing left on the stack -- error */
966 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n",
969 /* Restore state as it was in the most forward-advanced error */
970 yylvp = yylvals + yyerrctx->lexeme;
971 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
972 yylpp = yylpsns + yyerrctx->lexeme;
974 yylexp = yylexemes + yyerrctx->lexeme;
977 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
980 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base);
981 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
982 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base);
983 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
984 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
985 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base);
986 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
988 yystate = yyerrctx->state;
989 yyFreeState(yyerrctx);
994 if (yynewerrflag == 0) goto yyinrecovery;
995 #endif /* YYBTYACC */
997 YYERROR_CALL("syntax error");
998 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
999 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */
1003 goto yyerrlab; /* redundant goto avoids 'unused label' warning */
1014 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 &&
1015 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE)
1019 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n",
1020 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]);
1022 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1023 yystate = yytable[yyn];
1024 *++yystack.s_mark = yytable[yyn];
1025 *++yystack.l_mark = yylval;
1026 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1027 /* lookahead position is error end position */
1028 yyerror_loc_range[1] = yylloc;
1029 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */
1030 *++yystack.p_mark = yyloc;
1038 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n",
1039 YYDEBUGSTR, yydepth, *yystack.s_mark);
1041 if (yystack.s_mark <= yystack.s_base) goto yyabort;
1042 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1043 /* the current TOS position is the error start position */
1044 yyerror_loc_range[0] = *yystack.p_mark;
1046 #if defined(YYDESTRUCT_CALL)
1049 #endif /* YYBTYACC */
1050 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1051 YYDESTRUCT_CALL("error: discarding state",
1052 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark);
1054 YYDESTRUCT_CALL("error: discarding state",
1055 yystos[*yystack.s_mark], yystack.l_mark);
1056 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1057 #endif /* defined(YYDESTRUCT_CALL) */
1060 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1068 if (yychar == YYEOF) goto yyabort;
1072 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1073 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n",
1074 YYDEBUGSTR, yydepth, yystate, yychar, yys);
1077 #if defined(YYDESTRUCT_CALL)
1080 #endif /* YYBTYACC */
1081 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1082 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc);
1084 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval);
1085 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1086 #endif /* defined(YYDESTRUCT_CALL) */
1096 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)",
1097 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]);
1098 #ifdef YYSTYPE_TOSTRING
1101 #endif /* YYBTYACC */
1106 for (i = yym; i > 0; i--)
1108 if (i != yym) fputs(", ", stderr);
1109 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]],
1110 yystack.l_mark[1-i]), stderr);
1115 fputc('\n', stderr);
1119 yyval = yystack.l_mark[1-yym];
1121 memset(&yyval, 0, sizeof yyval);
1122 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1124 /* Perform position reduction */
1125 memset(&yyloc, 0, sizeof(yyloc));
1128 #endif /* YYBTYACC */
1130 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym);
1131 /* just in case YYERROR is invoked within the action, save
1132 the start of the rhs as the error start position */
1133 yyerror_loc_range[0] = yystack.p_mark[1-yym];
1140 #line 50 "err_inherit3.y"
1141 yyval.cval = yystack.l_mark[-1].cval;
1144 #line 50 "err_inherit3.y"
1145 yyval.tval = yystack.l_mark[-1].tval;
1148 #line 51 "err_inherit3.y"
1149 { yyval.nlist = yystack.l_mark[0].nlist; }
1152 #line 53 "err_inherit3.y"
1153 { yyval.nlist = yystack.l_mark[0].nlist; }
1156 #line 56 "err_inherit3.y"
1157 { yyval.cval = cGLOBAL; }
1160 #line 57 "err_inherit3.y"
1161 { yyval.cval = cLOCAL; }
1164 #line 60 "err_inherit3.y"
1165 { yyval.tval = tREAL; }
1168 #line 61 "err_inherit3.y"
1169 { yyval.tval = tINTEGER; }
1172 #line 64 "err_inherit3.y"
1173 yyval.cval = yystack.l_mark[-2];
1176 #line 65 "err_inherit3.y"
1177 { yyval.nlist->s = mksymbol(yystack.l_mark[-5].tval, yystack.l_mark[-5].cval, yystack.l_mark[0].id);
1178 yyval.nlist->next = yystack.l_mark[-1].nlist;
1182 #line 69 "err_inherit3.y"
1183 { yyval.nlist->s = mksymbol(yystack.l_mark[-3], yystack.l_mark[-3], yystack.l_mark[0].id);
1184 yyval.nlist->next = NULL;
1188 #line 74 "err_inherit3.y"
1189 yyval.cval = cLOCAL;
1192 #line 75 "err_inherit3.y"
1193 { yyval.nlist = yystack.l_mark[0].nlist; }
1195 #line 1196 "err_inherit3.tab.c"
1199 yystack.s_mark -= yym;
1200 yystate = *yystack.s_mark;
1201 yystack.l_mark -= yym;
1202 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1203 yystack.p_mark -= yym;
1206 if (yystate == 0 && yym == 0)
1211 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1212 #ifdef YYSTYPE_TOSTRING
1215 #endif /* YYBTYACC */
1216 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval));
1218 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL);
1222 *++yystack.s_mark = YYFINAL;
1223 *++yystack.l_mark = yyval;
1224 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1225 *++yystack.p_mark = yyloc;
1233 /* we're currently re-reading tokens */
1235 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1243 /* in trial mode; save scanner results for future parse attempts */
1244 if (yylvp == yylvlim)
1245 { /* Enlarge lexical value queue */
1246 size_t p = (size_t) (yylvp - yylvals);
1247 size_t s = (size_t) (yylvlim - yylvals);
1249 s += YYLVQUEUEGROWTH;
1250 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL)
1252 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL)
1254 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1255 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL)
1258 yylvp = yylve = yylvals + p;
1259 yylvlim = yylvals + s;
1260 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1261 yylpp = yylpe = yylpsns + p;
1262 yylplim = yylpsns + s;
1264 yylexp = yylexemes + p;
1266 *yylexp = (YYINT) YYLEX;
1269 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1276 /* normal operation, no conflict encountered */
1277 #endif /* YYBTYACC */
1281 #endif /* YYBTYACC */
1282 if (yychar < 0) yychar = YYEOF;
1286 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN];
1287 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n",
1288 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys);
1292 if (yychar == YYEOF) goto yyaccept;
1295 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 &&
1296 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate)
1297 yystate = yytable[yyn];
1299 yystate = yydgoto[yym];
1303 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth);
1304 #ifdef YYSTYPE_TOSTRING
1307 #endif /* YYBTYACC */
1308 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval));
1310 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate);
1313 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow;
1314 *++yystack.s_mark = (YYINT) yystate;
1315 *++yystack.l_mark = yyval;
1316 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1317 *++yystack.p_mark = yyloc;
1322 /* Reduction declares that this path is valid. Set yypath and do a full parse */
1324 if (yypath) YYABORT;
1327 YYParseState *save = yyps->save;
1328 yyps->save = save->save;
1329 save->save = yypath;
1334 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n",
1335 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme));
1339 yyFreeState(yyerrctx);
1342 yylvp = yylvals + yypath->lexeme;
1343 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1344 yylpp = yylpsns + yypath->lexeme;
1346 yylexp = yylexemes + yypath->lexeme;
1348 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base);
1349 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT));
1350 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base);
1351 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE));
1352 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1353 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base);
1354 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE));
1356 yystate = yypath->state;
1358 #endif /* YYBTYACC */
1361 YYERROR_CALL("yacc stack overflow");
1365 YYERROR_CALL("memory exhausted");
1367 #endif /* YYBTYACC */
1377 if (yyps->save) goto yyvalid;
1378 #endif /* YYBTYACC */
1382 #if defined(YYDESTRUCT_CALL)
1383 if (yychar != YYEOF && yychar != YYEMPTY)
1384 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1385 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc);
1387 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval);
1388 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1392 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED)
1395 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp)
1396 YYDESTRUCT_CALL("cleanup: discarding state",
1397 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp);
1399 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv)
1400 YYDESTRUCT_CALL("cleanup: discarding state",
1401 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv);
1402 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */
1404 #endif /* defined(YYDESTRUCT_CALL) */
1409 yyFreeState(yyerrctx);
1414 YYParseState *save = yyps;
1421 YYParseState *save = yypath;
1422 yypath = save->save;
1426 #endif /* YYBTYACC */
1427 yyfreestack(&yystack);