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