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