1 /* original parser id follows */ 2 /* yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93" */ 3 /* (use YYMAJOR/YYMINOR for ifdefs dependent on parser version) */ 4 5 #define YYBYACC 1 6 #define YYMAJOR 1 7 #define YYMINOR 9 8 #define YYCHECK "yyyymmdd" 9 10 #define YYEMPTY (-1) 11 #define yyclearin (yychar = YYEMPTY) 12 #define yyerrok (yyerrflag = 0) 13 #define YYRECOVERING() (yyerrflag != 0) 14 #define YYENOMEM (-2) 15 #define YYEOF 0 16 #undef YYBTYACC 17 #define YYBTYACC 0 18 #define YYDEBUGSTR YYPREFIX "debug" 19 20 #ifndef yyparse 21 #define yyparse inherit2_parse 22 #endif /* yyparse */ 23 24 #ifndef yylex 25 #define yylex inherit2_lex 26 #endif /* yylex */ 27 28 #ifndef yyerror 29 #define yyerror inherit2_error 30 #endif /* yyerror */ 31 32 #ifndef yychar 33 #define yychar inherit2_char 34 #endif /* yychar */ 35 36 #ifndef yyval 37 #define yyval inherit2_val 38 #endif /* yyval */ 39 40 #ifndef yylval 41 #define yylval inherit2_lval 42 #endif /* yylval */ 43 44 #ifndef yydebug 45 #define yydebug inherit2_debug 46 #endif /* yydebug */ 47 48 #ifndef yynerrs 49 #define yynerrs inherit2_nerrs 50 #endif /* yynerrs */ 51 52 #ifndef yyerrflag 53 #define yyerrflag inherit2_errflag 54 #endif /* yyerrflag */ 55 56 #ifndef yylhs 57 #define yylhs inherit2_lhs 58 #endif /* yylhs */ 59 60 #ifndef yylen 61 #define yylen inherit2_len 62 #endif /* yylen */ 63 64 #ifndef yydefred 65 #define yydefred inherit2_defred 66 #endif /* yydefred */ 67 68 #ifndef yystos 69 #define yystos inherit2_stos 70 #endif /* yystos */ 71 72 #ifndef yydgoto 73 #define yydgoto inherit2_dgoto 74 #endif /* yydgoto */ 75 76 #ifndef yysindex 77 #define yysindex inherit2_sindex 78 #endif /* yysindex */ 79 80 #ifndef yyrindex 81 #define yyrindex inherit2_rindex 82 #endif /* yyrindex */ 83 84 #ifndef yygindex 85 #define yygindex inherit2_gindex 86 #endif /* yygindex */ 87 88 #ifndef yytable 89 #define yytable inherit2_table 90 #endif /* yytable */ 91 92 #ifndef yycheck 93 #define yycheck inherit2_check 94 #endif /* yycheck */ 95 96 #ifndef yyname 97 #define yyname inherit2_name 98 #endif /* yyname */ 99 100 #ifndef yyrule 101 #define yyrule inherit2_rule 102 #endif /* yyrule */ 103 104 #if YYBTYACC 105 106 #ifndef yycindex 107 #define yycindex inherit2_cindex 108 #endif /* yycindex */ 109 110 #ifndef yyctable 111 #define yyctable inherit2_ctable 112 #endif /* yyctable */ 113 114 #endif /* YYBTYACC */ 115 116 #define YYPREFIX "inherit2_" 117 118 #define YYPURE 0 119 120 #line 2 "inherit2.y" 121 #include <stdlib.h> 122 123 typedef enum {cGLOBAL, cLOCAL} class; 124 typedef enum {tREAL, tINTEGER} type; 125 typedef char * name; 126 127 struct symbol { class c; type t; name id; }; 128 typedef struct symbol symbol; 129 130 struct namelist { symbol *s; struct namelist *next; }; 131 typedef struct namelist namelist; 132 133 extern symbol *mksymbol(type t, class c, name id); 134 135 #ifdef YYBISON 136 #define YYLEX_DECL() yylex(void) 137 #define YYERROR_DECL() yyerror(const char *s) 138 #endif 139 #ifdef YYSTYPE 140 #undef YYSTYPE_IS_DECLARED 141 #define YYSTYPE_IS_DECLARED 1 142 #endif 143 #ifndef YYSTYPE_IS_DECLARED 144 #define YYSTYPE_IS_DECLARED 1 145 #line 39 "inherit2.y" 146 typedef union 147 { 148 class cval; 149 type tval; 150 namelist * nlist; 151 name id; 152 } YYSTYPE; 153 #endif /* !YYSTYPE_IS_DECLARED */ 154 #line 155 "inherit2.tab.c" 155 156 /* compatibility with bison */ 157 #ifdef YYPARSE_PARAM 158 /* compatibility with FreeBSD */ 159 # ifdef YYPARSE_PARAM_TYPE 160 # define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM) 161 # else 162 # define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM) 163 # endif 164 #else 165 # define YYPARSE_DECL() yyparse(void) 166 #endif 167 168 /* Parameters sent to lex. */ 169 #ifdef YYLEX_PARAM 170 # define YYLEX_DECL() yylex(void *YYLEX_PARAM) 171 # define YYLEX yylex(YYLEX_PARAM) 172 #else 173 # define YYLEX_DECL() yylex(void) 174 # define YYLEX yylex() 175 #endif 176 177 /* Parameters sent to yyerror. */ 178 #ifndef YYERROR_DECL 179 #define YYERROR_DECL() yyerror(const char *s) 180 #endif 181 #ifndef YYERROR_CALL 182 #define YYERROR_CALL(msg) yyerror(msg) 183 #endif 184 185 #ifndef YYDESTRUCT_DECL 186 #define YYDESTRUCT_DECL() yydestruct(const char *msg, int psymb, YYSTYPE *val) 187 #endif 188 #ifndef YYDESTRUCT_CALL 189 #define YYDESTRUCT_CALL(msg, psymb, val) yydestruct(msg, psymb, val) 190 #endif 191 192 extern int YYPARSE_DECL(); 193 194 #define GLOBAL 257 195 #define LOCAL 258 196 #define REAL 259 197 #define INTEGER 260 198 #define NAME 261 199 #define YYERRCODE 256 200 typedef short YYINT; 201 static const YYINT inherit2_lhs[] = { -1, 202 5, 6, 0, 0, 3, 3, 4, 4, 1, 1, 203 7, 2, 204 }; 205 static const YYINT inherit2_len[] = { 2, 206 0, 0, 5, 2, 1, 1, 1, 1, 2, 1, 207 0, 3, 208 }; 209 static const YYINT inherit2_defred[] = { 0, 210 5, 6, 7, 8, 0, 0, 11, 1, 4, 2, 211 2, 0, 0, 10, 0, 0, 9, 212 }; 213 #if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING) 214 static const YYINT inherit2_stos[] = { 0, 215 257, 258, 259, 260, 263, 266, 267, 267, 265, 270, 216 268, 269, 269, 261, 264, 264, 261, 217 }; 218 #endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */ 219 static const YYINT inherit2_dgoto[] = { 5, 220 15, 9, 6, 7, 11, 12, 10, 221 }; 222 static const YYINT inherit2_sindex[] = { -257, 223 0, 0, 0, 0, 0, -255, 0, 0, 0, 0, 224 0, -254, -254, 0, -253, -253, 0, 225 }; 226 static const YYINT inherit2_rindex[] = { 0, 227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 228 0, 0, 0, 0, 6, 9, 0, 229 }; 230 #if YYBTYACC 231 static const YYINT inherit2_cindex[] = { 0, 232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 233 0, 0, 0, 0, 0, 0, 0, 234 }; 235 #endif 236 static const YYINT inherit2_gindex[] = { 0, 237 -3, 0, 0, 5, 0, 1, 0, 238 }; 239 #define YYTABLESIZE 12 240 static const YYINT inherit2_table[] = { 1, 241 2, 3, 4, 3, 4, 12, 14, 17, 3, 16, 242 8, 13, 243 }; 244 static const YYINT inherit2_check[] = { 257, 245 258, 259, 260, 259, 260, 0, 261, 261, 0, 13, 246 6, 11, 247 }; 248 #if YYBTYACC 249 static const YYINT inherit2_ctable[] = { -1, 250 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 251 -1, 252 }; 253 #endif 254 #define YYFINAL 5 255 #ifndef YYDEBUG 256 #define YYDEBUG 0 257 #endif 258 #define YYMAXTOKEN 261 259 #define YYUNDFTOKEN 271 260 #define YYTRANSLATE(a) ((a) > YYMAXTOKEN ? YYUNDFTOKEN : (a)) 261 #if YYDEBUG 262 static const char *const inherit2_name[] = { 263 264 "$end",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 265 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 266 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 267 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 268 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 269 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 270 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"error","GLOBAL","LOCAL","REAL","INTEGER", 271 "NAME","$accept","declaration","namelist","locnamelist","class","type","$$1", 272 "$$2","$$3","illegal-symbol", 273 }; 274 static const char *const inherit2_rule[] = { 275 "$accept : declaration", 276 "$$1 :", 277 "$$2 :", 278 "declaration : class type $$1 $$2 namelist", 279 "declaration : type locnamelist", 280 "class : GLOBAL", 281 "class : LOCAL", 282 "type : REAL", 283 "type : INTEGER", 284 "namelist : namelist NAME", 285 "namelist : NAME", 286 "$$3 :", 287 "locnamelist : $$3 $$2 namelist", 288 289 }; 290 #endif 291 292 int yydebug; 293 int yynerrs; 294 295 int yyerrflag; 296 int yychar; 297 YYSTYPE yyval; 298 YYSTYPE yylval; 299 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 300 YYLTYPE yyloc; /* position returned by actions */ 301 YYLTYPE yylloc; /* position from the lexer */ 302 #endif 303 304 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 305 #ifndef YYLLOC_DEFAULT 306 #define YYLLOC_DEFAULT(loc, rhs, n) \ 307 do \ 308 { \ 309 if (n == 0) \ 310 { \ 311 (loc).first_line = ((rhs)[-1]).last_line; \ 312 (loc).first_column = ((rhs)[-1]).last_column; \ 313 (loc).last_line = ((rhs)[-1]).last_line; \ 314 (loc).last_column = ((rhs)[-1]).last_column; \ 315 } \ 316 else \ 317 { \ 318 (loc).first_line = ((rhs)[ 0 ]).first_line; \ 319 (loc).first_column = ((rhs)[ 0 ]).first_column; \ 320 (loc).last_line = ((rhs)[n-1]).last_line; \ 321 (loc).last_column = ((rhs)[n-1]).last_column; \ 322 } \ 323 } while (0) 324 #endif /* YYLLOC_DEFAULT */ 325 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 326 #if YYBTYACC 327 328 #ifndef YYLVQUEUEGROWTH 329 #define YYLVQUEUEGROWTH 32 330 #endif 331 #endif /* YYBTYACC */ 332 333 /* define the initial stack-sizes */ 334 #ifdef YYSTACKSIZE 335 #undef YYMAXDEPTH 336 #define YYMAXDEPTH YYSTACKSIZE 337 #else 338 #ifdef YYMAXDEPTH 339 #define YYSTACKSIZE YYMAXDEPTH 340 #else 341 #define YYSTACKSIZE 10000 342 #define YYMAXDEPTH 10000 343 #endif 344 #endif 345 346 #ifndef YYINITSTACKSIZE 347 #define YYINITSTACKSIZE 200 348 #endif 349 350 typedef struct { 351 unsigned stacksize; 352 YYINT *s_base; 353 YYINT *s_mark; 354 YYINT *s_last; 355 YYSTYPE *l_base; 356 YYSTYPE *l_mark; 357 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 358 YYLTYPE *p_base; 359 YYLTYPE *p_mark; 360 #endif 361 } YYSTACKDATA; 362 #if YYBTYACC 363 364 struct YYParseState_s 365 { 366 struct YYParseState_s *save; /* Previously saved parser state */ 367 YYSTACKDATA yystack; /* saved parser stack */ 368 int state; /* saved parser state */ 369 int errflag; /* saved error recovery status */ 370 int lexeme; /* saved index of the conflict lexeme in the lexical queue */ 371 YYINT ctry; /* saved index in yyctable[] for this conflict */ 372 }; 373 typedef struct YYParseState_s YYParseState; 374 #endif /* YYBTYACC */ 375 /* variables for the parser stack */ 376 static YYSTACKDATA yystack; 377 #if YYBTYACC 378 379 /* Current parser state */ 380 static YYParseState *yyps = 0; 381 382 /* yypath != NULL: do the full parse, starting at *yypath parser state. */ 383 static YYParseState *yypath = 0; 384 385 /* Base of the lexical value queue */ 386 static YYSTYPE *yylvals = 0; 387 388 /* Current position at lexical value queue */ 389 static YYSTYPE *yylvp = 0; 390 391 /* End position of lexical value queue */ 392 static YYSTYPE *yylve = 0; 393 394 /* The last allocated position at the lexical value queue */ 395 static YYSTYPE *yylvlim = 0; 396 397 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 398 /* Base of the lexical position queue */ 399 static YYLTYPE *yylpsns = 0; 400 401 /* Current position at lexical position queue */ 402 static YYLTYPE *yylpp = 0; 403 404 /* End position of lexical position queue */ 405 static YYLTYPE *yylpe = 0; 406 407 /* The last allocated position at the lexical position queue */ 408 static YYLTYPE *yylplim = 0; 409 #endif 410 411 /* Current position at lexical token queue */ 412 static YYINT *yylexp = 0; 413 414 static YYINT *yylexemes = 0; 415 #endif /* YYBTYACC */ 416 #line 78 "inherit2.y" 417 418 extern int YYLEX_DECL(); 419 extern void YYERROR_DECL(); 420 #line 421 "inherit2.tab.c" 421 422 /* Release memory associated with symbol. */ 423 #if ! defined YYDESTRUCT_IS_DECLARED 424 static void 425 YYDESTRUCT_DECL() 426 { 427 switch (psymb) 428 { 429 case 263: 430 #line 30 "inherit2.y" 431 { 432 namelist *p = (*val).nlist; 433 while (p != NULL) 434 { namelist *pp = p; 435 p = p->next; 436 free(pp->s); free(pp); 437 } 438 } 439 break; 440 #line 441 "inherit2.tab.c" 441 case 264: 442 #line 30 "inherit2.y" 443 { 444 namelist *p = (*val).nlist; 445 while (p != NULL) 446 { namelist *pp = p; 447 p = p->next; 448 free(pp->s); free(pp); 449 } 450 } 451 break; 452 #line 453 "inherit2.tab.c" 453 case 265: 454 #line 30 "inherit2.y" 455 { 456 namelist *p = (*val).nlist; 457 while (p != NULL) 458 { namelist *pp = p; 459 p = p->next; 460 free(pp->s); free(pp); 461 } 462 } 463 break; 464 #line 465 "inherit2.tab.c" 465 } 466 } 467 #define YYDESTRUCT_IS_DECLARED 1 468 #endif 469 470 /* For use in generated program */ 471 #define yydepth (int)(yystack.s_mark - yystack.s_base) 472 #if YYBTYACC 473 #define yytrial (yyps->save) 474 #endif /* YYBTYACC */ 475 476 #if YYDEBUG 477 #include <stdio.h> /* needed for printf */ 478 #endif 479 480 #include <stdlib.h> /* needed for malloc, etc */ 481 #include <string.h> /* needed for memset */ 482 483 /* allocate initial stack or double stack size, up to YYMAXDEPTH */ 484 static int yygrowstack(YYSTACKDATA *data) 485 { 486 int i; 487 unsigned newsize; 488 YYINT *newss; 489 YYSTYPE *newvs; 490 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 491 YYLTYPE *newps; 492 #endif 493 494 if ((newsize = data->stacksize) == 0) 495 newsize = YYINITSTACKSIZE; 496 else if (newsize >= YYMAXDEPTH) 497 return YYENOMEM; 498 else if ((newsize *= 2) > YYMAXDEPTH) 499 newsize = YYMAXDEPTH; 500 501 i = (int) (data->s_mark - data->s_base); 502 newss = (YYINT *)realloc(data->s_base, newsize * sizeof(*newss)); 503 if (newss == 0) 504 return YYENOMEM; 505 506 data->s_base = newss; 507 data->s_mark = newss + i; 508 509 newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs)); 510 if (newvs == 0) 511 return YYENOMEM; 512 513 data->l_base = newvs; 514 data->l_mark = newvs + i; 515 516 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 517 newps = (YYLTYPE *)realloc(data->p_base, newsize * sizeof(*newps)); 518 if (newps == 0) 519 return YYENOMEM; 520 521 data->p_base = newps; 522 data->p_mark = newps + i; 523 #endif 524 525 data->stacksize = newsize; 526 data->s_last = data->s_base + newsize - 1; 527 528 #if YYDEBUG 529 if (yydebug) 530 fprintf(stderr, "%sdebug: stack size increased to %d\n", YYPREFIX, newsize); 531 #endif 532 return 0; 533 } 534 535 #if YYPURE || defined(YY_NO_LEAKS) 536 static void yyfreestack(YYSTACKDATA *data) 537 { 538 free(data->s_base); 539 free(data->l_base); 540 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 541 free(data->p_base); 542 #endif 543 memset(data, 0, sizeof(*data)); 544 } 545 #else 546 #define yyfreestack(data) /* nothing */ 547 #endif /* YYPURE || defined(YY_NO_LEAKS) */ 548 #if YYBTYACC 549 550 static YYParseState * 551 yyNewState(unsigned size) 552 { 553 YYParseState *p = (YYParseState *) malloc(sizeof(YYParseState)); 554 if (p == NULL) return NULL; 555 556 p->yystack.stacksize = size; 557 if (size == 0) 558 { 559 p->yystack.s_base = NULL; 560 p->yystack.l_base = NULL; 561 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 562 p->yystack.p_base = NULL; 563 #endif 564 return p; 565 } 566 p->yystack.s_base = (YYINT *) malloc(size * sizeof(YYINT)); 567 if (p->yystack.s_base == NULL) return NULL; 568 p->yystack.l_base = (YYSTYPE *) malloc(size * sizeof(YYSTYPE)); 569 if (p->yystack.l_base == NULL) return NULL; 570 memset(p->yystack.l_base, 0, size * sizeof(YYSTYPE)); 571 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 572 p->yystack.p_base = (YYLTYPE *) malloc(size * sizeof(YYLTYPE)); 573 if (p->yystack.p_base == NULL) return NULL; 574 memset(p->yystack.p_base, 0, size * sizeof(YYLTYPE)); 575 #endif 576 577 return p; 578 } 579 580 static void 581 yyFreeState(YYParseState *p) 582 { 583 yyfreestack(&p->yystack); 584 free(p); 585 } 586 #endif /* YYBTYACC */ 587 588 #define YYABORT goto yyabort 589 #define YYREJECT goto yyabort 590 #define YYACCEPT goto yyaccept 591 #define YYERROR goto yyerrlab 592 #if YYBTYACC 593 #define YYVALID do { if (yyps->save) goto yyvalid; } while(0) 594 #define YYVALID_NESTED do { if (yyps->save && \ 595 yyps->save->save == 0) goto yyvalid; } while(0) 596 #endif /* YYBTYACC */ 597 598 int 599 YYPARSE_DECL() 600 { 601 int yym, yyn, yystate, yyresult; 602 #if YYBTYACC 603 int yynewerrflag; 604 YYParseState *yyerrctx = NULL; 605 #endif /* YYBTYACC */ 606 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 607 YYLTYPE yyerror_loc_range[2]; /* position of error start & end */ 608 #endif 609 #if YYDEBUG 610 const char *yys; 611 612 if ((yys = getenv("YYDEBUG")) != 0) 613 { 614 yyn = *yys; 615 if (yyn >= '0' && yyn <= '9') 616 yydebug = yyn - '0'; 617 } 618 if (yydebug) 619 fprintf(stderr, "%sdebug[<# of symbols on state stack>]\n", YYPREFIX); 620 #endif 621 622 #if YYBTYACC 623 yyps = yyNewState(0); if (yyps == 0) goto yyenomem; 624 yyps->save = 0; 625 #endif /* YYBTYACC */ 626 yym = 0; 627 yyn = 0; 628 yynerrs = 0; 629 yyerrflag = 0; 630 yychar = YYEMPTY; 631 yystate = 0; 632 633 #if YYPURE 634 memset(&yystack, 0, sizeof(yystack)); 635 #endif 636 637 if (yystack.s_base == NULL && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 638 yystack.s_mark = yystack.s_base; 639 yystack.l_mark = yystack.l_base; 640 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 641 yystack.p_mark = yystack.p_base; 642 #endif 643 yystate = 0; 644 *yystack.s_mark = 0; 645 646 yyloop: 647 if ((yyn = yydefred[yystate]) != 0) goto yyreduce; 648 if (yychar < 0) 649 { 650 #if YYBTYACC 651 do { 652 if (yylvp < yylve) 653 { 654 /* we're currently re-reading tokens */ 655 yylval = *yylvp++; 656 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 657 yylloc = *yylpp++; 658 #endif 659 yychar = *yylexp++; 660 break; 661 } 662 if (yyps->save) 663 { 664 /* in trial mode; save scanner results for future parse attempts */ 665 if (yylvp == yylvlim) 666 { /* Enlarge lexical value queue */ 667 size_t p = (size_t) (yylvp - yylvals); 668 size_t s = (size_t) (yylvlim - yylvals); 669 670 s += YYLVQUEUEGROWTH; 671 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) goto yyenomem; 672 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) goto yyenomem; 673 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 674 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) goto yyenomem; 675 #endif 676 yylvp = yylve = yylvals + p; 677 yylvlim = yylvals + s; 678 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 679 yylpp = yylpe = yylpsns + p; 680 yylplim = yylpsns + s; 681 #endif 682 yylexp = yylexemes + p; 683 } 684 *yylexp = (YYINT) YYLEX; 685 *yylvp++ = yylval; 686 yylve++; 687 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 688 *yylpp++ = yylloc; 689 yylpe++; 690 #endif 691 yychar = *yylexp++; 692 break; 693 } 694 /* normal operation, no conflict encountered */ 695 #endif /* YYBTYACC */ 696 yychar = YYLEX; 697 #if YYBTYACC 698 } while (0); 699 #endif /* YYBTYACC */ 700 if (yychar < 0) yychar = YYEOF; 701 #if YYDEBUG 702 if (yydebug) 703 { 704 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 705 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)", 706 YYDEBUGSTR, yydepth, yystate, yychar, yys); 707 #ifdef YYSTYPE_TOSTRING 708 #if YYBTYACC 709 if (!yytrial) 710 #endif /* YYBTYACC */ 711 fprintf(stderr, " <%s>", YYSTYPE_TOSTRING(yychar, yylval)); 712 #endif 713 fputc('\n', stderr); 714 } 715 #endif 716 } 717 #if YYBTYACC 718 719 /* Do we have a conflict? */ 720 if (((yyn = yycindex[yystate]) != 0) && (yyn += yychar) >= 0 && 721 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 722 { 723 YYINT ctry; 724 725 if (yypath) 726 { 727 YYParseState *save; 728 #if YYDEBUG 729 if (yydebug) 730 fprintf(stderr, "%s[%d]: CONFLICT in state %d: following successful trial parse\n", 731 YYDEBUGSTR, yydepth, yystate); 732 #endif 733 /* Switch to the next conflict context */ 734 save = yypath; 735 yypath = save->save; 736 save->save = NULL; 737 ctry = save->ctry; 738 if (save->state != yystate) YYABORT; 739 yyFreeState(save); 740 741 } 742 else 743 { 744 745 /* Unresolved conflict - start/continue trial parse */ 746 YYParseState *save; 747 #if YYDEBUG 748 if (yydebug) 749 { 750 fprintf(stderr, "%s[%d]: CONFLICT in state %d. ", YYDEBUGSTR, yydepth, yystate); 751 if (yyps->save) 752 fputs("ALREADY in conflict, continuing trial parse.\n", stderr); 753 else 754 fputs("Starting trial parse.\n", stderr); 755 } 756 #endif 757 save = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 758 if (save == NULL) goto yyenomem; 759 save->save = yyps->save; 760 save->state = yystate; 761 save->errflag = yyerrflag; 762 save->yystack.s_mark = save->yystack.s_base + (yystack.s_mark - yystack.s_base); 763 memcpy (save->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 764 save->yystack.l_mark = save->yystack.l_base + (yystack.l_mark - yystack.l_base); 765 memcpy (save->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 766 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 767 save->yystack.p_mark = save->yystack.p_base + (yystack.p_mark - yystack.p_base); 768 memcpy (save->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 769 #endif 770 ctry = yytable[yyn]; 771 if (yyctable[ctry] == -1) 772 { 773 #if YYDEBUG 774 if (yydebug && yychar >= YYEOF) 775 fprintf(stderr, "%s[%d]: backtracking 1 token\n", YYDEBUGSTR, yydepth); 776 #endif 777 ctry++; 778 } 779 save->ctry = ctry; 780 if (yyps->save == NULL) 781 { 782 /* If this is a first conflict in the stack, start saving lexemes */ 783 if (!yylexemes) 784 { 785 yylexemes = malloc((YYLVQUEUEGROWTH) * sizeof(YYINT)); 786 if (yylexemes == NULL) goto yyenomem; 787 yylvals = (YYSTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYSTYPE)); 788 if (yylvals == NULL) goto yyenomem; 789 yylvlim = yylvals + YYLVQUEUEGROWTH; 790 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 791 yylpsns = (YYLTYPE *) malloc((YYLVQUEUEGROWTH) * sizeof(YYLTYPE)); 792 if (yylpsns == NULL) goto yyenomem; 793 yylplim = yylpsns + YYLVQUEUEGROWTH; 794 #endif 795 } 796 if (yylvp == yylve) 797 { 798 yylvp = yylve = yylvals; 799 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 800 yylpp = yylpe = yylpsns; 801 #endif 802 yylexp = yylexemes; 803 if (yychar >= YYEOF) 804 { 805 *yylve++ = yylval; 806 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 807 *yylpe++ = yylloc; 808 #endif 809 *yylexp = (YYINT) yychar; 810 yychar = YYEMPTY; 811 } 812 } 813 } 814 if (yychar >= YYEOF) 815 { 816 yylvp--; 817 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 818 yylpp--; 819 #endif 820 yylexp--; 821 yychar = YYEMPTY; 822 } 823 save->lexeme = (int) (yylvp - yylvals); 824 yyps->save = save; 825 } 826 if (yytable[yyn] == ctry) 827 { 828 #if YYDEBUG 829 if (yydebug) 830 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 831 YYDEBUGSTR, yydepth, yystate, yyctable[ctry]); 832 #endif 833 if (yychar < 0) 834 { 835 yylvp++; 836 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 837 yylpp++; 838 #endif 839 yylexp++; 840 } 841 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) 842 goto yyoverflow; 843 yystate = yyctable[ctry]; 844 *++yystack.s_mark = (YYINT) yystate; 845 *++yystack.l_mark = yylval; 846 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 847 *++yystack.p_mark = yylloc; 848 #endif 849 yychar = YYEMPTY; 850 if (yyerrflag > 0) --yyerrflag; 851 goto yyloop; 852 } 853 else 854 { 855 yyn = yyctable[ctry]; 856 goto yyreduce; 857 } 858 } /* End of code dealing with conflicts */ 859 #endif /* YYBTYACC */ 860 if (((yyn = yysindex[yystate]) != 0) && (yyn += yychar) >= 0 && 861 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 862 { 863 #if YYDEBUG 864 if (yydebug) 865 fprintf(stderr, "%s[%d]: state %d, shifting to state %d\n", 866 YYDEBUGSTR, yydepth, yystate, yytable[yyn]); 867 #endif 868 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 869 yystate = yytable[yyn]; 870 *++yystack.s_mark = yytable[yyn]; 871 *++yystack.l_mark = yylval; 872 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 873 *++yystack.p_mark = yylloc; 874 #endif 875 yychar = YYEMPTY; 876 if (yyerrflag > 0) --yyerrflag; 877 goto yyloop; 878 } 879 if (((yyn = yyrindex[yystate]) != 0) && (yyn += yychar) >= 0 && 880 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yychar) 881 { 882 yyn = yytable[yyn]; 883 goto yyreduce; 884 } 885 if (yyerrflag != 0) goto yyinrecovery; 886 #if YYBTYACC 887 888 yynewerrflag = 1; 889 goto yyerrhandler; 890 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 891 892 yyerrlab: 893 /* explicit YYERROR from an action -- pop the rhs of the rule reduced 894 * before looking for error recovery */ 895 yystack.s_mark -= yym; 896 yystate = *yystack.s_mark; 897 yystack.l_mark -= yym; 898 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 899 yystack.p_mark -= yym; 900 #endif 901 902 yynewerrflag = 0; 903 yyerrhandler: 904 while (yyps->save) 905 { 906 int ctry; 907 YYParseState *save = yyps->save; 908 #if YYDEBUG 909 if (yydebug) 910 fprintf(stderr, "%s[%d]: ERROR in state %d, CONFLICT BACKTRACKING to state %d, %d tokens\n", 911 YYDEBUGSTR, yydepth, yystate, yyps->save->state, 912 (int)(yylvp - yylvals - yyps->save->lexeme)); 913 #endif 914 /* Memorize most forward-looking error state in case it's really an error. */ 915 if (yyerrctx == NULL || yyerrctx->lexeme < yylvp - yylvals) 916 { 917 /* Free old saved error context state */ 918 if (yyerrctx) yyFreeState(yyerrctx); 919 /* Create and fill out new saved error context state */ 920 yyerrctx = yyNewState((unsigned)(yystack.s_mark - yystack.s_base + 1)); 921 if (yyerrctx == NULL) goto yyenomem; 922 yyerrctx->save = yyps->save; 923 yyerrctx->state = yystate; 924 yyerrctx->errflag = yyerrflag; 925 yyerrctx->yystack.s_mark = yyerrctx->yystack.s_base + (yystack.s_mark - yystack.s_base); 926 memcpy (yyerrctx->yystack.s_base, yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 927 yyerrctx->yystack.l_mark = yyerrctx->yystack.l_base + (yystack.l_mark - yystack.l_base); 928 memcpy (yyerrctx->yystack.l_base, yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 929 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 930 yyerrctx->yystack.p_mark = yyerrctx->yystack.p_base + (yystack.p_mark - yystack.p_base); 931 memcpy (yyerrctx->yystack.p_base, yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 932 #endif 933 yyerrctx->lexeme = (int) (yylvp - yylvals); 934 } 935 yylvp = yylvals + save->lexeme; 936 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 937 yylpp = yylpsns + save->lexeme; 938 #endif 939 yylexp = yylexemes + save->lexeme; 940 yychar = YYEMPTY; 941 yystack.s_mark = yystack.s_base + (save->yystack.s_mark - save->yystack.s_base); 942 memcpy (yystack.s_base, save->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 943 yystack.l_mark = yystack.l_base + (save->yystack.l_mark - save->yystack.l_base); 944 memcpy (yystack.l_base, save->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 945 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 946 yystack.p_mark = yystack.p_base + (save->yystack.p_mark - save->yystack.p_base); 947 memcpy (yystack.p_base, save->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 948 #endif 949 ctry = ++save->ctry; 950 yystate = save->state; 951 /* We tried shift, try reduce now */ 952 if ((yyn = yyctable[ctry]) >= 0) goto yyreduce; 953 yyps->save = save->save; 954 save->save = NULL; 955 yyFreeState(save); 956 957 /* Nothing left on the stack -- error */ 958 if (!yyps->save) 959 { 960 #if YYDEBUG 961 if (yydebug) 962 fprintf(stderr, "%sdebug[%d,trial]: trial parse FAILED, entering ERROR mode\n", 963 YYPREFIX, yydepth); 964 #endif 965 /* Restore state as it was in the most forward-advanced error */ 966 yylvp = yylvals + yyerrctx->lexeme; 967 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 968 yylpp = yylpsns + yyerrctx->lexeme; 969 #endif 970 yylexp = yylexemes + yyerrctx->lexeme; 971 yychar = yylexp[-1]; 972 yylval = yylvp[-1]; 973 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 974 yylloc = yylpp[-1]; 975 #endif 976 yystack.s_mark = yystack.s_base + (yyerrctx->yystack.s_mark - yyerrctx->yystack.s_base); 977 memcpy (yystack.s_base, yyerrctx->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 978 yystack.l_mark = yystack.l_base + (yyerrctx->yystack.l_mark - yyerrctx->yystack.l_base); 979 memcpy (yystack.l_base, yyerrctx->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 980 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 981 yystack.p_mark = yystack.p_base + (yyerrctx->yystack.p_mark - yyerrctx->yystack.p_base); 982 memcpy (yystack.p_base, yyerrctx->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 983 #endif 984 yystate = yyerrctx->state; 985 yyFreeState(yyerrctx); 986 yyerrctx = NULL; 987 } 988 yynewerrflag = 1; 989 } 990 if (yynewerrflag == 0) goto yyinrecovery; 991 #endif /* YYBTYACC */ 992 993 YYERROR_CALL("syntax error"); 994 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 995 yyerror_loc_range[0] = yylloc; /* lookahead position is error start position */ 996 #endif 997 998 #if !YYBTYACC 999 goto yyerrlab; /* redundant goto avoids 'unused label' warning */ 1000 yyerrlab: 1001 #endif 1002 ++yynerrs; 1003 1004 yyinrecovery: 1005 if (yyerrflag < 3) 1006 { 1007 yyerrflag = 3; 1008 for (;;) 1009 { 1010 if (((yyn = yysindex[*yystack.s_mark]) != 0) && (yyn += YYERRCODE) >= 0 && 1011 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) YYERRCODE) 1012 { 1013 #if YYDEBUG 1014 if (yydebug) 1015 fprintf(stderr, "%s[%d]: state %d, error recovery shifting to state %d\n", 1016 YYDEBUGSTR, yydepth, *yystack.s_mark, yytable[yyn]); 1017 #endif 1018 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1019 yystate = yytable[yyn]; 1020 *++yystack.s_mark = yytable[yyn]; 1021 *++yystack.l_mark = yylval; 1022 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1023 /* lookahead position is error end position */ 1024 yyerror_loc_range[1] = yylloc; 1025 YYLLOC_DEFAULT(yyloc, yyerror_loc_range, 2); /* position of error span */ 1026 *++yystack.p_mark = yyloc; 1027 #endif 1028 goto yyloop; 1029 } 1030 else 1031 { 1032 #if YYDEBUG 1033 if (yydebug) 1034 fprintf(stderr, "%s[%d]: error recovery discarding state %d\n", 1035 YYDEBUGSTR, yydepth, *yystack.s_mark); 1036 #endif 1037 if (yystack.s_mark <= yystack.s_base) goto yyabort; 1038 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1039 /* the current TOS position is the error start position */ 1040 yyerror_loc_range[0] = *yystack.p_mark; 1041 #endif 1042 #if defined(YYDESTRUCT_CALL) 1043 #if YYBTYACC 1044 if (!yytrial) 1045 #endif /* YYBTYACC */ 1046 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1047 YYDESTRUCT_CALL("error: discarding state", 1048 yystos[*yystack.s_mark], yystack.l_mark, yystack.p_mark); 1049 #else 1050 YYDESTRUCT_CALL("error: discarding state", 1051 yystos[*yystack.s_mark], yystack.l_mark); 1052 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1053 #endif /* defined(YYDESTRUCT_CALL) */ 1054 --yystack.s_mark; 1055 --yystack.l_mark; 1056 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1057 --yystack.p_mark; 1058 #endif 1059 } 1060 } 1061 } 1062 else 1063 { 1064 if (yychar == YYEOF) goto yyabort; 1065 #if YYDEBUG 1066 if (yydebug) 1067 { 1068 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1069 fprintf(stderr, "%s[%d]: state %d, error recovery discarding token %d (%s)\n", 1070 YYDEBUGSTR, yydepth, yystate, yychar, yys); 1071 } 1072 #endif 1073 #if defined(YYDESTRUCT_CALL) 1074 #if YYBTYACC 1075 if (!yytrial) 1076 #endif /* YYBTYACC */ 1077 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1078 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval, &yylloc); 1079 #else 1080 YYDESTRUCT_CALL("error: discarding token", yychar, &yylval); 1081 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1082 #endif /* defined(YYDESTRUCT_CALL) */ 1083 yychar = YYEMPTY; 1084 goto yyloop; 1085 } 1086 1087 yyreduce: 1088 yym = yylen[yyn]; 1089 #if YYDEBUG 1090 if (yydebug) 1091 { 1092 fprintf(stderr, "%s[%d]: state %d, reducing by rule %d (%s)", 1093 YYDEBUGSTR, yydepth, yystate, yyn, yyrule[yyn]); 1094 #ifdef YYSTYPE_TOSTRING 1095 #if YYBTYACC 1096 if (!yytrial) 1097 #endif /* YYBTYACC */ 1098 if (yym > 0) 1099 { 1100 int i; 1101 fputc('<', stderr); 1102 for (i = yym; i > 0; i--) 1103 { 1104 if (i != yym) fputs(", ", stderr); 1105 fputs(YYSTYPE_TOSTRING(yystos[yystack.s_mark[1-i]], 1106 yystack.l_mark[1-i]), stderr); 1107 } 1108 fputc('>', stderr); 1109 } 1110 #endif 1111 fputc('\n', stderr); 1112 } 1113 #endif 1114 if (yym > 0) 1115 yyval = yystack.l_mark[1-yym]; 1116 else 1117 memset(&yyval, 0, sizeof yyval); 1118 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1119 1120 /* Perform position reduction */ 1121 memset(&yyloc, 0, sizeof(yyloc)); 1122 #if YYBTYACC 1123 if (!yytrial) 1124 #endif /* YYBTYACC */ 1125 { 1126 YYLLOC_DEFAULT(yyloc, &yystack.p_mark[1-yym], yym); 1127 /* just in case YYERROR is invoked within the action, save 1128 the start of the rhs as the error start position */ 1129 yyerror_loc_range[0] = yystack.p_mark[1-yym]; 1130 } 1131 #endif 1132 1133 switch (yyn) 1134 { 1135 case 1: 1136 #line 50 "inherit2.y" 1137 yyval.cval = yystack.l_mark[-1].cval; 1138 break; 1139 case 2: 1140 #line 50 "inherit2.y" 1141 yyval.tval = yystack.l_mark[-1].tval; 1142 break; 1143 case 3: 1144 #line 51 "inherit2.y" 1145 { yyval.nlist = yystack.l_mark[0].nlist; } 1146 break; 1147 case 4: 1148 #line 53 "inherit2.y" 1149 { yyval.nlist = yystack.l_mark[0].nlist; } 1150 break; 1151 case 5: 1152 #line 56 "inherit2.y" 1153 { yyval.cval = cGLOBAL; } 1154 break; 1155 case 6: 1156 #line 57 "inherit2.y" 1157 { yyval.cval = cLOCAL; } 1158 break; 1159 case 7: 1160 #line 60 "inherit2.y" 1161 { yyval.tval = tREAL; } 1162 break; 1163 case 8: 1164 #line 61 "inherit2.y" 1165 { yyval.tval = tINTEGER; } 1166 break; 1167 case 9: 1168 #line 65 "inherit2.y" 1169 { yyval.nlist->s = mksymbol(yystack.l_mark[-2].tval, yystack.l_mark[-3].cval, yystack.l_mark[0].id); 1170 yyval.nlist->next = yystack.l_mark[-1].nlist; 1171 } 1172 break; 1173 case 10: 1174 #line 69 "inherit2.y" 1175 { yyval.nlist->s = mksymbol(yystack.l_mark[-1].tval, yystack.l_mark[-2].cval, yystack.l_mark[0].id); 1176 yyval.nlist->next = NULL; 1177 } 1178 break; 1179 case 11: 1180 #line 74 "inherit2.y" 1181 yyval.cval = cLOCAL; 1182 break; 1183 case 12: 1184 #line 75 "inherit2.y" 1185 { yyval.nlist = yystack.l_mark[0].nlist; } 1186 break; 1187 #line 1188 "inherit2.tab.c" 1188 default: 1189 break; 1190 } 1191 yystack.s_mark -= yym; 1192 yystate = *yystack.s_mark; 1193 yystack.l_mark -= yym; 1194 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1195 yystack.p_mark -= yym; 1196 #endif 1197 yym = yylhs[yyn]; 1198 if (yystate == 0 && yym == 0) 1199 { 1200 #if YYDEBUG 1201 if (yydebug) 1202 { 1203 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1204 #ifdef YYSTYPE_TOSTRING 1205 #if YYBTYACC 1206 if (!yytrial) 1207 #endif /* YYBTYACC */ 1208 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[YYFINAL], yyval)); 1209 #endif 1210 fprintf(stderr, "shifting from state 0 to final state %d\n", YYFINAL); 1211 } 1212 #endif 1213 yystate = YYFINAL; 1214 *++yystack.s_mark = YYFINAL; 1215 *++yystack.l_mark = yyval; 1216 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1217 *++yystack.p_mark = yyloc; 1218 #endif 1219 if (yychar < 0) 1220 { 1221 #if YYBTYACC 1222 do { 1223 if (yylvp < yylve) 1224 { 1225 /* we're currently re-reading tokens */ 1226 yylval = *yylvp++; 1227 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1228 yylloc = *yylpp++; 1229 #endif 1230 yychar = *yylexp++; 1231 break; 1232 } 1233 if (yyps->save) 1234 { 1235 /* in trial mode; save scanner results for future parse attempts */ 1236 if (yylvp == yylvlim) 1237 { /* Enlarge lexical value queue */ 1238 size_t p = (size_t) (yylvp - yylvals); 1239 size_t s = (size_t) (yylvlim - yylvals); 1240 1241 s += YYLVQUEUEGROWTH; 1242 if ((yylexemes = realloc(yylexemes, s * sizeof(YYINT))) == NULL) 1243 goto yyenomem; 1244 if ((yylvals = realloc(yylvals, s * sizeof(YYSTYPE))) == NULL) 1245 goto yyenomem; 1246 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1247 if ((yylpsns = realloc(yylpsns, s * sizeof(YYLTYPE))) == NULL) 1248 goto yyenomem; 1249 #endif 1250 yylvp = yylve = yylvals + p; 1251 yylvlim = yylvals + s; 1252 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1253 yylpp = yylpe = yylpsns + p; 1254 yylplim = yylpsns + s; 1255 #endif 1256 yylexp = yylexemes + p; 1257 } 1258 *yylexp = (YYINT) YYLEX; 1259 *yylvp++ = yylval; 1260 yylve++; 1261 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1262 *yylpp++ = yylloc; 1263 yylpe++; 1264 #endif 1265 yychar = *yylexp++; 1266 break; 1267 } 1268 /* normal operation, no conflict encountered */ 1269 #endif /* YYBTYACC */ 1270 yychar = YYLEX; 1271 #if YYBTYACC 1272 } while (0); 1273 #endif /* YYBTYACC */ 1274 if (yychar < 0) yychar = YYEOF; 1275 #if YYDEBUG 1276 if (yydebug) 1277 { 1278 if ((yys = yyname[YYTRANSLATE(yychar)]) == NULL) yys = yyname[YYUNDFTOKEN]; 1279 fprintf(stderr, "%s[%d]: state %d, reading token %d (%s)\n", 1280 YYDEBUGSTR, yydepth, YYFINAL, yychar, yys); 1281 } 1282 #endif 1283 } 1284 if (yychar == YYEOF) goto yyaccept; 1285 goto yyloop; 1286 } 1287 if (((yyn = yygindex[yym]) != 0) && (yyn += yystate) >= 0 && 1288 yyn <= YYTABLESIZE && yycheck[yyn] == (YYINT) yystate) 1289 yystate = yytable[yyn]; 1290 else 1291 yystate = yydgoto[yym]; 1292 #if YYDEBUG 1293 if (yydebug) 1294 { 1295 fprintf(stderr, "%s[%d]: after reduction, ", YYDEBUGSTR, yydepth); 1296 #ifdef YYSTYPE_TOSTRING 1297 #if YYBTYACC 1298 if (!yytrial) 1299 #endif /* YYBTYACC */ 1300 fprintf(stderr, "result is <%s>, ", YYSTYPE_TOSTRING(yystos[yystate], yyval)); 1301 #endif 1302 fprintf(stderr, "shifting from state %d to state %d\n", *yystack.s_mark, yystate); 1303 } 1304 #endif 1305 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack) == YYENOMEM) goto yyoverflow; 1306 *++yystack.s_mark = (YYINT) yystate; 1307 *++yystack.l_mark = yyval; 1308 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1309 *++yystack.p_mark = yyloc; 1310 #endif 1311 goto yyloop; 1312 #if YYBTYACC 1313 1314 /* Reduction declares that this path is valid. Set yypath and do a full parse */ 1315 yyvalid: 1316 if (yypath) YYABORT; 1317 while (yyps->save) 1318 { 1319 YYParseState *save = yyps->save; 1320 yyps->save = save->save; 1321 save->save = yypath; 1322 yypath = save; 1323 } 1324 #if YYDEBUG 1325 if (yydebug) 1326 fprintf(stderr, "%s[%d]: state %d, CONFLICT trial successful, backtracking to state %d, %d tokens\n", 1327 YYDEBUGSTR, yydepth, yystate, yypath->state, (int)(yylvp - yylvals - yypath->lexeme)); 1328 #endif 1329 if (yyerrctx) 1330 { 1331 yyFreeState(yyerrctx); 1332 yyerrctx = NULL; 1333 } 1334 yylvp = yylvals + yypath->lexeme; 1335 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1336 yylpp = yylpsns + yypath->lexeme; 1337 #endif 1338 yylexp = yylexemes + yypath->lexeme; 1339 yychar = YYEMPTY; 1340 yystack.s_mark = yystack.s_base + (yypath->yystack.s_mark - yypath->yystack.s_base); 1341 memcpy (yystack.s_base, yypath->yystack.s_base, (size_t) (yystack.s_mark - yystack.s_base + 1) * sizeof(YYINT)); 1342 yystack.l_mark = yystack.l_base + (yypath->yystack.l_mark - yypath->yystack.l_base); 1343 memcpy (yystack.l_base, yypath->yystack.l_base, (size_t) (yystack.l_mark - yystack.l_base + 1) * sizeof(YYSTYPE)); 1344 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1345 yystack.p_mark = yystack.p_base + (yypath->yystack.p_mark - yypath->yystack.p_base); 1346 memcpy (yystack.p_base, yypath->yystack.p_base, (size_t) (yystack.p_mark - yystack.p_base + 1) * sizeof(YYLTYPE)); 1347 #endif 1348 yystate = yypath->state; 1349 goto yyloop; 1350 #endif /* YYBTYACC */ 1351 1352 yyoverflow: 1353 YYERROR_CALL("yacc stack overflow"); 1354 #if YYBTYACC 1355 goto yyabort_nomem; 1356 yyenomem: 1357 YYERROR_CALL("memory exhausted"); 1358 yyabort_nomem: 1359 #endif /* YYBTYACC */ 1360 yyresult = 2; 1361 goto yyreturn; 1362 1363 yyabort: 1364 yyresult = 1; 1365 goto yyreturn; 1366 1367 yyaccept: 1368 #if YYBTYACC 1369 if (yyps->save) goto yyvalid; 1370 #endif /* YYBTYACC */ 1371 yyresult = 0; 1372 1373 yyreturn: 1374 #if defined(YYDESTRUCT_CALL) 1375 if (yychar != YYEOF && yychar != YYEMPTY) 1376 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1377 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval, &yylloc); 1378 #else 1379 YYDESTRUCT_CALL("cleanup: discarding token", yychar, &yylval); 1380 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1381 1382 { 1383 YYSTYPE *pv; 1384 #if defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) 1385 YYLTYPE *pp; 1386 1387 for (pv = yystack.l_base, pp = yystack.p_base; pv <= yystack.l_mark; ++pv, ++pp) 1388 YYDESTRUCT_CALL("cleanup: discarding state", 1389 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv, pp); 1390 #else 1391 for (pv = yystack.l_base; pv <= yystack.l_mark; ++pv) 1392 YYDESTRUCT_CALL("cleanup: discarding state", 1393 yystos[*(yystack.s_base + (pv - yystack.l_base))], pv); 1394 #endif /* defined(YYLTYPE) || defined(YYLTYPE_IS_DECLARED) */ 1395 } 1396 #endif /* defined(YYDESTRUCT_CALL) */ 1397 1398 #if YYBTYACC 1399 if (yyerrctx) 1400 { 1401 yyFreeState(yyerrctx); 1402 yyerrctx = NULL; 1403 } 1404 while (yyps) 1405 { 1406 YYParseState *save = yyps; 1407 yyps = save->save; 1408 save->save = NULL; 1409 yyFreeState(save); 1410 } 1411 while (yypath) 1412 { 1413 YYParseState *save = yypath; 1414 yypath = save->save; 1415 save->save = NULL; 1416 yyFreeState(save); 1417 } 1418 #endif /* YYBTYACC */ 1419 yyfreestack(&yystack); 1420 return (yyresult); 1421 } 1422